r300g: introduce VAP invariant state
authorMarek Olšák <maraeo@gmail.com>
Fri, 25 Jun 2010 00:16:43 +0000 (02:16 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sat, 26 Jun 2010 15:57:20 +0000 (17:57 +0200)
Unlike other invariant states, this one must be emitted after VAP flush.

src/gallium/drivers/r300/r300_cb.h
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 69874712442401f5ff914369b00da7c979c8c6b7..61b28330b0bfe5621e7cc4b6337c0007efd50f23 100644 (file)
@@ -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) \
index 4e3be077d78d01d0206fc775ccfe38a4169312ec..dcd24021bc61998d1a98fe9465ba99c6611a2b46 100644 (file)
@@ -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,
index 976ef20510cd999b3f1b5e4381ba3ce1ce13c738..dc96d21f3189cf78eedab5b3b86658b43b70f6c0 100644 (file)
@@ -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. */
index 16cb16895ec25da5b09c1cba51f403e6ba14127b..413e2f62a79070a81576bec882f23b037d526a70 100644 (file)
@@ -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
index 0d4e1f7a23bdbd1e1673c76d2544bb2c2d1909d5..a18331222f3c5865732fe974df22b4964c9b6dda 100644 (file)
@@ -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);
 
index 9c0f877e8149375944f57e6681d7c57c78e4cbc2..27ec5bc2b3e004f08f20cc00425f9e55f6b1d574 100644 (file)
@@ -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) {