gl: Explicitly declare gl_Position as invariant when using MESA

This commit is contained in:
kd-11 2022-10-06 03:20:09 +03:00 committed by kd-11
parent d25d1ecb3a
commit 87411da95f
3 changed files with 57 additions and 48 deletions

View file

@ -58,8 +58,6 @@ void GLVertexDecompilerThread::insertInputs(std::stringstream& OS, const std::ve
void GLVertexDecompilerThread::insertConstants(std::stringstream& OS, const std::vector<ParamType>& constants) void GLVertexDecompilerThread::insertConstants(std::stringstream& OS, const std::vector<ParamType>& constants)
{ {
for (const ParamType &PT: constants) for (const ParamType &PT: constants)
{ {
for (const ParamItem &PI : PT.items) for (const ParamItem &PI : PT.items)
@ -131,6 +129,7 @@ void GLVertexDecompilerThread::insertMainStart(std::stringstream & OS)
properties2.emulate_zclip_transform = true; properties2.emulate_zclip_transform = true;
properties2.emulate_depth_clip_only = dev_caps.NV_depth_buffer_float_supported; properties2.emulate_depth_clip_only = dev_caps.NV_depth_buffer_float_supported;
properties2.low_precision_tests = dev_caps.vendor_NVIDIA; properties2.low_precision_tests = dev_caps.vendor_NVIDIA;
properties2.require_explicit_invariance = dev_caps.vendor_MESA;
insert_glsl_legacy_function(OS, properties2); insert_glsl_legacy_function(OS, properties2);
glsl::insert_vertex_input_fetch(OS, glsl::glsl_rules_opengl4, dev_caps.vendor_INTEL == false); glsl::insert_vertex_input_fetch(OS, glsl::glsl_rules_opengl4, dev_caps.vendor_INTEL == false);

View file

@ -598,7 +598,15 @@ namespace glsl
"}\n\n"; "}\n\n";
} }
if (props.domain == glsl::program_domain::glsl_vertex_program && props.emulate_zclip_transform) if (props.domain == glsl::program_domain::glsl_vertex_program)
{
if (props.require_explicit_invariance)
{
// PS3 has shader invariance, but we don't really care about most attributes outside ATTR0
OS << "invariant gl_Position;\n\n";
}
if (props.emulate_zclip_transform)
{ {
if (props.emulate_depth_clip_only) if (props.emulate_depth_clip_only)
{ {
@ -649,6 +657,7 @@ namespace glsl
" return vec4(pos.x, pos.y, d * pos.w, pos.w);\n" " return vec4(pos.x, pos.y, d * pos.w, pos.w);\n"
"}\n\n"; "}\n\n";
} }
}
return; return;
} }

View file

@ -31,6 +31,7 @@ namespace glsl
bool require_texture_expand : 1; bool require_texture_expand : 1;
bool require_srgb_to_linear : 1; bool require_srgb_to_linear : 1;
bool require_linear_to_srgb : 1; bool require_linear_to_srgb : 1;
bool require_explicit_invariance: 1;
bool emulate_coverage_tests : 1; bool emulate_coverage_tests : 1;
bool emulate_shadow_compare : 1; bool emulate_shadow_compare : 1;
bool emulate_zclip_transform : 1; bool emulate_zclip_transform : 1;