Optimize DrawBatch for faster sorting
This commit is contained in:
@@ -570,6 +570,7 @@ void RenderList::SortDrawCalls(const RenderContext& renderContext, bool reverseD
|
||||
const auto* drawCallsData = drawCalls.Get();
|
||||
const auto* listData = list.Indices.Get();
|
||||
const int32 listSize = list.Indices.Count();
|
||||
ZoneValue(listSize);
|
||||
|
||||
// Peek shared memory
|
||||
#define PREPARE_CACHE(list) (list).Clear(); (list).Resize(listSize)
|
||||
@@ -626,6 +627,7 @@ void RenderList::SortDrawCalls(const RenderContext& renderContext, bool reverseD
|
||||
}
|
||||
|
||||
DrawBatch batch;
|
||||
static_assert(sizeof(DrawBatch) == sizeof(uint64) * 2, "Fix the size of draw batch to optimize memory access.");
|
||||
batch.SortKey = sortedKeys[i];
|
||||
batch.StartIndex = i;
|
||||
batch.BatchSize = batchSize;
|
||||
|
||||
@@ -212,17 +212,17 @@ struct DrawBatch
|
||||
/// <summary>
|
||||
/// The first draw call index.
|
||||
/// </summary>
|
||||
int32 StartIndex;
|
||||
uint16 StartIndex;
|
||||
|
||||
/// <summary>
|
||||
/// A number of draw calls to be submitted at once.
|
||||
/// </summary>
|
||||
int32 BatchSize;
|
||||
uint16 BatchSize;
|
||||
|
||||
/// <summary>
|
||||
/// The total amount of instances (sum from all draw calls in this batch).
|
||||
/// </summary>
|
||||
int32 InstanceCount;
|
||||
uint32 InstanceCount;
|
||||
|
||||
bool operator<(const DrawBatch& other) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user