Mesa (master): r300g: flush CS if a buffer being deleted is referenced by it

Corbin Simpson csimpson at kemper.freedesktop.org
Tue Dec 15 19:04:49 PST 2009


Module: Mesa
Branch: master
Commit: 417ce06306962a9355cbb35cefcdea1951b0ce85
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=417ce06306962a9355cbb35cefcdea1951b0ce85

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sat Dec 12 23:44:02 2009 +0100

r300g: flush CS if a buffer being deleted is referenced by it

---

 src/gallium/winsys/drm/radeon/core/radeon_buffer.c |    6 ++++++
 src/gallium/winsys/drm/radeon/core/radeon_buffer.h |    1 +
 src/gallium/winsys/drm/radeon/core/radeon_drm.c    |    1 +
 3 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
index 2a8daed..76acc99 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
@@ -81,6 +81,7 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
         domain |= RADEON_GEM_DOMAIN_GTT;
     }
 
+    radeon_buffer->ws = radeon_ws;
     radeon_buffer->bo = radeon_bo_open(radeon_ws->priv->bom, 0, size,
             alignment, domain, 0);
     if (radeon_buffer->bo == NULL) {
@@ -131,6 +132,11 @@ static void radeon_buffer_del(struct pipe_buffer *buffer)
 {
     struct radeon_pipe_buffer *radeon_buffer =
         (struct radeon_pipe_buffer*)buffer;
+    struct radeon_winsys_priv *priv = radeon_buffer->ws->priv;
+
+    if (radeon_bo_is_referenced_by_cs(radeon_buffer->bo, priv->cs)) {
+        priv->cs->space_flush_fn(priv->cs->space_flush_data);
+    }
 
     radeon_bo_unref(radeon_buffer->bo);
     free(radeon_buffer);
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
index bfe2221..1e91e18 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
@@ -50,6 +50,7 @@
 struct radeon_pipe_buffer {
     struct pipe_buffer  base;
     struct radeon_bo    *bo;
+    struct radeon_winsys *ws;
     boolean flinked;
     uint32_t flink;
 };
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
index dec7c06..2f7fbc7 100644
--- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
@@ -171,6 +171,7 @@ struct pipe_buffer* radeon_buffer_from_handle(struct drm_api* api,
     radeon_buffer->base.screen = screen;
     radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL;
     radeon_buffer->bo = bo;
+    radeon_buffer->ws = (struct radeon_winsys*)screen->winsys;
     return &radeon_buffer->base;
 }
 



More information about the mesa-commit mailing list