radeonsi: add support for tessellation shader resources and samplers
authorMarek Olšák <marek.olsak@amd.com>
Thu, 18 Sep 2014 20:54:40 +0000 (22:54 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 22 Jul 2015 22:59:32 +0000 (00:59 +0200)
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_descriptors.c
src/gallium/drivers/radeonsi/si_state.h

index f31cccbba1757d137bff941dac22b4587685b5b4..2e2a35b2280054ff209851a6a9a95f61ae9f4f76 100644 (file)
@@ -1266,13 +1266,28 @@ static void si_set_user_data_base(struct si_context *sctx,
  */
 void si_shader_change_notify(struct si_context *sctx)
 {
-       /* VS can be bound as VS or ES. */
-       if (sctx->gs_shader)
+       /* VS can be bound as VS, ES, or LS. */
+       if (sctx->tes_shader)
+               si_set_user_data_base(sctx, PIPE_SHADER_VERTEX,
+                                     R_00B530_SPI_SHADER_USER_DATA_LS_0);
+       else if (sctx->gs_shader)
                si_set_user_data_base(sctx, PIPE_SHADER_VERTEX,
                                      R_00B330_SPI_SHADER_USER_DATA_ES_0);
        else
                si_set_user_data_base(sctx, PIPE_SHADER_VERTEX,
                                      R_00B130_SPI_SHADER_USER_DATA_VS_0);
+
+       /* TES can be bound as ES, VS, or not bound. */
+       if (sctx->tes_shader) {
+               if (sctx->gs_shader)
+                       si_set_user_data_base(sctx, PIPE_SHADER_TESS_EVAL,
+                                             R_00B330_SPI_SHADER_USER_DATA_ES_0);
+               else
+                       si_set_user_data_base(sctx, PIPE_SHADER_TESS_EVAL,
+                                             R_00B130_SPI_SHADER_USER_DATA_VS_0);
+       } else {
+               si_set_user_data_base(sctx, PIPE_SHADER_TESS_EVAL, 0);
+       }
 }
 
 static void si_emit_shader_pointer(struct si_context *sctx,
@@ -1303,20 +1318,33 @@ static void si_emit_shader_userdata(struct si_context *sctx,
        unsigned i;
        uint32_t *sh_base = sctx->shader_userdata.sh_base;
 
-       /* The VS copy shader needs these for clipping, streamout, and rings. */
        if (sctx->gs_shader) {
-               unsigned base = R_00B130_SPI_SHADER_USER_DATA_VS_0;
+               /* The VS copy shader needs these for clipping, streamout, and rings. */
+               unsigned vs_base = R_00B130_SPI_SHADER_USER_DATA_VS_0;
                unsigned i = PIPE_SHADER_VERTEX;
 
-               si_emit_shader_pointer(sctx, &sctx->const_buffers[i].desc, base, true);
-               si_emit_shader_pointer(sctx, &sctx->rw_buffers[i].desc, base, true);
+               si_emit_shader_pointer(sctx, &sctx->const_buffers[i].desc, vs_base, true);
+               si_emit_shader_pointer(sctx, &sctx->rw_buffers[i].desc, vs_base, true);
+
+               /* The TESSEVAL shader needs this for the ESGS ring buffer. */
+               si_emit_shader_pointer(sctx, &sctx->rw_buffers[i].desc,
+                                      R_00B330_SPI_SHADER_USER_DATA_ES_0, true);
+       } else if (sctx->tes_shader) {
+               /* The TESSEVAL shader needs this for streamout. */
+               si_emit_shader_pointer(sctx, &sctx->rw_buffers[PIPE_SHADER_VERTEX].desc,
+                                      R_00B130_SPI_SHADER_USER_DATA_VS_0, true);
        }
 
        for (i = 0; i < SI_NUM_SHADERS; i++) {
                unsigned base = sh_base[i];
 
+               if (!base)
+                       continue;
+
+               if (i != PIPE_SHADER_TESS_EVAL)
+                       si_emit_shader_pointer(sctx, &sctx->rw_buffers[i].desc, base, false);
+
                si_emit_shader_pointer(sctx, &sctx->const_buffers[i].desc, base, false);
-               si_emit_shader_pointer(sctx, &sctx->rw_buffers[i].desc, base, false);
                si_emit_shader_pointer(sctx, &sctx->samplers[i].views.desc, base, false);
                si_emit_shader_pointer(sctx, &sctx->samplers[i].states.desc, base, false);
        }
@@ -1368,6 +1396,7 @@ void si_init_all_descriptors(struct si_context *sctx)
 
        /* Set default and immutable mappings. */
        si_set_user_data_base(sctx, PIPE_SHADER_VERTEX, R_00B130_SPI_SHADER_USER_DATA_VS_0);
+       si_set_user_data_base(sctx, PIPE_SHADER_TESS_CTRL, R_00B430_SPI_SHADER_USER_DATA_HS_0);
        si_set_user_data_base(sctx, PIPE_SHADER_GEOMETRY, R_00B230_SPI_SHADER_USER_DATA_GS_0);
        si_set_user_data_base(sctx, PIPE_SHADER_FRAGMENT, R_00B030_SPI_SHADER_USER_DATA_PS_0);
 }
index 1510c2284d6940a6d286d73ac534e85b76563a09..edee6d413282ebadcded202bae22189d99f6fe2c 100644 (file)
@@ -30,7 +30,7 @@
 #include "si_pm4.h"
 #include "radeon/r600_pipe_common.h"
 
-#define SI_NUM_SHADERS (PIPE_SHADER_GEOMETRY+1)
+#define SI_NUM_SHADERS (PIPE_SHADER_TESS_EVAL+1)
 
 struct si_screen;
 struct si_shader;