r300g: Atomize rasterizer.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 10 Jan 2010 22:29:32 +0000 (14:29 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 11 Jan 2010 07:15:04 +0000 (23:15 -0800)
I want to stab things now.

src/gallium/drivers/r300/r300_blit.c
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
src/gallium/drivers/r300/r300_state_derived.c

index b2fec4a50bf1672e5821bd42c26d4e9d8016776f..c14414fff6b0904849965dd1cc57b657d658ec1f 100644 (file)
@@ -29,7 +29,7 @@ static void r300_blitter_save_states(struct r300_context* r300)
 {
     util_blitter_save_blend(r300->blitter, r300->blend_state.state);
     util_blitter_save_depth_stencil_alpha(r300->blitter, r300->dsa_state.state);
-    util_blitter_save_rasterizer(r300->blitter, r300->rs_state);
+    util_blitter_save_rasterizer(r300->blitter, r300->rs_state.state);
     util_blitter_save_fragment_shader(r300->blitter, r300->fs);
     util_blitter_save_vertex_shader(r300->blitter, r300->vs);
 }
index abd5d268747269a1d20c49644a68412f15856b13..9319b5ecfc45aedda160ff53613bbadcfe8d998f 100644 (file)
@@ -124,6 +124,7 @@ static void r300_setup_atoms(struct r300_context* r300)
     R300_INIT_ATOM(blend_color);
     R300_INIT_ATOM(clip);
     R300_INIT_ATOM(dsa);
+    R300_INIT_ATOM(rs);
 }
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
index 56c49f7efa121ce493cd0961d0a1504d6b388b6f..e8c56bbf8748531fde4d41555f24475f5416e5a8 100644 (file)
@@ -147,7 +147,6 @@ struct r300_ztop_state {
 #define R300_NEW_FRAMEBUFFERS    0x00000010
 #define R300_NEW_FRAGMENT_SHADER 0x00000020
 #define R300_NEW_FRAGMENT_SHADER_CONSTANTS    0x00000040
-#define R300_NEW_RASTERIZER      0x00000080
 #define R300_NEW_RS_BLOCK        0x00000100
 #define R300_NEW_SAMPLER         0x00000200
 #define R300_ANY_NEW_SAMPLERS    0x0001fe00
@@ -295,7 +294,7 @@ struct r300_context {
     /* Framebuffer state. We currently don't need our own version of this. */
     struct pipe_framebuffer_state framebuffer_state;
     /* Rasterizer state. */
-    struct r300_rs_state* rs_state;
+    struct r300_atom rs_state;
     /* RS block state. */
     struct r300_rs_block* rs_block;
     /* Sampler states. */
index 27fb9aa9ba8d5a823e64bc0f7d0fbcbe58c159a5..60e4a109d4462086950ad32e1ad6b7c624e30fb8 100644 (file)
@@ -145,6 +145,9 @@ static const float * get_shader_constant(
     struct rc_constant * constant,
     struct r300_constant_buffer * externals)
 {
+    struct r300_viewport_state* viewport =
+        (struct r300_viewport_state*)r300->viewport_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;
 
@@ -167,16 +170,17 @@ static const float * get_shader_constant(
 
                 /* Texture compare-fail value. */
                 /* XXX Since Gallium doesn't support GL_ARB_shadow_ambient,
-                 * this is always (0,0,0,0). */
+                 * this is always (0,0,0,0), right? */
                 case RC_STATE_SHADOW_AMBIENT:
                     vec[3] = 0;
                     break;
 
                 case RC_STATE_R300_VIEWPORT_SCALE:
-                    if (r300->rs_state->enable_vte) {
-                        vec[0] = r300->viewport_state->xscale;
-                        vec[1] = r300->viewport_state->yscale;
-                        vec[2] = r300->viewport_state->zscale;
+                /* XXX argfl stop crossing state */
+                    if (vte_enabled) {
+                        vec[0] = viewport->xscale;
+                        vec[1] = viewport->yscale;
+                        vec[2] = viewport->zscale;
                     } else {
                         vec[0] = 1;
                         vec[1] = 1;
@@ -185,10 +189,10 @@ static const float * get_shader_constant(
                     break;
 
                 case RC_STATE_R300_VIEWPORT_OFFSET:
-                    if (r300->rs_state->enable_vte) {
-                        vec[0] = r300->viewport_state->xoffset;
-                        vec[1] = r300->viewport_state->yoffset;
-                        vec[2] = r300->viewport_state->zoffset;
+                    if (vte_enabled) {
+                        vec[0] = viewport->xoffset;
+                        vec[1] = viewport->yoffset;
+                        vec[2] = viewport->zoffset;
                     } else {
                         /* Zeros. */
                     }
@@ -576,8 +580,9 @@ void r300_emit_query_end(struct r300_context* r300)
         r300_emit_query_finish(r300, query);
 }
 
-void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs)
+void r300_emit_rs_state(struct r300_context* r300, void* state)
 {
+    struct r300_rs_state* rs = (struct r300_rs_state*)state;
     CS_LOCALS(r300);
 
     BEGIN_CS(22);
@@ -655,7 +660,8 @@ static void r300_emit_scissor_regs(struct r300_context* r300,
 void r300_emit_scissor_state(struct r300_context* r300,
                              struct r300_scissor_state* scissor)
 {
-    if (r300->rs_state->rs.scissor) {
+    /* XXX argfl! */
+    if (((struct r300_rs_state*)r300->rs_state.state)->rs.scissor) {
         r300_emit_scissor_regs(r300, &scissor->scissor);
     } else {
         r300_emit_scissor_regs(r300, &scissor->framebuffer);
@@ -926,7 +932,8 @@ void r300_emit_viewport_state(struct r300_context* r300,
     OUT_CS_32F(viewport->zscale);
     OUT_CS_32F(viewport->zoffset);
 
-    if (r300->rs_state->enable_vte) {
+    /* XXX words fail me. */
+    if (((struct r300_rs_state*)r300->rs_state.state)->enable_vte) {
         OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control);
     } else {
         OUT_CS_REG(R300_VAP_VTE_CNTL, 0);
@@ -1100,11 +1107,6 @@ validate:
         r300->dirty_state &= ~R300_NEW_FRAMEBUFFERS;
     }
 
-    if (r300->dirty_state & R300_NEW_RASTERIZER) {
-        r300_emit_rs_state(r300, r300->rs_state);
-        r300->dirty_state &= ~R300_NEW_RASTERIZER;
-    }
-
     if (r300->dirty_state & R300_NEW_RS_BLOCK) {
         r300_emit_rs_block_state(r300, r300->rs_block);
         r300->dirty_state &= ~R300_NEW_RS_BLOCK;
index 0ccae0031bd5eb98a709024b991fd3e3568e1bd7..a6539b218b478904eb9fec2d5b62336f34dbfd53 100644 (file)
@@ -59,7 +59,7 @@ void r300_emit_query_begin(struct r300_context* r300,
 
 void r300_emit_query_end(struct r300_context* r300);
 
-void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs);
+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);
index a4ac9ad9a7bc74860ba02674c1eab7569ae396ad..7098f66f0c33f3deaad19f2973feaacb323d5937 100644 (file)
@@ -71,14 +71,15 @@ uint32_t r300_translate_primitive(unsigned prim)
 
 static boolean r300_nothing_to_draw(struct r300_context *r300)
 {
-    return r300->rs_state->rs.scissor &&
+    return ((struct r300_rs_state*)r300->rs_state.state)->rs.scissor &&
            r300->scissor_state->scissor.empty_area;
 }
 
 static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300,
                                             unsigned mode)
 {
-    uint32_t color_control = r300->rs_state->color_control;
+    struct r300_rs_state* rs = (struct r300_rs_state*)r300->rs_state.state;
+    uint32_t color_control = rs->color_control;
 
     /* By default (see r300_state.c:r300_create_rs_state) color_control is
      * initialized to provoking the first vertex.
@@ -98,7 +99,7 @@ static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300,
      * ~ C.
      */
 
-    if (r300->rs_state->rs.flatshade_first) {
+    if (rs->rs.flatshade_first) {
         switch (mode) {
             case PIPE_PRIM_TRIANGLE_FAN:
                 color_control |= R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_SECOND;
index 288b2149b50a0a214fe54cdb29c7647263d52029..8740a082b98f27ae0e8b6041d3dd7ed55441e7ea 100644 (file)
@@ -519,7 +519,8 @@ static void
                           r300_screen(r300->context.screen)->caps->is_r500);
 
     /* Don't rely on the order of states being set for the first time. */
-    if (!r300->rs_state || !r300->rs_state->rs.scissor) {
+    /* XXX ( >&) */
+    if (!r300->rs_state.state) {
         r300->dirty_state |= R300_NEW_SCISSOR;
     }
     r300->dirty_state |= R300_NEW_FRAMEBUFFERS;
@@ -721,9 +722,10 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
         draw_set_rasterizer_state(r300->draw, &rs->rs);
     }
 
-    r300->rs_state = rs;
+    r300->rs_state.state = rs;
+    r300->rs_state.dirty = TRUE;
+
     /* XXX Clean these up when we move to atom emits */
-    r300->dirty_state |= R300_NEW_RASTERIZER;
     r300->dirty_state |= R300_NEW_RS_BLOCK;
     r300->dirty_state |= R300_NEW_SCISSOR;
     r300->dirty_state |= R300_NEW_VIEWPORT;
@@ -868,10 +870,7 @@ static void r300_set_scissor_state(struct pipe_context* pipe,
     r300_set_scissor_regs(state, &r300->scissor_state->scissor,
                           r300_screen(r300->context.screen)->caps->is_r500);
 
-    /* Don't rely on the order of states being set for the first time. */
-    if (!r300->rs_state || r300->rs_state->rs.scissor) {
-        r300->dirty_state |= R300_NEW_SCISSOR;
-    }
+    r300->dirty_state |= R300_NEW_SCISSOR;
 }
 
 static void r300_set_viewport_state(struct pipe_context* pipe,
index a4029fca49f08c4f16a8044b697297f1ad0daa8d..e82aa07a6258c0b5fa10c6b888af912775461ff3 100644 (file)
@@ -139,7 +139,7 @@ static void r300_vertex_psc(struct r300_context* r300)
 
     /* If TCL is bypassed, map vertex streams to equivalent VS output
      * locations. */
-    if (r300->rs_state->enable_vte) {
+    if (((struct r300_rs_state*)r300->rs_state.state)->enable_vte) {
         stream_tab = identity;
     } else {
         stream_tab = r300->vs->stream_loc_notcl;