Added potential fix for Vulkan buffer creation crashes from SHBatch #265
|
@ -340,7 +340,7 @@ namespace SHADE
|
|||
}
|
||||
|
||||
// Transfer to GPU
|
||||
if (transformDataBuffer[frameIndex])
|
||||
if (transformDataBuffer[frameIndex] && !drawData.empty())
|
||||
transformDataBuffer[frameIndex]->WriteToMemory(transformData.data(), static_cast<uint32_t>(transformData.size() * sizeof(SHMatrix)), 0, 0);
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ namespace SHADE
|
|||
}
|
||||
|
||||
// Transfer to GPU
|
||||
if (instancedIntegerBuffer[frameIndex])
|
||||
if (instancedIntegerBuffer[frameIndex] && !drawData.empty())
|
||||
instancedIntegerBuffer[frameIndex]->WriteToMemory(instancedIntegerData.data(), static_cast<uint32_t>(instancedIntegerData.size() * sizeof(SHInstancedIntegerData)), 0, 0);
|
||||
|
||||
}
|
||||
|
@ -507,7 +507,9 @@ namespace SHADE
|
|||
isCPUBuffersDirty = false;
|
||||
}
|
||||
|
||||
// Send all buffered data to the GPU buffers
|
||||
// Send all buffered data to the GPU buffers if there is anything to render
|
||||
if (!drawData.empty())
|
||||
{
|
||||
using BuffUsage = vk::BufferUsageFlagBits;
|
||||
// - Draw Data
|
||||
const uint32_t DRAW_DATA_BYTES = static_cast<uint32_t>(drawData.size() * sizeof(vk::DrawIndexedIndirectCommand));
|
||||
|
@ -534,6 +536,7 @@ namespace SHADE
|
|||
);
|
||||
// - Material Properties Buffer
|
||||
rebuildMaterialBuffers(frameIndex, descPool);
|
||||
}
|
||||
|
||||
// Mark this frame as no longer dirty
|
||||
isDirty[frameIndex] = false;
|
||||
|
@ -551,7 +554,7 @@ namespace SHADE
|
|||
}
|
||||
|
||||
// Nothing to draw
|
||||
if (subBatches.empty())
|
||||
if (drawData.empty())
|
||||
return;
|
||||
|
||||
// Bind all required objects before drawing
|
||||
|
@ -586,7 +589,7 @@ namespace SHADE
|
|||
|
||||
void SHBatch::rebuildMaterialBuffers(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool)
|
||||
{
|
||||
if (matPropsData)
|
||||
if (matPropsData && !drawData.empty())
|
||||
{
|
||||
SHVkUtil::EnsureBufferAndCopyHostVisibleData
|
||||
(
|
||||
|
|
Loading…
Reference in New Issue