[Mesa-dev] [PATCH 2/2] wglinfo: query and report multisample information
Brian Paul
brianp at vmware.com
Mon Jun 9 05:26:53 PDT 2014
Before, we always reported zeros in the multisample columns of the
format list. Since PIXELFORMATDESCRIPTOR doesn't have fields for
multisample, we use a new format_info structure to extend that type.
---
src/wgl/wglinfo.c | 145 +++++++++++++++++++++++++++++++++--------------------
1 file changed, 91 insertions(+), 54 deletions(-)
diff --git a/src/wgl/wglinfo.c b/src/wgl/wglinfo.c
index 2b2c921..76478e2 100644
--- a/src/wgl/wglinfo.c
+++ b/src/wgl/wglinfo.c
@@ -50,6 +50,18 @@ typedef enum
} InfoMode;
+static GLboolean have_WGL_ARB_pixel_format;
+static GLboolean have_WGL_ARB_multisample;
+
+
+/**
+ * An extension of PIXELFORMATDESCRIPTOR to handle multisample, etc.
+ */
+struct format_info {
+ PIXELFORMATDESCRIPTOR pfd;
+ unsigned sampleBuffers, numSamples;
+};
+
static LRESULT CALLBACK
WndProc(HWND hWnd,
@@ -159,6 +171,12 @@ print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine)
printf("WGL extensions:\n");
print_extension_list(wglExtensions, singleLine);
}
+ if (extension_supported("WGL_ARB_pixel_format", wglExtensions)) {
+ have_WGL_ARB_pixel_format = GL_TRUE;
+ }
+ if (extension_supported("WGL_ARB_multisample", wglExtensions)) {
+ have_WGL_ARB_multisample = GL_TRUE;
+ }
}
#endif
printf("OpenGL vendor string: %s\n", glVendor);
@@ -208,27 +226,27 @@ visual_render_type_name(BYTE iPixelType)
}
static void
-print_visual_attribs_verbose(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
+print_visual_attribs_verbose(int iPixelFormat, const struct format_info *info)
{
printf("Visual ID: %x generic=%d native=%d\n",
iPixelFormat,
- ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
- ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0);
+ info->pfd.dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
+ info->pfd.dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0);
printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
- 0 /* ppfd->bufferSize */, 0 /* ppfd->level */,
- visual_render_type_name(ppfd->iPixelType),
- ppfd->dwFlags & PFD_DOUBLEBUFFER ? 1 : 0,
- ppfd->dwFlags & PFD_STEREO ? 1 : 0);
+ 0 /* info->pfd.bufferSize */, 0 /* info->pfd.level */,
+ visual_render_type_name(info->pfd.iPixelType),
+ info->pfd.dwFlags & PFD_DOUBLEBUFFER ? 1 : 0,
+ info->pfd.dwFlags & PFD_STEREO ? 1 : 0);
printf(" rgba: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",
- ppfd->cRedBits, ppfd->cGreenBits,
- ppfd->cBlueBits, ppfd->cAlphaBits);
+ info->pfd.cRedBits, info->pfd.cGreenBits,
+ info->pfd.cBlueBits, info->pfd.cAlphaBits);
printf(" cAuxBuffers=%d cDepthBits=%d cStencilBits=%d\n",
- ppfd->cAuxBuffers, ppfd->cDepthBits, ppfd->cStencilBits);
+ info->pfd.cAuxBuffers, info->pfd.cDepthBits, info->pfd.cStencilBits);
printf(" accum: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",
- ppfd->cAccumRedBits, ppfd->cAccumGreenBits,
- ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits);
+ info->pfd.cAccumRedBits, info->pfd.cAccumGreenBits,
+ info->pfd.cAccumBlueBits, info->pfd.cAccumAlphaBits);
printf(" multiSample=%d multiSampleBuffers=%d\n",
- 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */);
+ info->numSamples, info->sampleBuffers);
}
@@ -242,32 +260,32 @@ print_visual_attribs_short_header(void)
static void
-print_visual_attribs_short(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
+print_visual_attribs_short(int iPixelFormat, const struct format_info *info)
{
char *caveat = "None";
printf("0x%02x %2d %2d %2d %2d %2d %c%c %c %c %2d %2d %2d %2d %2d %2d %2d",
iPixelFormat,
- ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
- ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0,
+ info->pfd.dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
+ info->pfd.dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0,
0,
- 0 /* ppfd->bufferSize */,
- 0 /* ppfd->level */,
- ppfd->iPixelType == PFD_TYPE_RGBA ? 'r' : ' ',
- ppfd->iPixelType == PFD_TYPE_COLORINDEX ? 'c' : ' ',
- ppfd->dwFlags & PFD_DOUBLEBUFFER ? 'y' : '.',
- ppfd->dwFlags & PFD_STEREO ? 'y' : '.',
- ppfd->cRedBits, ppfd->cGreenBits,
- ppfd->cBlueBits, ppfd->cAlphaBits,
- ppfd->cAuxBuffers,
- ppfd->cDepthBits,
- ppfd->cStencilBits
+ 0 /* info->pfd.bufferSize */,
+ 0 /* info->pfd.level */,
+ info->pfd.iPixelType == PFD_TYPE_RGBA ? 'r' : ' ',
+ info->pfd.iPixelType == PFD_TYPE_COLORINDEX ? 'c' : ' ',
+ info->pfd.dwFlags & PFD_DOUBLEBUFFER ? 'y' : '.',
+ info->pfd.dwFlags & PFD_STEREO ? 'y' : '.',
+ info->pfd.cRedBits, info->pfd.cGreenBits,
+ info->pfd.cBlueBits, info->pfd.cAlphaBits,
+ info->pfd.cAuxBuffers,
+ info->pfd.cDepthBits,
+ info->pfd.cStencilBits
);
printf(" %2d %2d %2d %2d %2d %1d %s\n",
- ppfd->cAccumRedBits, ppfd->cAccumGreenBits,
- ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits,
- 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */,
+ info->pfd.cAccumRedBits, info->pfd.cAccumGreenBits,
+ info->pfd.cAccumBlueBits, info->pfd.cAccumAlphaBits,
+ info->sampleBuffers, info->numSamples,
caveat
);
}
@@ -283,29 +301,29 @@ print_visual_attribs_long_header(void)
static void
-print_visual_attribs_long(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
+print_visual_attribs_long(int iPixelFormat, const struct format_info *info)
{
printf("0x%2x %2d %11d %2d %2d %2d %4s %3d %3d %3d %3d %3d %3d",
iPixelFormat,
- ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
- ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0,
+ info->pfd.dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
+ info->pfd.dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0,
0,
- 0 /* ppfd->bufferSize */,
- 0 /* ppfd->level */,
- visual_render_type_name(ppfd->iPixelType),
- ppfd->dwFlags & PFD_DOUBLEBUFFER ? 1 : 0,
- ppfd->dwFlags & PFD_STEREO ? 1 : 0,
- ppfd->cRedBits, ppfd->cGreenBits,
- ppfd->cBlueBits, ppfd->cAlphaBits
+ 0 /* info->pfd.bufferSize */,
+ 0 /* info->pfd.level */,
+ visual_render_type_name(info->pfd.iPixelType),
+ info->pfd.dwFlags & PFD_DOUBLEBUFFER ? 1 : 0,
+ info->pfd.dwFlags & PFD_STEREO ? 1 : 0,
+ info->pfd.cRedBits, info->pfd.cGreenBits,
+ info->pfd.cBlueBits, info->pfd.cAlphaBits
);
printf(" %3d %4d %2d %3d %3d %3d %3d %2d %2d\n",
- ppfd->cAuxBuffers,
- ppfd->cDepthBits,
- ppfd->cStencilBits,
- ppfd->cAccumRedBits, ppfd->cAccumGreenBits,
- ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits,
- 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */
+ info->pfd.cAuxBuffers,
+ info->pfd.cDepthBits,
+ info->pfd.cStencilBits,
+ info->pfd.cAccumRedBits, info->pfd.cAccumGreenBits,
+ info->pfd.cAccumBlueBits, info->pfd.cAccumAlphaBits,
+ info->sampleBuffers, info->numSamples
);
}
@@ -313,20 +331,25 @@ print_visual_attribs_long(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
static void
print_visual_info(HDC hdc, InfoMode mode)
{
- PIXELFORMATDESCRIPTOR pfd;
+ PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB_func;
+ struct format_info info;
int numVisuals, numWglVisuals;
int i;
+ wglGetPixelFormatAttribivARB_func =
+ (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
+ wglGetProcAddress("wglGetPixelFormatAttribivARB");
+
numVisuals = DescribePixelFormat(hdc, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL);
if (numVisuals == 0)
return;
numWglVisuals = 0;
for (i = 0; i < numVisuals; i++) {
- if(!DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
+ if(!DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &info.pfd))
continue;
- //if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
+ //if(!(info.pfd.dwFlags & PFD_SUPPORT_OPENGL))
// continue;
++numWglVisuals;
@@ -340,18 +363,32 @@ print_visual_info(HDC hdc, InfoMode mode)
print_visual_attribs_long_header();
for (i = 0; i < numVisuals; i++) {
- if(!DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
+ if(!DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &info.pfd))
continue;
- //if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
+ //if(!(info.pfd.dwFlags & PFD_SUPPORT_OPENGL))
// continue;
+ if (have_WGL_ARB_pixel_format && have_WGL_ARB_multisample) {
+ int attribs[] = { WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB };
+ int values[2], layer = 0;
+ if (wglGetPixelFormatAttribivARB_func(hdc, i, layer,
+ 2, attribs, values)) {
+ info.sampleBuffers = values[0];
+ info.numSamples = values[1];
+ }
+ else {
+ info.sampleBuffers = 0;
+ info.numSamples = 0;
+ }
+ }
+
if (mode == Verbose)
- print_visual_attribs_verbose(i, &pfd);
+ print_visual_attribs_verbose(i, &info);
else if (mode == Normal)
- print_visual_attribs_short(i, &pfd);
+ print_visual_attribs_short(i, &info);
else if (mode == Wide)
- print_visual_attribs_long(i, &pfd);
+ print_visual_attribs_long(i, &info);
}
printf("\n");
}
--
1.7.10.4
More information about the mesa-dev
mailing list