r300-gallium: Emit viewport state.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 18 Mar 2009 22:17:38 +0000 (15:17 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 18 Mar 2009 22:44:04 +0000 (15:44 -0700)
Note that this will break you, hard, if you're not using RADEON_NO_TCL.
I really need to start vertex shaders soon.

src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_invariant.c

index 5431cf2f72a19466bee6e33d9f9c45c162efa31e..0e5e471d11682d20269dc5150ee690e950d0130b 100644 (file)
@@ -103,12 +103,13 @@ struct r300_texture_state {
 };
 
 struct r300_viewport_state {
-    float xscale;  /* R300_VAP_VPORT_XSCALE:  0x2098 */
-    float xoffset; /* R300_VAP_VPORT_XOFFSET: 0x209c */
-    float yscale;  /* R300_VAP_VPORT_YSCALE:  0x20a0 */
-    float yoffset; /* R300_VAP_VPORT_YOFFSET: 0x20a4 */
-    float zscale;  /* R300_VAP_VPORT_ZSCALE:  0x20a8 */
-    float zoffset; /* R300_VAP_VPORT_ZOFFSET: 0x20ac */
+    float xscale;         /* R300_VAP_VPORT_XSCALE:  0x2098 */
+    float xoffset;        /* R300_VAP_VPORT_XOFFSET: 0x209c */
+    float yscale;         /* R300_VAP_VPORT_YSCALE:  0x20a0 */
+    float yoffset;        /* R300_VAP_VPORT_YOFFSET: 0x20a4 */
+    float zscale;         /* R300_VAP_VPORT_ZSCALE:  0x20a8 */
+    float zoffset;        /* R300_VAP_VPORT_ZOFFSET: 0x20ac */
+    uint32_t vte_control; /* R300_VAP_VTE_CNTL:      0x20b0 */
 };
 
 #define R300_NEW_BLEND           0x0000001
index 7bd3420f7425ed96b0a8b8b3b3a15bb8e2124c8e..a2e771bd1b2c25a11df182df6c89ce24b58ff225 100644 (file)
@@ -340,6 +340,24 @@ void r300_emit_vertex_format_state(struct r300_context* r300)
     END_CS;
 }
 
+void r300_emit_viewport_state(struct r300_context* r300,
+                              struct r300_viewport_state* viewport)
+{
+    return;
+    CS_LOCALS(r300);
+
+    BEGIN_CS(7);
+    OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 7);
+    OUT_CS_32F(viewport->xscale);
+    OUT_CS_32F(viewport->xoffset);
+    OUT_CS_32F(viewport->yscale);
+    OUT_CS_32F(viewport->yoffset);
+    OUT_CS_32F(viewport->zscale);
+    OUT_CS_32F(viewport->zoffset);
+    OUT_CS(viewport->vte_control);
+    END_CS;
+}
+
 static void r300_flush_textures(struct r300_context* r300)
 {
     CS_LOCALS(r300);
@@ -431,6 +449,11 @@ void r300_emit_dirty_state(struct r300_context* r300)
         }
     }
 
+    if (r300->dirty_state & R300_NEW_VIEWPORT) {
+        r300_emit_viewport_state(r300, r300->viewport_state);
+        r300->dirty_state &= ~R300_NEW_VIEWPORT;
+    }
+
     if (dirty_tex) {
         r300_flush_textures(r300);
     }
index 04cbf71ce5033c9c30500b1ee3be8bbe0c2282d0..58bce22fc81a2090bdf580e620c104bc9df0d8f7 100644 (file)
@@ -529,8 +529,26 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
                                     const struct pipe_viewport_state* state)
 {
     struct r300_context* r300 = r300_context(pipe);
-    /* XXX handing this off to Draw for now */
-    draw_set_viewport_state(r300->draw, state);
+
+    r300->viewport_state->xscale = state->scale[0];
+    r300->viewport_state->yscale = state->scale[1];
+    r300->viewport_state->zscale = state->scale[2];
+
+    r300->viewport_state->xoffset = state->translate[0];
+    r300->viewport_state->yoffset = state->translate[1];
+    r300->viewport_state->zoffset = state->translate[2];
+
+    r300->viewport_state->vte_control = 0;
+    if (r300_screen(r300->context.screen)->caps->has_tcl) {
+        /* Do the transform in HW. */
+        r300->viewport_state->vte_control |=
+            R300_VPORT_X_SCALE_ENA | R300_VPORT_X_OFFSET_ENA |
+            R300_VPORT_Y_SCALE_ENA | R300_VPORT_Y_OFFSET_ENA |
+            R300_VPORT_Z_SCALE_ENA | R300_VPORT_Z_OFFSET_ENA;
+    } else {
+        /* Have Draw do the actual transform. */
+        draw_set_viewport_state(r300->draw, state);
+    }
 }
 
 static void r300_set_vertex_buffers(struct pipe_context* pipe,
index e584bfbfbfa30c1b2d92268caad9260d09c6c9a0..3d51a8e65d2541e90cdf0921e77bf2705ad7372a 100644 (file)
@@ -78,7 +78,7 @@ void r300_emit_invariant_state(struct r300_context* r300)
     END_CS;
 
     /* XXX unsorted stuff from surface_fill */
-    BEGIN_CS(99 + (caps->has_tcl ? 28 : 0));
+    BEGIN_CS(99 + (caps->has_tcl ? 26 : 0));
     /* Flush PVS. */
     OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);