Merge remote-tracking branch 'jturney/master'

This commit is contained in:
Keith Packard 2011-07-13 11:44:15 -07:00
commit 01dbf2514a
12 changed files with 128 additions and 53 deletions

View File

@ -142,7 +142,6 @@ struct __GLXscreen {
char *GLextensions; char *GLextensions;
char *GLXvendor; char *GLXvendor;
char *GLXversion;
char *GLXextensions; char *GLXextensions;
/** /**

View File

@ -43,7 +43,6 @@ typedef struct {
GLint *isGLXvis; GLint *isGLXvis;
char *GLXvendor; char *GLXvendor;
char *GLXversion;
char *GLXextensions; char *GLXextensions;
} __GLXscreenInfo; } __GLXscreenInfo;

View File

@ -477,7 +477,8 @@ static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
__glXScreenInit(&screen->base, pScreen); __glXScreenInit(&screen->base, pScreen);
screen->base.GLXversion = strdup("1.4"); screen->base.GLXmajor = 1;
screen->base.GLXminor = 4;
screen->base.GLXextensions = strdup("GLX_SGIX_fbconfig " screen->base.GLXextensions = strdup("GLX_SGIX_fbconfig "
"GLX_SGIS_multisample " "GLX_SGIS_multisample "
"GLX_ARB_multisample " "GLX_ARB_multisample "

View File

@ -16,7 +16,11 @@ if XWIN_MULTIWINDOWEXTWM
DEFS_MULTIWINDOWEXTWM = -DXWIN_MULTIWINDOWEXTWM DEFS_MULTIWINDOWEXTWM = -DXWIN_MULTIWINDOWEXTWM
endif endif
DEFS = $(DEFS_MULTIWINDOW) $(DEFS_MULTIWINDOWEXTWM) if XWIN_GLX_WINDOWS
DEFS_GLX_WINDOWS = -DXWIN_GLX_WINDOWS
endif
DEFS = $(DEFS_MULTIWINDOW) $(DEFS_MULTIWINDOWEXTWM) $(DEFS_GLX_WINDOWS)
INCLUDES = -I$(top_srcdir)/miext/rootless INCLUDES = -I$(top_srcdir)/miext/rootless

View File

@ -312,7 +312,7 @@ if dispatchheader :
for d in sorted(dispatch.keys()) : for d in sorted(dispatch.keys()) :
if wrappers.has_key(d) : if wrappers.has_key(d) :
print ' SET_'+ d + '(disp, ' + prefix + d + 'Wrapper);' print ' SET_'+ d + '(disp, (void *)' + prefix + d + 'Wrapper);'
else : else :
print '#warning No wrapper for ' + prefix + d + ' !' print '#warning No wrapper for ' + prefix + d + ' !'

View File

@ -49,8 +49,17 @@
- pbuffer clobbering: we don't get async notification, but can we arrange to emit the - pbuffer clobbering: we don't get async notification, but can we arrange to emit the
event when we notice it's been clobbered? at the very least, check if it's been clobbered event when we notice it's been clobbered? at the very least, check if it's been clobbered
before using it? before using it?
- are the __GLXConfig * we get handed back ones we are made (so we can extend the structure - XGetImage() doesn't work on pixmaps; need to do more work to make the format and location
with privates?) Or are they created inside the GLX core as well? of the native pixmap compatible
- implement GLX_EXT_texture_from_pixmap in terms of WGL_ARB_render_texture
(not quite straightforward as we will have to create a pbuffer and copy the pixmap texture
into it)
*/
/*
Assumptions:
- the __GLXConfig * we get handed back ones we are made (so we can extend the structure
with privates) and never get created inside the GLX core
*/ */
/* /*
@ -80,6 +89,17 @@
#define NUM_ELEMENTS(x) (sizeof(x)/ sizeof(x[1])) #define NUM_ELEMENTS(x) (sizeof(x)/ sizeof(x[1]))
/* Not yet in w32api */
#ifndef PFD_SUPPORT_DIRECTDRAW
#define PFD_SUPPORT_DIRECTDRAW 0x00002000
#endif
#ifndef PFD_DIRECT3D_ACCELERATED
#define PFD_DIRECT3D_ACCELERATED 0x00004000
#endif
#ifndef PFD_SUPPORT_COMPOSITION
#define PFD_SUPPORT_COMPOSITION 0x00008000
#endif
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* /*
* structure definitions * structure definitions
@ -200,22 +220,25 @@ static
const char *glxWinErrorMessage(void) const char *glxWinErrorMessage(void)
{ {
static char errorbuffer[1024]; static char errorbuffer[1024];
unsigned int last_error = GetLastError();
if (!FormatMessage( if (!FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
NULL, NULL,
GetLastError(), last_error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 0,
(LPTSTR) &errorbuffer, (LPTSTR) &errorbuffer,
sizeof(errorbuffer), sizeof(errorbuffer),
NULL )) NULL ))
{ {
snprintf(errorbuffer, sizeof(errorbuffer), "Unknown error in FormatMessage: %08x!", (unsigned)GetLastError()); snprintf(errorbuffer, sizeof(errorbuffer), "Unknown error");
} }
if (errorbuffer[strlen(errorbuffer)-1] == '\n') if ((errorbuffer[strlen(errorbuffer)-1] == '\n') || (errorbuffer[strlen(errorbuffer)-1] == '\r'))
errorbuffer[strlen(errorbuffer)-1] = 0; errorbuffer[strlen(errorbuffer)-1] = 0;
sprintf(errorbuffer + strlen(errorbuffer), " (%08x)", last_error);
return errorbuffer; return errorbuffer;
} }
@ -247,6 +270,9 @@ static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd)
DUMP_PFD_FLAG(PFD_SWAP_COPY); DUMP_PFD_FLAG(PFD_SWAP_COPY);
DUMP_PFD_FLAG(PFD_SWAP_LAYER_BUFFERS); DUMP_PFD_FLAG(PFD_SWAP_LAYER_BUFFERS);
DUMP_PFD_FLAG(PFD_GENERIC_ACCELERATED); DUMP_PFD_FLAG(PFD_GENERIC_ACCELERATED);
DUMP_PFD_FLAG(PFD_SUPPORT_DIRECTDRAW);
DUMP_PFD_FLAG(PFD_DIRECT3D_ACCELERATED);
DUMP_PFD_FLAG(PFD_SUPPORT_COMPOSITION);
DUMP_PFD_FLAG(PFD_DEPTH_DONTCARE); DUMP_PFD_FLAG(PFD_DEPTH_DONTCARE);
DUMP_PFD_FLAG(PFD_DOUBLEBUFFER_DONTCARE); DUMP_PFD_FLAG(PFD_DOUBLEBUFFER_DONTCARE);
DUMP_PFD_FLAG(PFD_STEREO_DONTCARE); DUMP_PFD_FLAG(PFD_STEREO_DONTCARE);
@ -328,7 +354,7 @@ fbConfigsDump(unsigned int n, __GLXconfig *c)
{ {
unsigned int i = ((GLXWinConfig *)c)->pixelFormatIndex; unsigned int i = ((GLXWinConfig *)c)->pixelFormatIndex;
ErrorF("%3d %2x %2x " ErrorF("%3d %3x %3x "
"%-11s" "%-11s"
" %3d %3d %s %s %s %s %s " " %3d %3d %s %s %s %s %s "
"%2d %2d %2d %2d " "%2d %2d %2d %2d "
@ -651,17 +677,37 @@ glxWinScreenProbe(ScreenPtr pScreen)
screen->base.swapInterval = glxWinScreenSwapInterval; screen->base.swapInterval = glxWinScreenSwapInterval;
screen->base.pScreen = pScreen; screen->base.pScreen = pScreen;
// Creating the fbConfigs initializes screen->base.fbconfigs and screen->base.numFBConfigs
if (strstr(wgl_extensions, "WGL_ARB_pixel_format")) if (strstr(wgl_extensions, "WGL_ARB_pixel_format"))
{ {
glxWinCreateConfigsExt(hdc, screen); glxWinCreateConfigsExt(hdc, screen);
screen->has_WGL_ARB_pixel_format = TRUE;
/*
Some graphics drivers appear to advertise WGL_ARB_pixel_format,
but it doesn't work usefully, so we have to be prepared for it
to fail and fall back to using DescribePixelFormat()
*/
if (screen->base.numFBConfigs > 0)
{
screen->has_WGL_ARB_pixel_format = TRUE;
}
} }
else
if (screen->base.numFBConfigs <= 0)
{ {
glxWinCreateConfigs(hdc, screen); glxWinCreateConfigs(hdc, screen);
screen->has_WGL_ARB_pixel_format = FALSE; screen->has_WGL_ARB_pixel_format = FALSE;
} }
// Initializes screen->base.fbconfigs and screen->base.numFBConfigs
/*
If we still didn't get any fbConfigs, we can't provide GLX for this screen
*/
if (screen->base.numFBConfigs <= 0)
{
free(screen);
LogMessage(X_ERROR,"AIGLX: No fbConfigs could be made from native OpenGL pixel formats\n");
return NULL;
}
/* These will be set by __glXScreenInit */ /* These will be set by __glXScreenInit */
screen->base.visuals = NULL; screen->base.visuals = NULL;
@ -689,30 +735,26 @@ glxWinScreenProbe(ScreenPtr pScreen)
// //
// Override the GLX version (__glXScreenInit() sets it to "1.2") // Override the GLX version (__glXScreenInit() sets it to "1.2")
// if we have all the needed extensionsto operate as a higher version // if we have all the needed extensions to operate as a higher version
// //
// SGIX_fbconfig && SGIX_pbuffer && SGI_make_current_read -> 1.3 // SGIX_fbconfig && SGIX_pbuffer && SGI_make_current_read -> 1.3
// ARB_multisample -> 1.4 // ARB_multisample -> 1.4
// //
if (screen->has_WGL_ARB_pbuffer && glx_sgi_make_current_read) if (screen->has_WGL_ARB_pbuffer && glx_sgi_make_current_read)
{ {
free(screen->base.GLXversion);
if (screen->has_WGL_ARB_multisample) if (screen->has_WGL_ARB_multisample)
{ {
screen->base.GLXversion = strdup("1.4");
screen->base.GLXmajor = 1; screen->base.GLXmajor = 1;
screen->base.GLXminor = 4; screen->base.GLXminor = 4;
} }
else else
{ {
screen->base.GLXversion = strdup("1.3");
screen->base.GLXmajor = 1; screen->base.GLXmajor = 1;
screen->base.GLXminor = 3; screen->base.GLXminor = 3;
} }
LogMessage(X_INFO, "AIGLX: Set GLX version to %s\n", screen->base.GLXversion);
} }
} }
LogMessage(X_INFO, "AIGLX: Set GLX version to %d.%d\n", screen->base.GLXmajor, screen->base.GLXminor);
wglMakeCurrent(NULL, NULL); wglMakeCurrent(NULL, NULL);
wglDeleteContext(hglrc); wglDeleteContext(hglrc);
@ -970,7 +1012,7 @@ int glxWinReleaseTexImage(__GLXcontext *baseContext,
* lists with the old one... * lists with the old one...
*/ */
static void static Bool
glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawableTypeOverride) glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawableTypeOverride)
{ {
__GLXscreen *screen = gc->base.pGlxScreen; __GLXscreen *screen = gc->base.pGlxScreen;
@ -992,10 +1034,10 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (!SetPixelFormat(hdc, winConfig->pixelFormatIndex, NULL)) if (!SetPixelFormat(hdc, winConfig->pixelFormatIndex, NULL))
{ {
ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage()); ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
return; return FALSE;
} }
return; return TRUE;
} }
/* /*
@ -1027,7 +1069,7 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (fbConfigToPixelFormat(gc->base.config, &pfd, drawableTypeOverride)) if (fbConfigToPixelFormat(gc->base.config, &pfd, drawableTypeOverride))
{ {
ErrorF("glxWinSetPixelFormat: fbConfigToPixelFormat failed\n"); ErrorF("glxWinSetPixelFormat: fbConfigToPixelFormat failed\n");
return; return FALSE;
} }
if (glxWinDebugSettings.dumpPFD) if (glxWinDebugSettings.dumpPFD)
@ -1043,7 +1085,7 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (pixelFormat == 0) if (pixelFormat == 0)
{ {
ErrorF("ChoosePixelFormat error: %s\n", glxWinErrorMessage()); ErrorF("ChoosePixelFormat error: %s\n", glxWinErrorMessage());
return; return FALSE;
} }
GLWIN_DEBUG_MSG("ChoosePixelFormat: chose pixelFormatIndex %d", pixelFormat); GLWIN_DEBUG_MSG("ChoosePixelFormat: chose pixelFormatIndex %d", pixelFormat);
@ -1052,7 +1094,7 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (!SetPixelFormat(hdc, pixelFormat, &pfd)) if (!SetPixelFormat(hdc, pixelFormat, &pfd))
{ {
ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage()); ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
return; return FALSE;
} }
} }
else else
@ -1061,7 +1103,7 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (pixelFormat == 0) if (pixelFormat == 0)
{ {
ErrorF("wglChoosePixelFormat error: %s\n", glxWinErrorMessage()); ErrorF("wglChoosePixelFormat error: %s\n", glxWinErrorMessage());
return; return FALSE;
} }
GLWIN_DEBUG_MSG("wglChoosePixelFormat: chose pixelFormatIndex %d", pixelFormat); GLWIN_DEBUG_MSG("wglChoosePixelFormat: chose pixelFormatIndex %d", pixelFormat);
@ -1070,9 +1112,11 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (!SetPixelFormat(hdc, pixelFormat, NULL)) if (!SetPixelFormat(hdc, pixelFormat, NULL))
{ {
ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage()); ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
return; return FALSE;
} }
} }
return TRUE;
} }
static HDC static HDC
@ -1123,7 +1167,13 @@ glxWinMakeDC(__GLXWinContext *gc, __GLXWinDrawable *draw, HDC *hdc, HWND *hwnd)
gc->hwnd = *hwnd; gc->hwnd = *hwnd;
/* We must select a pixelformat, but SetPixelFormat can only be called once for a window... */ /* We must select a pixelformat, but SetPixelFormat can only be called once for a window... */
glxWinSetPixelFormat(gc, *hdc, 0, GLX_WINDOW_BIT); if (!glxWinSetPixelFormat(gc, *hdc, 0, GLX_WINDOW_BIT))
{
ErrorF("glxWinSetPixelFormat error: %s\n", glxWinErrorMessage());
ReleaseDC(*hwnd, *hdc);
*hdc = NULL;
return NULL;
}
} }
} }
break; break;

