Original Post
I have a rough render queue implementation. However I am struggling with the implementation of spatial meta-data i.e. world-matrices of the command queue but there doesn't seem to be much literature about the subject. My implementation is based on bit-packing the necessary information in as tiny data-structures as possible to achieve narrow command streams/queue. An example of this would be packing a 24-bit fixed-point-math depth-key for including depth-sorting. Prior to rendering the stream(s) are sorted based on the packed data structures allowing for a flexible render system design.
There are several routes i can go with my implementation: 1) Embed the spatial meta-data in the command stream itself, by reserving a portion of the stream in the stride i.e. struct { int sortkey, matrix4x4 worldpos }; 2) Refer to the matrix by id i.e. struct { int sortkey, int matrixId }; 3) Embed the spatial information into a parameter set of the material.
No 1. Is my current implementation since it's straight forward, however this creates quite a wide command stream again, and every shader-pass I apply is added as a separate command. So this solution has possibilities for quite a bit of memory consumption/overhead i.e. 64 bytes extra per call. Deferred rendering in this situation will help somewhat since it minimizes the amount of time the geometry has to be reprocessed and therefor added to the queue, but i estimate you'd have at-least 2 to 3 passes (special effects, shadow mapping etc).
No 2. Seems rather appealing since you have an integer which would makes the command stream narrow again, 60 bytes gained per call. Which would allow for quicker sorting, less memory copying/swapping. However after sorting there is a chance that matrices are accessed in random order i.e. unpredictable fashion and making the algorithm cache hostile in comparison.
No. 3. Seems far from ideal since essentially if we treat the world matrix as another shader parameter the render pipeline has a tendency to be be 'unaware' of it. And my parameter set is optimized for storing their respective parameters for data efficiency rather than lookup efficiency i.e. using homogeneous arrays. Hence forth this solution in my opinion disables interesting instancing concepts with dx11/gl4 hardware i.e. pumping all world matrices into a uniform buffer and unpack them at shader level.
For now solution no. 1 is implemented and suffices for the time being, i also don't anticipate that to change in the foreseeable future, but i would like to orientate/educate myself on what would be considered the 'better' approach to meet the demands for 'scalable, stream-able, massive worlds rendering'. So I would like to know what experience you guys have with various implementations (regarding render queue's, I'm not interested in hearing about visitor patterns for scene-graph traversal) maybe you got something better that I've never considered.
There are several routes i can go with my implementation: 1) Embed the spatial meta-data in the command stream itself, by reserving a portion of the stream in the stride i.e. struct { int sortkey, matrix4x4 worldpos }; 2) Refer to the matrix by id i.e. struct { int sortkey, int matrixId }; 3) Embed the spatial information into a parameter set of the material.
No 1. Is my current implementation since it's straight forward, however this creates quite a wide command stream again, and every shader-pass I apply is added as a separate command. So this solution has possibilities for quite a bit of memory consumption/overhead i.e. 64 bytes extra per call. Deferred rendering in this situation will help somewhat since it minimizes the amount of time the geometry has to be reprocessed and therefor added to the queue, but i estimate you'd have at-least 2 to 3 passes (special effects, shadow mapping etc).
No 2. Seems rather appealing since you have an integer which would makes the command stream narrow again, 60 bytes gained per call. Which would allow for quicker sorting, less memory copying/swapping. However after sorting there is a chance that matrices are accessed in random order i.e. unpredictable fashion and making the algorithm cache hostile in comparison.
No. 3. Seems far from ideal since essentially if we treat the world matrix as another shader parameter the render pipeline has a tendency to be be 'unaware' of it. And my parameter set is optimized for storing their respective parameters for data efficiency rather than lookup efficiency i.e. using homogeneous arrays. Hence forth this solution in my opinion disables interesting instancing concepts with dx11/gl4 hardware i.e. pumping all world matrices into a uniform buffer and unpack them at shader level.
For now solution no. 1 is implemented and suffices for the time being, i also don't anticipate that to change in the foreseeable future, but i would like to orientate/educate myself on what would be considered the 'better' approach to meet the demands for 'scalable, stream-able, massive worlds rendering'. So I would like to know what experience you guys have with various implementations (regarding render queue's, I'm not interested in hearing about visitor patterns for scene-graph traversal) maybe you got something better that I've never considered.