r300g: atomize beginning occlusion query
authorMarek Olšák <maraeo@gmail.com>
Wed, 14 Apr 2010 02:22:22 +0000 (04:22 +0200)
committerMarek Olšák <maraeo@gmail.com>
Wed, 14 Apr 2010 02:48:19 +0000 (04:48 +0200)
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_defines.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_emit.h
src/gallium/drivers/r300/r300_flush.c
src/gallium/drivers/r300/r300_query.c

index 9a235baf7d70c5fb7cce6b5f011420eeb69b288e..06af2c2fd8d85bba939338d108b2eb86dbd98abb 100644 (file)
@@ -101,6 +101,7 @@ static void r300_setup_atoms(struct r300_context* r300)
      * the size of 0 here. */
     make_empty_list(&r300->atom_list);
     R300_INIT_ATOM(invariant_state, 71);
+    R300_INIT_ATOM(query_start, 4);
     R300_INIT_ATOM(ztop_state, 2);
     R300_INIT_ATOM(blend_state, 8);
     R300_INIT_ATOM(blend_color_state, is_r500 ? 3 : 2);
index 2655e7e0e1405858158241852e1a0ac2aa0b6cea..258b20d9737abe4c9e21766cfae8189202d6808e 100644 (file)
@@ -372,6 +372,8 @@ struct r300_context {
     struct r300_atom fs_constants;
     /* Framebuffer state. */
     struct r300_atom fb_state;
+    /* Occlusion query. */
+    struct r300_atom query_start;
     /* Rasterizer state. */
     struct r300_atom rs_state;
     /* RS block state. */
@@ -417,8 +419,6 @@ struct r300_context {
 
     struct pipe_viewport_state viewport;
 
-    /* Bitmask of dirty state objects. */
-    uint32_t dirty_state;
     /* Flag indicating whether or not the HW is dirty. */
     uint32_t dirty_hw;
     /* Whether polygon offset is enabled. */
index 0c3b970501d72375631b1911fd7ca5ab9872530a..8237c999aac4092559ca2230c790a14d41adb5c5 100644 (file)
 
 #define R300_RESOURCE_FLAG_TRANSFER     PIPE_RESOURCE_FLAG_DRV_PRIV
 
-/* Non-atom dirty state flags. */
-#define R300_NEW_QUERY                          0x40000000
-#define R300_NEW_KITCHEN_SINK                   0x7fffffff
-
 /* Tiling flags. */
 enum r300_buffer_tiling {
     R300_BUFFER_LINEAR = 0,
index afb47ead9c59863fd90e7c3a20ad367e6b6d8db0..8d5792b0ef9ffd6e67f32c05c37ae2afe22f28ac 100644 (file)
@@ -570,7 +570,7 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
     END_CS;
 }
 
-void r300_emit_query_start(struct r300_context *r300)
+void r300_emit_query_start(struct r300_context *r300, unsigned size, void*state)
 {
     struct r300_query *query = r300->query_current;
     CS_LOCALS(r300);
@@ -578,7 +578,7 @@ void r300_emit_query_start(struct r300_context *r300)
     if (!query)
        return;
 
-    BEGIN_CS(4);
+    BEGIN_CS(size);
     if (r300->screen->caps.family == CHIP_FAMILY_RV530) {
         OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL);
     } else {
@@ -1149,7 +1149,7 @@ validate:
         }
     }
     /* ...occlusion query buffer... */
-    if (r300->dirty_state & R300_NEW_QUERY) {
+    if (r300->query_start.dirty) {
         if (!r300_add_buffer(r300->rws, r300->oqbo,
                             0, RADEON_GEM_DOMAIN_GTT)) {
             r300->context.flush(&r300->context, 0, NULL);
@@ -1219,11 +1219,6 @@ void r300_emit_dirty_state(struct r300_context* r300)
     struct r300_screen* r300screen = r300->screen;
     struct r300_atom* atom;
 
-    if (r300->dirty_state & R300_NEW_QUERY) {
-        r300_emit_query_start(r300);
-        r300->dirty_state &= ~R300_NEW_QUERY;
-    }
-
     foreach(atom, &r300->atom_list) {
         if (atom->dirty || atom->always_dirty) {
             atom->emit(r300, atom->size, atom->state);
index 678e1822123833c316aa24ced710d57d6f1f0f57..56f7318cdbec97ec45f8150495183690da7b4348 100644 (file)
@@ -61,7 +61,7 @@ void r500_emit_fs_rc_constant_state(struct r300_context* r300, unsigned size, vo
 
 void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state);
 
-void r300_emit_query_start(struct r300_context* r300);
+void r300_emit_query_start(struct r300_context *r300, unsigned size, void *state);
 
 void r300_emit_query_end(struct r300_context* r300);
 
index 0d8158e19904b8bf2cb0619cbd466a65bbffa775..5e61f528b64a68543c66c29b64b176d0ea200ff5 100644 (file)
@@ -52,7 +52,6 @@ static void r300_flush(struct pipe_context* pipe,
 
     if (r300->dirty_hw) {
         FLUSH_CS;
-        r300->dirty_state = R300_NEW_KITCHEN_SINK;
         r300->dirty_hw = 0;
 
         /* New kitchen sink, baby. */
index 3348a0ada61c3aa88ab0068c31b59b412931b8d5..398edb9d1016f25c0cf4e7bf4ff9a0a210236fa3 100644 (file)
@@ -92,7 +92,7 @@ static void r300_begin_query(struct pipe_context* pipe,
 
     q->flushed = FALSE;
     r300->query_current = q;
-    r300->dirty_state |= R300_NEW_QUERY;
+    r300->query_start.dirty = TRUE;
 }
 
 static void r300_end_query(struct pipe_context* pipe,