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.