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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…