Skip to content

Commit

Permalink
vk: Fix undefined push-constant data
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Wunkolo committed Oct 9, 2024
1 parent 5b34356 commit dccc465
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/rend/vulkan/drawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float, 6> pushConstants = {
const std::array<float, 6> pushConstants = {
(float)scissorRect.offset.x,
(float)scissorRect.offset.y,
(float)scissorRect.offset.x + (float)scissorRect.extent.width,
Expand Down Expand Up @@ -336,7 +336,7 @@ void Drawer::DrawModVols(const vk::CommandBuffer& cmdBuffer, int first, int coun
}
cmdBuffer.bindVertexBuffers(0, curMainBuffer, {0});

std::array<float, 5> pushConstants = { 1 - FPU_SHAD_SCALE.scale_factor / 256.f, 0, 0, 0, 0 };
const std::array<float, 6> pushConstants = { 1 - FPU_SHAD_SCALE.scale_factor / 256.f, 0, 0, 0, 0, 0 };
cmdBuffer.pushConstants<float>(pipelineManager->GetPipelineLayout(), vk::ShaderStageFlagBits::eFragment, 0, pushConstants);

pipeline = pipelineManager->GetModifierVolumePipeline(ModVolMode::Final, 0, false);
Expand Down Expand Up @@ -422,7 +422,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<float, 5> pushConstants = { 0, 0, 0, 0, 0 };
const std::array<float, 6> pushConstants = { 0, 0, 0, 0, 0, 0 };
cmdBuffer.pushConstants<float>(pipelineManager->GetPipelineLayout(), vk::ShaderStageFlagBits::eFragment, 0, pushConstants);

RenderPass previous_pass{};
Expand Down

0 comments on commit dccc465

Please sign in to comment.