Mesa (main): nir/lower_psiz_mov: stop clobbering existing exports

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Feb 28 16:08:50 UTC 2022


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu Feb  3 10:21:19 2022 -0500

nir/lower_psiz_mov: stop clobbering existing exports

for this pass to work with xfb, the original value in the shader must be
preserved when xfb is active, and the driver must export only the newly
created output

Acked-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15184>

---

 src/compiler/nir/nir_lower_point_size_mov.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/compiler/nir/nir_lower_point_size_mov.c b/src/compiler/nir/nir_lower_point_size_mov.c
index 58d1868261a..4a71d75dea5 100644
--- a/src/compiler/nir/nir_lower_point_size_mov.c
+++ b/src/compiler/nir/nir_lower_point_size_mov.c
@@ -38,7 +38,7 @@ lower_impl(nir_function_impl *impl,
 {
    nir_shader *shader = impl->function->shader;
    nir_builder b;
-   nir_variable *in;
+   nir_variable *in, *new_out = NULL;
 
    nir_builder_init(&b, impl);
 
@@ -51,12 +51,19 @@ lower_impl(nir_function_impl *impl,
          pointsize_state_tokens,
          sizeof(in->state_slots[0].tokens));
 
+   /* the existing output can't be removed in order to avoid breaking xfb.
+    * drivers must check var->data.explicit_location to find the original output
+    * and only emit that one for xfb
+    */
+   if (!out || shader->info.has_transform_feedback_varyings) {
+      new_out = nir_variable_create(shader, nir_var_shader_out,
+                                    glsl_float_type(), "gl_PointSizeMESA");
+      new_out->data.location = VARYING_SLOT_PSIZ;
+   }
+
    if (!out) {
-      out = nir_variable_create(shader, nir_var_shader_out,
-                                glsl_float_type(), "gl_PointSize");
-      out->data.location = VARYING_SLOT_PSIZ;
       b.cursor = nir_before_cf_list(&impl->body);
-      nir_copy_var(&b, out, in);
+      nir_copy_var(&b, new_out, in);
    } else {
       nir_foreach_block_safe(block, impl) {
          nir_foreach_instr_safe(instr, block) {
@@ -66,7 +73,7 @@ lower_impl(nir_function_impl *impl,
                   nir_variable *var = nir_intrinsic_get_var(intr, 0);
                   if (var == out) {
                      b.cursor = nir_after_instr(instr);
-                     nir_copy_var(&b, out, in);
+                     nir_copy_var(&b, new_out ? new_out : out, in);
                   }
                }
             }



More information about the mesa-commit mailing list