summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2003-04-27 14:21:21 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2003-04-27 14:21:21 +0000
commit24a598b5affb8be8e04fc539c59f305677f53705 (patch)
treef6bb33a390ab5804c5f73e4879bd69e1e0b00ea5
parent5e2bc7d1c04a516dce19f91993ef83a743ac0a3f (diff)
For subsetted driver, when client is unmapped, unmap our dma buffers.
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_lock.h2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_state.c3
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_subset.h2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_subset_select.c105
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_subset_tex.c6
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_subset_vtx.c164
-rw-r--r--src/mesa/drivers/dri/radeon/server/radeon_dri.c27
7 files changed, 158 insertions, 151 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_lock.h b/src/mesa/drivers/dri/radeon/radeon_lock.h
index 61b74eae11..3dffa89bb1 100644
--- a/src/mesa/drivers/dri/radeon/radeon_lock.h
+++ b/src/mesa/drivers/dri/radeon/radeon_lock.h
@@ -90,6 +90,8 @@ extern int prevLockLine;
do { \
char __ret = 0; \
DEBUG_CHECK_LOCK(); \
+ if (0 && !rmesa->radeonScreen->buffers) \
+ fprintf(stderr, "LOCK_HARDWARE in %s -- no buffers\n", __FUNCTION__); \
DRM_CAS( rmesa->dri.hwLock, rmesa->dri.hwContext, \
(DRM_LOCK_HELD | rmesa->dri.hwContext), __ret ); \
if ( __ret ) \
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index 8c00f69947..f738903ec1 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -1066,6 +1066,8 @@ static void radeonViewport( GLcontext *ctx,
radeonUpdateWindow( ctx );
}
+
+#if _HAVE_FULL_GL
/**
* \brief Specify the depth range.
*
@@ -1082,6 +1084,7 @@ static void radeonDepthRange( GLcontext *ctx, GLclampd nearval,
{
radeonUpdateWindow( ctx );
}
+#endif
/*@}*/
diff --git a/src/mesa/drivers/dri/radeon/radeon_subset.h b/src/mesa/drivers/dri/radeon/radeon_subset.h
index 1b6e7bd432..c7f169281e 100644
--- a/src/mesa/drivers/dri/radeon/radeon_subset.h
+++ b/src/mesa/drivers/dri/radeon/radeon_subset.h
@@ -72,4 +72,6 @@ extern void radeonAgeTextures( radeonContextPtr rmesa, int heap );
extern void radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t );
+extern void radeonVtxfmtNotifyFocus( int have_focus );
+
#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_subset_select.c b/src/mesa/drivers/dri/radeon/radeon_subset_select.c
index c1f3535f53..5036531311 100644
--- a/src/mesa/drivers/dri/radeon/radeon_subset_select.c
+++ b/src/mesa/drivers/dri/radeon/radeon_subset_select.c
@@ -27,7 +27,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/* $Id: radeon_subset_select.c,v 1.1.2.6 2003/04/25 11:22:34 keithw Exp $ */
+/* $Id: radeon_subset_select.c,v 1.1.2.7 2003/04/27 14:21:22 keithw Exp $ */
#include "glheader.h"
@@ -958,102 +958,6 @@ void radeon_select_Install( GLcontext *ctx )
/*@}*/
-/**********************************************************************/
-/** \name Noop mode for operation without focus */
-/**********************************************************************/
-/*@{*/
-
-
-/**
- * \brief Process glBegin().
- *
- * \param mode primitive.
- */
-static void radeon_noop_Begin(GLenum mode)
-{
- GET_CURRENT_CONTEXT(ctx);
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
- if (mode > GL_POLYGON) {
- _mesa_error( ctx, GL_INVALID_ENUM, "glBegin" );
- return;
- }
-
- if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
- _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
- return;
- }
-
- if (rmesa->dri.drawable->numClipRects) {
- radeonVtxfmtInit( ctx );
- ctx->Exec->Begin( mode );
- return;
- }
-
- fprintf(stderr, "%s\n", __FUNCTION__);
- ctx->Driver.CurrentExecPrimitive = mode;
-}
-
-/**
- * \brief Process glEnd().
- */
-static void radeon_noop_End(void)
-{
- GET_CURRENT_CONTEXT(ctx);
- ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
-}
-
-/**
- * \brief Discards all arguments.
- */
-static void radeon_noop_Vertex2f(GLfloat x, GLfloat y)
-{
-}
-
-/**
- * \brief Discards all arguments.
- */
-static void radeon_noop_Vertexfv(const GLfloat * v)
-{
-}
-
-/**
- * \brief Discards all arguments.
- */
-static void radeon_noop_Vertex3f(GLfloat x, GLfloat y, GLfloat z)
-{
-}
-
-/**
- * \brief Install the noop callbacks.
- *
- * \param ctx GL context.
- *
- * Installs the noop callbacks into the glapi table. These functions
- * will not attempt to emit any DMA vertices, but will keep internal
- * GL state uptodate. Borrows heavily from the select code.
- */
-static void radeon_noop_Install( GLcontext *ctx )
-{
- struct _glapi_table *exec = ctx->Exec;
-
- exec->Color3f = radeon_select_Color3f;
- exec->Color3fv = radeon_select_Color3fv;
- exec->Color4f = radeon_select_Color4f;
- exec->Color4fv = radeon_select_Color4fv;
- exec->TexCoord2f = radeon_select_TexCoord2f;
- exec->TexCoord2fv = radeon_select_TexCoord2fv;
- exec->Vertex2f = radeon_noop_Vertex2f;
- exec->Vertex2fv = radeon_noop_Vertexfv;
- exec->Vertex3f = radeon_noop_Vertex3f;
- exec->Vertex3fv = radeon_noop_Vertexfv;
- exec->Begin = radeon_noop_Begin;
- exec->End = radeon_noop_End;
-
- ctx->Driver.FlushVertices = radeonSelectFlushVertices;
-}
-
-/*@}*/
/**
* \brief Set rasterization mode.
@@ -1068,14 +972,9 @@ static void radeon_noop_Install( GLcontext *ctx )
*/
static void radeonRenderMode( GLcontext *ctx, GLenum mode )
{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
switch (mode) {
case GL_RENDER:
- if (rmesa->dri.drawable->numClipRects)
- radeonVtxfmtInit( ctx );
- else
- radeon_noop_Install( ctx );
+ radeonVtxfmtInit( ctx );
break;
case GL_SELECT:
radeon_select_Install( ctx );
diff --git a/src/mesa/drivers/dri/radeon/radeon_subset_tex.c b/src/mesa/drivers/dri/radeon/radeon_subset_tex.c
index 8439e5056e..e98908a031 100644
--- a/src/mesa/drivers/dri/radeon/radeon_subset_tex.c
+++ b/src/mesa/drivers/dri/radeon/radeon_subset_tex.c
@@ -96,6 +96,8 @@ void radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t )
*/
static void radeonSwapOutTexObj( radeonContextPtr rmesa, radeonTexObjPtr t )
{
+ fprintf(stderr, "%s memblock: %p\n", __FUNCTION__, t->memBlock);
+
if ( t->memBlock ) {
mmFreeMem( t->memBlock );
t->memBlock = NULL;
@@ -211,6 +213,10 @@ static void radeonSetTexImages( radeonContextPtr rmesa,
GLint log2Width, log2Height;
GLuint txformat = 0;
+ /* This code cannot be reached once we have lost focus
+ */
+ assert(rmesa->radeonScreen->buffers);
+
/* Set the hardware texture format
*/
switch (baseImage->TexFormat->MesaFormat) {
diff --git a/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c b/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c
index 3d0d850661..abc984bc0f 100644
--- a/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c
+++ b/src/mesa/drivers/dri/radeon/radeon_subset_vtx.c
@@ -660,6 +660,7 @@ static void radeon_End( void )
}
+
/**
* \brief Flush vertices.
*
@@ -812,40 +813,6 @@ static void radeon_TexCoord2fv( const GLfloat *v )
radeon_TexCoord2f( v[0], v[1] );
}
-/**
- * \brief Setup the GL context callbacks.
- *
- * \param ctx GL context.
- *
- * Setups the GL context callbacks and links _glapi_table entries related to
- * the glBegin()/glEnd() pairs to the functions in this module.
- *
- * Called by radeonCreateContext() and radeonRenderMode().
- */
-void radeonVtxfmtInit( GLcontext *ctx )
-{
- struct _glapi_table *exec = ctx->Exec;
-
- exec->Color3f = radeon_Color3f;
- exec->Color3fv = radeon_Color3fv;
- exec->Color4f = radeon_Color4f;
- exec->Color4fv = radeon_Color4fv;
- exec->TexCoord2f = radeon_TexCoord2f;
- exec->TexCoord2fv = radeon_TexCoord2fv;
- exec->Vertex2f = radeon_Vertex2f;
- exec->Vertex2fv = radeon_Vertex2fv;
- exec->Vertex3f = radeon_Vertex3f;
- exec->Vertex3fv = radeon_Vertex3fv;
- exec->Begin = radeon_Begin;
- exec->End = radeon_End;
-
- vb.context = ctx;
-
- ctx->Driver.FlushVertices = radeonFlushVertices;
- ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
- radeonVtxfmtValidate( ctx );
- notify_noop();
-}
/**
* No-op.
@@ -910,3 +877,132 @@ void radeonSubsetVtxEnableTCL( radeonContextPtr rmesa, GLboolean flag )
{
rmesa->tcl.tcl_flag = flag ? RADEON_CP_VC_CNTL_TCL_ENABLE : 0;
}
+
+
+
+/**********************************************************************/
+/** \name Noop mode for operation without focus */
+/**********************************************************************/
+/*@{*/
+
+
+/**
+ * \brief Process glBegin().
+ *
+ * \param mode primitive.
+ */
+static void radeon_noop_Begin(GLenum mode)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (mode > GL_POLYGON) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBegin" );
+ return;
+ }
+
+ if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
+ return;
+ }
+
+ ctx->Driver.CurrentExecPrimitive = mode;
+}
+
+/**
+ * \brief Process glEnd().
+ */
+static void radeon_noop_End(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
+}
+
+
+/**
+ * \brief Install the noop callbacks.
+ *
+ * \param ctx GL context.
+ *
+ * Installs the noop callbacks into the glapi table. These functions
+ * will not attempt to emit any DMA vertices, but will keep internal
+ * GL state uptodate. Borrows heavily from the select code.
+ */
+static void radeon_noop_Install( GLcontext *ctx )
+{
+ ctx->Exec->Begin = radeon_noop_Begin;
+ ctx->Exec->End = radeon_noop_End;
+
+ vb.texcoordptr = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ vb.floatcolorptr = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
+
+ notify_noop();
+}
+
+
+/**
+ * \brief Setup the GL context callbacks.
+ *
+ * \param ctx GL context.
+ *
+ * Setups the GL context callbacks and links _glapi_table entries related to
+ * the glBegin()/glEnd() pairs to the functions in this module.
+ *
+ * Called by radeonCreateContext() and radeonRenderMode().
+ */
+void radeonVtxfmtInit( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct _glapi_table *exec = ctx->Exec;
+
+ exec->Color3f = radeon_Color3f;
+ exec->Color3fv = radeon_Color3fv;
+ exec->Color4f = radeon_Color4f;
+ exec->Color4fv = radeon_Color4fv;
+ exec->TexCoord2f = radeon_TexCoord2f;
+ exec->TexCoord2fv = radeon_TexCoord2fv;
+ exec->Vertex2f = radeon_Vertex2f;
+ exec->Vertex2fv = radeon_Vertex2fv;
+ exec->Vertex3f = radeon_Vertex3f;
+ exec->Vertex3fv = radeon_Vertex3fv;
+ exec->Begin = radeon_Begin;
+ exec->End = radeon_End;
+
+ vb.context = ctx;
+
+ ctx->Driver.FlushVertices = radeonFlushVertices;
+ ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
+
+ if (rmesa->radeonScreen->buffers) {
+ radeonVtxfmtValidate( ctx );
+ notify_noop();
+ }
+ else
+ radeon_noop_Install( ctx );
+}
+
+
+/*@}*/
+
+
+void radeonVtxfmtNotifyFocus( int have_focus )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ fprintf(stderr, "%s: %d\n", __FUNCTION__, have_focus);
+
+ if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1)
+ radeon_End();
+
+ if (have_focus && !rmesa->radeonScreen->buffers) {
+ rmesa->radeonScreen->buffers = drmMapBufs( rmesa->dri.fd );
+ }
+ else if (!have_focus && rmesa->radeonScreen->buffers) {
+ RADEON_FIREVERTICES( rmesa );
+ drmUnmapBufs( rmesa->radeonScreen->buffers );
+ rmesa->radeonScreen->buffers = 0;
+ }
+
+ radeonVtxfmtInit( ctx );
+}
+
diff --git a/src/mesa/drivers/dri/radeon/server/radeon_dri.c b/src/mesa/drivers/dri/radeon/server/radeon_dri.c
index 5a733a3fb0..e3aee7b9d9 100644
--- a/src/mesa/drivers/dri/radeon/server/radeon_dri.c
+++ b/src/mesa/drivers/dri/radeon/server/radeon_dri.c
@@ -782,7 +782,6 @@ static int RADEONScreenInit( struct DRIDriverContextRec *ctx, RADEONInfoPtr info
return 0;
}
-
if (drmAddMap( ctx->drmFD,
0,
ctx->shared.SAREASize,
@@ -814,12 +813,17 @@ static int RADEONScreenInit( struct DRIDriverContextRec *ctx, RADEONInfoPtr info
(drmHandle)ctx->FBStart,
ctx->FBSize,
DRM_FRAME_BUFFER,
+#if _HAVE_FULL_GL
0,
+#else
+ DRM_READ_ONLY,
+#endif
&ctx->shared.hFrameBuffer) < 0)
{
fprintf(stderr, "[drm] drmAddMap framebuffer failed\n");
return 0;
}
+
fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n",
ctx->shared.hFrameBuffer);
@@ -883,12 +887,6 @@ static int RADEONScreenInit( struct DRIDriverContextRec *ctx, RADEONInfoPtr info
/* Initialize kernel agp memory manager */
RADEONDRIAgpHeapInit(ctx, info);
- fprintf(stderr, "calling RADEONEngineRestore from %s\n", __FUNCTION__);
- if (0 && !RADEONEngineRestore( ctx )) {
- DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext);
- return 0;
- }
-
/* Initialize the SAREA private data structure */
{
RADEONSAREAPrivPtr pSAREAPriv;
@@ -903,18 +901,15 @@ static int RADEONScreenInit( struct DRIDriverContextRec *ctx, RADEONInfoPtr info
* the clear ioctl to do this, but would need to setup hw state
* first.
*/
- memset(ctx->FBAddress + info->frontOffset,
+ memset((char *)ctx->FBAddress + info->frontOffset,
0,
info->frontPitch * ctx->cpp * ctx->shared.virtualHeight );
- memset(ctx->FBAddress + info->backOffset,
+ memset((char *)ctx->FBAddress + info->backOffset,
0,
info->backPitch * ctx->cpp * ctx->shared.virtualHeight );
- /* Can release the lock now */
-/* DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); */
-
/* This is the struct passed to radeon_dri.so for its initialization */
ctx->driverClientMsg = malloc(sizeof(RADEONDRIRec));
ctx->driverClientMsgSize = sizeof(RADEONDRIRec);
@@ -945,6 +940,8 @@ static int RADEONScreenInit( struct DRIDriverContextRec *ctx, RADEONInfoPtr info
pRADEONDRI->agpTexOffset = info->agpTexStart;
pRADEONDRI->sarea_priv_offset = sizeof(XF86DRISAREARec);
+ /* Don't release the lock now - let the VT switch handler do it. */
+
return 1;
}
@@ -1231,18 +1228,20 @@ static void radeonHaltFBDev( struct DRIDriverContextRec *ctx )
}
+extern void radeonVtxfmtNotifyFocus( int );
/**
* \brief Exported driver interface for Mini GLX.
*
* \sa DRIDriverRec.
*/
-struct DRIDriverRec __driDRIDriver = {
+struct DRIDriverRec __driDriver = {
radeonInitScreenConfigs,
radeonValidateMode,
radeonPostValidateMode,
radeonInitFBDev,
radeonHaltFBDev,
RADEONEngineShutdown,
- RADEONEngineRestore
+ RADEONEngineRestore,
+ radeonVtxfmtNotifyFocus,
};