From 3651e67a25b14c8526225c72c73234d90232b2af Mon Sep 17 00:00:00 2001 From: kd-11 Date: Tue, 27 Jun 2017 17:49:07 +0300 Subject: [PATCH] vk: Fix mapping of output colors to render target ranges --- rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp index 41e374a815..43e2c4e82d 100644 --- a/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp +++ b/rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp @@ -91,18 +91,12 @@ void VKFragmentDecompilerThread::insertOutputs(std::stringstream & OS) { "ocol3", m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS ? "r4" : "h8" }, }; - //We always bind the first usable image to index 0, even if surface type is surface_type::b - //If only surface 1 is being written to, redirect to output 0 - - if (m_parr.HasParam(PF_PARAM_NONE, "vec4", table[1].second) && !m_parr.HasParam(PF_PARAM_NONE, "vec4", table[0].second)) - OS << "layout(location=0) out vec4 " << table[1].first << ";" << std::endl; - else + //NOTE: We do not skip outputs, the only possible combinations are a(0), b(0), ab(0,1), abc(0,1,2), abcd(0,1,2,3) + u8 output_index = 0; + for (int i = 0; i < sizeof(table) / sizeof(*table); ++i) { - for (int i = 0; i < sizeof(table) / sizeof(*table); ++i) - { - if (m_parr.HasParam(PF_PARAM_NONE, "vec4", table[i].second)) - OS << "layout(location=" << i << ") " << "out vec4 " << table[i].first << ";" << std::endl; - } + if (m_parr.HasParam(PF_PARAM_NONE, "vec4", table[i].second)) + OS << "layout(location=" << std::to_string(output_index++) << ") " << "out vec4 " << table[i].first << ";" << std::endl; } }