diff options
Diffstat (limited to 'hw/xwin/glx/indirect.c')
-rw-r--r-- | hw/xwin/glx/indirect.c | 205 |
1 files changed, 128 insertions, 77 deletions
diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c index c86fcf191..46622e99e 100644 --- a/hw/xwin/glx/indirect.c +++ b/hw/xwin/glx/indirect.c @@ -104,8 +104,6 @@ typedef struct { int notOpenGL; - int rgbaFloat; - int unsignedRgbaFloat; int unknownPixelType; int unaccelerated; } PixelFormatRejectStats; @@ -298,23 +296,26 @@ static void fbConfigsDump(unsigned int n, __GLXconfig * c, PixelFormatRejectStats *rejects) { LogMessage(X_INFO, "%d fbConfigs\n", n); - LogMessage(X_INFO, "ignored pixel formats: %d not OpenGL, %d RBGA float, %d RGBA unsigned float, %d unknown pixel type, %d unaccelerated\n", - rejects->notOpenGL, rejects->rgbaFloat, rejects->unsignedRgbaFloat, - rejects->unknownPixelType, rejects->unaccelerated); + LogMessage(X_INFO, "ignored pixel formats: %d not OpenGL, %d unknown pixel type, %d unaccelerated\n", + rejects->notOpenGL, rejects->unknownPixelType, rejects->unaccelerated); if (g_iLogVerbose < 3) return; ErrorF - ("pxf vis fb render Ste aux accum MS drawable Group/\n"); + ("pxf vis fb render Ste aux accum MS drawable Group/ sRGB\n"); ErrorF - ("idx ID ID VisualType Depth Lvl RGB CI DB Swap reo R G B A Z S buf AR AG AB AA bufs num W P Pb Float Trans Caveat\n"); + ("idx ID ID VisualType Depth Lvl RGB CI DB Swap reo R G B A Z S buf AR AG AB AA bufs num W P Pb Float Trans Caveat cap \n"); ErrorF - ("-----------------------------------------------------------------------------------------------------------------------------\n"); + ("----------------------------------------------------------------------------------------------------------------------------------\n"); while (c != NULL) { unsigned int i = ((GLXWinConfig *) c)->pixelFormatIndex; + const char *float_col = "."; + if (c->renderType & GLX_RGBA_FLOAT_BIT_ARB) float_col = "s"; + if (c->renderType & GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT) float_col = "u"; + ErrorF("%3d %3x %3x " "%-11s" " %3d %3d %s %s %s %s %s " @@ -326,7 +327,8 @@ fbConfigsDump(unsigned int n, __GLXconfig * c, PixelFormatRejectStats *rejects) " %s %s %s " " %s " " %s " - " %d %s" + " %d %s " + " %s" "\n", i, c->visualID, c->fbconfigID, visual_class_name(c->visualType), @@ -345,11 +347,11 @@ fbConfigsDump(unsigned int n, __GLXconfig * c, PixelFormatRejectStats *rejects) (c->drawableType & GLX_WINDOW_BIT) ? "y" : ".", (c->drawableType & GLX_PIXMAP_BIT) ? "y" : ".", (c->drawableType & GLX_PBUFFER_BIT) ? "y" : ".", - (c->renderType & (GLX_RGBA_FLOAT_BIT_ARB | - GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT)) ? "y" : ".", + float_col, (c->transparentPixel != GLX_NONE_EXT) ? "y" : ".", c->visualSelectGroup, - (c->visualRating == GLX_SLOW_VISUAL_EXT) ? "*" : " "); + (c->visualRating == GLX_SLOW_VISUAL_EXT) ? "*" : " ", + c->sRGBCapable ? "y" : "."); c = c->next; } @@ -689,11 +691,34 @@ glxWinScreenProbe(ScreenPtr pScreen) } { + int i; Bool glx_sgi_make_current_read = FALSE; + const struct + { + const char *wglext; + const char *glxext; + Bool mandatory; + } extensionMap[] = { + { "WGL_ARB_make_current_read", "GLX_SGI_make_current_read", 0 }, + { "WGL_EXT_swap_control", "GLX_SGI_swap_control", 0 }, + { "WGL_EXT_swap_control", "GLX_MESA_swap_control", 0 }, + // { "WGL_ARB_render_texture", "GLX_EXT_texture_from_pixmap", 0 }, + // Sufficiently different that it's not obvious if this can be done... + { "WGL_ARB_pbuffer", "GLX_SGIX_pbuffer", 0 }, + { "WGL_ARB_multisample", "GLX_ARB_multisample", 0 }, + { "WGL_ARB_multisample", "GLX_SGIS_multisample", 0 }, + { "WGL_ARB_pixel_format_float", "GLX_ARB_fbconfig_float", 0 }, + { "WGL_EXT_pixel_format_packed_float", "GLX_EXT_fbconfig_packed_float", 0 }, + { "WGL_ARB_create_context", "GLX_ARB_create_context", 0 }, + { "WGL_ARB_create_context_profile", "GLX_ARB_create_context_profile", 0 }, + { "WGL_ARB_create_context_robustness", "GLX_ARB_create_context_robustness", 0 }, + { "WGL_EXT_create_context_es2_profile", "GLX_EXT_create_context_es2_profile", 0 }, + { "WGL_ARB_framebuffer_sRGB", "GLX_ARB_framebuffer_sRGB", 0 }, + }; + // // Based on the WGL extensions available, enable various GLX extensions - // XXX: make this table-driven ? // memset(screen->glx_enable_bits, 0, __GLX_EXT_BYTES); @@ -703,52 +728,40 @@ glxWinScreenProbe(ScreenPtr pScreen) __glXEnableExtension(screen->glx_enable_bits, "GLX_OML_swap_method"); __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIX_fbconfig"); + for (i = 0; i < sizeof(extensionMap)/sizeof(extensionMap[0]); i++) { + if (strstr(wgl_extensions, extensionMap[i].wglext)) { + __glXEnableExtension(screen->glx_enable_bits, extensionMap[i].glxext); + LogMessage(X_INFO, "GLX: enabled %s\n", extensionMap[i].glxext); + } + else if (extensionMap[i].mandatory) { + LogMessage(X_ERROR, "required WGL extension %s is missing\n", extensionMap[i].wglext); + } + } + if (strstr(wgl_extensions, "WGL_ARB_make_current_read")) { - __glXEnableExtension(screen->glx_enable_bits, - "GLX_SGI_make_current_read"); - LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_make_current_read\n"); glx_sgi_make_current_read = TRUE; } + // Because it pre-dates WGL_EXT_extensions_string, GL_WIN_swap_hint might + // only be in GL_EXTENSIONS if (strstr(gl_extensions, "GL_WIN_swap_hint")) { __glXEnableExtension(screen->glx_enable_bits, "GLX_MESA_copy_sub_buffer"); LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n"); } - if (strstr(wgl_extensions, "WGL_EXT_swap_control")) { - __glXEnableExtension(screen->glx_enable_bits, - "GLX_SGI_swap_control"); - __glXEnableExtension(screen->glx_enable_bits, - "GLX_MESA_swap_control"); - LogMessage(X_INFO, - "AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control\n"); - } - -/* // Hmm? screen->texOffset */ -/* if (strstr(wgl_extensions, "WGL_ARB_render_texture")) */ -/* { */ -/* __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_texture_from_pixmap"); */ -/* LogMessage(X_INFO, "AIGLX: GLX_EXT_texture_from_pixmap backed by buffer objects\n"); */ -/* screen->has_WGL_ARB_render_texture = TRUE; */ -/* } */ - if (strstr(wgl_extensions, "WGL_ARB_pbuffer")) { - __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIX_pbuffer"); - LogMessage(X_INFO, "AIGLX: enabled GLX_SGIX_pbuffer\n"); screen->has_WGL_ARB_pbuffer = TRUE; } if (strstr(wgl_extensions, "WGL_ARB_multisample")) { - __glXEnableExtension(screen->glx_enable_bits, - "GLX_ARB_multisample"); - __glXEnableExtension(screen->glx_enable_bits, - "GLX_SGIS_multisample"); - LogMessage(X_INFO, - "AIGLX: enabled GLX_ARB_multisample and GLX_SGIS_multisample\n"); screen->has_WGL_ARB_multisample = TRUE; } + if (strstr(wgl_extensions, "WGL_ARB_framebuffer_sRGB")) { + screen->has_WGL_ARB_framebuffer_sRGB = TRUE; + } + screen->base.destroy = glxWinScreenDestroy; screen->base.createContext = glxWinCreateContext; screen->base.createDrawable = glxWinCreateDrawable; @@ -1146,14 +1159,14 @@ glxWinDeferredCreateDrawable(__GLXWinDrawable *draw, __GLXconfig *config) #define RASTERWIDTHBYTES(bmi) (((((bmi)->biWidth*(bmi)->biBitCount)+31)&~31)>>3) size = bmpHeader.biHeight * RASTERWIDTHBYTES(&bmpHeader); - ErrorF("shared memory region size %zu + %u\n", sizeof(BITMAPINFOHEADER), (unsigned int)size); + GLWIN_DEBUG_MSG("shared memory region size %zu + %u\n", sizeof(BITMAPINFOHEADER), (unsigned int)size); // Create unique name for mapping based on XID // // XXX: not quite unique as potentially this name could be used in // another server instance. Not sure how to deal with that. snprintf(name, sizeof(name), "Local\\CYGWINX_WINDOWSDRI_%08x", (unsigned int)draw->base.pDraw->id); - ErrorF("shared memory region name %s\n", name); + GLWIN_DEBUG_MSG("shared memory region name %s\n", name); // Create a file mapping backed by the pagefile draw->hSection = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, @@ -1827,13 +1840,34 @@ fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig * mode, int attribList[60]; SET_ATTR_VALUE(WGL_SUPPORT_OPENGL_ARB, TRUE); - SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, - (mode->visualType == - GLX_TRUE_COLOR) ? WGL_TYPE_RGBA_ARB : - WGL_TYPE_COLORINDEX_ARB); - SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, - (mode->visualType == - GLX_TRUE_COLOR) ? mode->rgbBits : mode->indexBits); + + switch (mode->renderType) + { + case GLX_COLOR_INDEX_BIT: + case GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT: + SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_COLORINDEX_ARB); + SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->indexBits); + break; + + default: + ErrorF("unexpected renderType %x\n", mode->renderType); + /* fall-through */ + case GLX_RGBA_BIT: + SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB); + SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->rgbBits); + break; + + case GLX_RGBA_FLOAT_BIT_ARB: + SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_FLOAT_ARB); + SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->rgbBits); + break; + + case GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT: + SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT); + SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->rgbBits); + break; + } + SET_ATTR_VALUE(WGL_RED_BITS_ARB, mode->redBits); SET_ATTR_VALUE(WGL_GREEN_BITS_ARB, mode->greenBits); SET_ATTR_VALUE(WGL_BLUE_BITS_ARB, mode->blueBits); @@ -1863,6 +1897,11 @@ fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig * mode, if (mode->visualRating == GLX_SLOW_VISUAL_EXT) SET_ATTR_VALUE(WGL_ACCELERATION_ARB, WGL_NO_ACCELERATION_ARB); + if (winScreen->has_WGL_ARB_multisample) { + SET_ATTR_VALUE(WGL_SAMPLE_BUFFERS_ARB, mode->sampleBuffers); + SET_ATTR_VALUE(WGL_SAMPLES_ARB, mode->samples); + } + // must support all the drawable types the mode supports if ((mode->drawableType | drawableTypeOverride) & GLX_WINDOW_BIT) SET_ATTR_VALUE(WGL_DRAW_TO_WINDOW_ARB, TRUE); @@ -1886,6 +1925,9 @@ fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig * mode, SET_ATTR_VALUE(WGL_DRAW_TO_PBUFFER_ARB, TRUE); } + if (winScreen->has_WGL_ARB_framebuffer_sRGB) + SET_ATTR_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, TRUE); + SET_ATTR_VALUE(0, 0); // terminator /* choose the first match */ @@ -2251,6 +2293,11 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen, PixelFormatRejectStats * ADD_ATTR(WGL_MAX_PBUFFER_HEIGHT_ARB); } + if (screen->has_WGL_ARB_framebuffer_sRGB) { + // we may not query these attrs if WGL_ARB_framebuffer_sRGB is not offered + ADD_ATTR(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); + } + /* fill in configs */ for (i = 0; i < numConfigs; i++) { int values[num_attrs]; @@ -2304,25 +2351,42 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen, PixelFormatRejectStats * c->base.indexBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0); c->base.rgbBits = 0; c->base.visualType = GLX_STATIC_COLOR; + c->base.renderType = GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT; + + /* + Assume RGBA rendering is available on all single-channel visuals + (it is specified to render to red component in single-channel + visuals, if supported, but there doesn't seem to be any mechanism + to check if it is supported) + + Color index rendering is only supported on single-channel visuals + */ + + break; + + case WGL_TYPE_RGBA_ARB: + c->base.indexBits = 0; + c->base.rgbBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0); + c->base.visualType = GLX_TRUE_COLOR; + c->base.renderType = GLX_RGBA_BIT; break; case WGL_TYPE_RGBA_FLOAT_ARB: - rejects->rgbaFloat++; - GLWIN_DEBUG_MSG - ("pixelFormat %d is WGL_TYPE_RGBA_FLOAT_ARB, skipping", i + 1); - continue; + c->base.indexBits = 0; + c->base.rgbBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0); + c->base.visualType = GLX_TRUE_COLOR; + c->base.renderType = GLX_RGBA_FLOAT_BIT_ARB; + // assert pbuffer drawable + // assert WGL_ARB_pixel_format_float + break; case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT: - rejects->unsignedRgbaFloat++; - GLWIN_DEBUG_MSG - ("pixelFormat %d is WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT, skipping", - i + 1); - continue; - - case WGL_TYPE_RGBA_ARB: c->base.indexBits = 0; c->base.rgbBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0); c->base.visualType = GLX_TRUE_COLOR; + c->base.renderType = GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT; + // assert pbuffer drawable + // assert WGL_EXT_pixel_format_packed_float break; default: @@ -2422,21 +2486,6 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen, PixelFormatRejectStats * | (ATTR_VALUE(WGL_DRAW_TO_BITMAP_ARB, 0) ? GLX_PIXMAP_BIT : 0) | (ATTR_VALUE(WGL_DRAW_TO_PBUFFER_ARB, 0) ? GLX_PBUFFER_BIT : 0)); - /* - Assume OpenGL RGBA rendering is available on all visuals - (it is specified to render to red component in single-channel visuals, - if supported, but there doesn't seem to be any mechanism to check if it - is supported) - - Color index rendering is only supported on single-channel visuals - */ - if (c->base.visualType == GLX_STATIC_COLOR) { - c->base.renderType = GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT; - } - else { - c->base.renderType = GLX_RGBA_BIT; - } - c->base.xRenderable = GL_TRUE; c->base.fbconfigID = -1; // will be set by __glXScreenInit() @@ -2518,7 +2567,9 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen, PixelFormatRejectStats * GLX_TEXTURE_1D_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT | GLX_TEXTURE_RECTANGLE_BIT_EXT; c->base.yInverted = -1; - c->base.sRGBCapable = 0; + + /* WGL_ARB_framebuffer_sRGB */ + c->base.sRGBCapable = ATTR_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, 0); n++; |