r300g: use the atom size directly during emission
authorMarek Olšák <maraeo@gmail.com>
Sat, 27 Feb 2010 22:12:46 +0000 (23:12 +0100)
committerMarek Olšák <maraeo@gmail.com>
Sat, 27 Feb 2010 23:46:35 +0000 (00:46 +0100)
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_derived.c

index 5f50b60eab7ff0a772c7ae4cf3965f90449e504c..3a84fc564d96d4f4c17be99e936eced178797758 100644 (file)
@@ -105,29 +105,31 @@ static void r300_flush_cb(void *data)
 
 static void r300_setup_atoms(struct r300_context* r300)
 {
+    boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500;
+    boolean has_tcl = r300_screen(r300->context.screen)->caps->has_tcl;
+
     /* Create the actual atom list.
      *
      * Each atom is examined and emitted in the order it appears here, which
      * can affect performance and conformance if not handled with care.
      *
-     * Some atoms never change size, others change every emit. This is just
-     * an upper bound on each atom, to keep the emission machinery from
-     * underallocating space. */
+     * Some atoms never change size, others change every emit - those have
+     * the size of 0 here. */
     make_empty_list(&r300->atom_list);
     R300_INIT_ATOM(invariant_state, 71);
     R300_INIT_ATOM(ztop_state, 2);
     R300_INIT_ATOM(blend_state, 8);
-    R300_INIT_ATOM(blend_color_state, 3);
-    R300_INIT_ATOM(clip_state, 29);
-    R300_INIT_ATOM(dsa_state, 8);
-    R300_INIT_ATOM(fb_state, 56);
-    R300_INIT_ATOM(rs_state, 25);
+    R300_INIT_ATOM(blend_color_state, is_r500 ? 3 : 2);
+    R300_INIT_ATOM(clip_state, has_tcl ? 5 + (6 * 4) : 2);
+    R300_INIT_ATOM(dsa_state, is_r500 ? 8 : 6);
+    R300_INIT_ATOM(fb_state, 0);
+    R300_INIT_ATOM(rs_state, 0);
     R300_INIT_ATOM(scissor_state, 3);
     R300_INIT_ATOM(viewport_state, 9);
-    R300_INIT_ATOM(rs_block_state, 21);
+    R300_INIT_ATOM(rs_block_state, 0);
     R300_INIT_ATOM(vertex_format_state, 26);
     R300_INIT_ATOM(pvs_flush, 2);
-    R300_INIT_ATOM(vs_state, 1031);
+    R300_INIT_ATOM(vs_state, 0);
     R300_INIT_ATOM(texture_cache_inval, 2);
 
     /* Some non-CSO atoms need explicit space to store the state locally. */
index ad19725e60bcd7d79de00a3e2d5eca4104bf4554..013611018b0d453589913420f81c53fb7cc206f9 100644 (file)
@@ -42,7 +42,7 @@ void r300_emit_blend_state(struct r300_context* r300,
         (struct pipe_framebuffer_state*)r300->fb_state.state;
     CS_LOCALS(r300);
 
-    BEGIN_CS(8);
+    BEGIN_CS(size);
     OUT_CS_REG(R300_RB3D_ROPCNTL, blend->rop);
     OUT_CS_REG_SEQ(R300_RB3D_CBLEND, 3);
     if (fb->nr_cbufs) {
@@ -67,13 +67,13 @@ void r300_emit_blend_color_state(struct r300_context* r300,
     CS_LOCALS(r300);
 
     if (r300screen->caps->is_r500) {
-        BEGIN_CS(3);
+        BEGIN_CS(size);
         OUT_CS_REG_SEQ(R500_RB3D_CONSTANT_COLOR_AR, 2);
         OUT_CS(bc->blend_color_red_alpha);
         OUT_CS(bc->blend_color_green_blue);
         END_CS;
     } else {
-        BEGIN_CS(2);
+        BEGIN_CS(size);
         OUT_CS_REG(R300_RB3D_BLEND_COLOR, bc->blend_color);
         END_CS;
     }
@@ -88,7 +88,7 @@ void r300_emit_clip_state(struct r300_context* r300,
     CS_LOCALS(r300);
 
     if (r300screen->caps->has_tcl) {
-        BEGIN_CS(5 + (6 * 4));
+        BEGIN_CS(size);
         OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG,
                 (r300screen->caps->is_r500 ?
                  R500_PVS_UCP_START : R300_PVS_UCP_START));
@@ -103,7 +103,7 @@ void r300_emit_clip_state(struct r300_context* r300,
                 R300_PS_UCP_MODE_CLIP_AS_TRIFAN);
         END_CS;
     } else {
-        BEGIN_CS(2);
+        BEGIN_CS(size);
         OUT_CS_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE);
         END_CS;
     }
@@ -119,7 +119,7 @@ void r300_emit_dsa_state(struct r300_context* r300, unsigned size, void* state)
     struct pipe_stencil_ref stencil_ref = r300->stencil_ref;
     CS_LOCALS(r300);
 
-    BEGIN_CS(r300screen->caps->is_r500 ? 8 : 6);
+    BEGIN_CS(size);
     OUT_CS_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function);
     OUT_CS_REG_SEQ(R300_ZB_CNTL, 3);
 
@@ -390,8 +390,7 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
     int i;
     CS_LOCALS(r300);
 
-    BEGIN_CS((10 * fb->nr_cbufs) + (2 * (4 - fb->nr_cbufs)) +
-             (fb->zsbuf ? 10 : 0) + 8);
+    BEGIN_CS(size);
 
     /* Flush and free renderbuffer caches. */
     OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT,
@@ -587,7 +586,7 @@ void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state)
     float scale, offset;
     CS_LOCALS(r300);
 
-    BEGIN_CS(17 + (rs->polygon_offset_enable ? 5 : 0));
+    BEGIN_CS(size);
     OUT_CS_REG(R300_VAP_CNTL_STATUS, rs->vap_control_status);
 
     OUT_CS_REG(R300_GB_AA_CONFIG, rs->antialiasing_config);
@@ -636,7 +635,7 @@ void r300_emit_rs_block_state(struct r300_context* r300,
 
     DBG(r300, DBG_DRAW, "r300: RS emit:\n");
 
-    BEGIN_CS(5 + count*2);
+    BEGIN_CS(size);
     if (r300screen->caps->is_r500) {
         OUT_CS_REG_SEQ(R500_RS_IP_0, count);
     } else {
@@ -722,7 +721,7 @@ void r300_emit_scissor_state(struct r300_context* r300,
             (((maxy - 1) + 1440) << R300_SCISSORS_Y_SHIFT);
     }
 
-    BEGIN_CS(3);
+    BEGIN_CS(size);
     OUT_CS_REG_SEQ(R300_SC_SCISSORS_TL, 2);
     OUT_CS(top_left);
     OUT_CS(bottom_right);
@@ -824,7 +823,7 @@ void r300_emit_vertex_format_state(struct r300_context* r300,
 
     DBG(r300, DBG_DRAW, "r300: VAP/PSC emit:\n");
 
-    BEGIN_CS(26);
+    BEGIN_CS(size);
     OUT_CS_REG(R300_VAP_VTX_SIZE, vertex_info->vinfo.size);
 
     OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL, 2);
@@ -857,7 +856,7 @@ void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state)
 {
     CS_LOCALS(r300);
 
-    BEGIN_CS(2);
+    BEGIN_CS(size);
     OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0);
     END_CS;
 }
@@ -887,7 +886,7 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state)
         return;
     }
 
