radeonsi: allow si_shader_select_with_key to return an optimized shader or fail
[mesa.git] / src / gallium / drivers / radeonsi / si_state_shaders.c
index e493f991a1bd8431d83228a4d4079f75559bd0e7..8ae77fda3f3009fc4346c4d9625235fecd8aa423 100644 (file)
@@ -337,10 +337,10 @@ void si_destroy_shader_cache(struct si_screen *sscreen)
 /* SHADER STATES */
 
 static void si_set_tesseval_regs(struct si_screen *sscreen,
-                                struct si_shader_selector *tes,
+                                const struct si_shader_selector *tes,
                                 struct si_pm4_state *pm4)
 {
-       struct tgsi_shader_info *info = &tes->info;
+       const struct tgsi_shader_info *info = &tes->info;
        unsigned tes_prim_mode = info->properties[TGSI_PROPERTY_TES_PRIM_MODE];
        unsigned tes_spacing = info->properties[TGSI_PROPERTY_TES_SPACING];
        bool tes_vertex_order_cw = info->properties[TGSI_PROPERTY_TES_VERTEX_ORDER_CW];
@@ -440,8 +440,8 @@ static void polaris_set_vgt_vertex_reuse(struct si_screen *sscreen,
                    PIPE_TESS_SPACING_FRACTIONAL_ODD)
                        vtx_reuse_depth = 14;
 
-               si_pm4_set_reg(pm4, R_028C58_VGT_VERTEX_REUSE_BLOCK_CNTL,
-                              vtx_reuse_depth);
+               assert(pm4->shader);
+               pm4->shader->vgt_vertex_reuse_block_cntl = vtx_reuse_depth;
        }
 }
 
@@ -464,12 +464,7 @@ static struct si_pm4_state *si_get_shader_pm4_state(struct si_shader *shader)
 static unsigned si_get_num_vs_user_sgprs(unsigned num_always_on_user_sgprs)
 {
        /* Add the pointer to VBO descriptors. */
-       if (HAVE_32BIT_POINTERS) {
-               return num_always_on_user_sgprs + 1;
-       } else {
-               assert(num_always_on_user_sgprs % 2 == 0);
-               return num_always_on_user_sgprs + 2;
-       }
+       return num_always_on_user_sgprs + 1;
 }
 
 static void si_shader_ls(struct si_screen *sscreen, struct si_shader *shader)
@@ -478,7 +473,7 @@ static void si_shader_ls(struct si_screen *sscreen, struct si_shader *shader)
        unsigned vgpr_comp_cnt;
        uint64_t va;
 
-       assert(sscreen->info.chip_class <= VI);
+       assert(sscreen->info.chip_class <= GFX8);
 
        pm4 = si_get_shader_pm4_state(shader);
        if (!pm4)
@@ -552,7 +547,7 @@ static void si_shader_hs(struct si_screen *sscreen, struct si_shader *shader)
                       S_00B428_FLOAT_MODE(shader->config.float_mode) |
                       S_00B428_LS_VGPR_COMP_CNT(ls_vgpr_comp_cnt));
 
-       if (sscreen->info.chip_class <= VI) {
+       if (sscreen->info.chip_class <= GFX8) {
                si_pm4_set_reg(pm4, R_00B42C_SPI_SHADER_PGM_RSRC2_HS,
                               shader->config.rsrc2);
        }
@@ -561,6 +556,7 @@ static void si_shader_hs(struct si_screen *sscreen, struct si_shader *shader)
 static void si_emit_shader_es(struct si_context *sctx)
 {
        struct si_shader *shader = sctx->queued.named.es->shader;
+       unsigned initial_cdw = sctx->gfx_cs->current.cdw;
 
        if (!shader)
                return;
@@ -574,6 +570,13 @@ static void si_emit_shader_es(struct si_context *sctx)
                                           SI_TRACKED_VGT_TF_PARAM,
                                           shader->vgt_tf_param);
 
+       if (shader->vgt_vertex_reuse_block_cntl)
+               radeon_opt_set_context_reg(sctx, R_028C58_VGT_VERTEX_REUSE_BLOCK_CNTL,
+                                          SI_TRACKED_VGT_VERTEX_REUSE_BLOCK_CNTL,
+                                          shader->vgt_vertex_reuse_block_cntl);
+
+       if (initial_cdw != sctx->gfx_cs->current.cdw)
+               sctx->context_roll = true;
 }
 
 static void si_shader_es(struct si_screen *sscreen, struct si_shader *shader)
