radv: update PS num_vgprs in case of epilogs rather than overallocating VGPRs
authorDaniel Schürmann <daniel@schuermann.dev>
Mon, 3 Apr 2023 10:15:36 +0000 (12:15 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 4 Apr 2023 18:35:43 +0000 (18:35 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22267>

src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_shader_args.c

index 1ea8e48..b34eae8 100644 (file)
@@ -1846,10 +1846,12 @@ radv_emit_ps_epilog_state(struct radv_cmd_buffer *cmd_buffer, struct radv_shader
    radeon_set_context_reg(cmd_buffer->cs, R_02823C_CB_SHADER_MASK,
                           ac_get_cb_shader_mask(ps_epilog->spi_shader_col_format));
 
-   /* The main shader must not use less VGPRs than the epilog, otherwise shared vgprs might not
-    * work.
-    */
-   assert(G_00B848_VGPRS(ps_shader->config.rsrc1) >= G_00B848_VGPRS(ps_epilog->rsrc1));
+   assert(ps_shader->config.num_shared_vgprs == 0);
+   if (G_00B848_VGPRS(ps_epilog->rsrc1) > G_00B848_VGPRS(ps_shader->config.rsrc1)) {
+      uint32_t rsrc1 = ps_shader->config.rsrc1;
+      rsrc1 = (rsrc1 & C_00B848_VGPRS) | (ps_epilog->rsrc1 & ~C_00B848_VGPRS);
+      radeon_set_sh_reg(cmd_buffer->cs, R_00B028_SPI_SHADER_PGM_RSRC1_PS, rsrc1);
+   }
 
    radv_cs_add_buffer(cmd_buffer->device->ws, cmd_buffer->cs, ps_epilog->bo);
 
index a376132..334d622 100644 (file)
@@ -311,12 +311,6 @@ declare_ps_input_vgprs(const struct radv_shader_info *info, struct radv_shader_a
          vgpr_arg++;
       }
    }
-
-   if (info->ps.has_epilog) {
-      /* FIXME: Ensure the main shader doesn't have less VGPRs than the epilog */
-      for (unsigned i = 0; i < MAX_RTS; i++)
-         ac_add_arg(&args->ac, AC_ARG_VGPR, 4, AC_ARG_INT, NULL);
-   }
 }
 
 static void