Commit 10c62bf0 authored by Brian's avatar Brian

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...
parent 03cfeb31
......@@ -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;
......
......@@ -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);
}
......
......@@ -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;
};
......
......@@ -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,
......
......@@ -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);
}
......@@ -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 * );
/*
......
......@@ -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,
......
......@@ -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 */
}
......
......@@ -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 );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment