r300g: attempt to make bo space check sane.
authorDave Airlie <airlied@redhat.com>
Wed, 14 Oct 2009 05:13:25 +0000 (15:13 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 14 Oct 2009 05:13:25 +0000 (15:13 +1000)
This attempts to make r300g do proper bo space checking as opposed
to whatever it was doing now.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_winsys.h
src/gallium/winsys/drm/radeon/core/radeon_r300.c

index 9cc455135db9bdaa926626caf7e4223be7536e58..e6bc80e48f8c906415ed3dcbdb51ffd0e0d93c18 100644 (file)
@@ -136,6 +136,13 @@ r300_is_buffer_referenced( struct pipe_context *pipe,
    return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
 }
 
+static void r300_flush_cb(void *data)
+{
+    struct r300_context* const cs_context_copy = data;
+
+    cs_context_copy->context.flush(&cs_context_copy->context, 0, NULL);
+}
+
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
                                          struct r300_winsys* r300_winsys)
 {
@@ -190,6 +197,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     r300_init_state_functions(r300);
 
     r300_emit_invariant_state(r300);
+
+    r300->winsys->set_flush_cb(r300->winsys, r300_flush_cb, r300);
     r300->dirty_state = R300_NEW_KITCHEN_SINK;
     r300->dirty_hw++;
 
index 99deb50400fbdb807f69edd8bf10edd8d9c06530..64748ad8f816fab459572c26fcfdbc3f733e66b2 100644 (file)
@@ -658,6 +658,9 @@ void r300_emit_dirty_state(struct r300_context* r300)
 
     r300_update_derived_state(r300);
 
+    /* Clean out BOs. */
+    r300->winsys->reset_bos(r300->winsys);
+
     /* XXX check size */
 validate:
     /* Color buffers... */
index f18ad75a47d8c6ef6ad1f60a08216407b29229d4..540f8eca92eb3d3567178f6ce03bce1ba3ee197e 100644 (file)
@@ -92,6 +92,12 @@ struct r300_winsys {
 
     /* Flush the CS. */
     void (*flush_cs)(struct r300_winsys* winsys);
+
+    /* winsys flush - callback from winsys when flush required */
+    void (*set_flush_cb)(struct r300_winsys *winsys,
+                        void (*flush_cb)(void *), void *data);
+
+    void (*reset_bos)(struct r300_winsys *winsys);
 };
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
index d2d84f1a8f0ee31b57db8dcb8e38c9710e8e6e07..3587892e00335305d21f9134009d64486202a06d 100644 (file)
 
 #include "radeon_r300.h"
 
+static void radeon_r300_set_flush_cb(struct r300_winsys *winsys,
+                                    void (*flush_cb)(void *),
+                                    void *data)
+{
+    struct radeon_winsys_priv* priv =
+        (struct radeon_winsys_priv*)winsys->radeon_winsys;
+
+    radeon_cs_space_set_flush(priv->cs, flush_cb,
+                             data);
+}
+
 static boolean radeon_r300_add_buffer(struct r300_winsys* winsys,
                                       struct pipe_buffer* pbuffer,
                                       uint32_t rd,
@@ -95,6 +106,13 @@ static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys,
     }
 }
 
+static void radeon_r300_reset_bos(struct r300_winsys *winsys)
+{
+    struct radeon_winsys_priv* priv =
+        (struct radeon_winsys_priv*)winsys->radeon_winsys;
+    radeon_cs_space_reset_bos(priv->cs);
+}
+
 static void radeon_r300_end_cs(struct r300_winsys* winsys,
                                const char* file,
                                const char* function,
@@ -119,9 +137,6 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys)
         radeon_cs_print(priv->cs, stderr);
     }
 
-    /* Clean out BOs. */
-    radeon_cs_space_reset_bos(priv->cs);
-
     /* Reset CS.
      * Someday, when we care about performance, we should really find a way
      * to rotate between two or three CS objects so that the GPU can be
@@ -203,6 +218,8 @@ radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys)
     winsys->write_cs_reloc = radeon_r300_write_cs_reloc;
     winsys->end_cs = radeon_r300_end_cs;
     winsys->flush_cs = radeon_r300_flush_cs;
+    winsys->reset_bos = radeon_r300_reset_bos;
+    winsys->set_flush_cb = radeon_r300_set_flush_cb;
 
     memcpy(winsys, old_winsys, sizeof(struct radeon_winsys));