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...
int fthrottle_mode;
GLboolean havePools;
struct pipe_context *pipe;
- struct pipe_winsys *winsys;
struct st_context *st_share = NULL;
if (sharedContextPrivate) {
__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) {
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;
#include "intel_batchbuffer.h"
#include "intel_batchpool.h"
#include "intel_swapbuffers.h"
+#include "intel_winsys.h"
#include "i830_dri.h"
#include "dri_bufpool.h"
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 |
(*glx_enable_extension) (psc, "GLX_SGI_make_current_read");
}
+ intelScreen->winsys = intel_create_pipe_winsys(sPriv->fd);
+
return GL_TRUE;
}
/* intelUnmapScreenRegions(intelScreen); */
if (intelScreen->havePools) {
- driPoolTakeDown(intelScreen->regionPool);
driPoolTakeDown(intelScreen->staticPool);
driPoolTakeDown(intelScreen->batchPool);
}
driOptionCache optionCache;
struct _DriBufferPool *batchPool;
- struct _DriBufferPool *regionPool;
struct _DriBufferPool *staticPool; /** for the X screen/framebuffer */
boolean havePools;
* which we need a rendering context, but none is currently bound.
*/
struct intel_context *dummyContext;
+
+ struct pipe_winsys *winsys;
};
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,
struct intel_pipe_winsys {
struct pipe_winsys winsys;
- struct intel_context *intel;
+ struct _DriBufferPool *regionPool;
};
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,
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);
}
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,
*/
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);
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 );
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);
+}
+
struct pipe_context {
struct pipe_winsys *winsys;
+ void *private; /** context private data (for DRI for example) */
+
void (*destroy)( struct pipe_context * );
/*
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,
}
static void
-xm_wait_idle(struct pipe_winsys *pws)
+xm_wait_idle(struct pipe_winsys *pws, void *context_private)
{
/* no-op */
}
/* 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;
}
}
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 );
}