From 08e7a23121e2242cb09b1d23127f315a82628196 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Tue, 2 May 2023 15:42:36 +0300 Subject: [PATCH] vk: Improved attribute interpolation for NVIDIA --- rpcs3/Emu/RSX/Program/GLSLCommon.cpp | 32 +++++++--------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/rpcs3/Emu/RSX/Program/GLSLCommon.cpp b/rpcs3/Emu/RSX/Program/GLSLCommon.cpp index 25a89883d8..a378349a50 100644 --- a/rpcs3/Emu/RSX/Program/GLSLCommon.cpp +++ b/rpcs3/Emu/RSX/Program/GLSLCommon.cpp @@ -1246,30 +1246,14 @@ namespace glsl // Interpolate the input attributes manually. // Matches AMD behavior where gl_BaryCoordSmoothAMD only provides x and y with z being autogenerated. - std::string interpolate_function_block; - if (g_cfg.video.shader_precision == gpu_preset_level::ultra) - { - interpolate_function_block = - "\n" - "vec4 _interpolate_varying3(const in vec4[3] v)\n" - "{\n" - " const double _gl_BaryCoord_x = double($gl_BaryCoord.x);\n" - " const double _gl_BaryCoord_y = double($gl_BaryCoord.y);\n" - " const double _gl_BaryCoord_z = double(1.0) - (_gl_BaryCoord_x + _gl_BaryCoord_y);\n" - " return vec4(_gl_BaryCoord_x * v[0] + _gl_BaryCoord_y * v[1] + _gl_BaryCoord_z * v[2]);\n" - "}\n\n"; - } - else - { - interpolate_function_block = - "\n" - "vec4 _interpolate_varying3(const in vec4[3] v)\n" - "{\n" - " vec3 _gl_BaryCoord = vec3($gl_BaryCoord.xy, 1.f);\n" - " _gl_BaryCoord.z = dot(_gl_BaryCoord, vec3(-1.f, -1.f, 1.f));\n" - " return vec4(_gl_BaryCoord.x * v[0] + _gl_BaryCoord.y * v[1] + _gl_BaryCoord.z * v[2]);\n" - "}\n\n"; - } + std::string interpolate_function_block = + "\n" + "vec4 _interpolate_varying3(const in vec4[3] v)\n" + "{\n" + " const vec4 p10 = v[1] - v[0];\n" + " const vec4 p20 = v[2] - v[0];\n" + " return v[0] + p10 * $gl_BaryCoord.y + p20 * $gl_BaryCoord.z;\n" + "}\n\n"; OS << fmt::replace_all(interpolate_function_block, {{ "$gl_BaryCoord", "gl_BaryCoord"s + std::string(ext_flavour) }}); for (const auto& reg : varying_list)