r600g: fix r600 context structure, avoid segfault when no scissor
authorJerome Glisse <jglisse@redhat.com>
Mon, 9 Aug 2010 15:32:45 +0000 (11:32 -0400)
committerJerome Glisse <jglisse@redhat.com>
Mon, 9 Aug 2010 15:33:25 +0000 (11:33 -0400)
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
src/gallium/drivers/r600/r600_context.h
src/gallium/drivers/r600/r600_state.c

index 431f8951b2ac705d38693a71cf2d4a90b1e441d8..c606dbbda33c3c974514fa6c1b2537121e0b8b4a 100644 (file)
@@ -94,7 +94,7 @@ struct r600_context_hw_states {
        struct radeon_state     *dsa;
        struct radeon_state     *blend;
        struct radeon_state     *viewport;
-       struct radeon_state     *cb[7];
+       struct radeon_state     *cb[8];
        struct radeon_state     *config;
        struct radeon_state     *cb_cntl;
        struct radeon_state     *db;
index ff621084d47ecbde4cf2775d2c0ef0bb5219c075..cad5185e3247bf3972d74dbccb7dc5d111e3b2ba 100644 (file)
@@ -836,12 +836,25 @@ static struct radeon_state *r600_rasterizer(struct r600_context *rctx)
 static struct radeon_state *r600_scissor(struct r600_context *rctx)
 {
        const struct pipe_scissor_state *state = &rctx->scissor->state.scissor;
+       const struct pipe_framebuffer_state *fb = &rctx->framebuffer->state.framebuffer;
        struct r600_screen *rscreen = rctx->screen;
        struct radeon_state *rstate;
+       unsigned minx, maxx, miny, maxy;
        u32 tl, br;
 
-       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);
+       if (state == NULL) {
+               minx = 0;
+               miny = 0;
+               maxx = fb->cbufs[0]->width;
+               maxy = fb->cbufs[0]->height;
+       } else {
+               minx = state->minx;
+               miny = state->miny;
+               maxx = state->maxx;
+               maxy = state->maxy;
+       }
+       tl = S_028240_TL_X(minx) | S_028240_TL_Y(miny) | S_028240_WINDOW_OFFSET_DISABLE(1);
+       br = S_028244_BR_X(maxx) | S_028244_BR_Y(maxy);
        rstate = radeon_state(rscreen->rw, R600_SCISSOR_TYPE, R600_SCISSOR);
        if (rstate == NULL)
                return NULL;