r600g: fix up vs export handling
authorAlex Deucher <alexander.deucher@amd.com>
Fri, 29 Jul 2011 15:29:53 +0000 (11:29 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 29 Jul 2011 15:34:02 +0000 (11:34 -0400)
Certain attributes (position, psize, etc.) don't
count as params; they are handled separately by the hw.
However, the VS is required to export at least one param
and r600_shader_from_tgsi() takes care of adding a dummy
export if there is none.  Make sure the VS param export
count in the SPI properly accounts for this.

Note: This is a candidate for the 7.11 branch.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_shader.c
src/gallium/drivers/r600/r600_shader.h
src/gallium/drivers/r600/r600_state.c

index 152c5cf13a08a917e6b18d5edfc960080e8ff7ed..bc6039dd40c72d99d61b5a90eaf928f994bc3c5b 100644 (file)
@@ -2298,7 +2298,7 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader
        struct r600_pipe_state *rstate = &shader->rstate;
        struct r600_shader *rshader = &shader->shader;
        unsigned spi_vs_out_id[10];
-       unsigned i, tmp;
+       unsigned i, tmp, nparams;
 
        /* clear previous register */
        rstate->nregs = 0;
@@ -2317,9 +2317,17 @@ void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader
                                        spi_vs_out_id[i], 0xFFFFFFFF, NULL);
        }
 
+       /* Certain attributes (position, psize, etc.) don't count as params.
+        * VS is required to export at least one param and r600_shader_from_tgsi()
+        * takes care of adding a dummy export.
+        */
+       nparams = rshader->noutput - rshader->npos;
+       if (nparams < 1)
+               nparams = 1;
+
        r600_pipe_state_add_reg(rstate,
                        R_0286C4_SPI_VS_OUT_CONFIG,
-                       S_0286C4_VS_EXPORT_COUNT(rshader->noutput - 1),
+                       S_0286C4_VS_EXPORT_COUNT(nparams - 1),
                        0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                        R_028860_SQ_PGM_RESOURCES_VS,
index 494f9370597f642295de3df61df9a1493c9c7f0d..fc56656f55d034340315824f3eacac0e3810e584 100644 (file)
@@ -332,6 +332,12 @@ static int tgsi_declaration(struct r600_shader_ctx *ctx)
                ctx->shader->output[i].sid = d->Semantic.Index;
                ctx->shader->output[i].gpr = ctx->file_offset[TGSI_FILE_OUTPUT] + i;
                ctx->shader->output[i].interpolate = d->Declaration.Interpolate;
+               if (ctx->type == TGSI_PROCESSOR_VERTEX) {
+                       /* these don't count as vertex param exports */
+                       if ((ctx->shader->output[i].name == TGSI_SEMANTIC_POSITION) ||
+                           (ctx->shader->output[i].name == TGSI_SEMANTIC_PSIZE))
+                               ctx->shader->npos++;
+               }
                break;
        case TGSI_FILE_CONSTANT:
        case TGSI_FILE_TEMPORARY:
index 3ba84bd8907574f62196e9f84c45203137472589..600c3e2f540f79849cee02b466ef52ec3e9870a1 100644 (file)
@@ -40,6 +40,7 @@ struct r600_shader {
        struct r600_bc          bc;
        unsigned                ninput;
        unsigned                noutput;
+       unsigned                npos;
        unsigned                nlds;
        struct r600_shader_io   input[32];
        struct r600_shader_io   output[32];
index 294c400caa17f754a7da74aea15ef560e919bdc0..1350a1cf565855910c011ab3f6718d24984c39ba 100644 (file)
@@ -2062,7 +2062,7 @@ void r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shad
        struct r600_pipe_state *rstate = &shader->rstate;
        struct r600_shader *rshader = &shader->shader;
        unsigned spi_vs_out_id[10];
-       unsigned i, tmp;
+       unsigned i, tmp, nparams;
 
        /* clear previous register */
        rstate->nregs = 0;
@@ -2084,9 +2084,17 @@ void r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shad
                                        spi_vs_out_id[i], 0xFFFFFFFF, NULL);
        }
 
+       /* Certain attributes (position, psize, etc.) don't count as params.
+        * VS is required to export at least one param and r600_shader_from_tgsi()
+        * takes care of adding a dummy export.
+        */
+       nparams = rshader->noutput - rshader->npos;
+       if (nparams < 1)
+               nparams = 1;
+
        r600_pipe_state_add_reg(rstate,
                        R_0286C4_SPI_VS_OUT_CONFIG,
-                       S_0286C4_VS_EXPORT_COUNT(rshader->noutput - 1),
+                       S_0286C4_VS_EXPORT_COUNT(nparams - 1),
                        0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                        R_028868_SQ_PGM_RESOURCES_VS,