r300g: Atomize scissors.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 11 Jan 2010 07:02:48 +0000 (23:02 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 11 Jan 2010 07:15:05 +0000 (23:15 -0800)
Argfl. Some of this code is so questionable.

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_render.c
src/gallium/drivers/r300/r300_state.c

index f003451083829b53b26b188588d06d754ae54792..af95bbe789c49f068cdd6ef81fcd0c53708fd71b 100644 (file)
@@ -73,7 +73,7 @@ static void r300_destroy_context(struct pipe_context* context)
     FREE(r300->blend_color_state.state);
     FREE(r300->clip_state.state);
     FREE(r300->rs_block);
-    FREE(r300->scissor_state);
+    FREE(r300->scissor_state.state);
     FREE(r300->vertex_info);
     FREE(r300->viewport_state.state);
     FREE(r300->ztop_state.state);
@@ -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(scissor);
     R300_INIT_ATOM(viewport);
 }
 
@@ -181,7 +182,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state);
     r300->clip_state.state = CALLOC_STRUCT(pipe_clip_state);
     r300->rs_block = CALLOC_STRUCT(r300_rs_block);
-    r300->scissor_state = CALLOC_STRUCT(r300_scissor_state);
+    r300->scissor_state.state = CALLOC_STRUCT(r300_scissor_state);
     r300->vertex_info = CALLOC_STRUCT(r300_vertex_info);
     r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state);
     r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state);
