From ea1cd9d31bb97f158e5be2568fb68a80e512960d Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Wed, 9 Oct 2024 13:25:36 -0700 Subject: [PATCH] vk: Fix undefined push-constant data The full push-constant region is 24 bytes(6 floats), but some of these push-constant writes only wrote 20 bytes of data(5 floats). Causing 4 bytes at the end to be left undefined. Resolved by pushing an extra zero. --- core/rend/vulkan/drawer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/rend/vulkan/drawer.cpp b/core/rend/vulkan/drawer.cpp index e67f32c1c..fd6220bc6 100644 --- a/core/rend/vulkan/drawer.cpp +++ b/core/rend/vulkan/drawer.cpp @@ -200,7 +200,7 @@ void Drawer::DrawPoly(const vk::CommandBuffer& cmdBuffer, u32 listType, bool sor if (tileClip == TileClipping::Inside || trilinearAlpha != 1.f || gpuPalette != 0) { - std::array pushConstants = { + const std::array pushConstants = { (float)scissorRect.offset.x, (float)scissorRect.offset.y, (float)scissorRect.offset.x + (float)scissorRect.extent.width, @@ -336,7 +336,7 @@ void Drawer::DrawModVols(const vk::CommandBuffer& cmdBuffer, int first, int coun } cmdBuffer.bindVertexBuffers(0, curMainBuffer, {0}); - std::array pushConstants = { 1 - FPU_SHAD_SCALE.scale_factor / 256.f, 0, 0, 0, 0 }; + const std::array pushConstants = { 1 - FPU_SHAD_SCALE.scale_factor / 256.f, 0, 0, 0, 0, 0 }; cmdBuffer.pushConstants(pipelineManager->GetPipelineLayout(), vk::ShaderStageFlagBits::eFragment, 0, pushConstants); pipeline = pipelineManager->GetModifierVolumePipeline(ModVolMode::Final, 0, false); @@ -430,7 +430,7 @@ bool Drawer::Draw(const Texture *fogTexture, const Texture *paletteTexture) cmdBuffer.bindIndexBuffer(curMainBuffer, offsets.indexOffset, vk::IndexType::eUint32); // Make sure to push constants even if not used - std::array pushConstants = { 0, 0, 0, 0, 0 }; + const std::array pushConstants = { 0, 0, 0, 0, 0, 0 }; cmdBuffer.pushConstants(pipelineManager->GetPipelineLayout(), vk::ShaderStageFlagBits::eFragment, 0, pushConstants); RenderPass previous_pass{};