Mesa (staging/22.1): nir/lower_point_size: apply point size clamping

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 23 16:19:37 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 3f0815a3338498169a4c557f1e0fe7b87c8b48aa
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f0815a3338498169a4c557f1e0fe7b87c8b48aa

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Mon Jun 20 14:33:09 2022 -0400

nir/lower_point_size: apply point size clamping

point size min/max values are provided through the state vars, so ensure
these are always applied in order to respect ARB_point_parameters

cc: mesa-stable

Acked-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17145>
(cherry picked from commit 4830cc77cb8d1f9113b799b68fbaefc91dcc5344)

---

 .pick_status.json                           |  2 +-
 src/compiler/nir/nir_lower_point_size_mov.c | 17 ++++++++++++-----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 87d8e22653c..b5ba11a43b7 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -445,7 +445,7 @@
         "description": "nir/lower_point_size: apply point size clamping",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/compiler/nir/nir_lower_point_size_mov.c b/src/compiler/nir/nir_lower_point_size_mov.c
index 3ef938e59ec..beedf33856c 100644
--- a/src/compiler/nir/nir_lower_point_size_mov.c
+++ b/src/compiler/nir/nir_lower_point_size_mov.c
@@ -43,10 +43,10 @@ lower_impl(nir_function_impl *impl,
    nir_builder_init(&b, impl);
 
    in = nir_variable_create(shader, nir_var_uniform,
-                            glsl_float_type(), "gl_PointSizeClampedMESA");
+                            glsl_vec4_type(), "gl_PointSizeClampedMESA");
    in->num_state_slots = 1;
    in->state_slots = ralloc_array(in, nir_state_slot, 1);
-   in->state_slots[0].swizzle = 0;
+   in->state_slots[0].swizzle = BITFIELD_MASK(4);
    memcpy(in->state_slots[0].tokens,
          pointsize_state_tokens,
          sizeof(in->state_slots[0].tokens));
@@ -61,9 +61,12 @@ lower_impl(nir_function_impl *impl,
       new_out->data.location = VARYING_SLOT_PSIZ;
    }
 
+
    if (!out) {
       b.cursor = nir_before_cf_list(&impl->body);
-      nir_copy_var(&b, new_out, in);
+      nir_ssa_def *load = nir_load_var(&b, in);
+      load = nir_fclamp(&b, nir_channel(&b, load, 0), nir_channel(&b, load, 1), nir_channel(&b, load, 2));
+      nir_store_var(&b, new_out, load, 0x1);
    } else {
       bool found = false;
       nir_foreach_block_safe(block, impl) {
@@ -74,7 +77,9 @@ 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, new_out ? new_out : out, in);
+                     nir_ssa_def *load = nir_load_var(&b, in);
+                     load = nir_fclamp(&b, nir_channel(&b, load, 0), nir_channel(&b, load, 1), nir_channel(&b, load, 2));
+                     nir_store_var(&b, new_out ? new_out : out, load, 0x1);
                      found = true;
                   }
                }
@@ -83,7 +88,9 @@ lower_impl(nir_function_impl *impl,
       }
       if (!found) {
          b.cursor = nir_before_cf_list(&impl->body);
-         nir_copy_var(&b, new_out, in);
+         nir_ssa_def *load = nir_load_var(&b, in);
+         load = nir_fclamp(&b, nir_channel(&b, load, 0), nir_channel(&b, load, 1), nir_channel(&b, load, 2));
+         nir_store_var(&b, new_out, load, 0x1);
       }
    }
 



More information about the mesa-commit mailing list