r300g: Atomize viewport.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 11 Jan 2010 02:07:28 +0000 (18:07 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 11 Jan 2010 07:15:05 +0000 (23:15 -0800)
Goddammit, some of these hax are really annoying.

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

index 9319b5ecfc45aedda160ff53613bbadcfe8d998f..f003451083829b53b26b188588d06d754ae54792 100644 (file)
@@ -75,7 +75,7 @@ static void r300_destroy_context(struct pipe_context* context)
     FREE(r300->rs_block);
     FREE(r300->scissor_state);
     FREE(r300->vertex_info);
-    FREE(r300->viewport_state);
+    FREE(r300->viewport_state.state);
     FREE(r300->ztop_state.state);
     FREE(r300);
 }
@@ -125,6 +125,7 @@ static void r300_setup_atoms(struct r300_context* r300)
     R300_INIT_ATOM(clip);
     R300_INIT_ATOM(dsa);
     R300_INIT_ATOM(rs);
+    R300_INIT_ATOM(viewport);
 }
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
@@ -182,7 +183,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     r300->rs_block = CALLOC_STRUCT(r300_rs_block);
     r300->scissor_state = CALLOC_STRUCT(r300_scissor_state);
     r300->vertex_info = CALLOC_STRUCT(r300_vertex_info);
-    r300->viewport_state = CALLOC_STRUCT(r300_viewport_state);
+    r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state);
     r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state);
 
     /* Open up the OQ BO. */
index e8c56bbf8748531fde4d41555f24475f5416e5a8..70b381fe74bc0ec2bd2ca1ed5041d9379904431c 100644 (file)
@@ -156,7 +156,6 @@ struct r300_ztop_state {
 #define R300_NEW_VERTEX_FORMAT   0x04000000
 #define R300_NEW_VERTEX_SHADER   0x08000000
 #define R300_NEW_VERTEX_SHADER_CONSTANTS    0x10000000
-#define R300_NEW_VIEWPORT        0x20000000
 #define R300_NEW_QUERY           0x40000000
 #define R300_NEW_KITCHEN_SINK    0x7fffffff
 
@@ -308,7 +307,7 @@ struct r300_context {
     /* Vertex shader. */
     struct r300_vertex_shader* vs;
     /* Viewport state. */
-    struct r300_viewport_state* viewport_state;
+    struct r300_atom viewport_state;
     /* ZTOP state. */
     struct r300_atom ztop_state;
 
index cfeb99a0adeeb7a418999ab216999c7ed1b33bc9..aa21682e4b37ac011468b02e23abac5f38bd3825 100644 (file)
@@ -146,7 +146,7 @@ static const float * get_shader_constant(
     struct r300_constant_buffer * externals)
 {
     struct r300_viewport_state* viewport =
-        (struct r300_viewport_state*)r300->viewport_state;
+        (struct r300_viewport_state*)r300->viewport_state.state;
     boolean vte_enabled = viewport->vte_control & ~R300_VTX_W0_FMT;
     static float vec[4] = { 0.0, 0.0, 0.0, 1.0 };
     struct pipe_texture *tex;
@@ -918,9 +918,9 @@ void r300_emit_vs_constant_buffer(struct r300_context* r300,
     END_CS;
 }
 
-void r300_emit_viewport_state(struct r300_context* r300,
-                              struct r300_viewport_state* viewport)
+void r300_emit_viewport_state(struct r300_context* r300, void* state)
 {
+    struct r300_viewport_state* viewport = (struct r300_viewport_state*)state;
     CS_LOCALS(r300);
 
     BEGIN_CS(9);
@@ -932,7 +932,7 @@ void r300_emit_viewport_state(struct r300_context* r300,
     OUT_CS_32F(viewport->zscale);
     OUT_CS_32F(viewport->zoffset);
 
-    /* XXX words fail me. */
+    /* XXX words still fail me. */
     if (((struct r300_rs_state*)r300->rs_state.state)->enable_vte) {
         OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control);
     } else {
@@ -1138,11 +1138,6 @@ validate:
         r300->dirty_state &= ~(R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES);
     }
 
-    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 a6539b218b478904eb9fec2d5b62336f34dbfd53..1a76de0da69274c64ea4d8445b47a74a588aba01 100644 (file)
@@ -85,8 +85,7 @@ void r300_emit_vs_constant_buffer(struct r300_context* r300,
 void r300_emit_vertex_shader(struct r300_context* r300,
                              struct r300_vertex_shader* vs);
 
-void r300_emit_viewport_state(struct r300_context* r300,
-                              struct r300_viewport_state* viewport);
+void r300_emit_viewport_state(struct r300_context* r300, void* state);
 
 void r300_emit_texture_count(struct r300_context* r300);
 
index 8740a082b98f27ae0e8b6041d3dd7ed55441e7ea..4c0b307ea88c6d4eb3a04ec0f333bb5ebc3fa975 100644 (file)
@@ -724,11 +724,11 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
 
     r300->rs_state.state = rs;
     r300->rs_state.dirty = TRUE;
+    r300->viewport_state.dirty = TRUE; /* XXX */
 
     /* XXX Clean these up when we move to atom emits */
     r300->dirty_state |= R300_NEW_RS_BLOCK;
     r300->dirty_state |= R300_NEW_SCISSOR;
-    r300->dirty_state |= R300_NEW_VIEWPORT;
     if (r300->fs && r300->fs->inputs.wpos != ATTR_UNUSED) {
         r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
     }
@@ -877,36 +877,38 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
                                     const struct pipe_viewport_state* state)
 {
     struct r300_context* r300 = r300_context(pipe);
+    struct r300_viewport_state* viewport =
+        (struct r300_viewport_state*)r300->viewport_state.state;
 
     /* Do the transform in HW. */
-    r300->viewport_state->vte_control = R300_VTX_W0_FMT;
+    viewport->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;
+        viewport->xscale = state->scale[0];
+        viewport->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;
+        viewport->yscale = state->scale[1];
+        viewport->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;
+        viewport->zscale = state->scale[2];
+        viewport->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;
+        viewport->xoffset = state->translate[0];
+        viewport->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;
+        viewport->yoffset = state->translate[1];
+        viewport->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;
+        viewport->zoffset = state->translate[2];
+        viewport->vte_control |= R300_VPORT_Z_OFFSET_ENA;
     }
 
-    r300->dirty_state |= R300_NEW_VIEWPORT;
+    r300->viewport_state.dirty = TRUE;
     if (r300->fs && r300->fs->inputs.wpos != ATTR_UNUSED) {
         r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
     }