r300-gallium: Emit UCP.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Fri, 5 Jun 2009 18:21:09 +0000 (11:21 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Fri, 5 Jun 2009 18:21:09 +0000 (11:21 -0700)
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 a9dd041e083a6c02397637d49aaeb24cfced8b8c..27bc7fd1a930d80e0f1e0435896c68f845d0877c 100644 (file)
@@ -117,23 +117,24 @@ struct r300_viewport_state {
     uint32_t vte_control; /* R300_VAP_VTE_CNTL:      0x20b0 */
 };
 
-#define R300_NEW_BLEND           0x0000001
-#define R300_NEW_BLEND_COLOR     0x0000002
-#define R300_NEW_CONSTANTS       0x0000004
-#define R300_NEW_DSA             0x0000008
-#define R300_NEW_FRAMEBUFFERS    0x0000010
-#define R300_NEW_FRAGMENT_SHADER 0x0000020
-#define R300_NEW_RASTERIZER      0x0000040
-#define R300_NEW_RS_BLOCK        0x0000080
-#define R300_NEW_SAMPLER         0x0000100
-#define R300_ANY_NEW_SAMPLERS    0x000ff00
-#define R300_NEW_SCISSOR         0x0010000
-#define R300_NEW_TEXTURE         0x0020000
-#define R300_ANY_NEW_TEXTURES    0x1fe0000
-#define R300_NEW_VERTEX_FORMAT   0x2000000
-#define R300_NEW_VERTEX_SHADER   0x4000000
-#define R300_NEW_VIEWPORT        0x8000000
-#define R300_NEW_KITCHEN_SINK    0xfffffff
+#define R300_NEW_BLEND           0x00000001
+#define R300_NEW_BLEND_COLOR     0x00000002
+#define R300_NEW_CLIP            0x00000004
+#define R300_NEW_CONSTANTS       0x00000008
+#define R300_NEW_DSA             0x00000010
+#define R300_NEW_FRAMEBUFFERS    0x00000020
+#define R300_NEW_FRAGMENT_SHADER 0x00000040
+#define R300_NEW_RASTERIZER      0x00000080
+#define R300_NEW_RS_BLOCK        0x00000100
+#define R300_NEW_SAMPLER         0x00000200
+#define R300_ANY_NEW_SAMPLERS    0x0001fe00
+#define R300_NEW_SCISSOR         0x00020000
+#define R300_NEW_TEXTURE         0x00040000
+#define R300_ANY_NEW_TEXTURES    0x03fc0000
+#define R300_NEW_VERTEX_FORMAT   0x04000000
+#define R300_NEW_VERTEX_SHADER   0x08000000
+#define R300_NEW_VIEWPORT        0x10000000
+#define R300_NEW_KITCHEN_SINK    0x1fffffff
 
 /* The next several objects are not pure Radeon state; they inherit from
  * various Gallium classes. */
@@ -292,6 +293,8 @@ struct r300_context {
     struct r300_blend_state* blend_state;
     /* Blend color state. */
     struct r300_blend_color_state* blend_color_state;
+    /* User clip planes. */
+    struct pipe_clip_state clip_state;
     /* Shader constants. */
     struct r300_constant_buffer shader_constants[PIPE_SHADER_TYPES];
     /* Depth, stencil, and alpha state. */
index 4a70f3afdea263479948174b436fa0dbc053947d..4c7370eee719e15369a8a091877ccabfad06d098 100644 (file)
@@ -56,6 +56,27 @@ void r300_emit_blend_color_state(struct r300_context* r300,
     }
 }
 
+void r300_emit_clip_state(struct r300_context* r300,
+                          struct pipe_clip_state* clip)
+{
+    int i;
+    struct r300_screen* r300screen = r300_screen(r300->context.screen);
+    CS_LOCALS(r300);
+
+    BEGIN_CS(3 + (6 * 4));
+    OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG,
+            (r300screen->caps->is_r500 ?
+             R500_PVS_UCP_START : R300_PVS_UCP_START));
+    OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 6 * 4);
+    for (i = 0; i < 6; i++) {
+        OUT_CS_32F(clip->ucp[i][0]);
+        OUT_CS_32F(clip->ucp[i][1]);
+        OUT_CS_32F(clip->ucp[i][2]);
+        OUT_CS_32F(clip->ucp[i][3]);
+    }
+    END_CS;
+}
+
 void r300_emit_dsa_state(struct r300_context* r300,
                            struct r300_dsa_state* dsa)
 {
@@ -527,6 +548,11 @@ validate:
         r300->dirty_state &= ~R300_NEW_BLEND_COLOR;
     }
 
+    if (r300->dirty_state & R300_NEW_CLIP) {
+        r300_emit_clip_state(r300, &r300->clip_state);
+        r300->dirty_state &= ~R300_NEW_CLIP;
+    }
+
     if (r300->dirty_state & R300_NEW_DSA) {
         r300_emit_dsa_state(r300, r300->dsa_state);
         r300->dirty_state &= ~R300_NEW_DSA;
index 36e14f69f78cdfa7fef4bc3732097a8f843e6fe8..946f625bd89df5da5ce011f7eb31e1788fdd56e9 100644 (file)
@@ -36,6 +36,9 @@ void r300_emit_blend_state(struct r300_context* r300,
 void r300_emit_blend_color_state(struct r300_context* r300,
                                  struct r300_blend_color_state* bc);
 
+void r300_emit_clip_state(struct r300_context* r300,
+                          struct pipe_clip_state* clip);
+
 void r300_emit_dsa_state(struct r300_context* r300,
                          struct r300_dsa_state* dsa);
 
index 0461ffd681afdd0e9d5d5dba4ab8c9658db293a9..29e721984f81178ae468c3a837969c787889f21a 100644 (file)
@@ -119,9 +119,10 @@ static void r300_set_clip_state(struct pipe_context* pipe,
                                 const struct pipe_clip_state* state)
 {
     struct r300_context* r300 = r300_context(pipe);
-    /* XXX add HW TCL clipping setup */
-    draw_flush(r300->draw);
-    draw_set_clip_state(r300->draw, state);
+
+    r300->clip_state = *state;
+
+    r300->dirty_state |= R300_NEW_CLIP;
 }
 
 static void