pygfx icon indicating copy to clipboard operation
pygfx copied to clipboard

Make use of render bundles

Open almarklein opened this issue 2 years ago • 4 comments

Somewhat related to #322, but is a bit more involved that a cache.

Needs:

  • [x] Expose render bundles in wgpu-native (done, I think).
  • [ ] Expose render bundles in wgpu-py.
  • [ ] Not a strict requirement, but in order to take full advantage, it'd be nice if we would not have to iterate over the whole scene graph on each draw.

almarklein avatar Apr 21 '23 11:04 almarklein

  • in order to take full advantage, it'd be nice if we would not have to iterate over the whole scene graph on each draw.

Can you explain this?

Korijn avatar May 16 '23 16:05 Korijn

Yeah. So with render bundles you can record a series of gpu commands, basically what we do here, and then replay the recorded commands later. So if you have say 1000 objects, you loop over them and record rendering them. Then the next frame it will be a single call to render them all.

Now if we still need to iterate over the 1000 objects to update or sync matrices, etc., then depending on how fast that is, it might defeat the purpose of using the render bundles. So with that comment I meant that to take maximum advantage of the ability to render a whole scene with one wgpu command, we should minimize the time spent on iterating over them.

almarklein avatar May 16 '23 19:05 almarklein

I see. Thanks!

I guess it means you can try to detect automatically what can be bundled, or you can rely on the user to mark worldobjects as "static" or something...

(My cat jumped on my keyboard... Sorry for closing)

Korijn avatar May 16 '23 21:05 Korijn

I guess it means you can try to detect automatically what can be bundled, or you can rely on the user to mark worldobjects as "static" or something...

Exactly, plenty of challenges there, I suspect.

almarklein avatar May 16 '23 21:05 almarklein