r300: Hook up state functions.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 14 Jan 2009 13:00:22 +0000 (05:00 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 2 Feb 2009 07:30:23 +0000 (23:30 -0800)
Haha, should not have attempted the scissors.

src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_state.c

index b9a9c2e21c2f696a14df3cfb235b03c88f322d7c..67cc1e45867800e9f898d9ac710a9baf17e4d781 100644 (file)
@@ -54,5 +54,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
 
     r300_init_surface_functions(r300);
 
+    r300_init_state_functions(r300);
+
     return &r300->context;
 }
index 81c559cedfe8b53dfa74db1699e9dae7f880c091..40c310abca2c3b88aaccc21175ed6bb6a58ce6c3 100644 (file)
@@ -44,11 +44,6 @@ struct r300_dsa_state {
     uint32_t stencil_ref_bf;    /* R300_ZB_STENCILREFMASK_BF: 0x4fd4 */
 };
 
-struct r300_scissor_state {
-    uint32_t scissor_top_left;     /* R300_SC_SCISSORS_TL: 0x43e0 */
-    uint32_t scissor_bottom_right; /* R300_SC_SCISSORS_BR: 0x43e4 */
-};
-
 #define R300_NEW_BLEND    0x1
 #define R300_NEW_DSA      0x2
 #define R300_NEW_SCISSOR  0x4
@@ -68,7 +63,7 @@ struct r300_context {
     /* Depth, stencil, and alpha state. */
     struct r300_dsa_state* dsa_state;
     /* Scissor state. */
-    struct r300_scissor_state* scissor_state;
+    struct pipe_scissor_state* scissor_state;
 
     /* Bitmask of dirty state objects. */
     uint32_t dirty_state;
@@ -80,6 +75,7 @@ static struct r300_context* r300_context(struct pipe_context* context) {
 }
 
 /* Context initialization. */
+void r300_init_state_functions(struct r300_context* r300);
 void r300_init_surface_functions(struct r300_context* r300);
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
index 0f0660c4030151ed9354bc366c614c7b652ae0cd..122e06c6e6a205c82d4b7eab1dcc782a245b7d86 100644 (file)
@@ -92,7 +92,7 @@ static uint32_t translate_blend_factor(int blend_fact) {
  *
  * This encompasses alpha blending, logic/raster ops, and blend dithering. */
 static void* r300_create_blend_state(struct pipe_context* pipe,
-                                     struct pipe_blend_state* state)
+                                     const struct pipe_blend_state* state)
 {
     struct r300_blend_state* blend = CALLOC_STRUCT(r300_blend_state);
 
@@ -310,48 +310,17 @@ static void r300_delete_dsa_state(struct pipe_context* pipe,
     FREE(state);
 }
 
-/* Create a new scissor state based on the CSO scissor state.
- *
- * This is only for the fragment scissors. */
-static void* r300_create_scissor_state(struct pipe_context* pipe,
-                                    struct pipe_scissor_state* state)
-{
-    uint32_t left, top, right, bottom;
-    struct r300_scissor_state* scissor = CALLOC_STRUCT(r300_scissor_state);
-
-    /* So, a bit of info. The scissors are offset by R300_SCISSORS_OFFSET in
-     * both directions for all values, and can only be 13 bits wide. Why?
-     * We may never know. */
-    left = (state->minx + R300_SCISSORS_OFFSET) & 0x1fff;
-    top = (state->miny + R300_SCISSORS_OFFSET) & 0x1fff;
-    right = (state->maxx + R300_SCISSORS_OFFSET) & 0x1fff;
-    bottom = (state->maxy + R300_SCISSORS_OFFSET) & 0x1fff;
-
-    scissor->scissor_top_left = (left << R300_SCISSORS_X_SHIFT) |
-            (top << R300_SCISSORS_Y_SHIFT);
-    scissor->scissor_bottom_right = (right << R300_SCISSORS_X_SHIFT) |
-            (bottom << R300_SCISSORS_Y_SHIFT);
-
-    return (void*)scissor;
-}
-
-/* Bind scissor state.*/
-static void r300_bind_scissor_state(struct pipe_context* pipe,
-                                 void* state)
+static void r300_set_scissor_state(struct pipe_context* pipe,
+                                   struct pipe_scissor_state* state)
 {
     struct r300_context* r300 = r300_context(pipe);
+    draw_flush(r300->draw);
 
-    r300->scissor_state = (struct r300_scissor_state*)state;
+    /* XXX figure out how this memory doesn't get lost in space
+    memcpy(r300->scissor, scissor, sizeof(struct pipe_scissor_state)); */
     r300->dirty_state |= R300_NEW_SCISSOR;
 }
 
-/* Delete scissor state. */
-static void r300_delete_scissor_state(struct pipe_context* pipe,
-                                   void* state)
-{
-    FREE(state);
-}
-
 static void* r300_create_vs_state(struct pipe_context* pipe,
                                   struct pipe_shader_state* state)
 {
@@ -371,4 +340,21 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* state)
     struct r300_context* context = r300_context(pipe);
     /* XXX handing this off to Draw for now */
     draw_delete_vertex_shader(context->draw, (struct draw_vertex_shader*)state);
+}
+
+void r300_init_state_functions(struct r300_context* r300) {
+
+    r300->context.create_blend_state = r300_create_blend_state;
+    r300->context.bind_blend_state = r300_bind_blend_state;
+    r300->context.delete_blend_state = r300_delete_blend_state;
+
+    r300->context.create_depth_stencil_alpha_state = r300_create_dsa_state;
+    r300->context.bind_depth_stencil_alpha_state = r300_bind_dsa_state;
+    r300->context.delete_depth_stencil_alpha_state = r300_delete_dsa_state;
+
+    r300->context.set_scissor_state = r300_set_scissor_state;
+
+    r300->context.create_vs_state = r300_create_vs_state;
+    r300->context.bind_vs_state = r300_bind_vs_state;
+    r300->context.delete_vs_state = r300_delete_vs_state;
 }
\ No newline at end of file