radv/rt: Restore prev barycentrics when rejecting hits
authorKonstantin Seurer <konstantin.seurer@gmail.com>
Fri, 4 Nov 2022 19:57:57 +0000 (20:57 +0100)
committerMarge Bot <emma+marge@anholt.net>
Sun, 6 Nov 2022 11:36:10 +0000 (11:36 +0000)
Closes: #6348
cc: mesa-stable

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19534>

src/amd/vulkan/radv_pipeline_rt.c

index a5ebf0d79e1892cfc385ddfc0de6aff5dae533c2..f114af5bac6d5ac62f8583a1e9de5669a39e5bdb 100644 (file)
@@ -1165,10 +1165,10 @@ handle_candidate_triangle(nir_builder *b, struct radv_triangle_intersection *int
    nir_ssa_def *hit_kind =
       nir_bcsel(b, intersection->frontface, nir_imm_int(b, 0xFE), nir_imm_int(b, 0xFF));
 
-   nir_store_scratch(
-      b, intersection->barycentrics,
-      nir_iadd_imm(b, nir_load_var(b, data->vars->stack_ptr), RADV_HIT_ATTRIB_OFFSET),
-      .align_mul = 16);
+   nir_ssa_def *barycentrics_addr =
+      nir_iadd_imm(b, nir_load_var(b, data->vars->stack_ptr), RADV_HIT_ATTRIB_OFFSET);
+   nir_ssa_def *prev_barycentrics = nir_load_scratch(b, 2, 32, barycentrics_addr, .align_mul = 16);
+   nir_store_scratch(b, intersection->barycentrics, barycentrics_addr, .align_mul = 16);
 
    nir_store_var(b, data->vars->ahit_accept, nir_imm_true(b), 0x1);
    nir_store_var(b, data->vars->ahit_terminate, nir_imm_false(b), 0x1);
@@ -1191,6 +1191,7 @@ handle_candidate_triangle(nir_builder *b, struct radv_triangle_intersection *int
 
       nir_push_if(b, nir_inot(b, nir_load_var(b, data->vars->ahit_accept)));
       {
+         nir_store_scratch(b, prev_barycentrics, barycentrics_addr, .align_mul = 16);
          nir_jump(b, nir_jump_continue);
       }
       nir_pop_if(b, NULL);