From 1f01a4b3b685a649d60a6a18235917619ced9164 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 12 Dec 2002 14:22:02 +0000 Subject: [PATCH] miniglx test will run with fb_dri.so (ie. swrast) driver, but output is garbled. --- src/mesa/main/context.c | 31 +++++++---- src/mesa/tnl/t_context.c | 3 +- src/mesa/tnl/t_imm_api.c | 4 +- src/miniglx/Makefile | 19 +++---- src/miniglx/NOTES | 53 +++++++----------- src/miniglx/dri_util.c | 2 + src/miniglx/dristruct.h | 104 ----------------------------------- src/miniglx/miniglx.c | 7 ++- src/miniglx/xf86drm.c | 115 --------------------------------------- 9 files changed, 56 insertions(+), 282 deletions(-) delete mode 100644 src/miniglx/dristruct.h diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 35964e63db7..e9334517200 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.188.2.1 2002/11/19 15:25:16 brianp Exp $ */ +/* $Id: context.c,v 1.188.2.1.2.1 2002/12/12 14:22:02 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -2203,6 +2203,8 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer, if (MESA_VERBOSE) _mesa_debug(newCtx, "_mesa_make_current2()\n"); + fprintf(stderr, "%s\n", __FUNCTION__); + /* Check that the context's and framebuffer's visuals are compatible. * We could do a lot more checking here but this'll catch obvious * problems. @@ -2245,13 +2247,14 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer, /* ask device driver for size of output buffer */ (*newCtx->Driver.GetBufferSize)( drawBuffer, &bufWidth, &bufHeight ); - if (drawBuffer->Width == bufWidth && drawBuffer->Height == bufHeight) - return; /* size is as expected */ + if (drawBuffer->Width != bufWidth || + drawBuffer->Height != bufHeight) { - drawBuffer->Width = bufWidth; - drawBuffer->Height = bufHeight; + drawBuffer->Width = bufWidth; + drawBuffer->Height = bufHeight; - newCtx->Driver.ResizeBuffers( drawBuffer ); + newCtx->Driver.ResizeBuffers( drawBuffer ); + } } if (readBuffer != drawBuffer && @@ -2262,17 +2265,21 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer, /* ask device driver for size of output buffer */ (*newCtx->Driver.GetBufferSize)( readBuffer, &bufWidth, &bufHeight ); - if (readBuffer->Width == bufWidth && readBuffer->Height == bufHeight) - return; /* size is as expected */ + if (readBuffer->Width != bufWidth || + readBuffer->Height != bufHeight) { - readBuffer->Width = bufWidth; - readBuffer->Height = bufHeight; + readBuffer->Width = bufWidth; + readBuffer->Height = bufHeight; - newCtx->Driver.ResizeBuffers( readBuffer ); + newCtx->Driver.ResizeBuffers( readBuffer ); + } } } - /* This is only for T&L - a bit out of place, or misnamed (BP) */ + /* Alert the driver - usually passed on to the sw t&l module, + * but also used to detect threaded cases in the radeon codegen + * hw t&l module. + */ if (newCtx->Driver.MakeCurrent) newCtx->Driver.MakeCurrent( newCtx, drawBuffer, readBuffer ); diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 4b5df8ffda6..d86a9fb253f 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -1,4 +1,4 @@ -/* $Id: t_context.c,v 1.30 2002/10/29 20:29:01 brianp Exp $ */ +/* $Id: t_context.c,v 1.30.4.1 2002/12/12 14:22:04 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -56,6 +56,7 @@ _tnl_MakeCurrent( GLcontext *ctx, GLframebuffer *drawBuffer, GLframebuffer *readBuffer ) { + fprintf(stderr, "%s\n", __FUNCTION__); #ifndef THREADS SET_IMMEDIATE( ctx, TNL_CURRENT_IM(ctx) ); #endif diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index 3bdcd38d72f..11fd74bde51 100644 --- a/src/mesa/tnl/t_imm_api.c +++ b/src/mesa/tnl/t_imm_api.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_api.c,v 1.35 2002/10/29 20:29:01 brianp Exp $ */ +/* $Id: t_imm_api.c,v 1.35.4.1 2002/12/12 14:22:04 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -606,8 +606,6 @@ static void _tnl_Normal3fv( const GLfloat *v ) { NORMALF( v[0], v[1], v[2] ); -/* struct immediate *IM = (struct immediate *)(((GLcontext *) _glapi_Context)->swtnl_im); */ -/* IM->Flag[IM->Count] = VERT_NORM; */ } diff --git a/src/miniglx/Makefile b/src/miniglx/Makefile index ccd77bf5246..31726b02acf 100644 --- a/src/miniglx/Makefile +++ b/src/miniglx/Makefile @@ -1,6 +1,7 @@ # Build a subset DRI-based libGL.so library. # Indirect rendering not supported, etc. +MESA=../.. SOURCES = dispatch.c \ dri_util.c \ @@ -10,25 +11,23 @@ SOURCES = dispatch.c \ OBJS = $(SOURCES:.c=.o) -INCLUDES = -I. -I.. -I../../include + +INCLUDES = -I. -I.. -I$(MESA)/include CFLAGS = -c -g $(INCLUDES) -MD LIBS = -ldl -default: libGL.so.1.2 libGL.so.1 libGL.so +default: libGL.so.1.2 libGL.so.1.2: $(OBJS) Makefile - gcc -shared -Wl,-soname,libGL.so -Wl,-Bsymbolic $(OBJS) $(LIBS) -o $@ - -libGL.so.1: - ln -s libGL.so.1.2 libGL.so.1 - -libGL.so: - ln -s libGL.so.1 libGL.so - + gcc -shared -Wl,-soname,libGL.so -Wl,-Bsymbolic $(OBJS) $(LIBS) -o $@ + rm -f $(MESA)/lib/libGL.so* + install -D libGL.so.1.2 $(MESA)/lib/libGL.so.1.2 + ln -s libGL.so.1.2 $(MESA)/lib/libGL.so.1 + ln -s libGL.so.1 $(MESA)/lib/libGL.so #miniglx.a: $(OBJECTS) Makefile # rm -f $@ && ar rcv $@ $(OBJECTS) && ranlib $@ diff --git a/src/miniglx/NOTES b/src/miniglx/NOTES index ee0d84e3be5..18a585b0307 100644 --- a/src/miniglx/NOTES +++ b/src/miniglx/NOTES @@ -11,55 +11,40 @@ dri_util.h - Previously part of the driver.so file. - Contains a lot of window-system specific code, but has only - a single entrypoint. Better located in libGL.so? + a single entrypoint. By moving this to live in libGL.so, + these details are made more "private" to libGL.so. We'd + probably have to reproduce an unfeasible amount of X's + clientside internals to keep this in the driver.so file. -glxclient.h - - removed - -glxext.c - - removed - miniglx.c - - Miniglx bindings. Not currently referenced by the makefile. + - Miniglx bindings. Includes things like XOpenDisplay as well + as more standard GLX fare. miniglxP.h - Cut down version of glxclient.h - -SERVER-SIDE CODE ----------------- - -dri.c - - Code from the X server for - - kernel module loading & initialization. - - responses to driver.so queries (see XF86dri.c) - -dri.h -dristruct.h - - Structs for dri.c - - - -XF86dri.c - - - The XF86DRI* commands. In normal dri, these send protocol - requests to the server. Here they can talk directly to - dri.c. In fact they should probably be pulled directly into - dri.c +drm.h +sarea.h + - kernel interfaces. Note that not all drivers will talk to a + kernel module xf86drm.c - The drm* commands. These are also currently present in the - loadable driver. Some of these are called by dri.c via - radeon_dri.c. May be possible to load the driver.so module - before calling any of these, or else to remove them from the - driver.so module and have them live here (** compatibility - concerns). + loadable driver. Some of these are called by dri_util.c. + May be possible to load the driver.so module before calling + any of these, or else to remove them from the driver.so + module and have them live here (** compatibility concerns). xf86drm.h - Interfaces for xf86drm.c. +These build a libGL.so which can load binary modules for an fbdev +environment. Those binary modules *could* work with X11, but +currently are incompatible with the X11 modules due to the movement of +shared code into libGL.so -- in particular dri_util.c and xf86drm.c +which were previously part of the loadable driver. diff --git a/src/miniglx/dri_util.c b/src/miniglx/dri_util.c index dc53cb94db5..b1bbea45fe5 100644 --- a/src/miniglx/dri_util.c +++ b/src/miniglx/dri_util.c @@ -696,6 +696,8 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, __DRIscreenPrivate *psp; char *driverName; + fprintf(stderr, "%s\n", __FUNCTION__); + psp = (__DRIscreenPrivate *)calloc(1, sizeof(__DRIscreenPrivate)); if (!psp) return NULL; diff --git a/src/miniglx/dristruct.h b/src/miniglx/dristruct.h deleted file mode 100644 index ba3b9704afd..00000000000 --- a/src/miniglx/dristruct.h +++ /dev/null @@ -1,104 +0,0 @@ -/* $XFree86: xc/programs/Xserver/GL/dri/dristruct.h,v 1.11 2002/09/18 18:14:51 martin Exp $ */ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Jens Owen - * - */ - -#ifndef DRI_STRUCT_H -#define DRI_STRUCT_H - -#include "xf86drm.h" - - -#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) \ - ((DRIWindowPrivIndex < 0) ? \ - NULL : \ - ((DRIDrawablePrivPtr)((pWin)->devPrivates[DRIWindowPrivIndex].ptr))) - -#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \ - ((DRIPixmapPrivIndex < 0) ? \ - NULL : \ - ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIWindowPrivIndex].ptr))) - -typedef struct _DRIDrawablePrivRec -{ - drmDrawable hwDrawable; - int drawableIndex; - ScreenPtr pScreen; - int refCount; -} DRIDrawablePrivRec, *DRIDrawablePrivPtr; - -struct _DRIContextPrivRec -{ - drmContext hwContext; - ScreenPtr pScreen; - Bool valid3D; - DRIContextFlags flags; - void** pContextStore; -}; - -#define DRI_SCREEN_PRIV(pScreen) \ - ((DRIScreenPrivIndex < 0) ? \ - NULL : \ - ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr))) - -#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \ - (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr)) - - -typedef struct _DRIScreenPrivRec -{ - Bool directRenderingSupport; - int drmFD; /* File descriptor for /dev/video/? */ - drmHandle hSAREA; /* Handle to SAREA, for mapping */ - XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */ - drmHandle hFrameBuffer; /* Handle to framebuffer, for mapping */ - drmContext myContext; /* DDX Driver's context */ - DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */ - DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */ - void** hiddenContextStore; /* hidden X context */ - void** partial3DContextStore; /* parital 3D context */ - DRIInfoPtr pDriverInfo; - int nrWindows; - XF86DRIClipRectRec private_buffer_rect; /* management of private buffers */ - DrawablePtr fullscreen; /* pointer to fullscreen drawable */ - XF86DRIClipRectRec fullscreen_rect; /* fake rect for fullscreen mode */ - DRIWrappedFuncsRec wrap; - DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES]; - DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */ - Bool createDummyCtx; - Bool createDummyCtxPriv; - Bool grabbedDRILock; - Bool drmSIGIOHandlerInstalled; - Bool wrapped; -} DRIScreenPrivRec, *DRIScreenPrivPtr; - -#endif /* DRI_STRUCT_H */ diff --git a/src/miniglx/miniglx.c b/src/miniglx/miniglx.c index 8c145d8375f..d95256fae61 100644 --- a/src/miniglx/miniglx.c +++ b/src/miniglx/miniglx.c @@ -1,4 +1,4 @@ -/* $Id: miniglx.c,v 1.1.4.10 2002/12/09 22:33:09 brianp Exp $ */ +/* $Id: miniglx.c,v 1.1.4.11 2002/12/12 14:22:03 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -532,7 +532,7 @@ XOpenDisplay( const char *display_name ) return NULL; } -#if 0 +#if 1 /* this effectively initializes the DRI driver - just an idea */ dpy->driScreen.private = (*dpy->createScreen)(dpy, 0, &(dpy->driScreen), dpy->numConfigs, @@ -993,10 +993,11 @@ glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx) ctx->drawBuffer = drawable; ctx->curBuffer = drawable; } - else { + else if (ctx && dpy) { /* unbind */ (*ctx->driContext.bindContext)(dpy, 0, 0, 0); } + return True; } diff --git a/src/miniglx/xf86drm.c b/src/miniglx/xf86drm.c index 40d94841829..a644f9608b7 100644 --- a/src/miniglx/xf86drm.c +++ b/src/miniglx/xf86drm.c @@ -1225,123 +1225,8 @@ int drmGetClient(int fd, int idx, int *auth, int *pid, int *uid, int drmGetStats(int fd, drmStatsT *stats) { - drm_stats_t s; - int i; - - if (ioctl(fd, DRM_IOCTL_GET_STATS, &s)) return -errno; - stats->count = 0; memset(stats, 0, sizeof(*stats)); - if (s.count > sizeof(stats->data)/sizeof(stats->data[0])) - return -1; - -#define SET_VALUE \ - stats->data[i].long_format = "%-20.20s"; \ - stats->data[i].rate_format = "%8.8s"; \ - stats->data[i].isvalue = 1; \ - stats->data[i].verbose = 0 - -#define SET_COUNT \ - stats->data[i].long_format = "%-20.20s"; \ - stats->data[i].rate_format = "%5.5s"; \ - stats->data[i].isvalue = 0; \ - stats->data[i].mult_names = "kgm"; \ - stats->data[i].mult = 1000; \ - stats->data[i].verbose = 0 - -#define SET_BYTE \ - stats->data[i].long_format = "%-20.20s"; \ - stats->data[i].rate_format = "%5.5s"; \ - stats->data[i].isvalue = 0; \ - stats->data[i].mult_names = "KGM"; \ - stats->data[i].mult = 1024; \ - stats->data[i].verbose = 0 - - - stats->count = s.count; - for (i = 0; i < s.count; i++) { - stats->data[i].value = s.data[i].value; - switch (s.data[i].type) { - case _DRM_STAT_LOCK: - stats->data[i].long_name = "Lock"; - stats->data[i].rate_name = "Lock"; - SET_VALUE; - break; - case _DRM_STAT_OPENS: - stats->data[i].long_name = "Opens"; - stats->data[i].rate_name = "O"; - SET_COUNT; - stats->data[i].verbose = 1; - break; - case _DRM_STAT_CLOSES: - stats->data[i].long_name = "Closes"; - stats->data[i].rate_name = "Lock"; - SET_COUNT; - stats->data[i].verbose = 1; - break; - case _DRM_STAT_IOCTLS: - stats->data[i].long_name = "Ioctls"; - stats->data[i].rate_name = "Ioc/s"; - SET_COUNT; - break; - case _DRM_STAT_LOCKS: - stats->data[i].long_name = "Locks"; - stats->data[i].rate_name = "Lck/s"; - SET_COUNT; - break; - case _DRM_STAT_UNLOCKS: - stats->data[i].long_name = "Unlocks"; - stats->data[i].rate_name = "Unl/s"; - SET_COUNT; - break; - case _DRM_STAT_IRQ: - stats->data[i].long_name = "IRQs"; - stats->data[i].rate_name = "IRQ/s"; - SET_COUNT; - break; - case _DRM_STAT_PRIMARY: - stats->data[i].long_name = "Primary Bytes"; - stats->data[i].rate_name = "PB/s"; - SET_BYTE; - break; - case _DRM_STAT_SECONDARY: - stats->data[i].long_name = "Secondary Bytes"; - stats->data[i].rate_name = "SB/s"; - SET_BYTE; - break; - case _DRM_STAT_DMA: - stats->data[i].long_name = "DMA"; - stats->data[i].rate_name = "DMA/s"; - SET_COUNT; - break; - case _DRM_STAT_SPECIAL: - stats->data[i].long_name = "Special DMA"; - stats->data[i].rate_name = "dma/s"; - SET_COUNT; - break; - case _DRM_STAT_MISSED: - stats->data[i].long_name = "Miss"; - stats->data[i].rate_name = "Ms/s"; - SET_COUNT; - break; - case _DRM_STAT_VALUE: - stats->data[i].long_name = "Value"; - stats->data[i].rate_name = "Value"; - SET_VALUE; - break; - case _DRM_STAT_BYTE: - stats->data[i].long_name = "Bytes"; - stats->data[i].rate_name = "B/s"; - SET_BYTE; - break; - case _DRM_STAT_COUNT: - default: - stats->data[i].long_name = "Count"; - stats->data[i].rate_name = "Cnt/s"; - SET_COUNT; - break; - } - } return 0; }