<div dir="ltr">I don't think we can do this either, as the indirect draw packets require a group of 2 SGPRs to put them in, even if you don't use them.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 29, 2018 at 12:40 PM, Samuel Pitoiset <span dir="ltr"><<a href="mailto:samuel.pitoiset@gmail.com" target="_blank">samuel.pitoiset@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This should reduce the number of emitted SH_REG packets.<br>
<br>
Signed-off-by: Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>><br>
---<br>
 src/amd/common/ac_nir_to_llvm.<wbr>c  | 23 +++++++++++++++++++----<br>
 src/amd/vulkan/radv_cmd_<wbr>buffer.c | 27 +++++++++++++++++----------<br>
 src/amd/vulkan/radv_pipeline.c   | 11 +++++++++++<br>
 src/amd/vulkan/radv_private.h    |  1 +<br>
 4 files changed, 48 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/src/amd/common/ac_nir_to_<wbr>llvm.c b/src/amd/common/ac_nir_to_<wbr>llvm.c<br>
index 47f62f42dc..34133b8d23 100644<br>
--- a/src/amd/common/ac_nir_to_<wbr>llvm.c<br>
+++ b/src/amd/common/ac_nir_to_<wbr>llvm.c<br>
@@ -655,8 +655,14 @@ declare_vs_specific_input_<wbr>sgprs(struct nir_to_llvm_context *ctx,<br>
                        add_arg(args, ARG_SGPR, ac_array_in_const_addr_space(<wbr>ctx->ac.v4i32),<br>
                                &ctx->vertex_buffers);<br>
                }<br>
-               add_arg(args, ARG_SGPR, ctx->ac.i32, &ctx->abi.base_vertex);<br>
-               add_arg(args, ARG_SGPR, ctx->ac.i32, &ctx->abi.start_instance);<br>
+<br>
+               if (ctx->shader_info->info.vs.<wbr>needs_base_vertex) {<br>
+                       add_arg(args, ARG_SGPR, ctx->ac.i32, &ctx->abi.base_vertex);<br>
+               }<br>
+<br>
+               if (ctx->shader_info->info.vs.<wbr>needs_start_instance) {<br>
+                       add_arg(args, ARG_SGPR, ctx->ac.i32, &ctx->abi.start_instance);<br>
+               }<br>
        }<br>
 }<br>
<br>
@@ -737,13 +743,22 @@ set_vs_specific_input_locs(<wbr>struct nir_to_llvm_context *ctx,<br>
        if (!ctx->is_gs_copy_shader &&<br>
            (stage == MESA_SHADER_VERTEX ||<br>
             (has_previous_stage && previous_stage == MESA_SHADER_VERTEX))) {<br>
+               uint8_t num_sgprs = 0;<br>
+<br>
                if (ctx->shader_info->info.vs.<wbr>has_vertex_buffers) {<br>
                        set_loc_shader(ctx, AC_UD_VS_VERTEX_BUFFERS,<br>
                                       user_sgpr_idx, 2);<br>
                }<br>
<br>
-               set_loc_shader(ctx, AC_UD_VS_BASE_VERTEX_START_<wbr>INSTANCE,<br>
-                              user_sgpr_idx, 2);<br>
+               if (ctx->shader_info->info.vs.<wbr>needs_base_vertex)<br>
+                       num_sgprs++;<br>
+               if (ctx->shader_info->info.vs.<wbr>needs_start_instance)<br>
+                       num_sgprs++;<br>
+<br>
+               if (num_sgprs > 0) {<br>
+                       set_loc_shader(ctx, AC_UD_VS_BASE_VERTEX_START_<wbr>INSTANCE,<br>
+                                      user_sgpr_idx, num_sgprs);<br>
+               }<br>
        }<br>
 }<br>
