radeonsi: use COMPUTE_DISPATCH_SCRATCH_BASE on gfx940
authorMarek Olšák <marek.olsak@amd.com>
Fri, 21 Oct 2022 19:59:36 +0000 (15:59 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 6 Apr 2023 15:00:53 +0000 (15:00 +0000)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22158>

src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_shader.c

index 5df9f82..cb1f117 100644 (file)
@@ -405,7 +405,8 @@ static bool si_setup_compute_scratch_buffer(struct si_context *sctx, struct si_s
    }
 
    if (sctx->compute_scratch_buffer != shader->scratch_bo && scratch_needed) {
-      if (sctx->gfx_level < GFX11) {
+      if (sctx->gfx_level < GFX11 &&
+          (sctx->family < CHIP_GFX940 || sctx->screen->info.has_graphics)) {
          uint64_t scratch_va = sctx->compute_scratch_buffer->gpu_address;
 
          if (!si_shader_binary_upload(sctx->screen, shader, scratch_va))
@@ -507,7 +508,9 @@ static bool si_switch_compute_shader(struct si_context *sctx, struct si_compute
                         S_00B8A0_INST_PREF_SIZE(si_get_shader_prefetch_size(shader)));
    }
 
-   if (sctx->gfx_level >= GFX11 && shader->scratch_bo) {
+   if ((sctx->gfx_level >= GFX11 ||
+        (sctx->family >= CHIP_GFX940 && !sctx->screen->info.has_graphics)) &&
+       shader->scratch_bo) {
       radeon_set_sh_reg_seq(R_00B840_COMPUTE_DISPATCH_SCRATCH_BASE_LO, 4);
       radeon_emit(sctx->compute_scratch_buffer->gpu_address >> 8);
       radeon_emit(sctx->compute_scratch_buffer->gpu_address >> 40);
index a3cc453..596d778 100644 (file)
@@ -2358,6 +2358,7 @@ bool si_compile_shader(struct si_screen *sscreen, struct ac_llvm_compiler *compi
 
    /* Add the scratch offset to input SGPRs. */
    if (sel->screen->info.gfx_level < GFX11 &&
+       (sel->screen->info.family < CHIP_GFX940 || sel->screen->info.has_graphics) &&
        shader->config.scratch_bytes_per_wave && !si_is_merged_shader(shader))
       shader->info.num_input_sgprs += 1; /* scratch byte offset */