radv/rt: Fix frontface culling with emulated RT

We need to preserve the divisor's sign for front/backface detection to
work correctly.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28034>
(cherry picked from commit 7792ee1c15)
This commit is contained in:
Friedrich Vock 2024-03-07 09:30:00 +01:00 committed by Eric Engestrom
parent dfc52d165a
commit eecce40e2a
2 changed files with 7 additions and 5 deletions

View file

@ -4,7 +4,7 @@
"description": "radv/rt: Fix frontface culling with emulated RT",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -269,11 +269,13 @@ intersect_ray_amd_software_tri(struct radv_device *device, nir_builder *b, nir_d
nir_push_if(b, det_cond_front);
{
t = nir_f2f32(b, nir_fdiv(b, t, det));
v = nir_f2f32(b, nir_fdiv(b, v, det));
w = nir_f2f32(b, nir_fdiv(b, w, det));
nir_def *det_abs = nir_fabs(b, det);
nir_def *indices[4] = {t, nir_imm_float(b, 1.0), v, w};
t = nir_f2f32(b, nir_fdiv(b, t, det_abs));
v = nir_f2f32(b, nir_fdiv(b, v, det_abs));
w = nir_f2f32(b, nir_fdiv(b, w, det_abs));
nir_def *indices[4] = {t, nir_f2f32(b, nir_fsign(b, det)), v, w};
nir_store_var(b, result, nir_vec(b, indices, 4), 0xf);
}
nir_pop_if(b, NULL);