r300g: turn clip state into a CB
authorMarek Olšák <maraeo@gmail.com>
Sun, 13 Jun 2010 02:37:45 +0000 (04:37 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sun, 13 Jun 2010 15:43:39 +0000 (17:43 +0200)
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_state.c

index cc64fc3d7a7721bb6e03d0a48580ce62bb227e3a..3bb1caef4087ae13bccc5ee0eef034994ff1cced 100644 (file)
@@ -34,7 +34,7 @@ static void r300_blitter_save_states(struct r300_context* r300)
     util_blitter_save_fragment_shader(r300->blitter, r300->fs.state);
     util_blitter_save_vertex_shader(r300->blitter, r300->vs_state.state);
     util_blitter_save_viewport(r300->blitter, &r300->viewport);
-    util_blitter_save_clip(r300->blitter, &r300->clip);
+    util_blitter_save_clip(r300->blitter, (struct pipe_clip_state*)r300->clip_state.state);
     util_blitter_save_vertex_elements(r300->blitter, r300->velems);
     util_blitter_save_vertex_buffers(r300->blitter, r300->vertex_buffer_count,
                                      r300->vertex_buffer);
index aac3660207f9873170f3dddc73573efaca1b9f9c..57cf68f0132ccd055d755cd40fc67bfa469b7c26 100644 (file)
@@ -26,6 +26,7 @@
 #include "util/u_simple_list.h"
 #include "util/u_upload_mgr.h"
 
+#include "r300_cb.h"
 #include "r300_context.h"
 #include "r300_emit.h"
 #include "r300_screen.h"
@@ -143,7 +144,7 @@ static void r300_setup_atoms(struct r300_context* r300)
 
     /* Some non-CSO atoms need explicit space to store the state locally. */
     r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state);
-    r300->clip_state.state = CALLOC_STRUCT(pipe_clip_state);
+    r300->clip_state.state = CALLOC_STRUCT(r300_clip_state);
     r300->fb_state.state = CALLOC_STRUCT(pipe_framebuffer_state);
     r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block);
     r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state);
@@ -171,10 +172,20 @@ static void r300_init_states(struct pipe_context *pipe)
     struct pipe_blend_color bc = {{0}};
     struct pipe_clip_state cs = {{{0}}};
     struct pipe_scissor_state ss = {0};
+    struct r300_clip_state *clip =
+            (struct r300_clip_state*)r300_context(pipe)->clip_state.state;
+    CB_LOCALS;
 
     pipe->set_blend_color(pipe, &bc);
-    pipe->set_clip_state(pipe, &cs);
     pipe->set_scissor_state(pipe, &ss);
+
+    if (r300_context(pipe)->screen->caps.has_tcl) {
+        pipe->set_clip_state(pipe, &cs);
+    } else {
+        BEGIN_CB(clip->cb, 2);
+        OUT_CB_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE);
+        END_CB;
+    }
 }
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
index 6d6185cf1f5ff12dfa1bca248c4fa908c29763f5..a8e813008f11cd80ce20e0e76e4721da766c1f64 100644 (file)
@@ -70,6 +70,12 @@ struct r300_blend_color_state {
     uint32_t cb[3];
 };
 
+struct r300_clip_state {
+    struct pipe_clip_state clip;
+
+    uint32_t cb[29];
+};
+
 struct r300_dsa_state {
     uint32_t alpha_function;    /* R300_FG_ALPHA_FUNC: 0x4bd4 */
     uint32_t alpha_reference;   /* R500_FG_ALPHA_VALUE: 0x4be0 */
@@ -433,9 +439,6 @@ struct r300_context {
     struct vertex_info vertex_info;
 
     struct pipe_stencil_ref stencil_ref;
-
-    struct pipe_clip_state clip;
-
     struct pipe_viewport_state viewport;
 
     /* Stream locations for SWTCL. */
index 04a3ab5fb3712a6353b0ba097fb2cd136b3d0402..e2e1074b3235c425ae43965ac1081d203d218be8 100644 (file)
@@ -62,24 +62,10 @@ void r300_emit_blend_color_state(struct r300_context* r300,
 void r300_emit_clip_state(struct r300_context* r300,
                           unsigned size, void* state)
 {
-    struct pipe_clip_state* clip = (struct pipe_clip_state*)state;
+    struct r300_clip_state* clip = (struct r300_clip_state*)state;
     CS_LOCALS(r300);
 
-    if (r300->screen->caps.has_tcl) {
-        BEGIN_CS(size);
-        OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG,
-                (r300->screen->caps.is_r500 ?
-                 R500_PVS_UCP_START : R300_PVS_UCP_START));
-        OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 6 * 4);
-        OUT_CS_TABLE(clip->ucp, 6 * 4);
-        OUT_CS_REG(R300_VAP_CLIP_CNTL, ((1 << clip->nr) - 1) |
-                R300_PS_UCP_MODE_CLIP_AS_TRIFAN);
-        END_CS;
-    } else {
-        BEGIN_CS(size);
-        OUT_CS_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE);
-        END_CS;
-    }
+    WRITE_CS_TABLE(clip->cb, size);
 }
 
 void r300_emit_dsa_state(struct r300_context* r300, unsigned size, void* state)
index d5ed119527f5bbab0dbd97dbfa600f85dc35dfa4..c4b7d734c2c8d2c92cd02263fe8cd5dc4ad74017 100644 (file)
@@ -421,18 +421,27 @@ static void r300_set_clip_state(struct pipe_context* pipe,
                                 const struct pipe_clip_state* state)
 {
     struct r300_context* r300 = r300_context(pipe);
+    struct r300_clip_state *clip =
+            (struct r300_clip_state*)r300->clip_state.state;
+    CB_LOCALS;
 
-    r300->clip = *state;
+    clip->clip = *state;
 
     if (r300->screen->caps.has_tcl) {
-        memcpy(r300->clip_state.state, state, sizeof(struct pipe_clip_state));
-        r300->clip_state.size = 29;
+        BEGIN_CB(clip->cb, 29);
+        OUT_CB_REG(R300_VAP_PVS_VECTOR_INDX_REG,
+                (r300->screen->caps.is_r500 ?
+                 R500_PVS_UCP_START : R300_PVS_UCP_START));
+        OUT_CB_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 6 * 4);
+        OUT_CB_TABLE(state->ucp, 6 * 4);
+        OUT_CB_REG(R300_VAP_CLIP_CNTL, ((1 << state->nr) - 1) |
+                R300_PS_UCP_MODE_CLIP_AS_TRIFAN);
+        END_CB;
 
         r300->clip_state.dirty = TRUE;
     } else {
         draw_flush(r300->draw);
         draw_set_clip_state(r300->draw, state);
-        r300->clip_state.size = 2;
     }
 }