Fixed instanced rendering the wrong number of instances #115

Merged
Pycorax merged 1 commits from Fix-IncorrectMDI into main 2022-10-25 15:20:50 +08:00
1 changed files with 4 additions and 2 deletions
Showing only changes of commit 9f98bed4d1 - Show all commits

View File

@ -310,14 +310,16 @@ namespace SHADE
for (auto& subBatch : subBatches) for (auto& subBatch : subBatches)
{ {
// Create command // Create command
const uint32_t CURR_INSTANCES = static_cast<uint32_t>(subBatch.Renderables.size());
drawData.emplace_back(vk::DrawIndexedIndirectCommand drawData.emplace_back(vk::DrawIndexedIndirectCommand
{ {
.indexCount = subBatch.Mesh->IndexCount, .indexCount = subBatch.Mesh->IndexCount,
.instanceCount = static_cast<uint32_t>(subBatch.Renderables.size()), .instanceCount = CURR_INSTANCES,
.firstIndex = subBatch.Mesh->FirstIndex, .firstIndex = subBatch.Mesh->FirstIndex,
.vertexOffset = subBatch.Mesh->FirstVertex, .vertexOffset = subBatch.Mesh->FirstVertex,
.firstInstance = nextInstanceIndex++ .firstInstance = nextInstanceIndex
}); });
nextInstanceIndex += CURR_INSTANCES;
// Fill in buffers (CPU) // Fill in buffers (CPU)
for (auto rendId : subBatch.Renderables) for (auto rendId : subBatch.Renderables)