Open vorg opened 7 years ago
This makes sense and internally regl tracks all this info anyway. Exposing it would be an easy win.
Do you want to take a shot at this?
Yes, i'll have more time next week and probably start with exposing total counts.
There is also a question of how much of that should be in core? Below is a screenshot of what hopefully will become regl-profiler
similar to PerfMeter. It currently depends on wrapping regl.frame
, regl.texture
, gl.useProgram
, gl.drawArrays
etc. I had to drill down to gl.*
calls as one regl resource can create multiple dependent resources (eg. FBO creates dept buffer by default). Again, total counts currently used for resource ids would help.
profiler.time(label)
, profiler.timeEnd(label)
currently using performance.now()
and gl.finish()
, I should switch to disjoint queries as gl.finish approach doesn't work in Chrome. Used for bigger app subsystems / pipelines.gl
call count per frame. Used to better understand how to nest regl
commands (e.g. for shared uniforms) and organise batching.const regl = require('regl')({ profile: true })
const profiler = require('regl-profiler')(regl)
const drawMesh = regl({ .... })
// start measuring CPU and GPU timings for the given command
profiler.addCommand('drawMesh', drawMesh)
// measure some timespan
profiler.time('init')
...
profiler.timeEnd('init')
// whole frame call back will be measured automatically
regl.frame(() => {
// draw will attach fixed canvas element in the top right corner and draw stats
profiler.draw()
})
- List of all buffers, textures etc. could be useful for debugging
You can get this and more with the excellent WebGL Inspector extension.
@dcposch I was big fan of WebGL inspector but there is number of issues:
As of late, I have found Spector.js to be incredibly helpful. It is available as a standalone module you can integrate into your project and also has browser extensions.
As the application grows so is the number of components that create regl commands and relaying on
regl.stats
andreglCommand.stats
is not enough. Some issues:texture.subimage
can take significant time of run every frame. Any ideas how to handle that? Currently I rely on wrapping update code withconsole.time/timeEnd
andregl._gl.finish()
This is connected to Debugging helper tools