diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-11-07 16:07:17 -0700 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-11-07 16:08:04 -0700 |
commit | 10c62bf0683437672c83339138a6802d56aeca8f (patch) | |
tree | cdf17f1ce6ed6d6c96132013752c8f365aa41e72 /src/mesa | |
parent | 03cfeb31af7834c2b2701ad25ec39f8375df6c96 (diff) |
Remove context dependencies in winsys layer.
The winsys object is now per-screen and shared by multiple contexts.
The regionPool is now part of the i915 winsys layer.
The winsys wait_idle() and flush_frontbuffer() funcs will get more attention...
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/intel_winsys/intel_context.c | 11 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel_winsys/intel_screen.c | 12 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel_winsys/intel_screen.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel_winsys/intel_winsys.h | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c | 52 | ||||
-rw-r--r-- | src/mesa/pipe/p_context.h | 2 | ||||
-rw-r--r-- | src/mesa/pipe/p_winsys.h | 5 | ||||
-rw-r--r-- | src/mesa/pipe/xlib/xm_winsys.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_flush.c | 5 |
9 files changed, 51 insertions, 46 deletions
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_context.c b/src/mesa/drivers/dri/intel_winsys/intel_context.c index 88551bc3a3..47be72b233 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_context.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_context.c @@ -143,7 +143,6 @@ intelCreateContext(const __GLcontextModes * visual, int fthrottle_mode; GLboolean havePools; struct pipe_context *pipe; - struct pipe_winsys *winsys; struct st_context *st_share = NULL; if (sharedContextPrivate) { @@ -186,13 +185,11 @@ intelCreateContext(const __GLcontextModes * visual, __intel_debug = driParseDebugString(getenv("INTEL_DEBUG"), debug_control); #endif - winsys = intel_create_pipe_winsys( intel ); - /* * Pipe-related setup */ if (!getenv("INTEL_HW")) { - pipe = intel_create_softpipe( intel, winsys ); + pipe = intel_create_softpipe( intel, intelScreen->winsys ); } else { switch (intel->intelScreen->deviceID) { @@ -204,17 +201,19 @@ intelCreateContext(const __GLcontextModes * visual, case PCI_CHIP_Q35_G: case PCI_CHIP_I915_G: case PCI_CHIP_I915_GM: - pipe = intel_create_i915simple( intel, winsys ); + pipe = intel_create_i915simple( intel, intelScreen->winsys ); break; default: fprintf(stderr, "Unknown PCIID %x in %s, using software driver\n", intel->intelScreen->deviceID, __FUNCTION__); - pipe = intel_create_softpipe( intel, winsys ); + pipe = intel_create_softpipe( intel, intelScreen->winsys ); break; } } + pipe->private = intel; + intel->st = st_create_context(pipe, visual, st_share); return GL_TRUE; diff --git a/src/mesa/drivers/dri/intel_winsys/intel_screen.c b/src/mesa/drivers/dri/intel_winsys/intel_screen.c index 334803e264..01460e5be3 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_screen.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_screen.c @@ -34,6 +34,7 @@ #include "intel_batchbuffer.h" #include "intel_batchpool.h" #include "intel_swapbuffers.h" +#include "intel_winsys.h" #include "i830_dri.h" #include "dri_bufpool.h" @@ -165,17 +166,11 @@ intelCreatePools(__DRIscreenPrivate * sPriv) if (intelScreen->havePools) return GL_TRUE; - batchPoolSize /= BATCH_SZ; - intelScreen->regionPool = driDRMPoolInit(sPriv->fd); - - if (!intelScreen->regionPool) - return GL_FALSE; - intelScreen->staticPool = driDRMStaticPoolInit(sPriv->fd); - if (!intelScreen->staticPool) return GL_FALSE; + batchPoolSize /= BATCH_SZ; intelScreen->batchPool = driBatchPoolInit(sPriv->fd, DRM_BO_FLAG_EXE | DRM_BO_FLAG_MEM_TT | @@ -245,6 +240,8 @@ intelInitDriver(__DRIscreenPrivate * sPriv) (*glx_enable_extension) (psc, "GLX_SGI_make_current_read"); } + intelScreen->winsys = intel_create_pipe_winsys(sPriv->fd); + return GL_TRUE; } @@ -257,7 +254,6 @@ intelDestroyScreen(__DRIscreenPrivate * sPriv) /* intelUnmapScreenRegions(intelScreen); */ if (intelScreen->havePools) { - driPoolTakeDown(intelScreen->regionPool); driPoolTakeDown(intelScreen->staticPool); driPoolTakeDown(intelScreen->batchPool); } diff --git a/src/mesa/drivers/dri/intel_winsys/intel_screen.h b/src/mesa/drivers/dri/intel_winsys/intel_screen.h index f0446fe7b3..3396f9e564 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_screen.h +++ b/src/mesa/drivers/dri/intel_winsys/intel_screen.h @@ -65,7 +65,6 @@ struct intel_screen driOptionCache optionCache; struct _DriBufferPool *batchPool; - struct _DriBufferPool *regionPool; struct _DriBufferPool *staticPool; /** for the X screen/framebuffer */ boolean havePools; @@ -74,6 +73,8 @@ struct intel_screen * which we need a rendering context, but none is currently bound. */ struct intel_context *dummyContext; + + struct pipe_winsys *winsys; }; diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h b/src/mesa/drivers/dri/intel_winsys/intel_winsys.h index d7de57227b..89e63e0a79 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys.h @@ -35,7 +35,10 @@ struct pipe_buffer_handle; struct _DriBufferObject; struct pipe_winsys * -intel_create_pipe_winsys( struct intel_context *intel ); +intel_create_pipe_winsys( int fd ); + +void +intel_destroy_pipe_winsys( struct pipe_winsys *winsys ); struct pipe_context * intel_create_softpipe( struct intel_context *intel, diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c index 02c72e9d7f..16fff77af4 100644 --- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c +++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c @@ -48,7 +48,7 @@ struct intel_pipe_winsys { struct pipe_winsys winsys; - struct intel_context *intel; + struct _DriBufferPool *regionPool; }; @@ -110,11 +110,7 @@ static void intel_buffer_data(struct pipe_winsys *winsys, unsigned size, const void *data, unsigned usage ) { - struct intel_context *intel = intel_pipe_winsys(winsys)->intel; - - LOCK_HARDWARE( intel ); driBOData( dri_bo(buf), size, data, 0 ); - UNLOCK_HARDWARE( intel ); } static void intel_buffer_subdata(struct pipe_winsys *winsys, @@ -142,14 +138,10 @@ static struct pipe_buffer_handle * intel_buffer_create(struct pipe_winsys *winsys, unsigned alignment) { - struct intel_context *intel = intel_pipe_winsys(winsys)->intel; struct _DriBufferObject *buffer; - - LOCK_HARDWARE( intel ); - driGenBuffers( intel->intelScreen->regionPool, + struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys); + driGenBuffers( iws->regionPool, "pipe buffer", 1, &buffer, alignment, 0, 0 ); - UNLOCK_HARDWARE( intel ); - return pipe_bo(buffer); } @@ -157,21 +149,18 @@ intel_buffer_create(struct pipe_winsys *winsys, static struct pipe_buffer_handle * intel_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes) { - struct intel_context *intel = intel_pipe_winsys(winsys)->intel; struct _DriBufferObject *buffer; - - LOCK_HARDWARE( intel ); - driGenUserBuffer( intel->intelScreen->regionPool, + struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys); + driGenUserBuffer( iws->regionPool, "pipe user buffer", &buffer, ptr, bytes); - UNLOCK_HARDWARE( intel ); - return pipe_bo(buffer); } -static void intel_wait_idle( struct pipe_winsys *winsys ) +static void +intel_wait_idle( struct pipe_winsys *winsys, void *context_private ) { - struct intel_context *intel = intel_pipe_winsys(winsys)->intel; + struct intel_context *intel = (struct intel_context *) context_private; if (intel->batch->last_fence) { driFenceFinish(intel->batch->last_fence, @@ -188,9 +177,10 @@ static void intel_wait_idle( struct pipe_winsys *winsys ) */ static void intel_flush_frontbuffer( struct pipe_winsys *winsys, - struct pipe_surface *surf ) + struct pipe_surface *surf, + void *context_private) { - struct intel_context *intel = intel_pipe_winsys(winsys)->intel; + struct intel_context *intel = (struct intel_context *) context_private; __DRIdrawablePrivate *dPriv = intel->driDrawable; intelDisplaySurface(dPriv, surf, NULL); @@ -301,7 +291,7 @@ intel_get_name( struct pipe_winsys *winsys ) struct pipe_winsys * -intel_create_pipe_winsys( struct intel_context *intel ) +intel_create_pipe_winsys( int fd ) { struct intel_pipe_winsys *iws = CALLOC_STRUCT( intel_pipe_winsys ); @@ -324,13 +314,25 @@ intel_create_pipe_winsys( struct intel_context *intel ) iws->winsys.wait_idle = intel_wait_idle; iws->winsys.printf = intel_printf; iws->winsys.get_name = intel_get_name; - iws->intel = intel; - iws->winsys.region_alloc = intel_i915_region_alloc; iws->winsys.region_release = intel_i915_region_release; - iws->winsys.surface_alloc = intel_i915_surface_alloc; iws->winsys.surface_release = intel_i915_surface_release; + if (fd) + iws->regionPool = driDRMPoolInit(fd); + return &iws->winsys; } + + +void +intel_destroy_pipe_winsys( struct pipe_winsys *winsys ) +{ + struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys); + if (iws->regionPool) { + driPoolTakeDown(iws->regionPool); + } + free(iws); +} + diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index ddc7acc747..3962c0fa6d 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -43,6 +43,8 @@ struct pipe_state_cache; struct pipe_context { struct pipe_winsys *winsys; + void *private; /** context private data (for DRI for example) */ + void (*destroy)( struct pipe_context * ); /* diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h index 9dbac87b4b..ee10e30559 100644 --- a/src/mesa/pipe/p_winsys.h +++ b/src/mesa/pipe/p_winsys.h @@ -64,14 +64,15 @@ struct pipe_winsys const char *(*get_name)( struct pipe_winsys *sws ); /** Wait for any buffered rendering to finish */ - void (*wait_idle)( struct pipe_winsys *sws ); + void (*wait_idle)( struct pipe_winsys *sws, void *context_private ); /** * Do any special operations to ensure frontbuffer contents are * displayed, eg copy fake frontbuffer. */ void (*flush_frontbuffer)( struct pipe_winsys *sws, - struct pipe_surface *surf ); + struct pipe_surface *surf, + void *context_private ); /** Debug output */ void (*printf)( struct pipe_winsys *sws, diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c index cae53c70db..ea6b06a93c 100644 --- a/src/mesa/pipe/xlib/xm_winsys.c +++ b/src/mesa/pipe/xlib/xm_winsys.c @@ -168,7 +168,7 @@ xm_flush_frontbuffer(struct pipe_winsys *pws, } static void -xm_wait_idle(struct pipe_winsys *pws) +xm_wait_idle(struct pipe_winsys *pws, void *context_private) { /* no-op */ } diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 819957a1ee..6354306e75 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -71,7 +71,8 @@ void st_flush( struct st_context *st ) /* Hook for copying "fake" frontbuffer if necessary: */ - st->pipe->winsys->flush_frontbuffer( st->pipe->winsys, front_surf ); + st->pipe->winsys->flush_frontbuffer( st->pipe->winsys, front_surf, + st->pipe->private ); st->flags.frontbuffer_dirty = 0; } } @@ -94,7 +95,7 @@ static void st_Finish(GLcontext *ctx) struct st_context *st = ctx->st; st_flush( st ); - st->pipe->winsys->wait_idle( st->pipe->winsys ); + st->pipe->winsys->wait_idle( st->pipe->winsys, st->pipe->private ); } |