r600/sfn: Lower FS inputs to temps late and, and lower interpolate at

This fixes FS shaders where a var is loaded with two different
interpolators.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9330>
This commit is contained in:
Gert Wollny
2021-02-26 16:14:52 +01:00
parent 3ba7784b1e
commit c427ed7ffe
2 changed files with 19 additions and 1 deletions

View File

@@ -1188,7 +1188,7 @@ const struct nir_shader_compiler_options r600_nir_fs_options = {
.lower_extract_word = true, .lower_extract_word = true,
.lower_rotate = true, .lower_rotate = true,
.max_unroll_iterations = 32, .max_unroll_iterations = 32,
.lower_all_io_to_temps = true, .lower_interpolate_at = true,
.vectorize_io = true, .vectorize_io = true,
.has_umad24 = true, .has_umad24 = true,
.has_umul24 = true, .has_umul24 = true,

View File

@@ -902,6 +902,24 @@ int r600_shader_from_nir(struct r600_context *rctx,
if (sel->nir->info.stage != MESA_SHADER_FRAGMENT) if (sel->nir->info.stage != MESA_SHADER_FRAGMENT)
io_modes |= nir_var_shader_out; io_modes |= nir_var_shader_out;
if (sel->nir->info.stage == MESA_SHADER_FRAGMENT) {
/* Lower IO to temporaries late, because otherwise we get into trouble
* with the glsl 4.40 interpolateAt swizzle tests. There seems to be a bug
* somewhere that results in the input alweas reading from the same temp
* regardless of interpolation when the lowering is done early */
NIR_PASS_V(sel->nir, nir_lower_io_to_temporaries, nir_shader_get_entrypoint(sel->nir),
true, true);
/* Since we're doing nir_lower_io_to_temporaries late, we need
* to lower all the copy_deref's introduced by
* lower_io_to_temporaries before calling nir_lower_io.
*/
NIR_PASS_V(sel->nir, nir_split_var_copies);
NIR_PASS_V(sel->nir, nir_lower_var_copies);
NIR_PASS_V(sel->nir, nir_lower_global_vars_to_local);
}
NIR_PASS_V(sel->nir, nir_lower_io, io_modes, r600_glsl_type_size, NIR_PASS_V(sel->nir, nir_lower_io, io_modes, r600_glsl_type_size,
nir_lower_io_lower_64bit_to_32); nir_lower_io_lower_64bit_to_32);