radeonsi: don't update indexed flag in SGPR if it's unused
authorMarek Olšák <marek.olsak@amd.com>
Wed, 25 Nov 2020 07:25:59 +0000 (02:25 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 1 Dec 2020 20:33:03 +0000 (15:33 -0500)
to skip the register update when switching between indexed and non-indexed

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7721>

src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_shader_nir.c
src/gallium/drivers/radeonsi/si_state_draw.c

index 1f06324..c91ed02 100644 (file)
@@ -367,6 +367,7 @@ struct si_shader_info {
    bool uses_linear_sample;
    bool uses_interp_at_sample;
    bool uses_instanceid;
+   bool uses_base_vertex;
    bool uses_drawid;
    bool uses_primid;
    bool uses_frontface;
index 0a2367a..9ce534f 100644 (file)
@@ -345,6 +345,7 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf
 
    info->uses_frontface = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_FRONT_FACE);
    info->uses_instanceid = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_INSTANCE_ID);
+   info->uses_base_vertex = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_BASE_VERTEX);
    info->uses_invocationid = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_INVOCATION_ID);
    info->uses_grid_size = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_NUM_WORK_GROUPS);
    info->uses_subgroup_info = nir->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_LOCAL_INVOCATION_INDEX) ||
index 831555a..9279bd5 100644 (file)
@@ -640,8 +640,10 @@ static void si_emit_rasterizer_prim_state(struct si_context *sctx)
 ALWAYS_INLINE
 static void si_emit_vs_state(struct si_context *sctx, const struct pipe_draw_info *info)
 {
-   sctx->current_vs_state &= C_VS_STATE_INDEXED;
-   sctx->current_vs_state |= S_VS_STATE_INDEXED(!!info->index_size);
+   if (sctx->vs_shader.cso->info.uses_base_vertex) {
+      sctx->current_vs_state &= C_VS_STATE_INDEXED;
+      sctx->current_vs_state |= S_VS_STATE_INDEXED(!!info->index_size);
+   }
 
    if (sctx->num_vs_blit_sgprs) {
       /* Re-emit the state after we leave u_blitter. */