yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

gl_shader_decompiler: Move position varying location from 15 to 0 and apply an offset

This commit is contained in:
ReinUsesLisp 2018-10-07 17:27:15 -03:00
parent ee4d538850
commit 7c2d6ef210
1 changed files with 10 additions and 6 deletions

View File

@ -30,7 +30,7 @@ using Tegra::Shader::SubOp;
constexpr u32 PROGRAM_END = MAX_PROGRAM_CODE_LENGTH; constexpr u32 PROGRAM_END = MAX_PROGRAM_CODE_LENGTH;
constexpr u32 PROGRAM_HEADER_SIZE = sizeof(Tegra::Shader::Header); constexpr u32 PROGRAM_HEADER_SIZE = sizeof(Tegra::Shader::Header);
constexpr u32 POSITION_VARYING_LOCATION = 15; enum : u32 { POSITION_VARYING_LOCATION = 0, GENERIC_VARYING_START_LOCATION = 1 };
constexpr u32 MAX_GEOMETRY_BUFFERS = 6; constexpr u32 MAX_GEOMETRY_BUFFERS = 6;
constexpr u32 MAX_ATTRIBUTES = 0x100; // Size in vec4s, this value is untested constexpr u32 MAX_ATTRIBUTES = 0x100; // Size in vec4s, this value is untested
@ -559,7 +559,10 @@ private:
// TODO(bunnei): Use proper number of elements for these // TODO(bunnei): Use proper number of elements for these
u32 idx = u32 idx =
static_cast<u32>(element.first) - static_cast<u32>(Attribute::Index::Attribute_0); static_cast<u32>(element.first) - static_cast<u32>(Attribute::Index::Attribute_0);
ASSERT(idx != POSITION_VARYING_LOCATION); if (stage != Maxwell3D::Regs::ShaderStage::Vertex) {
// If inputs are varyings, add an offset
idx += GENERIC_VARYING_START_LOCATION;
}
std::string attr{GetInputAttribute(element.first, element.second)}; std::string attr{GetInputAttribute(element.first, element.second)};
if (stage == Maxwell3D::Regs::ShaderStage::Geometry) { if (stage == Maxwell3D::Regs::ShaderStage::Geometry) {
@ -580,10 +583,11 @@ private:
} }
for (const auto& index : declr_output_attribute) { for (const auto& index : declr_output_attribute) {
// TODO(bunnei): Use proper number of elements for these // TODO(bunnei): Use proper number of elements for these
declarations.AddLine("layout (location = " + const u32 idx = static_cast<u32>(index) -
std::to_string(static_cast<u32>(index) - static_cast<u32>(Attribute::Index::Attribute_0) +
static_cast<u32>(Attribute::Index::Attribute_0)) + GENERIC_VARYING_START_LOCATION;
") out vec4 " + GetOutputAttribute(index) + ';'); declarations.AddLine("layout (location = " + std::to_string(idx) + ") out vec4 " +
GetOutputAttribute(index) + ';');
} }
declarations.AddNewLine(); declarations.AddNewLine();
} }