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

Author: Marek Olšák <[email protected]>
Date:   Fri Aug 14 19:11:37 2020 -0400

radeonsi: remove in/out/uniform variables from NIR after lowering IO

Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Connor Abbott <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6445>

---

 src/gallium/drivers/radeonsi/si_shader_nir.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 00371224368..d9e3ac41868 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -752,6 +752,23 @@ static void si_lower_io(struct nir_shader *nir)
    NIR_PASS_V(nir, nir_opt_constant_folding);
    NIR_PASS_V(nir, nir_io_add_const_offset_to_base, nir_var_shader_in);
    NIR_PASS_V(nir, nir_io_add_const_offset_to_base, nir_var_shader_out);
+
+   /* Remove dead derefs, so that nir_validate doesn't fail. */
+   NIR_PASS_V(nir, nir_opt_dce);
+
+   /* Remove input and output nir_variables, because we don't need them
+    * anymore. Also remove uniforms, because those should have been lowered
+    * to UBOs already.
+    */
+   unsigned modes = nir_var_shader_in | nir_var_shader_out | nir_var_uniform;
+   nir_foreach_variable_with_modes_safe(var, nir, modes) {
+      if (var->data.mode == nir_var_uniform &&
+          (glsl_type_get_image_count(var->type) ||
+           glsl_type_get_sampler_count(var->type)))
+         continue;
+
+      exec_node_remove(&var->node);
+   }
 }
 
 /**

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

Reply via email to