Reputation: 1252
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.
Upvotes: 0
Views: 2109
Reputation: 8123
Your browser may use software rendering for some reason, check your browsers GPU debugging page to see if there's anything wrong, in Chrome that is chrome://gpu
, in Firefox it's the GPU section in about:support
.
Upvotes: 2