pipebuffer: Drop reliance on pipe_winsys.
authorJosé Fonseca <jfonseca@vmware.com>
Tue, 10 Feb 2009 16:18:22 +0000 (16:18 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 10 Feb 2009 17:37:53 +0000 (17:37 +0000)
src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c

index 61afdfe82adffcfffced59b7ab014818e686468d..f9e62264368e7b83625bb096462f14b678c06564 100644 (file)
@@ -44,7 +44,6 @@
 #include "pipe/p_compiler.h"
 #include "pipe/p_error.h"
 #include "pipe/p_debug.h"
-#include "pipe/internal/p_winsys_screen.h"
 #include "pipe/p_thread.h"
 #include "util/u_memory.h"
 #include "util/u_double_list.h"
@@ -64,7 +63,7 @@ struct fenced_buffer_list
 {
    pipe_mutex mutex;
    
-   struct pipe_winsys *winsys;
+   struct pb_fence_ops *ops;
    
    size_t numDelayed;
    
@@ -140,12 +139,12 @@ static INLINE void
 _fenced_buffer_remove(struct fenced_buffer_list *fenced_list,
                       struct fenced_buffer *fenced_buf)
 {
-   struct pipe_winsys *winsys = fenced_list->winsys;
+   struct pb_fence_ops *ops = fenced_list->ops;
 
    assert(fenced_buf->fence);
    assert(fenced_buf->list == fenced_list);
    
-   winsys->fence_reference(winsys, &fenced_buf->fence, NULL);
+   ops->fence_reference(ops, &fenced_buf->fence, NULL);
    fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
    
    assert(fenced_buf->head.prev);
@@ -168,7 +167,7 @@ static INLINE enum pipe_error
 _fenced_buffer_finish(struct fenced_buffer *fenced_buf)
 {
    struct fenced_buffer_list *fenced_list = fenced_buf->list;
-   struct pipe_winsys *winsys = fenced_list->winsys;
+   struct pb_fence_ops *ops = fenced_list->ops;
 
 #if 0
    debug_warning("waiting for GPU");
@@ -176,7 +175,7 @@ _fenced_buffer_finish(struct fenced_buffer *fenced_buf)
 
    assert(fenced_buf->fence);
    if(fenced_buf->fence) {
-      if(winsys->fence_finish(winsys, fenced_buf->fence, 0) != 0) {
+      if(ops->fence_finish(ops, fenced_buf->fence, 0) != 0) {
         return PIPE_ERROR;
       }
       /* Remove from the fenced list */
@@ -196,7 +195,7 @@ static void
 _fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, 
                                int wait)
 {
-   struct pipe_winsys *winsys = fenced_list->winsys;
+   struct pb_fence_ops *ops = fenced_list->ops;
    struct list_head *curr, *next;
    struct fenced_buffer *fenced_buf;
    struct pipe_fence_handle *prev_fence = NULL;
@@ -209,15 +208,15 @@ _fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
       if(fenced_buf->fence != prev_fence) {
         int signaled;
         if (wait)
-           signaled = winsys->fence_finish(winsys, fenced_buf->fence, 0);
+           signaled = ops->fence_finish(ops, fenced_buf->fence, 0);
         else
-           signaled = winsys->fence_signalled(winsys, fenced_buf->fence, 0);
+           signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
         if (signaled != 0)
            break;
         prev_fence = fenced_buf->fence;
       }
       else {
-        assert(winsys->fence_signalled(winsys, fenced_buf->fence, 0) == 0);
+        assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
       }
 
       _fenced_buffer_remove(fenced_list, fenced_buf);
@@ -237,14 +236,14 @@ fenced_buffer_destroy(struct pb_buffer *buf)
    pipe_mutex_lock(fenced_list->mutex);
    assert(fenced_buf->base.base.refcount == 0);
    if (fenced_buf->fence) {
-      struct pipe_winsys *winsys = fenced_list->winsys;
-      if(winsys->fence_signalled(winsys, fenced_buf->fence, 0) == 0) {
+      struct pb_fence_ops *ops = fenced_list->ops;
+      if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) {
         struct list_head *curr, *prev;
         curr = &fenced_buf->head;
         prev = curr->prev;
         do {
            fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
-           assert(winsys->fence_signalled(winsys, fenced_buf->fence, 0) == 0);
+           assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
            _fenced_buffer_remove(fenced_list, fenced_buf);
            curr = prev;
            prev = curr->prev;
@@ -366,11 +365,11 @@ fenced_buffer_fence(struct pb_buffer *buf,
 {
    struct fenced_buffer *fenced_buf;
    struct fenced_buffer_list *fenced_list;
-   struct pipe_winsys *winsys;
+   struct pb_fence_ops *ops;
 
    fenced_buf = fenced_buffer(buf);
    fenced_list = fenced_buf->list;
-   winsys = fenced_list->winsys;
+   ops = fenced_list->ops;
    
    if(fence == fenced_buf->fence) {
       /* Nothing to do */
@@ -384,7 +383,7 @@ fenced_buffer_fence(struct pb_buffer *buf,
    if (fenced_buf->fence)
       _fenced_buffer_remove(fenced_list, fenced_buf);
    if (fence) {
-      winsys->fence_reference(winsys, &fenced_buf->fence, fence);
+      ops->fence_reference(ops, &fenced_buf->fence, fence);
       fenced_buf->flags |= fenced_buf->validation_flags;
       _fenced_buffer_add(fenced_buf);
    }
@@ -447,7 +446,7 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
 
 
 struct fenced_buffer_list *
-fenced_buffer_list_create(struct pipe_winsys *winsys) 
+fenced_buffer_list_create(struct pb_fence_ops *ops) 
 {
    struct fenced_buffer_list *fenced_list;
 
@@ -455,7 +454,7 @@ fenced_buffer_list_create(struct pipe_winsys *winsys)
    if (!fenced_list)
       return NULL;
 
-   fenced_list->winsys = winsys;
+   fenced_list->ops = ops;
 
    LIST_INITHEAD(&fenced_list->delayed);
 
@@ -494,6 +493,8 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
 
    pipe_mutex_unlock(fenced_list->mutex);
    
+   fenced_list->ops->destroy(fenced_list->ops);
+   
    FREE(fenced_list);
 }
 
index b15c6761946167b8ef56a09643f774422f4c797e..d1c9d4c17dff7b4bc4044816146d456eee86d460 100644 (file)
@@ -59,7 +59,6 @@ extern "C" {
 #endif
 
 
-struct pipe_winsys;
 struct pipe_buffer;
 struct pipe_fence_handle;
 
@@ -70,13 +69,42 @@ struct pipe_fence_handle;
 struct fenced_buffer_list;
 
 
+struct pb_fence_ops
+{
+   void (*destroy)( struct pb_fence_ops *ops );
+
+   /** Set ptr = fence, with reference counting */
+   void (*fence_reference)( struct pb_fence_ops *ops,
+                            struct pipe_fence_handle **ptr,
+                            struct pipe_fence_handle *fence );
+
+   /**
+    * Checks whether the fence has been signalled.
+    * \param flags  driver-specific meaning
+    * \return zero on success.
+    */
+   int (*fence_signalled)( struct pb_fence_ops *ops,
+                           struct pipe_fence_handle *fence,
+                           unsigned flag );
+
+   /**
+    * Wait for the fence to finish.
+    * \param flags  driver-specific meaning
+    * \return zero on success.
+    */
+   int (*fence_finish)( struct pb_fence_ops *ops,
+                        struct pipe_fence_handle *fence,
+                        unsigned flag );
+};
+
+
 /**
  * Create a fenced buffer list.
  * 
  * See also fenced_bufmgr_create for a more convenient way to use this.
  */
 struct fenced_buffer_list *
-fenced_buffer_list_create(struct pipe_winsys *winsys);
+fenced_buffer_list_create(struct pb_fence_ops *ops);
 
 
 /**
index 0a8264a924301091cb53b8fd522a7c7bae771ed0..fec8db91c7160bed46659c91a89e772b0208403c 100644 (file)
@@ -61,7 +61,6 @@ extern "C" {
 
 struct pb_desc;
 struct pipe_buffer;
-struct pipe_winsys;
 
 
 /** 
@@ -163,6 +162,8 @@ pb_cache_manager_create(struct pb_manager *provider,
                        unsigned usecs); 
 
 
+struct pb_fence_ops;
+
 /** 
  * Fenced buffer manager.
  *
@@ -174,7 +175,7 @@ pb_cache_manager_create(struct pb_manager *provider,
  */
 struct pb_manager *
 fenced_bufmgr_create(struct pb_manager *provider,
-                     struct pipe_winsys *winsys);
+                     struct pb_fence_ops *ops);
 
 
 struct pb_manager *
index 513ed28ca633f28d4f521a8ecf692347bcfd2739..47e9fee53389049335442fd1557ad31543318f2c 100644 (file)
@@ -122,7 +122,7 @@ fenced_bufmgr_destroy(struct pb_manager *mgr)
 
 struct pb_manager *
 fenced_bufmgr_create(struct pb_manager *provider, 
-                     struct pipe_winsys *winsys) 
+                     struct pb_fence_ops *ops) 
 {
    struct fenced_pb_manager *fenced_mgr;
 
@@ -138,7 +138,7 @@ fenced_bufmgr_create(struct pb_manager *provider,
    fenced_mgr->base.flush = fenced_bufmgr_flush;
 
    fenced_mgr->provider = provider;
-   fenced_mgr->fenced_list = fenced_buffer_list_create(winsys);
+   fenced_mgr->fenced_list = fenced_buffer_list_create(ops);
    if(!fenced_mgr->fenced_list) {
       FREE(fenced_mgr);
       return NULL;