r300: when using cs path emit scissor in the cmdbuffer
authorJerome Glisse <jglisse@redhat.com>
Thu, 28 May 2009 11:48:38 +0000 (13:48 +0200)
committerJerome Glisse <jglisse@redhat.com>
Thu, 28 May 2009 11:48:38 +0000 (13:48 +0200)
src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_cmdbuf.h
src/mesa/drivers/dri/r300/r300_render.c
src/mesa/drivers/dri/r300/r300_swtcl.c

index e605076a51904cf4ed8361470646115b4d57671a..b949c3b5b217e1764ecf088961580af78b50b2ee 100644 (file)
@@ -209,6 +209,45 @@ static void emit_tex_offsets(GLcontext *ctx, struct radeon_state_atom * atom)
        }
 }
 
+void r300_emit_scissor(GLcontext *ctx)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       BATCH_LOCALS(&r300->radeon);
+    unsigned x1, y1, x2, y2;
+       struct radeon_renderbuffer *rrb;
+
+    if (!r300->radeon.radeonScreen->driScreen->dri2.enabled) {
+        return;
+    }
+       rrb = radeon_get_colorbuffer(&r300->radeon);
+       if (!rrb || !rrb->bo) {
+               fprintf(stderr, "no rrb\n");
+               return;
+       }
+    if (r300->radeon.state.scissor.enabled) {
+        x1 = r300->radeon.state.scissor.rect.x1;
+        y1 = r300->radeon.state.scissor.rect.y1;
+        x2 = r300->radeon.state.scissor.rect.x2 - 1;
+        y2 = r300->radeon.state.scissor.rect.y2 - 1;
+    } else {
+        x1 = 0;
+        y1 = 0;
+        x2 = rrb->width - 1;
+        y2 = rrb->height - 1;
+    }
+    if (r300->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV515) {
+        x1 += R300_SCISSORS_OFFSET;
+        y1 += R300_SCISSORS_OFFSET;
+        x2 += R300_SCISSORS_OFFSET;
+        y2 += R300_SCISSORS_OFFSET;
+    }
+    BEGIN_BATCH_NO_AUTOSTATE(3);
+    OUT_BATCH_REGSEQ(R300_SC_SCISSORS_TL, 2);
+    OUT_BATCH((x1 << R300_SCISSORS_X_SHIFT)|(y1 << R300_SCISSORS_Y_SHIFT));
+    OUT_BATCH((x2 << R300_SCISSORS_X_SHIFT)|(y2 << R300_SCISSORS_Y_SHIFT));
+    END_BATCH();
+}
+
 static void emit_cb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
index 3786813de36d73653d394140c2f9616360e4fc0e..53bcc0eeb49d6db0373487d32f2a01c6d82ad0c5 100644 (file)
@@ -39,6 +39,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_context.h"
 
 extern void r300InitCmdBuf(r300ContextPtr r300);
+void r300_emit_scissor(GLcontext *ctx);
 
 void emit_vpu(GLcontext *ctx, struct radeon_state_atom * atom);
 int check_vpu(GLcontext *ctx, struct radeon_state_atom *atom);
index 7edeaed6d82cc42436e7a4be090bd0d81aef560d..92310a02647be4a8ab8a9ccd47dfb6b77bd1e855 100644 (file)
@@ -189,6 +189,7 @@ static void r300FireEB(r300ContextPtr rmesa, int vertex_count, int type)
 {
        BATCH_LOCALS(&rmesa->radeon);
 
+    r300_emit_scissor(rmesa->radeon.glCtx);
        if (vertex_count > 0) {
                BEGIN_BATCH(10);
                OUT_BATCH_PACKET3(R300_PACKET3_3D_DRAW_INDX_2, 0);
@@ -329,6 +330,7 @@ static void r300FireAOS(r300ContextPtr rmesa, int vertex_count, int type)
 {
        BATCH_LOCALS(&rmesa->radeon);
 
+    r300_emit_scissor(rmesa->radeon.glCtx);
        BEGIN_BATCH(3);
        OUT_BATCH_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0);
        OUT_BATCH(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_count << 16) | type);
index 78fa031479ceaf9dfc733b081ef2f7c162a912ed..68e24dec8fa4d28cceabda70409a2d2c4c0151da 100644 (file)
@@ -683,6 +683,7 @@ void r300_swtcl_flush(GLcontext *ctx, uint32_t current_offset)
                           rmesa->radeon.hw.max_state_size + (12*sizeof(int)),
                           __FUNCTION__);
        radeonEmitState(&rmesa->radeon);
+    r300_emit_scissor(ctx);
        r300EmitVertexAOS(rmesa,
                        rmesa->radeon.swtcl.vertex_size,
                        rmesa->radeon.dma.current,