r600g: fix scissor/cliprect confusion
authorDave Airlie <airlied@redhat.com>
Wed, 13 Oct 2010 04:23:36 +0000 (14:23 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 13 Oct 2010 05:11:30 +0000 (15:11 +1000)
gallium calls them scissors, but r600 hw like r300 is better off using
cliprects to implement them as we can turn them on/off a lot easier.

src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_state.c

index 99085647a75c3235661daf5a231232aab8827906..a5298e3fdf9e41d0014282682397d4cc4292b27c 100644 (file)
@@ -241,6 +241,7 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx,
        struct r600_pipe_state *rstate;
        unsigned tmp;
        unsigned prov_vtx = 1, polygon_dual_mode;
+       unsigned clip_rule;
 
        if (rs == NULL) {
                return NULL;
@@ -250,6 +251,8 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx,
        rs->flatshade = state->flatshade;
        rs->sprite_coord_enable = state->sprite_coord_enable;
 
+       clip_rule = state->scissor ? 0xAAAA : 0xFFFF;
+
        /* offset */
        rs->offset_units = state->offset_units;
        rs->offset_scale = state->offset_scale * 12.0f;
@@ -299,6 +302,7 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate, R_028C18_PA_CL_GB_HORZ_DISC_ADJ, 0x3F800000, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate, R_028B7C_PA_SU_POLY_OFFSET_CLAMP, 0x0, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate, R_028C08_PA_SU_VTX_CNTL, 0x00000005, 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg(rstate, R_02820C_PA_SC_CLIPRECT_RULE, clip_rule, 0xFFFFFFFF, NULL);
        return rstate;
 }
 
@@ -629,18 +633,6 @@ static void evergreen_set_scissor_state(struct pipe_context *ctx,
        rstate->id = R600_PIPE_STATE_SCISSOR;
        tl = S_028240_TL_X(state->minx) | S_028240_TL_Y(state->miny);
        br = S_028244_BR_X(state->maxx) | S_028244_BR_Y(state->maxy);
-       r600_pipe_state_add_reg(rstate,
-                               R_028030_PA_SC_SCREEN_SCISSOR_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028034_PA_SC_SCREEN_SCISSOR_BR, br,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028204_PA_SC_WINDOW_SCISSOR_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028208_PA_SC_WINDOW_SCISSOR_BR, br,
-                               0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                                R_028210_PA_SC_CLIPRECT_0_TL, tl,
                                0xFFFFFFFF, NULL);
@@ -665,15 +657,6 @@ static void evergreen_set_scissor_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate,
                                R_02822C_PA_SC_CLIPRECT_3_BR, br,
                                0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028200_PA_SC_WINDOW_OFFSET, 0x00000000,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_02820C_PA_SC_CLIPRECT_RULE, 0x0000FFFF,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028230_PA_SC_EDGERULE, 0xAAAAAAAA,
-                               0xFFFFFFFF, NULL);
 
        free(rctx->states[R600_PIPE_STATE_SCISSOR]);
        rctx->states[R600_PIPE_STATE_SCISSOR] = rstate;
@@ -911,36 +894,9 @@ static void evergreen_set_framebuffer_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate,
                                R_028208_PA_SC_WINDOW_SCISSOR_BR, br,
                                0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028210_PA_SC_CLIPRECT_0_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028214_PA_SC_CLIPRECT_0_BR, br,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028218_PA_SC_CLIPRECT_1_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_02821C_PA_SC_CLIPRECT_1_BR, br,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028220_PA_SC_CLIPRECT_2_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028224_PA_SC_CLIPRECT_2_BR, br,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028228_PA_SC_CLIPRECT_3_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_02822C_PA_SC_CLIPRECT_3_BR, br,
-                               0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                                R_028200_PA_SC_WINDOW_OFFSET, 0x00000000,
                                0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_02820C_PA_SC_CLIPRECT_RULE, 0x0000FFFF,
-                               0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                                R_028230_PA_SC_EDGERULE, 0xAAAAAAAA,
                                0xFFFFFFFF, NULL);
index 70461d24ea2badb8a62dd9f1b7816279ed82a3ad..25310eeda4e2977c6e13f962f3811f4b91cf2936 100644 (file)
@@ -446,6 +446,7 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
        struct r600_pipe_state *rstate;
        unsigned tmp;
        unsigned prov_vtx = 1, polygon_dual_mode;
+       unsigned clip_rule;
 
        if (rs == NULL) {
                return NULL;
@@ -455,6 +456,7 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
        rs->flatshade = state->flatshade;
        rs->sprite_coord_enable = state->sprite_coord_enable;
 
+       clip_rule = state->scissor ? 0xAAAA : 0xFFFF;
        /* offset */
        rs->offset_units = state->offset_units;
        rs->offset_scale = state->offset_scale * 12.0f;
@@ -505,6 +507,8 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate, R_028C14_PA_CL_GB_HORZ_CLIP_ADJ, 0x3F800000, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate, R_028C18_PA_CL_GB_HORZ_DISC_ADJ, 0x3F800000, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate, R_028DFC_PA_SU_POLY_OFFSET_CLAMP, 0x00000000, 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg(rstate, R_02820C_PA_SC_CLIPRECT_RULE, clip_rule, 0xFFFFFFFF, NULL);
+
        return rstate;
 }
 
