mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 08:21:29 +12:00
rsx: Fix shader compilation
This commit is contained in:
parent
a0ef1a672c
commit
9c0b2338cf
5 changed files with 22 additions and 16 deletions
|
@ -1145,6 +1145,7 @@ namespace glsl
|
|||
|
||||
void insert_fragment_shader_inputs_block(
|
||||
std::stringstream& OS,
|
||||
const std::string_view ext_flavour,
|
||||
const RSXFragmentProgram& prog,
|
||||
const std::vector<ParamType>& params,
|
||||
const two_sided_lighting_config& _2sided_lighting,
|
||||
|
@ -1157,7 +1158,7 @@ namespace glsl
|
|||
std::string type;
|
||||
};
|
||||
|
||||
rsx::simple_array<_varying_register_config> varying_list;
|
||||
std::vector<_varying_register_config> varying_list;
|
||||
|
||||
for (const ParamType& PT : params)
|
||||
{
|
||||
|
@ -1208,7 +1209,7 @@ namespace glsl
|
|||
}
|
||||
|
||||
// Make the output a little nicer
|
||||
varying_list.sort(FN(x.location < y.location));
|
||||
std::sort(varying_list.begin(), varying_list.end(), FN(x.location < y.location));
|
||||
|
||||
if (!(prog.ctrl & RSX_SHADER_CONTROL_ATTRIBUTE_INTERPOLATION))
|
||||
{
|
||||
|
@ -1217,22 +1218,27 @@ namespace glsl
|
|||
OS << "layout(location=" << reg.location << ") in " << reg.type << " " << reg.name << ";\n";
|
||||
}
|
||||
|
||||
OS << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& reg : varying_list)
|
||||
{
|
||||
OS << "layout(location=" << reg.location << ") pervertexNV in " << reg.type << " " << reg.name << "_raw[3];\n";
|
||||
OS << "layout(location=" << reg.location << ") pervertex" << ext_flavour << " in " << reg.type << " " << reg.name << "_raw[3];\n";
|
||||
}
|
||||
|
||||
// Interpolate the input attributes manually.
|
||||
// Matches AMD behavior where gl_BaryCoordSmoothAMD only provides x and y with z being autogenerated.
|
||||
OS <<
|
||||
"vec4 _interpolate_varying3(const in vec4[3] v)\n"
|
||||
"{\n"
|
||||
" const BaryCoord_z = 1.0 - (gl_BaryCoordNV.x + gl_BaryCoordNV.y);\n"
|
||||
" return gl_BaryCoordNV.x * v[0] + gl_BaryCoordNV.y * v[1] + BaryCoord_z * v[2];\n"
|
||||
"}\n\n";
|
||||
OS << fmt::replace_all(
|
||||
"\n"
|
||||
"vec4 _interpolate_varying3(const in vec4[3] v)\n"
|
||||
"{\n"
|
||||
" const float _gl_BaryCoord_z = 1.0 - ($gl_BaryCoord.x + $gl_BaryCoord.y);\n"
|
||||
" return $gl_BaryCoord.x * v[0] + $gl_BaryCoord.y * v[1] + _gl_BaryCoord_z * v[2];\n"
|
||||
"}\n\n",
|
||||
{
|
||||
{ "$gl_BaryCoord", "gl_BaryCoord"s + std::string(ext_flavour) }
|
||||
});
|
||||
|
||||
for (const auto& reg : varying_list)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue