Replies: 1 comment
-
|
The double-buffer approach is more or less what's implemented in the WIP PR pygfx/rendercanvas#138. I imagine that once we have that, it would also be possible to some a similar mechanism to record the full window of normal canvas. Would that cover your particular use-case?
Yes, that would still probably make sense. But we should probably wait until wgpu and rendercanvas have a next release that have improved async support. Then we can do image = await renderer.snapshot_asyc()
# or
render.snapshot_async().then(handle_image_func)
Yes, eventually I hope to remove all sync calls in Pygfx.
The renderer holds the internal textures (color and depth), so it seems like the correct object to ask for a snapshot. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I've been using pygfx (via fastplotlib) for scientific visualization and needed to record animations to video. I noticed that the current
snapshot()method blocks onqueue.read_texture(), which creates a serial pipeline where GPU and CPU can't overlap.Benchmark
I experimented with double-buffered staging buffers using
map_async()+sync_wait():How it works
The key insight:
map_async()returns immediately. By the time we callsync_wait()for frame N-1, the GPU has already finished the copy, so it returns almost instantly.Proof of Concept
Here's a standalone benchmark (no pygfx changes needed):
# See gist: https://gist.github.com/hyiip/079b52198f2bcb8251987e1be295e790Full benchmark code
Questions
Would pygfx be interested in an async snapshot API? Something like:
Does this align with the async direction discussed in Support async use of wgpu? #615?
Is
WgpuRendererthe right place, or would a separate helper class be preferred?Happy to contribute a PR if there's interest!
Related
Figureto a video file robustly fastplotlib/fastplotlib#918 - Record Figure to a video file robustlyThanks for the great library!
Beta Was this translation helpful? Give feedback.
All reactions