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