Each Draw in a DrawList might be processed by multiple RenderSteps (determined by the Draw's Renderer), which can be sorted independently. Each (step, draw) pair produces its own SortKey.
The goal of sorting draws for the DrawPass is to minimize pipeline transitions and dynamic binds within a pipeline, while still respecting the overall painter's order. This decreases the number of low-level draw commands in a command buffer and increases the size of those, allowing the GPU to operate more efficiently and have fewer bubbles within its own instruction stream.
The Draw's CompresssedPaintersOrder and DisjointStencilINdex represent the most significant bits of the key, and are shared by all SortKeys produced by the same draw. Next, the pipeline description is encoded in two steps:
- The index of the RenderStep packed in the high bits to ensure each step for a draw is ordered correctly.
- An index into a cache of pipeline descriptions is used to encode the identity of the pipeline (SortKeys that differ in the bits from #1 necessarily would have different descriptions, but then the specific ordering of the RenderSteps isn't enforced). Last, the SortKey encodes an index into the set of uniform bindings accumulated for a DrawPass. This allows the SortKey to cluster draw steps that have both a compatible pipeline and do not require rebinding uniform data or other state (e.g. scissor). Since the uniform data index and the pipeline description index are packed into indices and not actual pointers, a given SortKey is only valid for the a specific DrawList->DrawPass conversion.
Definition at line 372 of file DrawPass.cpp.