Mesa (master): r300g: introduce VAP invariant state

Marek Olšák mareko at kemper.freedesktop.org
Sun Jun 27 13:17:52 UTC 2010


Module: Mesa
Branch: master
Commit: fcacc6a076ee5bc894eb7f5a7943715ff1ddf9ee
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fcacc6a076ee5bc894eb7f5a7943715ff1ddf9ee

Author: Marek Olšák <maraeo at gmail.com>
Date:   Fri Jun 25 02:16:43 2010 +0200

r300g: introduce VAP invariant state

Unlike other invariant states, this one must be emitted after VAP flush.

---

 src/gallium/drivers/r300/r300_cb.h      |    2 +-
 src/gallium/drivers/r300/r300_context.c |   25 +++++++++++++++++++++++--
 src/gallium/drivers/r300/r300_context.h |    6 ++++++
 src/gallium/drivers/r300/r300_emit.c    |   17 +++++++----------
 src/gallium/drivers/r300/r300_emit.h    |    3 +++
 src/gallium/drivers/r300/r300_state.c   |    3 +--
 6 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_cb.h b/src/gallium/drivers/r300/r300_cb.h
index 6987471..61b2833 100644
--- a/src/gallium/drivers/r300/r300_cb.h
+++ b/src/gallium/drivers/r300/r300_cb.h
@@ -90,7 +90,7 @@
 } while (0)
 
 #define BEGIN_CS_AS_CB(r300, size) \
-    BEGIN_CB(r300->rws->get_cs_pointer(r300->rws, dwords), dwords)
+    BEGIN_CB(r300->rws->get_cs_pointer(r300->rws, size), size)
 
 #define END_CB do { \
     CB_DEBUG(if (cs_count != 0) \
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 4e3be07..dcd2402 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -81,6 +81,7 @@ static void r300_destroy_context(struct pipe_context* context)
     FREE(r300->rs_block_state.state);
     FREE(r300->scissor_state.state);
     FREE(r300->textures_state.state);
+    FREE(r300->vap_invariant_state.state);
     FREE(r300->viewport_state.state);
     FREE(r300->ztop_state.state);
     FREE(r300->fs_constants.state);
@@ -119,20 +120,24 @@ static void r300_setup_atoms(struct r300_context* r300)
      * Some atoms never change size, others change every emit - those have
      * the size of 0 here. */
     make_empty_list(&r300->atom_list);
-    /* RB3D (unpipelined), ZB (unpipelined), US, SC. */
+    /* GB (unpipelined), RB3D (unpipelined), ZB (unpipelined), US, SC. */
     R300_INIT_ATOM(gpu_flush, 9);
     R300_INIT_ATOM(aa_state, 4);
     R300_INIT_ATOM(fb_state, 0);
     R300_INIT_ATOM(ztop_state, 2);
+    /* ZB, FG. */
     R300_INIT_ATOM(dsa_state, is_r500 ? 8 : 6);
+    /* RB3D. */
     R300_INIT_ATOM(blend_state, 8);
     R300_INIT_ATOM(blend_color_state, is_r500 ? 3 : 2);
+    /* SC. */
     R300_INIT_ATOM(scissor_state, 3);
-    /* All sorts of things. */
+    /* GB, FG, GA, SU, SC, RB3D. */
     R300_INIT_ATOM(invariant_state, 22);
     /* VAP. */
     R300_INIT_ATOM(viewport_state, 9);
     R300_INIT_ATOM(pvs_flush, 2);
+    R300_INIT_ATOM(vap_invariant_state, 9);
     R300_INIT_ATOM(vertex_stream_state, 0);
     R300_INIT_ATOM(vs_state, 0);
     R300_INIT_ATOM(vs_constants, 0);
@@ -166,6 +171,7 @@ static void r300_setup_atoms(struct r300_context* r300)
     r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block);
     r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state);
     r300->textures_state.state = CALLOC_STRUCT(r300_textures_state);
+    r300->vap_invariant_state.state = CALLOC_STRUCT(r300_vap_invariant_state);
     r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state);
     r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state);
     r300->fs_constants.state = CALLOC_STRUCT(r300_constant_buffer);
@@ -194,6 +200,8 @@ static void r300_init_states(struct pipe_context *pipe)
             (struct r300_clip_state*)r300->clip_state.state;
     struct r300_gpu_flush *gpuflush =
             (struct r300_gpu_flush*)r300->gpu_flush.state;
