From 9b577f2a887968483b88b629673d3f9904a179ff Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 21 Nov 2019 16:11:15 -0800 Subject: 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: 7025dbe794b ("nir: Skip emitting no-op movs from the builder.") Reviewed-by: Eric Anholt Reviewed-by: Ian Romanick --- src/gallium/auxiliary/pipe-loader/driinfo_gallium.h | 1 + src/gallium/include/state_tracker/st_api.h | 1 + src/gallium/state_trackers/dri/dri_screen.c | 2 ++ 3 files changed, 4 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h index 69967d916f2..bac60215d15 100644 --- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h +++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h @@ -38,6 +38,7 @@ DRI_CONF_SECTION_END DRI_CONF_SECTION_MISCELLANEOUS DRI_CONF_ALWAYS_HAVE_DEPTH_BUFFER("false") DRI_CONF_GLSL_ZERO_INIT("false") + DRI_CONF_VS_POSITION_ALWAYS_INVARIANT("false") DRI_CONF_ALLOW_RGB10_CONFIGS("true") DRI_CONF_ALLOW_FP16_CONFIGS("false") DRI_CONF_SECTION_END diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 297954d70bf..9fd36447c7b 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -228,6 +228,7 @@ struct st_config_options bool allow_glsl_builtin_variable_redeclaration; bool allow_higher_compat_version; bool glsl_zero_init; + bool vs_position_always_invariant; bool force_glsl_abs_sqrt; bool allow_glsl_cross_stage_interpolation_mismatch; bool allow_glsl_layout_qualifier_on_function_parameters; diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 0da789643fc..8600ce029f0 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -84,6 +84,8 @@ dri_fill_st_options(struct dri_screen *screen) options->allow_higher_compat_version = driQueryOptionb(optionCache, "allow_higher_compat_version"); options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init"); + options->vs_position_always_invariant = + driQueryOptionb(optionCache, "vs_position_always_invariant"); options->force_glsl_abs_sqrt = driQueryOptionb(optionCache, "force_glsl_abs_sqrt"); options->allow_glsl_cross_stage_interpolation_mismatch = -- cgit v1.2.3