From 468e05c6e83f8d4d16f31d77cfedb02bec45d346 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 24 Apr 2026 12:20:32 +0200 Subject: [PATCH] Fix crash on Vulkan when constant buffer is missing --- Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp | 9 ++++++++- Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp | 4 +--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp index 6b552d2b7..3fda88f97 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp @@ -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; diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp index 0e6244271..c2407f8ab 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp @@ -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; }