radv/rt: use terminate() when returning from raygen shaders
authorDaniel Schürmann <daniel@schuermann.dev>
Thu, 26 Jan 2023 17:45:01 +0000 (18:45 +0100)
committerMarge Bot <emma+marge@anholt.net>
Wed, 8 Mar 2023 16:59:41 +0000 (16:59 +0000)
Q2RTX stats:
Totals from 7 (0.01% of 134913) affected shaders:

CodeSize: 204712 -> 204744 (+0.02%); split: -0.06%, +0.07%
Instrs: 37526 -> 37522 (-0.01%); split: -0.07%, +0.06%
Latency: 950563 -> 956024 (+0.57%)
InvThroughput: 187915 -> 188977 (+0.57%)
Copies: 4829 -> 4763 (-1.37%)
Branches: 1570 -> 1583 (+0.83%)
PreSGPRs: 407 -> 400 (-1.72%)
PreVGPRs: 614 -> 617 (+0.49%)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21736>

src/amd/compiler/aco_lower_to_hw_instr.cpp
src/amd/vulkan/radv_rt_shader.c

index af26ead..4bba62f 100644 (file)
@@ -2249,8 +2249,9 @@ lower_to_hw_instr(Program* program)
                   if (program->gfx_level >= GFX11)
                      target =
                         program->has_color_exports ? V_008DFC_SQ_EXP_MRT : V_008DFC_SQ_EXP_MRTZ;
-                  bld.exp(aco_opcode::exp, Operand(v1), Operand(v1), Operand(v1), Operand(v1), 0,
-                          target, false, true, true);
+                  if (program->stage == fragment_fs)
+                     bld.exp(aco_opcode::exp, Operand(v1), Operand(v1), Operand(v1), Operand(v1),
+                             0, target, false, true, true);
                   if (should_dealloc_vgprs)
                      bld.sopp(aco_opcode::s_sendmsg, -1, sendmsg_dealloc_vgprs);
                   bld.sopp(aco_opcode::s_endpgm);
index bb55116..c60c5f9 100644 (file)
@@ -375,7 +375,7 @@ lower_rt_instructions(nir_shader *shader, struct rt_variables *vars, unsigned ca
             }
             case nir_intrinsic_rt_return_amd: {
                if (shader->info.stage == MESA_SHADER_RAYGEN) {
-                  nir_store_var(&b_shader, vars->idx, nir_imm_int(&b_shader, 0), 1);
+                  nir_terminate(&b_shader);
                   break;
                }
                insert_rt_return(&b_shader, vars);
@@ -1588,11 +1588,6 @@ create_rt_shader(struct radv_device *device, const VkRayTracingPipelineCreateInf
    nir_store_var(&b, vars.launch_size, nir_vec(&b, xyz, 3), 0x7);
 
    nir_loop *loop = nir_push_loop(&b);
-
-   nir_push_if(&b, nir_ieq_imm(&b, nir_load_var(&b, vars.idx), 0));
-   nir_jump(&b, nir_jump_break);
-   nir_pop_if(&b, NULL);
-
    nir_ssa_def *idx = nir_load_var(&b, vars.idx);
 
    /* Insert traversal shader */