<div dir="ltr">We don't always emit 0 for that SGPR. See radv_cs_emit_indirect_draw_packet.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 29, 2018 at 12:39 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">We always emit 0 in there, just remove the allocated user SGPR<br>
and return a constant instead. This will free one SGPR for apps<br>
that need the draw ID.<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 | 17 +++--------------<br>
src/amd/vulkan/radv_cmd_<wbr>buffer.c | 6 ++----<br>
src/amd/vulkan/radv_pipeline.c | 4 ----<br>
src/amd/vulkan/radv_private.h | 1 -<br>
4 files changed, 5 insertions(+), 23 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 b3336ffafe..47f62f42dc 100644<br>
--- a/src/amd/common/ac_nir_to_<wbr>llvm.c<br>
+++ b/src/amd/common/ac_nir_to_<wbr>llvm.c<br>
@@ -571,11 +571,7 @@ static void allocate_user_sgprs(struct nir_to_llvm_context *ctx,<br>
case MESA_SHADER_VERTEX:<br>
if (!ctx->is_gs_copy_shader) {<br>
user_sgpr_info->sgpr_count += ctx->shader_info->info.vs.has_<wbr>vertex_buffers ? 2 : 0;<br>
- if (ctx->shader_info->info.vs.<wbr>needs_draw_id) {<br>
- user_sgpr_info->sgpr_count += 3;<br>
- } else {<br>
- user_sgpr_info->sgpr_count += 2;<br>
- }<br>
+ user_sgpr_info->sgpr_count += 2;<br>
}<br>
if (ctx->options->key.vs.as_ls)<br>
user_sgpr_info->sgpr_count++;<br>
@@ -661,9 +657,6 @@ declare_vs_specific_input_<wbr>sgprs(struct nir_to_llvm_context *ctx,<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>
- if (ctx->shader_info->info.vs.<wbr>needs_draw_id) {<br>
- add_arg(args, ARG_SGPR, ctx->ac.i32, &ctx->abi.draw_id);<br>
- }<br>
}<br>
}<br>
<br>
@@ -749,12 +742,8 @@ set_vs_specific_input_locs(<wbr>struct nir_to_llvm_context *ctx,<br>
user_sgpr_idx, 2);<br>
}<br>
<br>
- unsigned vs_num = 2;<br>
- if (ctx->shader_info->info.vs.<wbr>needs_draw_id)<br>
- vs_num++;<br>
-<br>
set_loc_shader(ctx, AC_UD_VS_BASE_VERTEX_START_<wbr>INSTANCE,<br>
- user_sgpr_idx, vs_num);<br>
+ user_sgpr_idx, 2);<br>
}<br>
}<br>
<br>
@@ -4332,7 +4321,7 @@ static void visit_intrinsic(struct ac_nir_context *ctx,<br>
result = ctx->abi->start_instance;<br>
break;<br>
case nir_intrinsic_load_draw_id:<br>
- result = ctx->abi->draw_id;<br>
+ result = ctx->abi->draw_id ? ctx->abi->draw_id : ctx->ac.i32_0;<br>
break;<br>
case nir_intrinsic_load_view_index:<br>
result = ctx->nctx->view_index ? ctx->nctx->view_index : ctx->ac.i32_0;<br>
diff --git a/src/amd/vulkan/radv_cmd_<wbr>buffer.c b/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
index b694174de6..e347c3f563 100644<br>
--- a/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
+++ b/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
@@ -3360,13 +3360,11 @@ radv_emit_draw_packets(struct radv_cmd_buffer *cmd_buffer,<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,<br>
- state->pipeline->graphics.vtx_<wbr>emit_num);<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_emit_num == 3)<br>
- radeon_emit(cs, 0);<br>
+<br>
state->last_first_instance = info->first_instance;<br>
state->last_vertex_offset = info->vertex_offset;<br>
}<br>
diff --git a/src/amd/vulkan/radv_<wbr>pipeline.c b/src/amd/vulkan/radv_<wbr>pipeline.c<br>
index 589e49a813..a3ba6ee3aa 100644<br>
--- a/src/amd/vulkan/radv_<wbr>pipeline.c<br>
+++ b/src/amd/vulkan/radv_<wbr>pipeline.c<br>
@@ -2691,10 +2691,6 @@ radv_pipeline_init(struct radv_pipeline *pipeline,<br>
if (loc->sgpr_idx != -1) {<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>
- if (radv_get_vertex_shader(<wbr>pipeline)->info.info.vs.needs_<wbr>draw_id)<br>
- pipeline->graphics.vtx_emit_<wbr>num = 3;<br>
- else<br>
- pipeline->graphics.vtx_emit_<wbr>num = 2;<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 f650b9a360..7ad0c3baa8 100644<br>
--- a/src/amd/vulkan/radv_private.<wbr>h<br>
+++ b/src/amd/vulkan/radv_private.<wbr>h<br>
@@ -1257,7 +1257,6 @@ 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>