Fix crash on Vulkan when constant buffer is missing

This commit is contained in:
2026-04-24 12:20:32 +02:00
parent a46402df6b
commit 468e05c6e8
2 changed files with 9 additions and 4 deletions
@@ -671,7 +671,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;
@@ -947,9 +947,7 @@ GPUBufferVulkan* HelperResourcesVulkan::GetDummyVertexBuffer()
GPUConstantBuffer* HelperResourcesVulkan::GetDummyConstantBuffer()
{
if (!_dummyCB)
{
_dummyCB = _device->CreateConstantBuffer(256, TEXT("DummyConstantBuffer"));
}
_dummyCB = _device->CreateConstantBuffer(1024, TEXT("DummyConstantBuffer"));
return _dummyCB;
}