Add profile event to hardware instancing building and insert draw count into profiler zone data

This commit is contained in:
Wojtek Figat
2024-06-27 21:03:52 +02:00
parent 7b5edc363a
commit 138e17508b

View File

@@ -691,7 +691,7 @@ void RenderList::ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsL
// Prepare instance buffer
if (useInstancing)
{
// Prepare buffer memory
PROFILE_CPU_NAMED("Build Instancing");
int32 instancedBatchesCount = 0;
for (int32 i = 0; i < list.Batches.Count(); i++)
{
@@ -705,12 +705,8 @@ void RenderList::ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsL
if (batch.Instances.Count() > 1)
instancedBatchesCount += batch.Instances.Count();
}
if (instancedBatchesCount == 0)
if (instancedBatchesCount != 0)
{
// Faster path if none of the draw batches requires instancing
useInstancing = false;
goto DRAW;
}
_instanceBuffer.Clear();
_instanceBuffer.Data.Resize(instancedBatchesCount * sizeof(InstanceData));
auto instanceData = (InstanceData*)_instanceBuffer.Data.Get();
@@ -744,10 +740,15 @@ void RenderList::ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsL
// Upload data
_instanceBuffer.Flush(context);
}
DRAW:
else
{
// No batches so no instancing
useInstancing = false;
}
}
// Execute draw calls
int32 draws = list.Batches.Count();
MaterialBase::BindParameters bindParams(context, renderContext);
bindParams.Input = input;
bindParams.BindViewData();
@@ -856,6 +857,7 @@ DRAW:
}
}
}
draws += list.PreBatchedDrawCalls.Count();
}
else
{
@@ -909,6 +911,7 @@ DRAW:
context->BindVB(ToSpan(drawCall.Geometry.VertexBuffers, 3), drawCall.Geometry.VertexBuffersOffsets);
context->DrawIndexedInstanced(drawCall.Draw.IndicesCount, drawCall.InstanceCount, 0, 0, drawCall.Draw.StartIndex);
}
draws += batch.Instances.Count();
}
if (list.Batches.IsEmpty() && list.Indices.Count() != 0)
{
@@ -931,8 +934,10 @@ DRAW:
context->DrawIndexedInstanced(drawCall.Draw.IndicesCount, drawCall.InstanceCount, 0, 0, drawCall.Draw.StartIndex);
}
}
draws += list.Indices.Count();
}
}
ZoneValue(draws);
}
void SurfaceDrawCallHandler::GetHash(const DrawCall& drawCall, uint32& batchKey)