diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 73a7bb27c..06f6a1cd4 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -334,7 +334,7 @@ private: return fmt::format("reg_tmp{}", index); case RegisterType::FloatUniform: if (address_register_index != 0) { - return fmt::format("uniforms.f[{} + address_registers.{}]", index, + return fmt::format("get_offset_register({}, address_registers.{})", index, "xyz"[address_register_index - 1]); } return fmt::format("uniforms.f[{}]", index); @@ -835,6 +835,14 @@ private: #endif } + shader.AddLine("vec4 get_offset_register(int base_index, int offset) {{"); + ++shader.scope; + shader.AddLine("int fixed_offset = offset >= -128 && offset <= 127 ? offset : 0;"); + shader.AddLine("uint index = uint((base_index + fixed_offset) & 0x7F);"); + shader.AddLine("return index < 96u ? uniforms.f[index] : vec4(1.0);"); + --shader.scope; + shader.AddLine("}}\n"); + // Add declarations for registers shader.AddLine("bvec2 conditional_code = bvec2(false);"); shader.AddLine("ivec3 address_registers = ivec3(0);");