<br>
diff --git a/src/amd/vulkan/radv_cmd_<wbr>buffer.c b/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
index e347c3f563..ccfafe8b58 100644<br>
--- a/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
+++ b/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
@@ -3356,17 +3356,24 @@ radv_emit_draw_packets(struct radv_cmd_buffer *cmd_buffer,<br>
                        }<br>
                }<br>
        } else {<br>
-               assert(state->pipeline-><wbr>graphics.vtx_base_sgpr);<br>
-<br>
-               if (info->vertex_offset != state->last_vertex_offset ||<br>
-                   info->first_instance != state->last_first_instance) {<br>
-                       radeon_set_sh_reg_seq(cs, state->pipeline->graphics.vtx_<wbr>base_sgpr, 2);<br>
-<br>
-                       radeon_emit(cs, info->vertex_offset);<br>
-                       radeon_emit(cs, info->first_instance);<br>
+               if (state->pipeline->graphics.<wbr>vtx_base_sgpr &&<br>
+                   (info->vertex_offset != state->last_vertex_offset ||<br>
+                    info->first_instance != state->last_first_instance)) {<br>
+                       struct radv_shader_variant *vs =<br>
+                               radv_get_vertex_shader(state-><wbr>pipeline);<br>
+<br>
+                       radeon_set_sh_reg_seq(cs, state->pipeline->graphics.vtx_<wbr>base_sgpr,<br>
+                                             state->pipeline->graphics.vtx_<wbr>emit_num);<br>
+<br>
+                       if (vs->info.info.vs.needs_base_<wbr>vertex) {<br>
+                               radeon_emit(cs, info->vertex_offset);<br>
+                               state->last_vertex_offset = info->vertex_offset;<br>
+                       }<br>
<br>
-                       state->last_first_instance = info->first_instance;<br>
-                       state->last_vertex_offset = info->vertex_offset;<br>
+                       if (vs->info.info.vs.needs_start_<wbr>instance) {<br>
+                               radeon_emit(cs, info->first_instance);<br>
+                               state->last_first_instance = info->first_instance;<br>
+                       }<br>
                }<br>
<br>
                if (state->last_num_instances != info->instance_count) {<br>
diff --git a/src/amd/vulkan/radv_<wbr>pipeline.c b/src/amd/vulkan/radv_<wbr>pipeline.c<br>
index a3ba6ee3aa..38b6be683d 100644<br>
--- a/src/amd/vulkan/radv_<wbr>pipeline.c<br>
+++ b/src/amd/vulkan/radv_<wbr>pipeline.c<br>
@@ -2689,8 +2689,19 @@ radv_pipeline_init(struct radv_pipeline *pipeline,<br>
        struct ac_userdata_info *loc = radv_lookup_user_sgpr(<wbr>pipeline, MESA_SHADER_VERTEX,<br>
                                                             AC_UD_VS_BASE_VERTEX_START_<wbr>INSTANCE);<br>
        if (loc->sgpr_idx != -1) {<br>
+               struct radv_shader_variant *vs =<br>
+                       radv_get_vertex_shader(<wbr>pipeline);<br>
+               uint8_t num_sgprs = 0;<br>
+<br>
                pipeline->graphics.vtx_base_<wbr>sgpr = pipeline->user_data_0[MESA_<wbr>SHADER_VERTEX];<br>
                pipeline->graphics.vtx_base_<wbr>sgpr += loc->sgpr_idx * 4;<br>
+<br>
+               if (vs->info.info.vs.needs_base_<wbr>vertex)<br>
+                       num_sgprs++;<br>
+               if (vs->info.info.vs.needs_start_<wbr>instance)<br>
+                       num_sgprs++;<br>
+<br>
+               pipeline->graphics.vtx_emit_<wbr>num = num_sgprs;<br>
        }<br>
<br>
        pipeline->graphics.vtx_reuse_<wbr>depth = 30;<br>
diff --git a/src/amd/vulkan/radv_private.<wbr>h b/src/amd/vulkan/radv_private.<wbr>h<br>
index 7ad0c3baa8..f650b9a360 100644<br>
--- a/src/amd/vulkan/radv_private.<wbr>h<br>
+++ b/src/amd/vulkan/radv_private.<wbr>h<br>
@@ -1257,6 +1257,7 @@ struct radv_pipeline {<br>
                        bool wd_switch_on_eop;<br>
                        bool ia_switch_on_eoi;<br>
                        bool partial_vs_wave;<br>
+                       uint8_t vtx_emit_num;<br>
                        uint32_t vtx_reuse_depth;<br>
                        struct radv_prim_vertex_count prim_vertex_count;<br>
                        bool can_use_guardband;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.16.1<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>