@@ -584,7 +587,7 @@ static void si_shader_es(struct si_screen *sscreen, struct si_shader *shader)
        uint64_t va;
        unsigned oc_lds_en;
 
-       assert(sscreen->info.chip_class <= VI);
+       assert(sscreen->info.chip_class <= GFX8);
 
        pm4 = si_get_shader_pm4_state(shader);
        if (!pm4)
@@ -758,6 +761,8 @@ static void gfx9_get_gs_info(struct si_shader_selector *es,
 static void si_emit_shader_gs(struct si_context *sctx)
 {
        struct si_shader *shader = sctx->queued.named.gs->shader;
+       unsigned initial_cdw = sctx->gfx_cs->current.cdw;
+
        if (!shader)
                return;
 
@@ -813,7 +818,14 @@ static void si_emit_shader_gs(struct si_context *sctx)
                        radeon_opt_set_context_reg(sctx, R_028B6C_VGT_TF_PARAM,
                                                   SI_TRACKED_VGT_TF_PARAM,
                                                   shader->vgt_tf_param);
+               if (shader->vgt_vertex_reuse_block_cntl)
+                       radeon_opt_set_context_reg(sctx, R_028C58_VGT_VERTEX_REUSE_BLOCK_CNTL,
+                                                  SI_TRACKED_VGT_VERTEX_REUSE_BLOCK_CNTL,
+                                                  shader->vgt_vertex_reuse_block_cntl);
        }
+
+       if (initial_cdw != sctx->gfx_cs->current.cdw)
+               sctx->context_roll = true;
 }
 
 static void si_shader_gs(struct si_screen *sscreen, struct si_shader *shader)
@@ -949,6 +961,8 @@ static void si_shader_gs(struct si_screen *sscreen, struct si_shader *shader)
 static void si_emit_shader_vs(struct si_context *sctx)
 {
        struct si_shader *shader = sctx->queued.named.vs->shader;
+       unsigned initial_cdw = sctx->gfx_cs->current.cdw;
+
        if (!shader)
                return;
 
@@ -959,7 +973,7 @@ static void si_emit_shader_vs(struct si_context *sctx)
                                   SI_TRACKED_VGT_PRIMITIVEID_EN,
                                   shader->ctx_reg.vs.vgt_primitiveid_en);
 
