r300g: Start using atoms.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 10 Jan 2010 17:35:55 +0000 (09:35 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 10 Jan 2010 19:17:34 +0000 (11:17 -0800)
No benefits yet.

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_emit.h
src/gallium/drivers/r300/r300_state.c

index ffe066d53693488e1eec4a19a2962fc9293ee901..6c6e0567a44caa9147400c6f2ae85f6452e12cc4 100644 (file)
@@ -27,7 +27,7 @@
 
 static void r300_blitter_save_states(struct r300_context* r300)
 {
-    util_blitter_save_blend(r300->blitter, r300->blend_state);
+    util_blitter_save_blend(r300->blitter, r300->blend_state.state);
     util_blitter_save_depth_stencil_alpha(r300->blitter, r300->dsa_state);
     util_blitter_save_rasterizer(r300->blitter, r300->rs_state);
     util_blitter_save_fragment_shader(r300->blitter, r300->fs);
index d5c2d63d393babb83a5c18c6c400abc21b77b90b..2cdc946e907ce6f5ed151c97cbe5d84e7460a2b8 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "r300_blit.h"
 #include "r300_context.h"
+#include "r300_emit.h"
 #include "r300_flush.h"
 #include "r300_query.h"
 #include "r300_render.h"
@@ -107,6 +108,18 @@ static void r300_flush_cb(void *data)
     cs_context_copy->context.flush(&cs_context_copy->context, 0, NULL);
 }
 
+#define R300_INIT_ATOM(name) \
+    r300->name##_state.state = NULL; \
+    r300->name##_state.emit = r300_emit_##name##_state; \
+    r300->name##_state.dirty = FALSE; \
+    insert_at_tail(&r300->atom_list, &r300->name##_state);
+
+static void r300_setup_atoms(struct r300_context* r300)
+{
+    make_empty_list(&r300->atom_list);
+    R300_INIT_ATOM(blend);
+}
+
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
                                          struct radeon_winsys* radeon_winsys)
 {
@@ -166,6 +179,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
             PIPE_BUFFER_USAGE_VERTEX, 4096);
     make_empty_list(&r300->query_list);
 
+    r300_setup_atoms(r300);
+
     r300_init_flush_functions(r300);
 
     r300_init_query_functions(r300);
index 232530b7dc447b1840cadc9d1189ea4ca0e66186..41582504fd95aa51f6b7d2a7fc44bcec51f0b066 100644 (file)
 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
 
+struct r300_context;
+
 struct r300_fragment_shader;
 struct r300_vertex_shader;
 
+struct r300_atom {
+    struct r300_atom *prev, *next;
+    void* state;
+    void (*emit)(struct r300_context*, void*);
+    boolean dirty;
+};
+
 struct r300_blend_state {
     uint32_t blend_control;       /* R300_RB3D_CBLEND: 0x4e04 */
     uint32_t alpha_blend_control; /* R300_RB3D_ABLEND: 0x4e08 */
@@ -135,7 +144,6 @@ struct r300_ztop_state {
     uint32_t z_buffer_top;      /* R300_ZB_ZTOP: 0x4f14 */
 };
 
-#define R300_NEW_BLEND           0x00000001
 #define R300_NEW_BLEND_COLOR     0x00000002
 #define R300_NEW_CLIP            0x00000004
 #define R300_NEW_DSA             0x00000008
@@ -273,8 +281,10 @@ struct r300_context {
     struct r300_vertex_info* vertex_info;
 
     /* Various CSO state objects. */
+    /* Beginning of atom list. */
+    struct r300_atom atom_list;
     /* Blend state. */
-    struct r300_blend_state* blend_state;
+    struct r300_atom blend_state;
     /* Blend color state. */
     struct r300_blend_color_state* blend_color_state;
     /* User clip planes. */
index f8bfa714fefe458e02466140d5ec2ea794e61af7..8c9c7e9d0375b86cbe7d2e774df263fe104a8657 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "util/u_format.h"
 #include "util/u_math.h"
+#include "util/u_simple_list.h"
 
 #include "r300_context.h"
 #include "r300_cs.h"
@@ -36,9 +37,9 @@
 #include "r300_texture.h"
 #include "r300_vs.h"
 
-void r300_emit_blend_state(struct r300_context* r300,
-                           struct r300_blend_state* blend)
+void r300_emit_blend_state(struct r300_context* r300, void* state)
 {
+    struct r300_blend_state* blend = (struct r300_blend_state*)state;
     CS_LOCALS(r300);
     BEGIN_CS(8);
     OUT_CS_REG_SEQ(R300_RB3D_CBLEND, 3);
@@ -978,6 +979,7 @@ void r300_emit_dirty_state(struct r300_context* r300)
 {
     struct r300_screen* r300screen = r300_screen(r300->context.screen);
     struct r300_texture* tex;
+    struct r300_atom* atom;
     int i, dirty_tex = 0;
     boolean invalid = FALSE;
 
@@ -1060,9 +1062,11 @@ validate:
         r300->dirty_state &= ~R300_NEW_QUERY;
     }
 
-    if (r300->dirty_state & R300_NEW_BLEND) {
-        r300_emit_blend_state(r300, r300->blend_state);
-        r300->dirty_state &= ~R300_NEW_BLEND;
+    foreach(atom, &r300->atom_list) {
+        if (atom->dirty) {
+            atom->emit(r300, atom->state);
+            atom->dirty = FALSE;
+        }
     }
 
     if (r300->dirty_state & R300_NEW_BLEND_COLOR) {
index 3797d3d332addfdb133ce978854145b99932d71b..34356438e4469b8fb9afc3fabfeed5ca80737add 100644 (file)
@@ -32,7 +32,7 @@ struct r300_vertex_program_code;
 void r300_emit_aos(struct r300_context* r300, unsigned offset);
 
 void r300_emit_blend_state(struct r300_context* r300,
-                           struct r300_blend_state* blend);
+                           void* blend);
 
 void r300_emit_blend_color_state(struct r300_context* r300,
                                  struct r300_blend_color_state* bc);
index a145a7f18a5820bc79f1c80e84a92a455dfe7d0c..db8aca6c9f2bebab335a9063956563ed522a1745 100644 (file)
@@ -317,8 +317,8 @@ static void r300_bind_blend_state(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    r300->blend_state = (struct r300_blend_state*)state;
-    r300->dirty_state |= R300_NEW_BLEND;
+    r300->blend_state.state = state;
+    r300->blend_state.dirty = TRUE;
 }
 
 /* Free blend state. */
@@ -521,8 +521,9 @@ static void
         r300->dirty_state |= R300_NEW_SCISSOR;
     }
     r300->dirty_state |= R300_NEW_FRAMEBUFFERS;
-    r300->dirty_state |= R300_NEW_BLEND;
     r300->dirty_state |= R300_NEW_DSA;
+
+    r300->blend_state.dirty = TRUE;
 }
 
 /* Create fragment shader state. */