diff options
author | Iago Toral Quiroga <[email protected]> | 2019-11-13 09:19:22 +0100 |
---|---|---|
committer | Iago Toral Quiroga <[email protected]> | 2019-11-14 10:49:00 +0100 |
commit | f512965b0b3d70525424f100e534b8ac0a43a376 (patch) | |
tree | 9f5836852e3e3662a9b4ce1e521d36a7df95c8f1 /src/mesa/state_tracker/st_glsl_to_nir.cpp | |
parent | 66d24a9ef705b8f9f15dab8059b63781f9fb28ca (diff) |
mesa/st: make sure we remove dead IO variables before handing NIR to backends
Commit "1c2bf82d24a glsl: disable lower_fragdata_array() for NIR drivers"
disabled the GLSL IR lowering that turned gl_FragData from an array into a
collection of scalar outputs under the assumption that this was already being
handled properly elsewhere, however there are some corner cases where NIR
would fail to do this, leaving gl_FragData[] as an array variable. This can
break backends that assume that all their outputs will be scalar and use the
variable definitions from the shader to do their output setup, such as the
case of V3D.
At least one corner case was found in some Portal shaders from shader-db, where
NIR would optimize out the full body of a fragment shader. In this scenario,
the empty shader would keep the original array definition of gl_FragData[],
causing the backend to assert.
We need to do this late enough for it to be effective, since doing it in
st_nir_preprocess does not fix the original problem.
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2091
Fixes: 1c2bf82d ("glsl: disable lower_fragdata_array() for NIR drivers")
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_glsl_to_nir.cpp')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_nir.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 5aa47a42b2a..6cadf15d6df 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -493,7 +493,8 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog, st_nir_opts(nir); } - nir_variable_mode mask = nir_var_function_temp; + nir_variable_mode mask = (nir_variable_mode) + (nir_var_shader_in | nir_var_shader_out | nir_var_function_temp ); nir_remove_dead_variables(nir, mask); NIR_PASS_V(nir, nir_lower_atomics_to_ssbo, |