-       if (sctx->chip_class <= VI) {
+       if (sctx->chip_class <= GFX8) {
                radeon_opt_set_context_reg(sctx, R_028AB4_VGT_REUSE_OFF,
                                           SI_TRACKED_VGT_REUSE_OFF,
                                           shader->ctx_reg.vs.vgt_reuse_off);
@@ -981,6 +995,14 @@ static void si_emit_shader_vs(struct si_context *sctx)
                radeon_opt_set_context_reg(sctx, R_028B6C_VGT_TF_PARAM,
                                           SI_TRACKED_VGT_TF_PARAM,
                                           shader->vgt_tf_param);
+
+       if (shader->vgt_vertex_reuse_block_cntl)
+               radeon_opt_set_context_reg(sctx, R_028C58_VGT_VERTEX_REUSE_BLOCK_CNTL,
+                                          SI_TRACKED_VGT_VERTEX_REUSE_BLOCK_CNTL,
+                                          shader->vgt_vertex_reuse_block_cntl);
+
+       if (initial_cdw != sctx->gfx_cs->current.cdw)
+               sctx->context_roll = true;
 }
 
 /**
@@ -1030,7 +1052,7 @@ static void si_shader_vs(struct si_screen *sscreen, struct si_shader *shader,
                shader->ctx_reg.vs.vgt_primitiveid_en = 0;
        }
 
-       if (sscreen->info.chip_class <= VI) {
+       if (sscreen->info.chip_class <= GFX8) {
                /* Reuse needs to be set off if we write oViewport. */
                shader->ctx_reg.vs.vgt_reuse_off =
                                S_028AB4_REUSE_OFF(info->writes_viewport_index);
@@ -1143,6 +1165,8 @@ static unsigned si_get_spi_shader_col_format(struct si_shader *shader)
 static void si_emit_shader_ps(struct si_context *sctx)
 {
        struct si_shader *shader = sctx->queued.named.ps->shader;
+       unsigned initial_cdw = sctx->gfx_cs->current.cdw;
+
        if (!shader)
                return;
 
@@ -1168,6 +1192,9 @@ static void si_emit_shader_ps(struct si_context *sctx)
        radeon_opt_set_context_reg(sctx, R_02823C_CB_SHADER_MASK,
                                   SI_TRACKED_CB_SHADER_MASK,
                                   shader->ctx_reg.ps.cb_shader_mask);
+
+       if (initial_cdw != sctx->gfx_cs->current.cdw)
+               sctx->context_roll = true;
 }
 
 static void si_shader_ps(struct si_shader *shader)
@@ -1352,19 +1379,42 @@ static void si_shader_selector_key_vs(struct si_context *sctx,
            vs->info.properties[TGSI_PROPERTY_VS_BLIT_SGPRS])
                return;
 
-       prolog_key->instance_divisor_is_one =
-               sctx->vertex_elements->instance_divisor_is_one;
-       prolog_key->instance_divisor_is_fetched =
-               sctx->vertex_elements->instance_divisor_is_fetched;
+       struct si_vertex_elements *elts = sctx->vertex_elements;
+
+       prolog_key->instance_divisor_is_one = elts->instance_divisor_is_one;
+       prolog_key->instance_divisor_is_fetched = elts->instance_divisor_is_fetched;
 
        /* Prefer a monolithic shader to allow scheduling divisions around
         * VBO loads. */
        if (prolog_key->instance_divisor_is_fetched)
                key->opt.prefer_mono = 1;
 
-       unsigned count = MIN2(vs->info.num_inputs,
-                             sctx->vertex_elements->count);
-       memcpy(key->mono.vs_fix_fetch, sctx->vertex_elements->fix_fetch, count);
+       unsigned count = MIN2(vs->info.num_inputs, elts->count);
+       unsigned count_mask = (1 << count) - 1;
+       unsigned fix = elts->fix_fetch_always & count_mask;
+       unsigned opencode = elts->fix_fetch_opencode & count_mask;
+
+       if (sctx->vertex_buffer_unaligned & elts->vb_alignment_check_mask) {
+               uint32_t mask = elts->fix_fetch_unaligned & count_mask;
+               while (mask) {
+                       unsigned i = u_bit_scan(&mask);
+                       unsigned log_hw_load_size = 1 + ((elts->hw_load_is_dword >> i) & 1);
+                       unsigned vbidx = elts->vertex_buffer_index[i];
+                       struct pipe_vertex_buffer *vb = &sctx->vertex_buffer[vbidx];
+                       unsigned align_mask = (1 << log_hw_load_size) - 1;
+                       if (vb->buffer_offset & align_mask ||
+                           vb->stride & align_mask) {
+                               fix |= 1 << i;
+                               opencode |= 1 << i;
+                       }
+               }
+       }
+
+       while (fix) {
+               unsigned i = u_bit_scan(&fix);
+               key->mono.vs_fix_fetch[i].bits = elts->fix_fetch[i];
+       }
+       key->mono.vs_fetch_opencode = opencode;
 }
 
 static void si_shader_selector_key_hw_vs(struct si_context *sctx,
@@ -1552,11 +1602,11 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
                    blend && blend->alpha_to_coverage)
                        key->part.ps.epilog.spi_shader_col_format |= V_028710_SPI_SHADER_32_AR;
 
-               /* On SI and CIK except Hawaii, the CB doesn't clamp outputs
+               /* On GFX6 and GFX7 except Hawaii, the CB doesn't clamp outputs
                 * to the range supported by the type if a channel has less
                 * than 16 bits and the export format is 16_ABGR.
                 */