-    BEGIN_CS(9 + code->length);
+    BEGIN_CS(size);
     /* R300_VAP_PVS_CODE_CNTL_0
      * R300_VAP_PVS_CONST_CNTL
      * R300_VAP_PVS_CODE_CNTL_1
@@ -953,11 +952,11 @@ void r300_emit_viewport_state(struct r300_context* r300,
     CS_LOCALS(r300);
 
     if (r300->tcl_bypass) {
-        BEGIN_CS(2);
+        BEGIN_CS(2); /* XXX tcl_bypass will be removed in gallium anyway */
         OUT_CS_REG(R300_VAP_VTE_CNTL, 0);
         END_CS;
     } else {
-        BEGIN_CS(9);
+        BEGIN_CS(size);
         OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6);
         OUT_CS_32F(viewport->xscale);
         OUT_CS_32F(viewport->xoffset);
@@ -997,7 +996,7 @@ void r300_emit_ztop_state(struct r300_context* r300,
     struct r300_ztop_state* ztop = (struct r300_ztop_state*)state;
     CS_LOCALS(r300);
 
-    BEGIN_CS(2);
+    BEGIN_CS(size);
     OUT_CS_REG(R300_ZB_ZTOP, ztop->z_buffer_top);
     END_CS;
 }
@@ -1006,7 +1005,7 @@ void r300_emit_texture_cache_inval(struct r300_context* r300, unsigned size, voi
 {
     CS_LOCALS(r300);
 
-    BEGIN_CS(2);
+    BEGIN_CS(size);
     OUT_CS_REG(R300_TX_INVALTAGS, 0);
     END_CS;
 }
index 15e0a0ad358b86e3f90d2a0e7b73fbe939415c9e..97a0897a5e240d47f18d8286c6740fb7a2bbbc00 100644 (file)
@@ -1111,7 +1111,7 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader)
         }
 
         r300->vs_state.state = vs;
-        r300->vs_state.size = vs->code.length + 11;
+        r300->vs_state.size = vs->code.length + 9;
         r300->vs_state.dirty = TRUE;
 
         r300->vertex_format_state.dirty = TRUE;
index b33d44990a94008f0f5aa78e7cd135757de74ae5..86301e23d7eacef32a7c657aea50bab4f1756b54 100644 (file)
@@ -420,7 +420,7 @@ static void r300_update_rs_block(struct r300_context* r300,
     /* Now, after all that, see if we actually need to update the state. */
     if (memcmp(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block))) {
         memcpy(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block));
-        r300->rs_block_state.size = 5 + count;
+        r300->rs_block_state.size = 5 + count*2;
         r300->rs_block_state.dirty = TRUE;
     }
 }