Fix crash on Vulkan when constant buffer is missing

This commit is contained in:
2026-04-24 12:20:32 +02:00
parent d6113be58c
commit 881bc4d629
2 changed files with 9 additions and 4 deletions
@@ -604,7 +604,14 @@ void GPUContextVulkan::UpdateDescriptorSets(const SpirvShaderDescriptorInfo& des
VkDeviceSize offset = 0, range = 0;
uint32 dynamicOffset = 0;
if (!handle)
handle = (GPUConstantBufferVulkan*)_device->HelperResources.GetDummyConstantBuffer();
{
auto cb = (GPUConstantBufferVulkan*)_device->HelperResources.GetDummyConstantBuffer();
// TODO: cache this allocation within a frame
const auto allocation = _device->UniformBufferUploader->Allocate(cb->GetSize(), 0, this);
Platform::MemoryClear(allocation.CPUAddress, allocation.Size);
cb->Allocation = allocation;
handle = cb;
}
handle->DescriptorAsDynamicUniformBuffer(this, buffer, offset, range, dynamicOffset);
needsWrite |= dsWriter.WriteDynamicUniformBuffer(descriptorIndex, buffer, offset, range, dynamicOffset, index);
break;
@@ -946,9 +946,7 @@ GPUBufferVulkan* HelperResourcesVulkan::GetDummyVertexBuffer()
GPUConstantBuffer* HelperResourcesVulkan::GetDummyConstantBuffer()
{
if (!_dummyCB)
{
_dummyCB = _device->CreateConstantBuffer(256, TEXT("DummyConstantBuffer"));
}
_dummyCB = _device->CreateConstantBuffer(1024, TEXT("DummyConstantBuffer"));
return _dummyCB;
}