In my rendering system each renderable object implements the following interface (at minimum):
interface IRenderableComponent
{
void CreateRenderOperations(RenderOperationList);
}
Render operations implement the following interface.
interface IRenderOperation
{
RenderPasses RenderPass; // Bit mask field for passes it is included in.
bool IntersectsWith(CameraBounds);
void Apply(RenderContext);
}
The idea is that the RenderContext will traverse the scene graph and ask each node for its render operations - nodes would take this opportunity to calculate as much as possible before handing off their render operations (e.g. calculate the final world matrix).
Each pass (currently, shadow casting, shadowed, post-shadow) is then given the collection and can use it to render the scene or portions of it (e.g. taking shadow mapping as an example it would be used to render the scene from the perspective of a spotlight). A side-effect of this is that the entire scene does need to be dumped to the list.
The collection is currently implemented using a skip list; where each 'list' in the skip list represents a render pass - this allows me to quickly enumerate possible operations in the current pass (after profiling my original implementation I found I was spending quite some time iterating over every single operation). However, because a skip list is a linked list I need to instantiate a huge amount of Node objects and this is adding pressure to the garbage collector (where a clean list is nice because you can keep the allocated array and just zero it).
Do you have any thoughts on a better structure to hold this information; or alternatively a way to implement a skip list in a more memory-friendly fashion?
This is C# (which is irrelevant) as well as 2D (also irrelevant).