Render Queue Design Guidelines and Sorting

Started by
2 comments, last by AndreyVK_D3D 3 years, 1 month ago

So I'm trying to rearchitect my rendering engine to take advantage of render queues, and for the most part I understand the concepts and most of the implementation details involved, but I wanted to get some feedback as to how to go about approaching this based on other posts and articles I've read. I've never really implemented a rendering queue (my game objects just basically render themselves when they're updated in my game loop atm) so I may be way off the mark here.

The way I might implement it is to have a RenderTask/RenderCommand that holds all the bindable textures, uniform data, material/shader data, and mesh VAOs and might also extend to graphics state commands like clearing the depth or stencil buffers or enabling/disabling back face culling.

The RenderTask would then be submitted to something like a RenderableCollection/RenderGroup and is sorted within said group using an integer/bitfield key where the bits specify certain info necessary for sorting, such as material/shader id (to minimize state changes), transparency, draw layer, etc.

I have a few questions about this:

1. how correct is this design? I feel like I might be missing some layers or details here.

2. Is sorting only really required at only one level of a render queue implementation, in this case within RenderGroup?

2. Is a RenderGroup in this case akin to a render pass? Or is a render pass another layer that I would add above the RenderGroup, to which a RenderGroup can be submitted? Would that even be necessary?

3. On the topic of render passes, how can I effectively handle dependencies between stages/passes (i.e. if my color or post processing stages need access to textures generated by the shadow or depth passes)

4. On the topic of RenderTasks that set some graphics state, how can I guarantee that this gets called when needed, if multiple of the same command can exist in the queue (i.e. might have to enable stencil buffer operations for only certain meshes, or might want to debug draw specific bounding boxes).

Would really appreciate some guidance here. I feel like I'm mostly on the right page but it just hasn't completely clicked yet.

Advertisement

Hi. This article has been there for a while, but imho the core concept still stands: https://realtimecollisiondetection.net/blog/?p=86

If you need sorting, depends on your needs, some general thoughts:

  • if you have objects with non-opaque materials, those need to be drawn after opaque, sorted back to front
  • non opaque could be sorted front to back to minimize overdraw, but opinions on this differ (recent hardware cares less); don’t micro optimize if not needed
  • sorting on mesh, material, shader reduces the amount of state/ binding changes, which is a good idea

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

cozzie said:
Hi. This article has been there for a while, but imho the core concept still stands: https://realtimecollisiondetection.net/blog/?p=86

Yes, this is good article, but what about sorting and culling for instanced(grass, bushes, trees) objects ? It can reduce performance. I think should consider GPU implementation using compute shaders for sorting and culling, for non-opaque materials may be used OIT

3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms

This topic is closed to new replies.

Advertisement