index 05ea7ad0f90edcff7c11dac936f503fef6a5117f..70a04d6f445e7a06ef3c4f66a959397b7f6542a9 100644 (file)
@@ -145,7 +145,6 @@ struct r300_ztop_state {
 #define R300_NEW_RS_BLOCK        0x00000100
 #define R300_NEW_SAMPLER         0x00000200
 #define R300_ANY_NEW_SAMPLERS    0x0001fe00
-#define R300_NEW_SCISSOR         0x00020000
 #define R300_NEW_TEXTURE         0x00040000
 #define R300_ANY_NEW_TEXTURES    0x03fc0000
 #define R300_NEW_VERTEX_FORMAT   0x04000000
@@ -295,7 +294,7 @@ struct r300_context {
     struct r300_sampler_state* sampler_states[8];
     int sampler_count;
     /* Scissor state. */
-    struct r300_scissor_state* scissor_state;
+    struct r300_atom scissor_state;
     /* Texture states. */
     struct r300_texture* textures[8];
     int texture_count;
index 86d4000d086b700e2a65aaa7b4a13bbc3283f3ab..0e5533c7902ac7c834a3437542b1d4902003bb50 100644 (file)
@@ -653,9 +653,9 @@ static void r300_emit_scissor_regs(struct r300_context* r300,
     END_CS;
 }
 
-void r300_emit_scissor_state(struct r300_context* r300,
-                             struct r300_scissor_state* scissor)
+void r300_emit_scissor_state(struct r300_context* r300, void* state)
 {
+    struct r300_scissor_state* scissor = (struct r300_scissor_state*)state;
     /* XXX argfl! */
     if (((struct r300_rs_state*)r300->rs_state.state)->rs.scissor) {
         r300_emit_scissor_regs(r300, &scissor->scissor);
@@ -1108,11 +1108,6 @@ validate:
         r300->dirty_state &= ~R300_NEW_RS_BLOCK;
     }
 
-    if (r300->dirty_state & R300_NEW_SCISSOR) {
-        r300_emit_scissor_state(r300, r300->scissor_state);
-        r300->dirty_state &= ~R300_NEW_SCISSOR;
-    }
-
     /* Samplers and textures are tracked separately but emitted together. */
     if (r300->dirty_state &
             (R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) {
index 1a76de0da69274c64ea4d8445b47a74a588aba01..05a6bfeae869486907987d621d491cac3e2c08a3 100644 (file)
@@ -64,8 +64,7 @@ void r300_emit_rs_state(struct r300_context* r300, void* state);
 void r300_emit_rs_block_state(struct r300_context* r300,
                               struct r300_rs_block* rs);
 
-void r300_emit_scissor_state(struct r300_context* r300,
-                             struct r300_scissor_state* scissor);
+void r300_emit_scissor_state(struct r300_context* r300, void* state);
 
 void r300_emit_texture(struct r300_context* r300,
                        struct r300_sampler_state* sampler,
index 7098f66f0c33f3deaad19f2973feaacb323d5937..2bd3acea410e997c37c4a1f51186b554c027e101 100644 (file)
@@ -72,7 +72,7 @@ uint32_t r300_translate_primitive(unsigned prim)
 static boolean r300_nothing_to_draw(struct r300_context *r300)
 {
     return ((struct r300_rs_state*)r300->rs_state.state)->rs.scissor &&
-           r300->scissor_state->scissor.empty_area;
+           ((struct r300_scissor_state*)r300->scissor_state.state)->scissor.empty_area;
 }
 
 static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300,
index da1f40c8ef6125dc58ac8f101d821a9ac686f812..86773adc8dbec23e2d89e1632e10997e9fff031e 100644 (file)
@@ -504,7 +504,9 @@ static void
                                const struct pipe_framebuffer_state* state)
 {
     struct r300_context* r300 = r300_context(pipe);
-    struct pipe_scissor_state scissor;
+    struct r300_scissor_state* scissor =
+        (struct r300_scissor_state*)r300->scissor_state.state;
+    struct pipe_scissor_state pscissor;
 
     if (r300->draw) {
         draw_flush(r300->draw);
@@ -512,21 +514,19 @@ static void
 
     r300->framebuffer_state = *state;
 
-    scissor.minx = scissor.miny = 0;
-    scissor.maxx = state->width;
-    scissor.maxy = state->height;
-    r300_set_scissor_regs(&scissor, &r300->scissor_state->framebuffer,
+    /* XXX Arg. This is silly. */
+    pscissor.minx = pscissor.miny = 0;
+    pscissor.maxx = state->width;
+    pscissor.maxy = state->height;
+    r300_set_scissor_regs(&pscissor, &scissor->framebuffer,
                           r300_screen(r300->context.screen)->caps->is_r500);
 
     /* Don't rely on the order of states being set for the first time. */
-    /* XXX ( >&) */
-    if (!r300->rs_state.state) {
-        r300->dirty_state |= R300_NEW_SCISSOR;
-    }
     r300->dirty_state |= R300_NEW_FRAMEBUFFERS;
 
     r300->blend_state.dirty = TRUE;
     r300->dsa_state.dirty = TRUE;
+    r300->scissor_state.dirty = TRUE;
 }
 
 /* Create fragment shader state. */
@@ -725,11 +725,11 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
     r300->rs_state.state = rs;
     r300->rs_state.dirty = TRUE;
     /* XXX Why is this still needed, dammit!? */
+    r300->scissor_state.dirty = TRUE;
     r300->viewport_state.dirty = TRUE;
 
     /* XXX Clean these up when we move to atom emits */
     r300->dirty_state |= R300_NEW_RS_BLOCK;
-    r300->dirty_state |= R300_NEW_SCISSOR;
     if (r300->fs && r300->fs->inputs.wpos != ATTR_UNUSED) {
         r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
     }
@@ -867,11 +867,13 @@ static void r300_set_scissor_state(struct pipe_context* pipe,
                                    const struct pipe_scissor_state* state)
 {
     struct r300_context* r300 = r300_context(pipe);
+    struct r300_scissor_state* scissor =
+        (struct r300_scissor_state*)r300->scissor_state.state;
 
-    r300_set_scissor_regs(state, &r300->scissor_state->scissor,
+    r300_set_scissor_regs(state, &scissor->scissor,
                           r300_screen(r300->context.screen)->caps->is_r500);
 
-    r300->dirty_state |= R300_NEW_SCISSOR;
+    r300->scissor_state.dirty = TRUE;
 }
 
 static void r300_set_viewport_state(struct pipe_context* pipe,