-               if (sctx->chip_class <= CIK && sctx->family != CHIP_HAWAII) {
+               if (sctx->chip_class <= GFX7 && sctx->family != CHIP_HAWAII) {
                        key->part.ps.epilog.color_is_int8 = sctx->framebuffer.color_is_int8;
                        key->part.ps.epilog.color_is_int10 = sctx->framebuffer.color_is_int10;
                }
@@ -1630,7 +1680,7 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
                key->part.ps.epilog.alpha_func = si_get_alpha_test_func(sctx);
 
                /* ps_uses_fbfetch is true only if the color buffer is bound. */
-               if (sctx->ps_uses_fbfetch) {
+               if (sctx->ps_uses_fbfetch && !sctx->blitter->running) {
                        struct pipe_surface *cb0 = sctx->framebuffer.state.cbufs[0];
                        struct pipe_resource *tex = cb0->texture;
 
@@ -1744,12 +1794,19 @@ static bool si_check_missing_main_part(struct si_screen *sscreen,
        return true;
 }
 
-/* Select the hw shader variant depending on the current state. */
-static int si_shader_select_with_key(struct si_screen *sscreen,
-                                    struct si_shader_ctx_state *state,
-                                    struct si_compiler_ctx_state *compiler_state,
-                                    struct si_shader_key *key,
-                                    int thread_index)
+/**
+ * Select a shader variant according to the shader key.
+ *
+ * \param optimized_or_none  If the key describes an optimized shader variant and
+ *                           the compilation isn't finished, don't select any
+ *                           shader and return an error.
+ */
+int si_shader_select_with_key(struct si_screen *sscreen,
+                             struct si_shader_ctx_state *state,
+                             struct si_compiler_ctx_state *compiler_state,
+                             struct si_shader_key *key,
+                             int thread_index,
+                             bool optimized_or_none)
 {
        struct si_shader_selector *sel = state->cso;
        struct si_shader_selector *previous_stage_sel = NULL;
@@ -1765,6 +1822,9 @@ again:
                   memcmp(&current->key, key, sizeof(*key)) == 0)) {
                if (unlikely(!util_queue_fence_is_signalled(&current->ready))) {
                        if (current->is_optimized) {
+                               if (optimized_or_none)
+                                       return -1;
+
                                memset(&key->opt, 0, sizeof(key->opt));
                                goto current_not_ready;
                        }
@@ -1801,6 +1861,8 @@ current_not_ready:
                                 * shader so as not to cause a stall due to compilation.
                                 */
                                if (iter->is_optimized) {
+                                       if (optimized_or_none)
+                                               return -1;
                                        memset(&key->opt, 0, sizeof(key->opt));
                                        goto again;
                                }
@@ -1842,12 +1904,13 @@ current_not_ready:
                        util_queue_fence_wait(&previous_stage_sel->ready);
        }
 
-       /* Compile the main shader part if it doesn't exist. This can happen
-        * if the initial guess was wrong. */
        bool is_pure_monolithic =
                sscreen->use_monolithic_shaders ||
                memcmp(&key->mono, &zeroed.mono, sizeof(key->mono)) != 0;
 
+       /* Compile the main shader part if it doesn't exist. This can happen
+        * if the initial guess was wrong.
+        */
        if (!is_pure_monolithic) {
                bool ok;
 
@@ -1904,9 +1967,7 @@ current_not_ready:
                memcmp(&key->opt, &zeroed.opt, sizeof(key->opt)) != 0;
 
        /* If it's an optimized shader, compile it asynchronously. */
-       if (shader->is_optimized &&
-           !is_pure_monolithic &&
-           thread_index < 0) {
+       if (shader->is_optimized && thread_index < 0) {
                /* Compile it asynchronously. */
                util_queue_add_job(&sscreen->shader_compiler_queue_low_priority,
                                   shader, &shader->ready,
@@ -1925,6 +1986,12 @@ current_not_ready:
                /* Use the default (unoptimized) shader for now. */
                memset(&key->opt, 0, sizeof(key->opt));
                mtx_unlock(&sel->mutex);
+
+               if (sscreen->options.sync_compile)
+                       util_queue_fence_wait(&shader->ready);
+
+               if (optimized_or_none)
+                       return -1;
                goto again;
        }
 
@@ -1961,7 +2028,7 @@ static int si_shader_select(struct pipe_context *ctx,
 
        si_shader_selector_key(ctx, state->cso, &key);
        return si_shader_select_with_key(sctx->screen, state, compiler_state,
-                                        &key, -1);
+                                        &key, -1, false);
 }
 
 static void si_parse_next_shader_property(const struct tgsi_shader_info *info,
@@ -2016,6 +2083,9 @@ static void si_init_shader_selector_async(void *job, int thread_index)
        assert(thread_index < ARRAY_SIZE(sscreen->compiler));
        compiler = &sscreen->compiler[thread_index];
 
+       if (sel->nir)
+               si_lower_nir(sel);
+
        /* Compile the main shader part for use with a prolog and/or epilog.
         * If this fails, the driver will try to compile a monolithic shader
         * on demand.
@@ -2134,12 +2204,12 @@ void si_schedule_initial_compile(struct si_context *sctx, unsigned processor,
        util_queue_fence_init(ready_fence);
 
        struct util_async_debug_callback async_debug;
-       bool wait =
+       bool debug =
                (sctx->debug.debug_message && !sctx->debug.async) ||
                sctx->is_debug ||
                si_can_dump_shader(sctx->screen, processor);
 
-       if (wait) {
+       if (debug) {
                u_async_debug_init(&async_debug);
                compiler_ctx_state->debug = async_debug.base;
        }
@@ -2147,11 +2217,14 @@ void si_schedule_initial_compile(struct si_context *sctx, unsigned processor,
        util_queue_add_job(&sctx->screen->shader_compiler_queue, job,
                           ready_fence, execute, NULL);
 
-       if (wait) {
+       if (debug) {
                util_queue_fence_wait(ready_fence);
                u_async_debug_drain(&async_debug, &sctx->debug);
                u_async_debug_cleanup(&async_debug);
        }
+
+       if (sctx->screen->options.sync_compile)
+               util_queue_fence_wait(ready_fence);
 }
 
 /* Return descriptor slot usage masks from the given shader info. */
@@ -2210,10 +2283,9 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
 
                sel->nir = state->ir.nir;
 
+               si_nir_opts(sel->nir);
                si_nir_scan_shader(sel->nir, &sel->info);
-               si_nir_scan_tess_ctrl(sel->nir, &sel->info, &sel->tcs_info);
-
-               si_lower_nir(sel);
+               si_nir_scan_tess_ctrl(sel->nir, &sel->tcs_info);
        }
 
        sel->type = sel->info.processor;
@@ -2647,10 +2719,10 @@ static void si_delete_shader(struct si_context *sctx, struct si_shader *shader)
                switch (shader->selector->type) {
                case PIPE_SHADER_VERTEX:
                        if (shader->key.as_ls) {
-                               assert(sctx->chip_class <= VI);
+                               assert(sctx->chip_class <= GFX8);
                                si_pm4_delete_state(sctx, ls, shader->pm4);
                        } else if (shader->key.as_es) {
-                               assert(sctx->chip_class <= VI);
+                               assert(sctx->chip_class <= GFX8);
                                si_pm4_delete_state(sctx, es, shader->pm4);
                        } else {
                                si_pm4_delete_state(sctx, vs, shader->pm4);
@@ -2661,7 +2733,7 @@ static void si_delete_shader(struct si_context *sctx, struct si_shader *shader)
                        break;
                case PIPE_SHADER_TESS_EVAL:
                        if (shader->key.as_es) {
-                               assert(sctx->chip_class <= VI);
+                               assert(sctx->chip_class <= GFX8);
                                si_pm4_delete_state(sctx, es, shader->pm4);
                        } else {
                                si_pm4_delete_state(sctx, vs, shader->pm4);
@@ -2836,9 +2908,13 @@ static void si_emit_spi_map(struct si_context *sctx)
        /* R_028644_SPI_PS_INPUT_CNTL_0 */
        /* Dota 2: Only ~16% of SPI map updates set different values. */
        /* Talos: Only ~9% of SPI map updates set different values. */
+       unsigned initial_cdw = sctx->gfx_cs->current.cdw;
        radeon_opt_set_context_regn(sctx, R_028644_SPI_PS_INPUT_CNTL_0,
                                    spi_ps_input_cntl,
                                    sctx->tracked_regs.spi_ps_input_cntl, num_interp);
+
+       if (initial_cdw != sctx->gfx_cs->current.cdw)
+               sctx->context_roll = true;
 }
 
 /**
@@ -2874,10 +2950,10 @@ static bool si_update_gs_ring_buffers(struct si_context *sctx)
        unsigned num_se = sctx->screen->info.max_se;
        unsigned wave_size = 64;
        unsigned max_gs_waves = 32 * num_se; /* max 32 per SE on GCN */
-       /* On SI-CI, the value comes from VGT_GS_VERTEX_REUSE = 16.
-        * On VI+, the value comes from VGT_VERTEX_REUSE_BLOCK_CNTL = 30 (+2).
+       /* On GFX6-GFX7, the value comes from VGT_GS_VERTEX_REUSE = 16.
+        * On GFX8+, the value comes from VGT_VERTEX_REUSE_BLOCK_CNTL = 30 (+2).
         */
-       unsigned gs_vertex_reuse = (sctx->chip_class >= VI ? 32 : 16) * num_se;
+       unsigned gs_vertex_reuse = (sctx->chip_class >= GFX8 ? 32 : 16) * num_se;
        unsigned alignment = 256 * num_se;
        /* The maximum size is 63.999 MB per SE. */
        unsigned max_size = ((unsigned)(63.999 * 1024 * 1024) & ~255) * num_se;
@@ -2904,7 +2980,7 @@ static bool si_update_gs_ring_buffers(struct si_context *sctx)
         *
         * GFX9 doesn't have the ESGS ring.
         */
-       bool update_esgs = sctx->chip_class <= VI &&
+       bool update_esgs = sctx->chip_class <= GFX8 &&
                           esgs_ring_size &&
                           (!sctx->esgs_ring ||
                            sctx->esgs_ring->width0 < esgs_ring_size);
@@ -2942,9 +3018,9 @@ static bool si_update_gs_ring_buffers(struct si_context *sctx)
        if (!pm4)
                return false;
 
-       if (sctx->chip_class >= CIK) {
+       if (sctx->chip_class >= GFX7) {
                if (sctx->esgs_ring) {
-                       assert(sctx->chip_class <= VI);
+                       assert(sctx->chip_class <= GFX8);
                        si_pm4_set_reg(pm4, R_030900_VGT_ESGS_RING_SIZE,
                                       sctx->esgs_ring->width0 / 256);
                }
@@ -2976,7 +3052,7 @@ static bool si_update_gs_ring_buffers(struct si_context *sctx)
 
        /* Set ring bindings. */
        if (sctx->esgs_ring) {
-               assert(sctx->chip_class <= VI);
+               assert(sctx->chip_class <= GFX8);
                si_set_ring_buffer(sctx, SI_ES_RING_ESGS,
                                   sctx->esgs_ring, 0, sctx->esgs_ring->width0,
                                   true, true, 4, 64, 0);
@@ -3058,7 +3134,7 @@ static int si_update_scratch_buffer(struct si_context *sctx,
        /* Update the shader state to use the new shader bo. */
        si_shader_init_pm4_state(sctx->screen, shader);
 
-       r600_resource_reference(&shader->scratch_bo, sctx->scratch_buffer);
+       si_resource_reference(&shader->scratch_bo, sctx->scratch_buffer);
 
        si_shader_unlock(shader);
        return 1;
@@ -3168,7 +3244,7 @@ static bool si_update_spi_tmpring_size(struct si_context *sctx)
        if (scratch_needed_size > 0) {
                if (scratch_needed_size > current_scratch_buffer_size) {
                        /* Create a bigger scratch buffer */
-                       r600_resource_reference(&sctx->scratch_buffer, NULL);
+                       si_resource_reference(&sctx->scratch_buffer, NULL);
 
                        sctx->scratch_buffer =
                                si_aligned_buffer_create(&sctx->screen->b,
@@ -3218,14 +3294,14 @@ static void si_init_tess_factor_ring(struct si_context *sctx)
 
        si_init_config_add_vgt_flush(sctx);
 
-       si_pm4_add_bo(sctx->init_config, r600_resource(sctx->tess_rings),
+       si_pm4_add_bo(sctx->init_config, si_resource(sctx->tess_rings),
                      RADEON_USAGE_READWRITE, RADEON_PRIO_SHADER_RINGS);
 
-       uint64_t factor_va = r600_resource(sctx->tess_rings)->gpu_address +
+       uint64_t factor_va = si_resource(sctx->tess_rings)->gpu_address +
                             sctx->screen->tess_offchip_ring_size;
 
        /* Append these registers to the init config state. */
-       if (sctx->chip_class >= CIK) {
+       if (sctx->chip_class >= GFX7) {
                si_pm4_set_reg(sctx->init_config, R_030938_VGT_TF_RING_SIZE,
                               S_030938_SIZE(sctx->screen->tess_factor_ring_size / 4));
                si_pm4_set_reg(sctx->init_config, R_030940_VGT_TF_MEMORY_BASE,
@@ -3313,7 +3389,7 @@ bool si_update_shaders(struct si_context *sctx)
                }
 
                /* VS as LS */
-               if (sctx->chip_class <= VI) {
+               if (sctx->chip_class <= GFX8) {
                        r = si_shader_select(ctx, &sctx->vs_shader,
                                             &compiler_state);
                        if (r)
@@ -3345,7 +3421,7 @@ bool si_update_shaders(struct si_context *sctx)
 
                if (sctx->gs_shader.cso) {
                        /* TES as ES */
-                       if (sctx->chip_class <= VI) {
+                       if (sctx->chip_class <= GFX8) {
                                r = si_shader_select(ctx, &sctx->tes_shader,
                                                     &compiler_state);
                                if (r)
@@ -3361,7 +3437,7 @@ bool si_update_shaders(struct si_context *sctx)
                        si_pm4_bind_state(sctx, vs, sctx->tes_shader.current->pm4);
                }
        } else if (sctx->gs_shader.cso) {
-               if (sctx->chip_class <= VI) {
+               if (sctx->chip_class <= GFX8) {
                        /* VS as ES */
                        r = si_shader_select(ctx, &sctx->vs_shader,
                                             &compiler_state);
@@ -3394,7 +3470,7 @@ bool si_update_shaders(struct si_context *sctx)
                        return false;
        } else {
                si_pm4_bind_state(sctx, gs, NULL);
-               if (sctx->chip_class <= VI)
+               if (sctx->chip_class <= GFX8)
                        si_pm4_bind_state(sctx, es, NULL);
        }
 
@@ -3441,7 +3517,7 @@ bool si_update_shaders(struct si_context *sctx)
                        sctx->smoothing_enabled = sctx->ps_shader.current->key.part.ps.epilog.poly_line_smoothing;
                        si_mark_atom_dirty(sctx, &sctx->atoms.s.msaa_config);
 
-                       if (sctx->chip_class == SI)
+                       if (sctx->chip_class == GFX6)
                                si_mark_atom_dirty(sctx, &sctx->atoms.s.db_render_state);
 
                        if (sctx->framebuffer.nr_samples <= 1)
@@ -3459,7 +3535,7 @@ bool si_update_shaders(struct si_context *sctx)
                        return false;
        }
 
-       if (sctx->chip_class >= CIK) {
+       if (sctx->chip_class >= GFX7) {
                if (si_pm4_state_enabled_and_changed(sctx, ls))
                        sctx->prefetch_L2_mask |= SI_PREFETCH_LS;
                else if (!sctx->queued.named.ls)