1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

vk: Improved attribute interpolation for NVIDIA

This commit is contained in:
kd-11 2023-05-02 15:42:36 +03:00 committed by kd-11
parent bf190fd3d8
commit 08e7a23121

View File

@ -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)