Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
513 views
in Technique[技术] by (71.8m points)

High CPU usage running webassembly based WebGL program

I am making a game using webassembly (C++ and emscripten), where I am using OpenGL to generate graphics. I have noticed that my game often uses a lot of CPU, typically 200-300%. This CPU usage becomes higher if I have a larger 3D model or if my shader is more complicated.

Is this normal for webassembly? Or am I doing something wrong? I'm bit worried that I made a mistake since normally I would not expect the CPU usage to be directly linked to the size of 3D models (I would expect that to mostly take a toll on the graphics card), but since it is webassembly it might be different.

Are there any good tips for trying to reduce CPU usage when running OpenGL and webassembly?

Edit: The basic example I started working from was https://github.com/timhutton/opengl-canvas-wasm live demo here (https://timhutton.github.io/opengl-canvas-wasm/) This already runs at quite high CPU. What is wrong with that example making it run at such high CPU load? It is not the glBufferData, even removing that keeps the CPU high.

question from:https://stackoverflow.com/questions/65945876/high-cpu-usage-running-webassembly-based-webgl-program

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to reply this article.

OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...