@@ -832,18 +836,6 @@ static void r600_set_scissor_state(struct pipe_context *ctx,
        rstate->id = R600_PIPE_STATE_SCISSOR;
        tl = S_028240_TL_X(state->minx) | S_028240_TL_Y(state->miny) | S_028240_WINDOW_OFFSET_DISABLE(1);
        br = S_028244_BR_X(state->maxx) | S_028244_BR_Y(state->maxy);
-       r600_pipe_state_add_reg(rstate,
-                               R_028030_PA_SC_SCREEN_SCISSOR_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028034_PA_SC_SCREEN_SCISSOR_BR, br,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028204_PA_SC_WINDOW_SCISSOR_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028208_PA_SC_WINDOW_SCISSOR_BR, br,
-                               0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                                R_028210_PA_SC_CLIPRECT_0_TL, tl,
                                0xFFFFFFFF, NULL);
@@ -868,17 +860,6 @@ static void r600_set_scissor_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate,
                                R_02822C_PA_SC_CLIPRECT_3_BR, br,
                                0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028200_PA_SC_WINDOW_OFFSET, 0x00000000,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_02820C_PA_SC_CLIPRECT_RULE, 0x0000FFFF,
-                               0xFFFFFFFF, NULL);
-       if (rctx->family >= CHIP_RV770) {
-               r600_pipe_state_add_reg(rstate,
-                                       R_028230_PA_SC_EDGERULE, 0xAAAAAAAA,
-                                       0xFFFFFFFF, NULL);
-       }
 
        free(rctx->states[R600_PIPE_STATE_SCISSOR]);
        rctx->states[R600_PIPE_STATE_SCISSOR] = rstate;
@@ -1098,36 +1079,9 @@ static void r600_set_framebuffer_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate,
                                R_028254_PA_SC_VPORT_SCISSOR_0_BR, br,
                                0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028210_PA_SC_CLIPRECT_0_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028214_PA_SC_CLIPRECT_0_BR, br,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028218_PA_SC_CLIPRECT_1_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_02821C_PA_SC_CLIPRECT_1_BR, br,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028220_PA_SC_CLIPRECT_2_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028224_PA_SC_CLIPRECT_2_BR, br,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_028228_PA_SC_CLIPRECT_3_TL, tl,
-                               0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_02822C_PA_SC_CLIPRECT_3_BR, br,
-                               0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate,
                                R_028200_PA_SC_WINDOW_OFFSET, 0x00000000,
                                0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate,
-                               R_02820C_PA_SC_CLIPRECT_RULE, 0x0000FFFF,
-                               0xFFFFFFFF, NULL);
        if (rctx->family >= CHIP_RV770) {
                r600_pipe_state_add_reg(rstate,
                                        R_028230_PA_SC_EDGERULE, 0xAAAAAAAA,
@@ -1532,14 +1486,14 @@ void r600_init_config(struct r600_pipe_context *rctx)
                r600_pipe_state_add_reg(rstate, R_009830_DB_DEBUG, 0x00000000, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_009838_DB_WATERMARKS, 0x00420204, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_0286C8_SPI_THREAD_GROUPING, 0x00000000, 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate, R_028A4C_PA_SC_MODE_CNTL, 0x00514000, 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg(rstate, R_028A4C_PA_SC_MODE_CNTL, 0x00514002, 0xFFFFFFFF, NULL);
        } else {
                r600_pipe_state_add_reg(rstate, R_008D8C_SQ_DYN_GPR_CNTL_PS_FLUSH_REQ, 0x00000000, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_009508_TA_CNTL_AUX, 0x07000003, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_009830_DB_DEBUG, 0x82000000, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_009838_DB_WATERMARKS, 0x01020204, 0xFFFFFFFF, NULL);
                r600_pipe_state_add_reg(rstate, R_0286C8_SPI_THREAD_GROUPING, 0x00000001, 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate, R_028A4C_PA_SC_MODE_CNTL, 0x00004010, 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg(rstate, R_028A4C_PA_SC_MODE_CNTL, 0x00004012, 0xFFFFFFFF, NULL);
        }
        r600_pipe_state_add_reg(rstate, R_0288A8_SQ_ESGS_RING_ITEMSIZE, 0x00000000, 0xFFFFFFFF, NULL);
        r600_pipe_state_add_reg(rstate, R_0288AC_SQ_GSVS_RING_ITEMSIZE, 0x00000000, 0xFFFFFFFF, NULL);