r300-gallium: Use viewport state.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 15 Apr 2009 22:09:43 +0000 (15:09 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 15 Apr 2009 22:10:24 +0000 (15:10 -0700)
src/gallium/drivers/r300/r300_state.c

index 2a77fd173906877fd349644e67176e661a2524c3..c9507ae193703121e5404e504e57ad0f00b78a18 100644 (file)
@@ -555,25 +555,41 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    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;
+        r300->viewport_state->vte_control = R300_VTX_W0_FMT;
+
+        if (state->scale[0] != 1.0f) {
+            r300->viewport_state->xscale = state->scale[0];
+            r300->viewport_state->vte_control |= R300_VPORT_X_SCALE_ENA;
+        }
+        if (state->scale[1] != 1.0f) {
+            r300->viewport_state->yscale = state->scale[1];
+            r300->viewport_state->vte_control |= R300_VPORT_Y_SCALE_ENA;
+        }
+        if (state->scale[2] != 1.0f) {
+            r300->viewport_state->zscale = state->scale[2];
+            r300->viewport_state->vte_control |= R300_VPORT_Z_SCALE_ENA;
+        }
+        if (state->translate[0] != 0.0f) {
+            r300->viewport_state->xoffset = state->translate[0];
+            r300->viewport_state->vte_control |= R300_VPORT_X_OFFSET_ENA;
+        }
+        if (state->translate[1] != 0.0f) {
+            r300->viewport_state->yoffset = state->translate[1];
+            r300->viewport_state->vte_control |= R300_VPORT_Y_OFFSET_ENA;
+        }
+        if (state->translate[2] != 0.0f) {
+            r300->viewport_state->zoffset = state->translate[2];
+            r300->viewport_state->vte_control |= R300_VPORT_Z_OFFSET_ENA;
+        }
     } else {
+        r300->viewport_state->vte_control = 0;
         /* Have Draw do the actual transform. */
         draw_set_viewport_state(r300->draw, state);
     }
+
+    r300->dirty_state |= R300_NEW_VIEWPORT;
 }
 
 static void r300_set_vertex_buffers(struct pipe_context* pipe,