r300: Moar state handlers.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sat, 24 Jan 2009 09:32:14 +0000 (01:32 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 2 Feb 2009 07:30:27 +0000 (23:30 -0800)
Ah, my code's so bad. It's amazing.

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

index f2dc8aedaad5982624c3814b9a51e3fe3297093d..494c9e54c026e8f2354705effe744eef0c05d407 100644 (file)
@@ -340,4 +340,7 @@ void r300_parse_chipset(struct r300_capabilities* caps)
             /* XXX not an r300?! */
             break;
     }
+
+    /* Force off TCL for now */
+    caps->has_tcl = FALSE;
 }
index 0d7ba581cc9d8adbc4cdeda23eefb6940ea51c88..52ddfa1df953a9a4e6f0e8c6831264f95c45b766 100644 (file)
@@ -79,6 +79,9 @@ struct r300_scissor_state {
     uint32_t scissor_bottom_right; /* R300_SC_SCISSORS_BR: 0x43e4 */
 };
 
+struct r300_texture_state {
+};
+
 #define R300_NEW_BLEND           0x0001
 #define R300_NEW_BLEND_COLOR     0x0002
 #define R300_NEW_DSA             0x0004
@@ -121,6 +124,8 @@ struct r300_context {
     struct r300_dsa_state* dsa_state;
     /* Fragment shader state. */
     struct r300_fs_state* fs_state;
+    /* Framebuffer state. We currently don't need our own version of this. */
+    struct pipe_framebuffer_state framebuffer_state;
     /* Rasterizer state. */
     struct r300_rs_state* rs_state;
     /* Sampler states. */
@@ -128,6 +133,10 @@ struct r300_context {
     int sampler_count;
     /* Scissor state. */
     struct r300_scissor_state* scissor_state;
+    /* Texture states. */
+    struct r300_texture* textures[8];
+    struct r300_texture_state* texture_states[8];
+    int texture_count;
     /* Bitmask of dirty state objects. */
     uint32_t dirty_state;
     /* Flag indicating whether or not the HW is dirty. */
index 9d9a4ec2020af6b80ce1789be520157b4e2100be..4f9d44bbfd768bd5d72952e8549cd0f5250d82e1 100644 (file)
@@ -195,6 +195,15 @@ static void r300_set_blend_color(struct pipe_context* pipe,
     r300->dirty_state |= R300_NEW_BLEND_COLOR;
 }
 
+static void r300_set_clip_state(struct pipe_context* pipe,
+                                const struct pipe_clip_state* state)
+{
+    struct r300_context* r300 = r300_context(pipe);
+    /* XXX Draw */
+    draw_flush(r300->draw);
+    draw_set_clip_state(r300->draw, state);
+}
+
 static uint32_t translate_depth_stencil_function(int zs_func) {
     switch (zs_func) {
         case PIPE_FUNC_NEVER:
@@ -358,6 +367,19 @@ static void r300_delete_dsa_state(struct pipe_context* pipe,
     FREE(state);
 }
 
+static void
+    r300_set_framebuffer_state(struct pipe_context* pipe,
+                               const struct pipe_framebuffer_state* state)
+{
+    struct r300_context* r300 = r300_context(pipe);
+
+    draw_flush(r300->draw);
+
+    r300->framebuffer_state = *state;
+
+    /* XXX do we need to mark dirty state? */
+}
+
 /* Create fragment shader state. */
 static void* r300_create_fs_state(struct pipe_context* pipe,
                                   const struct pipe_shader_state* state)
@@ -383,6 +405,12 @@ static void r300_delete_fs_state(struct pipe_context* pipe, void* state)
     FREE(state);
 }
 
+static void r300_set_polygon_stipple(struct pipe_context* pipe,
+                                     const struct pipe_poly_stipple* state)
+{
+    /* XXX */
+}
+
 #if 0
 struct pipe_rasterizer_state
 {
@@ -621,6 +649,36 @@ static void r300_delete_sampler_state(struct pipe_context* pipe, void* state)
     FREE(state);
 }
 
+static void r300_set_sampler_textures(struct pipe_context* pipe,
+                                      unsigned count,
+                                      struct pipe_texture** texture)
+{
+    struct r300_context* r300 = r300_context(pipe);
+    int i;
+
+    /* XXX magic num */
+    if (count > 8) {
+        return;
+    }
+
+    for (i = 0; i < count; i++) {
+        if (r300->textures[i] != (struct r300_texture*)texture[i]) {
+            pipe_texture_reference((struct pipe_texture**)&r300->textures[i],
+                texture[i]);
+            /* XXX NEW_TEXTURE instead? */
+            r300->dirty_state |= (R300_NEW_SAMPLER << i);
+        }
+    }
+
+    for (i = count; i < 8; i++) {
+        /* XXX also state change? */
+        pipe_texture_reference((struct pipe_texture**)&r300->textures[i],
+            NULL);
+    }
+
+    r300->texture_count = count;
+}
+
 static void r300_set_scissor_state(struct pipe_context* pipe,
                                    const struct pipe_scissor_state* state)
 {
@@ -645,6 +703,14 @@ static void r300_set_scissor_state(struct pipe_context* pipe,
     r300->dirty_state |= R300_NEW_SCISSOR;
 }
 
+static void r300_set_viewport_state(struct pipe_context* pipe,
+                                     const struct pipe_viewport_state* state)
+{
+    struct r300_context* r300 = r300_context(pipe);
+    /* XXX handing this off to Draw for now */
+    draw_set_viewport_state(r300->draw, state);
+}
+
 static void* r300_create_vs_state(struct pipe_context* pipe,
                                   const struct pipe_shader_state* state)
 {
@@ -674,14 +740,20 @@ void r300_init_state_functions(struct r300_context* r300) {
 
     r300->context.set_blend_color = r300_set_blend_color;
 
+    r300->context.set_clip_state = r300_set_clip_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_framebuffer_state = r300_set_framebuffer_state;
+
     r300->context.create_fs_state = r300_create_fs_state;
     r300->context.bind_fs_state = r300_bind_fs_state;
     r300->context.delete_fs_state = r300_delete_fs_state;
 
+    r300->context.set_polygon_stipple = r300_set_polygon_stipple;
+
     r300->context.create_rasterizer_state = r300_create_rs_state;
     r300->context.bind_rasterizer_state = r300_bind_rs_state;
     r300->context.delete_rasterizer_state = r300_delete_rs_state;
@@ -690,8 +762,12 @@ void r300_init_state_functions(struct r300_context* r300) {
     r300->context.bind_sampler_states = r300_bind_sampler_states;
     r300->context.delete_sampler_state = r300_delete_sampler_state;
 
+    r300->context.set_sampler_textures = r300_set_sampler_textures;
+
     r300->context.set_scissor_state = r300_set_scissor_state;
 
+    r300->context.set_viewport_state = r300_set_viewport_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;