Browse Source

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

niki 2 years ago
parent
commit
de1a4c3149
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/modules/graphics/vulkan/Shader.cpp

+ 3 - 1
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)