r600g: fix linear and flat interpolation
authorVadim Girlin <vadimgirlin@gmail.com>
Tue, 24 Jan 2012 19:32:50 +0000 (23:32 +0400)
committerDave Airlie <airlied@redhat.com>
Sat, 28 Jan 2012 16:20:37 +0000 (16:20 +0000)
Signed-off-by: Vadim Girlin <vadimgirlin@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_common.c

index 3bec748661a3bdac2be65c62f7790acd20ba7358..a988fabe3c1bde233a1bdd51cef5607d6bc0c3c0 100644 (file)
@@ -909,7 +909,7 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx,
        rstate->id = R600_PIPE_STATE_RASTERIZER;
        if (state->flatshade_first)
                prov_vtx = 0;
-       tmp = S_0286D4_FLAT_SHADE_ENA(state->flatshade);
+       tmp = S_0286D4_FLAT_SHADE_ENA(1);
        if (state->sprite_coord_enable) {
                tmp |= S_0286D4_PNT_SPRITE_ENA(1) |
                        S_0286D4_PNT_SPRITE_OVRD_X(2) |
@@ -985,9 +985,11 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate, R_02820C_PA_SC_CLIPRECT_RULE, clip_rule, 0xFFFFFFFF, NULL, 0);
        r600_pipe_state_add_reg(rstate, R_028810_PA_CL_CLIP_CNTL,
                        S_028810_PS_UCP_MODE(3) | S_028810_ZCLIP_NEAR_DISABLE(!state->depth_clip) |
-                       S_028810_ZCLIP_FAR_DISABLE(!state->depth_clip),
-                       S_028810_PS_UCP_MODE(3) | S_028810_ZCLIP_NEAR_DISABLE(1) |
-                       S_028810_ZCLIP_FAR_DISABLE(1), NULL, 0);
+                       S_028810_ZCLIP_FAR_DISABLE(!state->depth_clip) |
+                       S_028810_DX_LINEAR_ATTR_CLIP_ENA(1),
+                       ~(C_028810_PS_UCP_MODE & C_028810_ZCLIP_NEAR_DISABLE &
+                       C_028810_ZCLIP_FAR_DISABLE &
+                       C_028810_DX_LINEAR_ATTR_CLIP_ENA), NULL, 0);
        return rstate;
 }
 
@@ -2307,8 +2309,9 @@ void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader
                        tmp = S_028644_SEMANTIC(sid);
 
                        if (rshader->input[i].name == TGSI_SEMANTIC_POSITION ||
-                               rshader->input[i].interpolate == TGSI_INTERPOLATE_COLOR ||
-                               rshader->input[i].interpolate == TGSI_INTERPOLATE_CONSTANT) {
+                               rshader->input[i].interpolate == TGSI_INTERPOLATE_CONSTANT ||
+                               (rshader->input[i].interpolate == TGSI_INTERPOLATE_COLOR &&
+                                       rctx->rasterizer && rctx->rasterizer->flatshade)) {
                                tmp |= S_028644_FLAT_SHADE(1);
                        }
 
@@ -2427,6 +2430,8 @@ void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader
                                0xFFFFFFFF, NULL, 0);
 
        shader->sprite_coord_enable = rctx->sprite_coord_enable;
+       if (rctx->rasterizer)
+               shader->flatshade = rctx->rasterizer->flatshade;
 }
 
 void evergreen_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader)
index 9de8e7efaca2d9450f52103017b680e004cdeded..47c6ad0335a2097df163b0f585f475426d237f54 100644 (file)
@@ -146,6 +146,7 @@ struct r600_pipe_shader {
        struct r600_vertex_element      vertex_elements;
        struct tgsi_token               *tokens;
        unsigned        sprite_coord_enable;
+       unsigned        flatshade;
        struct pipe_stream_output_info  so;
 };
 
index e093e5003a9368dd1ebef9962c0a91d7f5a60336..8e5342c81145690ceb9aaad2e5fad0c9b6f3fc3b 100644 (file)
@@ -967,7 +967,7 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
        rstate->id = R600_PIPE_STATE_RASTERIZER;
        if (state->flatshade_first)
                prov_vtx = 0;
