Recording FPS in webGL

后端 未结 5 549
甜味超标
甜味超标 2020-12-18 12:54

I am trying to compare performance for 3d applications on mobile devices. I have a 3d solar system set up in webGL and im trying to record or at least display the FPS. So

5条回答
  •  既然无缘
    2020-12-18 13:48

    Since none of the other answers addressed the "in WebGL" part of the question, I'll add the following important details when measuring FPS in WebGL correctly.

    window.console.time('custom-timer-id');    // start timer
    
    /* webgl draw call here */                 // e.g., gl.drawElements();
    
    gl.finish();                               // ensure the GPU is ready
    
    window.console.timeEnd('custom-timer-id'); // end timer
    

    For simplicity I used the console timer. I'm trying to make the point to always use WebGLRenderingContext.finish() to ensure the correct time is measured as all WebGL calls to the GPU are asynchronous!

提交回复
热议问题