Mesa (main): nir/lower_point_size: apply point size clamping
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 22 13:53:25 UTC 2022
Module: Mesa
Branch: main
Commit: 4830cc77cb8d1f9113b799b68fbaefc91dcc5344
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4830cc77cb8d1f9113b799b68fbaefc91dcc5344
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>
---
src/compiler/nir/nir_lower_point_size_mov.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
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