Module: Mesa
Branch: master
Commit: c427ed7ffee4f26b991e6a40616a4cfc2120da08
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c427ed7ffee4f26b991e6a40616a4cfc2120da08

Author: Gert Wollny <[email protected]>
Date:   Fri Feb 26 16:14:52 2021 +0100

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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9330>

---

 src/gallium/drivers/r600/r600_pipe_common.c |  2 +-
 src/gallium/drivers/r600/sfn/sfn_nir.cpp    | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/r600_pipe_common.c 
b/src/gallium/drivers/r600/r600_pipe_common.c
index 9b57691af40..20060685570 100644
--- a/src/gallium/drivers/r600/r600_pipe_common.c
+++ b/src/gallium/drivers/r600/r600_pipe_common.c
@@ -1188,7 +1188,7 @@ const struct nir_shader_compiler_options 
r600_nir_fs_options = {
        .lower_extract_word = true,
         .lower_rotate = true,
        .max_unroll_iterations = 32,
-       .lower_all_io_to_temps = true,
+       .lower_interpolate_at = true,
        .vectorize_io = true,
        .has_umad24 = true,
        .has_umul24 = true,
diff --git a/src/gallium/drivers/r600/sfn/sfn_nir.cpp 
b/src/gallium/drivers/r600/sfn/sfn_nir.cpp
index 0767f1bb71a..3765c699e6c 100644
--- a/src/gallium/drivers/r600/sfn/sfn_nir.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_nir.cpp
@@ -902,6 +902,24 @@ int r600_shader_from_nir(struct r600_context *rctx,
    if (sel->nir->info.stage != MESA_SHADER_FRAGMENT)
       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_lower_io_lower_64bit_to_32);
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to