+    struct r300_vap_invariant_state *vap_invariant =
+            (struct r300_vap_invariant_state*)r300->vap_invariant_state.state;
     CB_LOCALS;
 
     pipe->set_blend_color(pipe, &bc);
@@ -226,6 +234,19 @@ static void r300_init_states(struct pipe_context *pipe)
         OUT_CB_REG(RADEON_WAIT_UNTIL, RADEON_WAIT_3D_IDLECLEAN);
         END_CB;
     }
+
+    /* Initialize the VAP invariant state. */
+    {
+        BEGIN_CB(vap_invariant->cb, 9);
+        OUT_CB_REG(VAP_PVS_VTX_TIMEOUT_REG, 0xffff);
+        OUT_CB_REG_SEQ(R300_VAP_GB_VERT_CLIP_ADJ, 4);
+        OUT_CB_32F(1.0);
+        OUT_CB_32F(1.0);
+        OUT_CB_32F(1.0);
+        OUT_CB_32F(1.0);
+        OUT_CB_REG(R300_VAP_PSC_SGN_NORM_CNTL, R300_SGN_NORM_NO_ZERO);
+        END_CB;
+    }
 }
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 976ef20..dc96d21 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -224,6 +224,10 @@ struct r300_vertex_stream_state {
     unsigned count;
 };
 
+struct r300_vap_invariant_state {
+    uint32_t cb[9];
+};
+
 struct r300_viewport_state {
     float xscale;         /* R300_VAP_VPORT_XSCALE:  0x2098 */
     float xoffset;        /* R300_VAP_VPORT_XOFFSET: 0x209c */
@@ -471,6 +475,8 @@ struct r300_context {
     struct r300_atom ztop_state;
     /* PVS flush. */
     struct r300_atom pvs_flush;
+    /* VAP invariant state. */
+    struct r300_atom vap_invariant_state;
     /* Texture cache invalidate. */
     struct r300_atom texture_cache_inval;
     /* GPU flush. */
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 16cb168..413e2f6 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -819,6 +819,13 @@ void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state)
     END_CS;
 }
 
+void r300_emit_vap_invariant_state(struct r300_context *r300,
+                                   unsigned size, void *state)
+{
+    CS_LOCALS(r300);
+    WRITE_CS_TABLE(state, size);
+}
+
 void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state)
 {
     struct r300_vertex_shader* vs = (struct r300_vertex_shader*)state;
@@ -843,16 +850,6 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state)
     CS_LOCALS(r300);
 
     BEGIN_CS(size);
-    /* Amount of time to wait for vertex fetches in PVS */
-    OUT_CS_REG(VAP_PVS_VTX_TIMEOUT_REG, 0xffff);
-
-    OUT_CS_REG_SEQ(R300_VAP_GB_VERT_CLIP_ADJ, 4);
-    OUT_CS_32F(1.0);
-    OUT_CS_32F(1.0);
-    OUT_CS_32F(1.0);
-    OUT_CS_32F(1.0);
-
-    OUT_CS_REG(R300_VAP_PSC_SGN_NORM_CNTL, R300_SGN_NORM_NO_ZERO);
 
     /* R300_VAP_PVS_CODE_CNTL_0
      * R300_VAP_PVS_CONST_CNTL
diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h
index 0d4e1f7..a183312 100644
--- a/src/gallium/drivers/r300/r300_emit.h
+++ b/src/gallium/drivers/r300/r300_emit.h
@@ -80,6 +80,9 @@ void r300_emit_textures_state(struct r300_context *r300,
 
 void r300_emit_aos_swtcl(struct r300_context *r300, boolean indexed);
 
+void r300_emit_vap_invariant_state(struct r300_context *r300,
+                                   unsigned size, void *state);
+
 void r300_emit_vertex_stream_state(struct r300_context* r300,
                                    unsigned size, void* state);
 
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 9c0f877..27ec5bc 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -1567,7 +1567,6 @@ static void* r300_create_vs_state(struct pipe_context* pipe,
                                   const struct pipe_shader_state* shader)
 {
     struct r300_context* r300 = r300_context(pipe);
-
     struct r300_vertex_shader* vs = CALLOC_STRUCT(r300_vertex_shader);
 
     /* Copy state directly into shader. */
@@ -1604,7 +1603,7 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader)
     if (r300->screen->caps.has_tcl) {
         r300->vs_state.dirty = TRUE;
         r300->vs_state.size =
-                vs->code.length + 18 +
+                vs->code.length + 9 +
                 (vs->immediates_count ? vs->immediates_count * 4 + 3 : 0);
 
         if (vs->externals_count) {




More information about the mesa-commit mailing list