Measure gpu time for all render passes #769
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds support to measure the GPU time for the different render passes, which can be useful in benchmarks to see how much strain each pass in the rendering process puts on the GPU, and how certain choices affect the GPU usage. This feature is opt-in, one must set
renderer.measure_gpu_times = True
. This flag is undocumented/experimental for now.Note1: This relies on pygfx/wgpu-py#505, which is not yet released. But IMO that's ok, since for now this feature is undocumented and only used by ourselves (meaning devs who checkout the
main
of wgpu-py).Note2: Using this feature requires
gfx.renderers.wgpu.enable_wgpu_features("timestamp-query")
.This PR:
GpuTimeMeasurer
to abstract away the details, so that the rendering code has minimal extra stuff to do the measurements.render()
call, and uses it to measure the render passes, blender combine pass (if applicable), flush pass, and shadow passes.stats
prop atrenderer.stats["gpu_times"]
.An example output from the benchmark code I'm working on. You can see how the number of measurements changes depending on the presence of shadows and used blend mode.