r600g: switch btw flat/linear interpolation
authorJerome Glisse <jglisse@redhat.com>
Wed, 28 Jul 2010 23:59:38 +0000 (19:59 -0400)
committerJerome Glisse <jglisse@redhat.com>
Wed, 28 Jul 2010 23:59:38 +0000 (19:59 -0400)
I am not sure how to properly handle flat shading regarding
non color parameter to fragment shader. It seems we should
still interpolate non color using linear interpolation and
flat shade only apply to color.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
src/gallium/drivers/r600/r600_shader.c
src/gallium/drivers/r600/r600_shader.h
src/gallium/drivers/r600/r600_state.c

index 8837a7272b57e70f8382a50cd2984966896eefbc..3f1979b9ccb4f4caebb95b75a8b39e747421ddf9 100644 (file)
@@ -169,7 +169,10 @@ static int r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_context_sta
        for (i = 0; i < rshader->ninput; i++) {
                tmp = S_028644_SEMANTIC(rshader->input[i].sid);
                tmp |= S_028644_SEL_CENTROID(1);
-               tmp |= S_028644_FLAT_SHADE(rshader->flat_shade);
+               if (rshader->input[i].name == TGSI_SEMANTIC_COLOR ||
+                       rshader->input[i].name == TGSI_SEMANTIC_BCOLOR) {
+                       tmp |= S_028644_FLAT_SHADE(rshader->flat_shade);
+               }
                state->states[R600_PS_SHADER__SPI_PS_INPUT_CNTL_0 + i] = tmp;
        }
        state->states[R600_PS_SHADER__SPI_PS_IN_CONTROL_0] = S_0286CC_NUM_INTERP(rshader->ninput) |
@@ -287,6 +290,7 @@ static int tgsi_declaration(struct r600_shader_ctx *ctx)
                i = ctx->shader->ninput++;
                ctx->shader->input[i].name = d->Semantic.Name;
                ctx->shader->input[i].sid = d->Semantic.Index;
+               ctx->shader->input[i].interpolate = d->Declaration.Interpolate;
                ctx->shader->input[i].gpr = ctx->file_offset[TGSI_FILE_INPUT] + i;
                if (ctx->type == TGSI_PROCESSOR_VERTEX) {
                        /* turn input into fetch */
@@ -313,6 +317,7 @@ static int tgsi_declaration(struct r600_shader_ctx *ctx)
                ctx->shader->output[i].name = d->Semantic.Name;
                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;
                break;
        case TGSI_FILE_CONSTANT:
        case TGSI_FILE_TEMPORARY:
index 23b6a83b9a923d1fb3c23c35ff78f3741f32dbfc..ee0381e8bdd753a90a117c445c9ab4ea1f2e7b9c 100644 (file)
@@ -29,6 +29,7 @@ struct r600_shader_io {
        unsigned                name;
        unsigned                gpr;
        int                     sid;
+       unsigned                interpolate;
 };
 
 struct r600_shader {
index 0f1e1cd7610e5001f2f662f6c42fe0ff443fcca6..5b98dbe236fad0b5e4eea1e7a39cdfb1eaf8dbcb 100644 (file)
@@ -692,8 +692,6 @@ static struct radeon_state *r600_rasterizer(struct r600_context *rctx)
        struct radeon_state *rstate;
 
        rctx->flat_shade = state->flatshade;
-       rctx->flat_shade = 0;
-R600_ERR("flat shade with texture broke tex coord interp\n");
        rstate = radeon_state(rscreen->rw, R600_RASTERIZER_TYPE, R600_RASTERIZER);
        if (rstate == NULL)
                return NULL;