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@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17145>
This commit is contained in:
Mike Blumenkrantz 2022-06-20 14:33:09 -04:00 committed by Marge Bot
parent 42a1264951
commit 4830cc77cb
1 changed files with 12 additions and 5 deletions

View File

@ -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);
}
}