View File

@ -43,17 +43,14 @@
static type type##proc = NULL; static type type##proc = NULL;
#define PRERESOLVE(type, symbol) \ #define PRERESOLVE(type, symbol) \
type##proc = (type)wglGetProcAddress(symbol); \ type##proc = (type)wglGetProcAddress(symbol);
if (type##proc == NULL) \
ErrorF("wglwrap: Can't resolve \"%s\"\n", symbol); \
else \
ErrorF("wglwrap: Resolved \"%s\"\n", symbol);
#define RESOLVE_RET(type, symbol, retval) \ #define RESOLVE_RET(type, symbol, retval) \
if (type##proc == NULL) { \ if (type##proc == NULL) { \
__glXErrorCallBack(0); \ ErrorF("wglwrap: Can't resolve \"%s\"\n", symbol); \
return retval; \ __glXErrorCallBack(0); \
} return retval; \
}
#define RESOLVE(procname, symbol) RESOLVE_RET(procname, symbol,) #define RESOLVE(procname, symbol) RESOLVE_RET(procname, symbol,)

View File

@ -19,7 +19,7 @@ winCreateWindowsWindow (WindowPtr pWin);
*/ */
HWND winGetWindowInfo(WindowPtr pWin) HWND winGetWindowInfo(WindowPtr pWin)
{ {
winDebug("%s: pWin=%p\n", __FUNCTION__, pWin); winTrace("%s: pWin %p XID 0x%x\n", __FUNCTION__, pWin, pWin->drawable.id);
/* a real window was requested */ /* a real window was requested */
if (pWin != NULL) if (pWin != NULL)
@ -61,6 +61,9 @@ HWND winGetWindowInfo(WindowPtr pWin)
{ {
/* copy window handle */ /* copy window handle */
hwnd = pWinPriv->hWnd; hwnd = pWinPriv->hWnd;
/* mark GLX active on that hwnd */
pWinPriv->fWglUsed = TRUE;
} }
return hwnd; return hwnd;

View File

@ -208,6 +208,10 @@ Enable or disable the \fICtrl-Alt-Backspace\fP key combination as a
signal to exit the X Server. The \fICtrl-Alt-Backspace\fP key combination signal to exit the X Server. The \fICtrl-Alt-Backspace\fP key combination
is disabled by default. is disabled by default.
.TP 8 .TP 8
.B \-[no]wgl
Enable [disable] the GLX extension to use the native Windows WGL interface
for hardware accelerated OpenGL (AIGLX). (Experimental)
.TP 8
.B \-[no]winkill .B \-[no]winkill
Enable or disable the \fIAlt-F4\fP key combination as a signal to exit the Enable or disable the \fIAlt-F4\fP key combination as a signal to exit the
X Server. X Server.

View File

@ -110,7 +110,10 @@ winCreateWindowMultiWindow (WindowPtr pWin)
pWinPriv->hWnd = NULL; pWinPriv->hWnd = NULL;
pWinPriv->pScreenPriv = winGetScreenPriv(pWin->drawable.pScreen); pWinPriv->pScreenPriv = winGetScreenPriv(pWin->drawable.pScreen);
pWinPriv->fXKilled = FALSE; pWinPriv->fXKilled = FALSE;
#ifdef XWIN_GLX_WINDOWS
pWinPriv->fWglUsed = FALSE;
#endif
return fResult; return fResult;
} }
@ -372,9 +375,8 @@ winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent)
ScreenPtr pScreen = pWin->drawable.pScreen; ScreenPtr pScreen = pWin->drawable.pScreen;
winScreenPriv(pScreen); winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG winDebug("winReparentMultiWindow - pWin:%08x XID:0x%x, reparent from pWin:%08x XID:0x%x to pWin:%08x XID:0x%x\n",
ErrorF ("winReparentMultiWindow - pWin: %08x\n", pWin); pWin, pWin->drawable.id, pPriorParent, pPriorParent->drawable.id, pWin->parent, pWin->parent->drawable.id);
#endif
WIN_UNWRAP(ReparentWindow); WIN_UNWRAP(ReparentWindow);
if (pScreen->ReparentWindow) if (pScreen->ReparentWindow)
@ -498,9 +500,7 @@ winCreateWindowsWindow (WindowPtr pWin)
winInitMultiWindowClass(); winInitMultiWindowClass();
#if CYGMULTIWINDOW_DEBUG winDebug("winCreateWindowsTopLevelWindow - pWin:%08x XID:0x%x \n", pWin, pWin->drawable.id);
ErrorF ("winCreateWindowsWindow - pWin: %08x\n", pWin);
#endif
iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN); iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN); iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
@ -626,9 +626,7 @@ winDestroyWindowsWindow (WindowPtr pWin)
HICON hIcon; HICON hIcon;
HICON hIconSm; HICON hIconSm;
#if CYGMULTIWINDOW_DEBUG winDebug("winDestroyWindowsWindow - pWin:%08x XID:0x%x \n", pWin, pWin->drawable.id);
ErrorF ("winDestroyWindowsWindow\n");
#endif
/* Bail out if the Windows window handle is invalid */ /* Bail out if the Windows window handle is invalid */
if (pWinPriv->hWnd == NULL) if (pWinPriv->hWnd == NULL)
@ -652,6 +650,11 @@ winDestroyWindowsWindow (WindowPtr pWin)
winDestroyIcon(hIcon); winDestroyIcon(hIcon);
winDestroyIcon(hIconSm); winDestroyIcon(hIconSm);
#ifdef XWIN_GLX_WINDOWS
/* No longer note WGL used on this window */
pWinPriv->fWglUsed = FALSE;
#endif
/* Process all messages on our queue */ /* Process all messages on our queue */
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{ {
@ -663,9 +666,7 @@ winDestroyWindowsWindow (WindowPtr pWin)
winInDestroyWindowsWindow = oldstate; winInDestroyWindowsWindow = oldstate;
#if CYGMULTIWINDOW_DEBUG winDebug("winDestroyWindowsWindow - done\n");
ErrorF ("-winDestroyWindowsWindow\n");
#endif
} }

View File

@ -472,6 +472,20 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
return 0; return 0;
} }
#ifdef XWIN_GLX_WINDOWS
if (pWinPriv->fWglUsed)
{
/*
For regions which are being drawn by GL, the shadow framebuffer doesn't have the
correct bits, so don't bitblt from the shadow framebuffer
XXX: For now, just leave it alone, but ideally we want to send an expose event to
the window so it really redraws the affected region...
*/
ValidateRect(hwnd, &(ps.rcPaint));
}
else
#endif
/* Try to copy from the shadow buffer */ /* Try to copy from the shadow buffer */
if (!BitBlt (hdcUpdate, if (!BitBlt (hdcUpdate,
ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.left, ps.rcPaint.top,

View File

@ -80,6 +80,9 @@ typedef struct
winPrivScreenPtr pScreenPriv; winPrivScreenPtr pScreenPriv;
Bool fXKilled; Bool fXKilled;
HDWP hDwp; HDWP hDwp;
#ifdef XWIN_GLX_WINDOWS
Bool fWglUsed;
#endif
/* Privates used by primary fb DirectDraw server */ /* Privates used by primary fb DirectDraw server */
LPDDSURFACEDESC pddsdPrimary; LPDDSURFACEDESC pddsdPrimary;