radeonsi: add si_emit_global_shader_pointers() helper
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 28 Jun 2017 16:19:09 +0000 (18:19 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 22 Aug 2017 09:34:24 +0000 (11:34 +0200)
To share common code between rw buffers and bindless descriptors.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_descriptors.c

index c26b8291cfb11464c23fa3704550607bb354f93e..13a9a08ea58c030c0d74f245767f0d13f7f27879 100644 (file)
@@ -2195,6 +2195,35 @@ static void si_emit_shader_pointer(struct si_context *sctx,
        radeon_emit(cs, va >> 32);
 }
 
+static void si_emit_global_shader_pointers(struct si_context *sctx,
+                                          struct si_descriptors *descs)
+{
+       si_emit_shader_pointer(sctx, descs,
+                              R_00B030_SPI_SHADER_USER_DATA_PS_0);
+       si_emit_shader_pointer(sctx, descs,
+                              R_00B130_SPI_SHADER_USER_DATA_VS_0);
+
+       if (sctx->b.chip_class >= GFX9) {
+               /* GFX9 merged LS-HS and ES-GS.
+                * Set RW_BUFFERS in the special registers, so that
+                * it's preloaded into s[0:1] instead of s[8:9].
+                */
+               si_emit_shader_pointer(sctx, descs,
+                                      R_00B208_SPI_SHADER_USER_DATA_ADDR_LO_GS);
+               si_emit_shader_pointer(sctx, descs,
+                                      R_00B408_SPI_SHADER_USER_DATA_ADDR_LO_HS);
+       } else {
+               si_emit_shader_pointer(sctx, descs,
+                                      R_00B230_SPI_SHADER_USER_DATA_GS_0);
+               si_emit_shader_pointer(sctx, descs,
+                                      R_00B330_SPI_SHADER_USER_DATA_ES_0);
+               si_emit_shader_pointer(sctx, descs,
+                                      R_00B430_SPI_SHADER_USER_DATA_HS_0);
+               si_emit_shader_pointer(sctx, descs,
+                                      R_00B530_SPI_SHADER_USER_DATA_LS_0);
+       }
+}
+
 void si_emit_graphics_shader_pointers(struct si_context *sctx,
                                       struct r600_atom *atom)
 {
@@ -2204,32 +2233,8 @@ void si_emit_graphics_shader_pointers(struct si_context *sctx,
 
        descs = &sctx->descriptors[SI_DESCS_RW_BUFFERS];
 
-       if (sctx->shader_pointers_dirty & (1 << SI_DESCS_RW_BUFFERS)) {
-               si_emit_shader_pointer(sctx, descs,
-                                      R_00B030_SPI_SHADER_USER_DATA_PS_0);
-               si_emit_shader_pointer(sctx, descs,
-                                      R_00B130_SPI_SHADER_USER_DATA_VS_0);
-
-               if (sctx->b.chip_class >= GFX9) {
-                       /* GFX9 merged LS-HS and ES-GS.
-                        * Set RW_BUFFERS in the special registers, so that
-                        * it's preloaded into s[0:1] instead of s[8:9].
-                        */
-                       si_emit_shader_pointer(sctx, descs,
-                                              R_00B208_SPI_SHADER_USER_DATA_ADDR_LO_GS);
-                       si_emit_shader_pointer(sctx, descs,
-                                              R_00B408_SPI_SHADER_USER_DATA_ADDR_LO_HS);
-               } else {
-                       si_emit_shader_pointer(sctx, descs,
-                                              R_00B230_SPI_SHADER_USER_DATA_GS_0);
-                       si_emit_shader_pointer(sctx, descs,
-                                              R_00B330_SPI_SHADER_USER_DATA_ES_0);
-                       si_emit_shader_pointer(sctx, descs,
-                                              R_00B430_SPI_SHADER_USER_DATA_HS_0);
-                       si_emit_shader_pointer(sctx, descs,
-                                              R_00B530_SPI_SHADER_USER_DATA_LS_0);
-               }
-       }
+       if (sctx->shader_pointers_dirty & (1 << SI_DESCS_RW_BUFFERS))
+               si_emit_global_shader_pointers(sctx, descs);
 
        mask = sctx->shader_pointers_dirty &
               u_bit_consecutive(SI_DESCS_FIRST_SHADER,