diff options
author | José Fonseca <jrfonseca@tungstengraphics.com> | 2007-11-15 17:07:50 +0000 |
---|---|---|
committer | José Fonseca <jrfonseca@tungstengraphics.com> | 2007-11-15 17:07:50 +0000 |
commit | 90dd0cb822f2fe14258c786e5c37da69472b7d17 (patch) | |
tree | 709a0073a8e5cd66442199d4bd529a4097573cba /src/mesa | |
parent | 193c85ec7a1aec44eebc67c6224fb6ecbb4607a5 (diff) |
Include fences in the i915simple winsys interface.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.c | 14 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel_winsys/intel_winsys.h | 17 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c | 60 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_batch.h | 10 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_context.h | 3 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_flush.c | 3 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_winsys.h | 18 |
8 files changed, 96 insertions, 31 deletions
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.c b/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.c index 49e04d81ec..ed223977e2 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.c @@ -307,20 +307,6 @@ intel_batchbuffer_flush(struct intel_batchbuffer *batch) } -void -intel_batchbuffer_finish(struct intel_batchbuffer *batch) -{ - struct _DriFenceObject *fence = intel_batchbuffer_flush(batch); - if (fence) { - driFenceReference(fence); - driFenceFinish(fence, - DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW, - GL_FALSE); - driFenceUnReference(fence); - } -} - - /* This is the only way buffers get added to the validate list. */ boolean diff --git a/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.h b/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.h index 82feafa21f..2c943e68e5 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.h @@ -72,8 +72,6 @@ struct intel_batchbuffer *intel_batchbuffer_alloc(struct intel_context *intel); void intel_batchbuffer_free(struct intel_batchbuffer *batch); -void intel_batchbuffer_finish(struct intel_batchbuffer *batch); - struct _DriFenceObject *intel_batchbuffer_flush(struct intel_batchbuffer *batch); diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h b/src/mesa/drivers/dri/intel_winsys/intel_winsys.h index 89e63e0a79..f944cd23c3 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys.h @@ -32,7 +32,9 @@ struct intel_context; struct pipe_context; struct pipe_winsys; struct pipe_buffer_handle; +struct pipe_fence; struct _DriBufferObject; +struct _DriFenceObject; struct pipe_winsys * intel_create_pipe_winsys( int fd ); @@ -66,5 +68,20 @@ pipe_bo( struct _DriBufferObject *bo ) } +/* Turn the pipe opaque buffer pointer into a dri_bufmgr opaque + * buffer pointer... + */ +static INLINE struct _DriFenceObject * +dri_fo( struct pipe_fence *bo ) +{ + return (struct _DriFenceObject *)bo; +} + +static INLINE struct pipe_fence * +pipe_fo( struct _DriFenceObject *bo ) +{ + return (struct pipe_fence *)bo; +} + #endif diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c index 8e0eea4392..7713d6e48d 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c @@ -111,19 +111,62 @@ static void intel_i915_batch_reloc( struct i915_winsys *sws, -static void intel_i915_batch_flush( struct i915_winsys *sws ) +static struct pipe_fence * +intel_i915_batch_flush( struct i915_winsys *sws ) { struct intel_context *intel = intel_i915_winsys(sws)->intel; - intel_batchbuffer_flush( intel->batch ); -// if (0) intel_i915_batch_wait_idle( sws ); + return pipe_fo(intel_batchbuffer_flush( intel->batch )); } -static void intel_i915_batch_finish( struct i915_winsys *sws ) +static void +intel_i915_fence_reference( struct i915_winsys *sws, + struct pipe_fence **dst_fence, + struct pipe_fence *src_fence ) { - struct intel_context *intel = intel_i915_winsys(sws)->intel; - intel_batchbuffer_finish( intel->batch ); + struct _DriFenceObject **dri_dst_fence = (struct _DriFenceObject **)dst_fence; + struct _DriFenceObject *dri_src_fence = (struct _DriFenceObject *)dst_fence; + + if(dri_src_fence) + driFenceReference(dri_src_fence); + + if(*dri_dst_fence) + driFenceUnReference(*dri_dst_fence); + + *dri_dst_fence = dri_src_fence; +} + + +static int +intel_i915_fence_is_signalled( struct i915_winsys *sws, + struct pipe_fence *fence ) +{ + struct _DriFenceObject *dri_fence = dri_fo(fence); + int ret = 1; + if (fence) { + driFenceReference(dri_fence); + ret = driFenceSignaled(dri_fence, + DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW); + driFenceUnReference(dri_fence); + } + return ret; +} + + +static int +intel_i915_fence_wait( struct i915_winsys *sws, + struct pipe_fence *fence ) +{ + struct _DriFenceObject *dri_fence = dri_fo(fence); + if (fence) { + driFenceReference(dri_fence); + driFenceFinish(dri_fence, + DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW, + GL_FALSE); + driFenceUnReference(dri_fence); + } + return 1; } @@ -143,7 +186,10 @@ intel_create_i915simple( struct intel_context *intel, iws->winsys.batch_dword = intel_i915_batch_dword; iws->winsys.batch_reloc = intel_i915_batch_reloc; iws->winsys.batch_flush = intel_i915_batch_flush; - iws->winsys.batch_finish = intel_i915_batch_finish; + iws->winsys.fence_reference = intel_i915_fence_reference; + iws->winsys.fence_is_signalled = intel_i915_fence_is_signalled; + iws->winsys.fence_wait = intel_i915_fence_wait; + iws->intel = intel; /* Create the i915simple context: diff --git a/src/mesa/pipe/i915simple/i915_batch.h b/src/mesa/pipe/i915simple/i915_batch.h index fb88cd6db0..99b03c37db 100644 --- a/src/mesa/pipe/i915simple/i915_batch.h +++ b/src/mesa/pipe/i915simple/i915_batch.h @@ -44,11 +44,11 @@ #define ADVANCE_BATCH() -#define FLUSH_BATCH() do { \ - if (0) i915_dump_batchbuffer( i915 ); \ - i915->winsys->batch_flush( i915->winsys ); \ - i915->batch_start = NULL; \ - i915->hardware_dirty = ~0; \ +#define FLUSH_BATCH() do { \ + if (0) i915_dump_batchbuffer( i915 ); \ + i915->last_fence = i915->winsys->batch_flush( i915->winsys ); \ + i915->batch_start = NULL; \ + i915->hardware_dirty = ~0; \ } while (0) #endif diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index ee430ebc90..488682f852 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -80,6 +80,7 @@ +struct pipe_fence; struct i915_cache_context; /* Use to calculate differences between state emitted to hardware and @@ -184,6 +185,8 @@ struct i915_context unsigned dirty; unsigned *batch_start; + + struct pipe_fence *last_fence; /** Vertex buffer */ struct pipe_buffer_handle *vbo; diff --git a/src/mesa/pipe/i915simple/i915_flush.c b/src/mesa/pipe/i915simple/i915_flush.c index 3c2069b827..1044cb1bdb 100644 --- a/src/mesa/pipe/i915simple/i915_flush.c +++ b/src/mesa/pipe/i915simple/i915_flush.c @@ -69,7 +69,8 @@ static void i915_flush( struct pipe_context *pipe, FLUSH_BATCH(); if (flags & PIPE_FLUSH_WAIT) { - i915->winsys->batch_finish(i915->winsys); + if( i915->last_fence ) + i915->winsys->fence_wait(i915->winsys, i915->last_fence); } } diff --git a/src/mesa/pipe/i915simple/i915_winsys.h b/src/mesa/pipe/i915simple/i915_winsys.h index 2c0f335d34..03457c1d61 100644 --- a/src/mesa/pipe/i915simple/i915_winsys.h +++ b/src/mesa/pipe/i915simple/i915_winsys.h @@ -52,6 +52,7 @@ struct pipe_buffer_handle; struct pipe_winsys; +struct pipe_fence; /** @@ -97,8 +98,21 @@ struct i915_winsys { unsigned access_flags, unsigned delta ); - void (*batch_flush)( struct i915_winsys *sws ); - void (*batch_finish)( struct i915_winsys *sws ); + struct pipe_fence *(*batch_flush)( struct i915_winsys *sws ); + + + /* Fence + */ + void (*fence_reference)( struct i915_winsys *sws, + struct pipe_fence **dst_fence, + struct pipe_fence *src_fence ); + + int (*fence_is_signalled)( struct i915_winsys *sws, + struct pipe_fence *fence ); + + int (*fence_wait)( struct i915_winsys *sws, + struct pipe_fence *fence ); + }; #define I915_BUFFER_ACCESS_WRITE 0x1 |