driconf, glsl: Add a vs_position_always_invariant option

Many applications use multi-pass rendering and require their vertex
shader position to be computed the same way each time.  Optimizations
may consider, say, fusing a multiply-add based on global usage of an
expression in a shader.  But a second shader with the same expression
may have different code, causing that optimization to make the other
choice the second time around.

The correct solution is for applications to mark their VS outputs
'invariant', indicating they need multiple shaders to compute that
output in the same manner.  However, most applications fail to do so.

So, we add a new driconf option - vs_position_always_invariant - which
forces the gl_Position output in vertex shaders to be marked invariant.

Fixes: 7025dbe794 ("nir: Skip emitting no-op movs from the builder.")
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Kenneth Graunke
2019-11-21 16:11:15 -08:00
parent 424d5e4e11
commit 9b577f2a88
8 changed files with 23 additions and 0 deletions
+6
View File
@@ -1435,6 +1435,9 @@ builtin_variable_generator::add_varying(int slot, const glsl_type *type,
void
builtin_variable_generator::generate_varyings()
{
struct gl_shader_compiler_options *options =
&state->ctx->Const.ShaderCompilerOptions[state->stage];
/* gl_Position and gl_PointSize are not visible from fragment shaders. */
if (state->stage != MESA_SHADER_FRAGMENT) {
add_varying(VARYING_SLOT_POS, vec4_t, GLSL_PRECISION_HIGH, "gl_Position");
@@ -1526,6 +1529,9 @@ builtin_variable_generator::generate_varyings()
var->data.sample = fields[i].sample;
var->data.patch = fields[i].patch;
var->init_interface_type(per_vertex_out_type);
var->data.invariant = fields[i].location == VARYING_SLOT_POS &&
options->PositionAlwaysInvariant;
}
}
}