r300: Add sampler state skeleton.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Thu, 22 Jan 2009 11:45:14 +0000 (03:45 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 2 Feb 2009 07:30:25 +0000 (23:30 -0800)
Heh, serendipitous sibilance. Anyway, need to flesh this out.

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

index f4d8014..3877c98 100644 (file)
@@ -65,17 +65,21 @@ struct r300_rs_state {
     uint32_t cull_mode;             /* R300_SU_CULL_MODE: 0x42b8 */
 };
 
+struct r300_sampler_state {
+};
+
 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          0x01
-#define R300_NEW_BLEND_COLOR    0x02
-#define R300_NEW_DSA            0x04
-#define R300_NEW_RS             0x08
-#define R300_NEW_SCISSOR        0x10
-#define R300_NEW_KITCHEN_SINK   0x1f
+#define R300_NEW_BLEND          0x0001
+#define R300_NEW_BLEND_COLOR    0x0002
+#define R300_NEW_DSA            0x0004
+#define R300_NEW_RS             0x0008
+#define R300_NEW_SAMPLER        0x0010
+#define R300_NEW_SCISSOR        0x1000
+#define R300_NEW_KITCHEN_SINK   0x1fff
 
 struct r300_context {
     /* Parent class */
@@ -95,9 +99,11 @@ struct r300_context {
     struct r300_dsa_state* dsa_state;
     /* Rasterizer state. */
     struct r300_rs_state* rs_state;
+    /* Sampler states. */
+    struct r300_sampler_state* sampler_states[8];
+    int sampler_count;
     /* Scissor state. */
     struct r300_scissor_state* scissor_state;
-
     /* Bitmask of dirty state objects. */
     uint32_t dirty_state;
     /* Flag indicating whether or not the HW is dirty. */
index 3978ca1..7fb0fc2 100644 (file)
@@ -457,6 +457,41 @@ static void r300_delete_rs_state(struct pipe_context* pipe, void* state)
     FREE(state);
 }
 
+static void*
+        r300_create_sampler_state(struct pipe_context* pipe,
+                                  const struct pipe_sampler_state* state)
+{
+    struct r300_sampler_state* sampler = CALLOC_STRUCT(r300_sampler_state);
+
+    return (void*)sampler;
+}
+
+static void r300_bind_sampler_states(struct pipe_context* pipe,
+                                     unsigned count,
+                                     void** states)
+{
+    struct r300_context* r300 = r300_context(pipe);
+    int i = 0;
+
+    if (count > 8) {
+        return;
+    }
+
+    for (i; i < count; i++) {
+        if (r300->sampler_states[i] != states[i]) {
+            r300->sampler_states[i] = states[i];
+            r300->dirty_state |= (R300_NEW_SAMPLER << i);
+        }
+    }
+
+    r300->sampler_count = count;
+}
+
+static void r300_delete_sampler_state(struct pipe_context* pipe, void* state)
+{
+    FREE(state);
+}
+
 static void r300_set_scissor_state(struct pipe_context* pipe,
                                    const struct pipe_scissor_state* state)
 {
@@ -510,17 +545,21 @@ void r300_init_state_functions(struct r300_context* r300) {
 
     r300->context.set_blend_color = r300_set_blend_color;
 
+    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.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;
 
-    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.create_sampler_state = r300_create_sampler_state;
+    r300->context.bind_sampler_states = r300_bind_sampler_states;
+    r300->context.delete_sampler_state = r300_delete_sampler_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
+}