From de1a4c31490e033cb88e5b3266212e27cc8bd579 Mon Sep 17 00:00:00 2001 From: niki Date: Sat, 12 Nov 2022 03:22:23 +0100 Subject: [PATCH] vulkan: fix crash when creating compute shaders If the size of the default uniform block ends up being 0, there will be a crash since creating a buffer of size 0 is invalid. A simple if-statement fixes this issue --- src/modules/graphics/vulkan/Shader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/vulkan/Shader.cpp b/src/modules/graphics/vulkan/Shader.cpp index 893a5abd6..0a17ff70f 100644 --- a/src/modules/graphics/vulkan/Shader.cpp +++ b/src/modules/graphics/vulkan/Shader.cpp @@ -1023,7 +1023,9 @@ void Shader::createDescriptorPoolSizes() void Shader::createStreamBuffers() { - streamBuffers.push_back(new StreamBuffer(vgfx, BUFFERUSAGE_UNIFORM, STREAMBUFFER_DEFAULT_SIZE * uniformBufferSizeAligned)); + size_t size = STREAMBUFFER_DEFAULT_SIZE * uniformBufferSizeAligned; + if (size > 0) + streamBuffers.push_back(new StreamBuffer(vgfx, BUFFERUSAGE_UNIFORM, size)); } void Shader::setVideoTextures(graphics::Texture *ytexture, graphics::Texture *cbtexture, graphics::Texture *crtexture)