-       tmp = S_0286D4_FLAT_SHADE_ENA(state->flatshade);
+       tmp = S_0286D4_FLAT_SHADE_ENA(1);
        if (state->sprite_coord_enable) {
                tmp |= S_0286D4_PNT_SPRITE_ENA(1) |
                        S_0286D4_PNT_SPRITE_OVRD_X(2) |
@@ -1035,9 +1035,11 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate, R_02820C_PA_SC_CLIPRECT_RULE, clip_rule, 0xFFFFFFFF, NULL, 0);
        r600_pipe_state_add_reg(rstate, R_028810_PA_CL_CLIP_CNTL,
                        S_028810_PS_UCP_MODE(3) | S_028810_ZCLIP_NEAR_DISABLE(!state->depth_clip) |
-                       S_028810_ZCLIP_FAR_DISABLE(!state->depth_clip),
-                       S_028810_PS_UCP_MODE(3) | S_028810_ZCLIP_NEAR_DISABLE(1) |
-                       S_028810_ZCLIP_FAR_DISABLE(1), NULL, 0);
+                       S_028810_ZCLIP_FAR_DISABLE(!state->depth_clip) |
+                       S_028810_DX_LINEAR_ATTR_CLIP_ENA(1),
+                       ~(C_028810_PS_UCP_MODE & C_028810_ZCLIP_NEAR_DISABLE &
+                       C_028810_ZCLIP_FAR_DISABLE &
+                       C_028810_DX_LINEAR_ATTR_CLIP_ENA), NULL, 0);
        return rstate;
 }
 
@@ -2096,11 +2098,10 @@ void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shad
 
                tmp = S_028644_SEMANTIC(sid);
 
-               if (rshader->input[i].name == TGSI_SEMANTIC_POSITION) {
-                       tmp |= S_028644_FLAT_SHADE(1);
-               }
-               if (rshader->input[i].interpolate == TGSI_INTERPOLATE_COLOR ||
-                   rshader->input[i].interpolate == TGSI_INTERPOLATE_CONSTANT)
+               if (rshader->input[i].name == TGSI_SEMANTIC_POSITION ||
+                       rshader->input[i].interpolate == TGSI_INTERPOLATE_CONSTANT ||
+                       (rshader->input[i].interpolate == TGSI_INTERPOLATE_COLOR &&
+                               rctx->rasterizer && rctx->rasterizer->flatshade))
                        tmp |= S_028644_FLAT_SHADE(1);
 
                if (rshader->input[i].name == TGSI_SEMANTIC_GENERIC &&
@@ -2203,6 +2204,8 @@ void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader *shad
                                0xFFFFFFFF, NULL, 0);
 
        shader->sprite_coord_enable = rctx->sprite_coord_enable;
+       if (rctx->rasterizer)
+               shader->flatshade = rctx->rasterizer->flatshade;
 }
 
 void r600_pipe_shader_vs(struct pipe_context *ctx, struct r600_pipe_shader *shader)
index 80b28d9e7ca8683956ebcbe2dad22fa81593d92b..333e10cc5e9b30d0d4d9e28377e82994bdfa7abe 100644 (file)
@@ -595,8 +595,9 @@ static void r600_update_derived_state(struct r600_pipe_context *rctx)
                r600_update_alpha_ref(rctx);
        }
 
-       if (rctx->ps_shader && rctx->sprite_coord_enable &&
-               (rctx->ps_shader->sprite_coord_enable != rctx->sprite_coord_enable)) {
+       if (rctx->ps_shader && ((rctx->sprite_coord_enable &&
+               (rctx->ps_shader->sprite_coord_enable != rctx->sprite_coord_enable)) ||
+               (rctx->rasterizer && rctx->rasterizer->flatshade != rctx->ps_shader->flatshade))) {
 
                if (rctx->chip_class >= EVERGREEN)
                        evergreen_pipe_shader_ps(ctx, rctx->ps_shader);