hw/xwin/glx: Add GLX_ARB_framebuffer_sRGB extension

v2:
Fix a bogus warning about a missing pixelformat attribute issued for every
pixelformat when WGL_ARB_framebuffer_sRGB isn't available

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
Jon Turney 2016-07-15 15:15:18 +01:00
parent 1fc240c687
commit e3398d921b
2 changed files with 27 additions and 6 deletions

View File

@ -293,11 +293,11 @@ fbConfigsDump(unsigned int n, __GLXconfig * c)
return;
ErrorF("%d fbConfigs\n", n);
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;
@ -317,7 +317,8 @@ fbConfigsDump(unsigned int n, __GLXconfig * c)
" %s %s %s "
" %s "
" %s "
" %d %s"
" %d %s "
" %s"
"\n",
i, c->visualID, c->fbconfigID,
visual_class_name(c->visualType),
@ -339,7 +340,8 @@ fbConfigsDump(unsigned int n, __GLXconfig * c)
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;
}
@ -599,6 +601,7 @@ glxWinScreenProbe(ScreenPtr pScreen)
{ "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 },
};
//
@ -633,6 +636,10 @@ glxWinScreenProbe(ScreenPtr pScreen)
if (strstr(wgl_extensions, "WGL_ARB_multisample"))
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;
@ -1753,6 +1760,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 */
@ -2114,6 +2124,11 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
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];
@ -2376,7 +2391,12 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
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 */
if (screen->has_WGL_ARB_framebuffer_sRGB)
c->base.sRGBCapable = ATTR_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, 0);
else
c->base.sRGBCapable = 0;
n++;

View File

@ -69,6 +69,7 @@ struct __GLXWinScreen {
Bool has_WGL_ARB_pbuffer;
Bool has_WGL_ARB_render_texture;
Bool has_WGL_ARB_make_current_read;
Bool has_WGL_ARB_framebuffer_sRGB;
/* wrapped screen functions */
RealizeWindowProcPtr RealizeWindow;