summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-04-10 16:37:15 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-04-10 19:50:34 +0100
commite5d700721b05910f935c873ebb23d23f49961ebf (patch)
tree259a5693bfc8a3c5abf5f5ec2704bc9b24d2b00f /src/gallium/state_trackers
parent48f0543b39969694626bbeeca0b69b184db315f6 (diff)
wgl: Keep copies of the PIXELFORMATDESCRIPTOR structures.
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c87
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.c30
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_pixelformat.c142
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_pixelformat.h13
4 files changed, 139 insertions, 133 deletions
diff --git a/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c
index 140bb43caa..0e2d407699 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c
@@ -56,7 +56,7 @@ stw_query_attrib(
{
uint count;
uint index;
- const struct stw_pixelformat_info *pf;
+ const struct stw_pixelformat_info *pfi;
count = stw_pixelformat_get_extended_count();
@@ -69,30 +69,27 @@ stw_query_attrib(
if (index >= count)
return FALSE;
- pf = stw_pixelformat_get_info( index );
+ pfi = stw_pixelformat_get_info( index );
switch (attrib) {
case WGL_DRAW_TO_WINDOW_ARB:
- *pvalue = TRUE;
+ *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_WINDOW ? TRUE : FALSE;
return TRUE;
case WGL_DRAW_TO_BITMAP_ARB:
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_BITMAP ? TRUE : FALSE;
return TRUE;
case WGL_NEED_PALETTE_ARB:
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_NEED_PALETTE ? TRUE : FALSE;
return TRUE;
case WGL_NEED_SYSTEM_PALETTE_ARB:
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE;
return TRUE;
case WGL_SWAP_METHOD_ARB:
- if (pf->flags & STW_PF_FLAG_DOUBLEBUFFER)
- *pvalue = WGL_SWAP_COPY_ARB;
- else
- *pvalue = WGL_SWAP_UNDEFINED_ARB;
+ *pvalue = pfi->pfd.dwFlags & PFD_SWAP_COPY ? WGL_SWAP_COPY_ARB : WGL_SWAP_UNDEFINED_ARB;
return TRUE;
case WGL_SWAP_LAYER_BUFFERS_ARB:
@@ -134,96 +131,108 @@ stw_query_attrib(
break;
case WGL_SUPPORT_GDI_ARB:
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_GDI ? TRUE : FALSE;
break;
case WGL_SUPPORT_OPENGL_ARB:
- *pvalue = TRUE;
+ *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_OPENGL ? TRUE : FALSE;
break;
case WGL_DOUBLE_BUFFER_ARB:
- if (pf->flags & STW_PF_FLAG_DOUBLEBUFFER)
- *pvalue = TRUE;
- else
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_DOUBLEBUFFER ? TRUE : FALSE;
break;
case WGL_STEREO_ARB:
- *pvalue = FALSE;
+ *pvalue = pfi->pfd.dwFlags & PFD_STEREO ? TRUE : FALSE;
break;
case WGL_PIXEL_TYPE_ARB:
- *pvalue = WGL_TYPE_RGBA_ARB;
+ switch (pfi->pfd.iPixelType) {
+ case PFD_TYPE_RGBA:
+ *pvalue = WGL_TYPE_RGBA_ARB;
+ break;
+ case PFD_TYPE_COLORINDEX:
+ *pvalue = WGL_TYPE_COLORINDEX_ARB;
+ break;
+ default:
+ return FALSE;
+ }
break;
case WGL_COLOR_BITS_ARB:
- *pvalue = (int) (pf->color.redbits + pf->color.greenbits + pf->color.bluebits);
+ *pvalue = pfi->pfd.cColorBits;
break;
case WGL_RED_BITS_ARB:
- *pvalue = (int) pf->color.redbits;
+ *pvalue = pfi->pfd.cRedBits;
break;
case WGL_RED_SHIFT_ARB:
- *pvalue = (int) pf->color.redshift;
+ *pvalue = pfi->pfd.cRedShift;
break;
case WGL_GREEN_BITS_ARB:
- *pvalue = (int) pf->color.greenbits;
+ *pvalue = pfi->pfd.cGreenBits;
break;
case WGL_GREEN_SHIFT_ARB:
- *pvalue = (int) pf->color.greenshift;
+ *pvalue = pfi->pfd.cGreenShift;
break;
case WGL_BLUE_BITS_ARB:
- *pvalue = (int) pf->color.bluebits;
+ *pvalue = pfi->pfd.cBlueBits;
break;
case WGL_BLUE_SHIFT_ARB:
- *pvalue = (int) pf->color.blueshift;
+ *pvalue = pfi->pfd.cBlueShift;
break;
case WGL_ALPHA_BITS_ARB:
- *pvalue = (int) pf->color.alphabits;
+ *pvalue = pfi->pfd.cAlphaBits;
break;
case WGL_ALPHA_SHIFT_ARB:
- *pvalue = (int) pf->color.alphashift;
+ *pvalue = pfi->pfd.cAlphaShift;
break;
case WGL_ACCUM_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumBits;
+ break;
+
case WGL_ACCUM_RED_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumRedBits;
+ break;
+
case WGL_ACCUM_GREEN_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumGreenBits;
+ break;
+
case WGL_ACCUM_BLUE_BITS_ARB:
+ *pvalue = pfi->pfd.cAccumBlueBits;
+ break;
+
case WGL_ACCUM_ALPHA_BITS_ARB:
- *pvalue = 0;
+ *pvalue = pfi->pfd.cAccumAlphaBits;
break;
case WGL_DEPTH_BITS_ARB:
- *pvalue = (int) pf->depth.depthbits;
+ *pvalue = pfi->pfd.cDepthBits;
break;
case WGL_STENCIL_BITS_ARB:
- *pvalue = (int) pf->depth.stencilbits;
+ *pvalue = pfi->pfd.cStencilBits;
break;
case WGL_AUX_BUFFERS_ARB:
- *pvalue = 0;
+ *pvalue = pfi->pfd.cAuxBuffers;
break;
case WGL_SAMPLE_BUFFERS_ARB:
- if (pf->flags & STW_PF_FLAG_MULTISAMPLED)
- *pvalue = stw_query_sample_buffers();
- else
- *pvalue = 0;
+ *pvalue = pfi->numSampleBuffers;
break;
case WGL_SAMPLES_ARB:
- if (pf->flags & STW_PF_FLAG_MULTISAMPLED)
- *pvalue = stw_query_samples();
- else
- *pvalue = 0;
+ *pvalue = pfi->numSamples;
break;
default:
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c
index f7098198c0..e6bb8e1847 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.c
@@ -109,21 +109,21 @@ stw_create_layer_context(
/* Create visual based on flags
*/
visual = _mesa_create_visual(
- GL_TRUE,
- (pf->flags & STW_PF_FLAG_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE,
- GL_FALSE,
- pf->color.redbits,
- pf->color.greenbits,
- pf->color.bluebits,
- pf->color.alphabits,
- 0,
- pf->depth.depthbits,
- pf->depth.stencilbits,
- 0,
- 0,
- 0,
- 0,
- (pf->flags & STW_PF_FLAG_MULTISAMPLED) ? stw_query_samples() : 0 );
+ (pf->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE,
+ (pf->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE,
+ (pf->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE,
+ pf->pfd.cRedBits,
+ pf->pfd.cGreenBits,
+ pf->pfd.cBlueBits,
+ pf->pfd.cAlphaBits,
+ (pf->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pf->pfd.cColorBits : 0,
+ pf->pfd.cDepthBits,
+ pf->pfd.cStencilBits,
+ pf->pfd.cAccumRedBits,
+ pf->pfd.cAccumGreenBits,
+ pf->pfd.cAccumBlueBits,
+ pf->pfd.cAccumAlphaBits,
+ pf->numSamples );
if (visual == NULL)
goto fail;
diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
index daf42c02fe..7bbab0e972 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
@@ -36,23 +36,68 @@
static void
stw_pixelformat_add(
struct stw_device *stw_dev,
- unsigned flags,
const struct stw_pixelformat_color_info *color,
const struct stw_pixelformat_depth_info *depth,
+ boolean doublebuffer,
+ boolean multisampled,
boolean extended )
{
- struct stw_pixelformat_info *pf;
+ struct stw_pixelformat_info *pfi;
assert(stw_dev->pixelformat_extended_count < STW_MAX_PIXELFORMATS);
if(stw_dev->pixelformat_extended_count >= STW_MAX_PIXELFORMATS)
return;
- pf = &stw_dev->pixelformats[stw_dev->pixelformat_extended_count];
+ pfi = &stw_dev->pixelformats[stw_dev->pixelformat_extended_count];
- pf->flags = flags;
- pf->color = *color;
- pf->depth = *depth;
+ memset(pfi, 0, sizeof *pfi);
+
+ pfi->pfd.nSize = sizeof pfi->pfd;
+ pfi->pfd.nVersion = 1;
+ pfi->pfd.dwFlags = PFD_SUPPORT_OPENGL;
+
+ /* TODO: also support non-native pixel formats */
+ pfi->pfd.dwFlags |= PFD_DRAW_TO_WINDOW ;
+
+ if (doublebuffer)
+ pfi->pfd.dwFlags |= PFD_DOUBLEBUFFER | PFD_SWAP_COPY;
+
+ pfi->pfd.iPixelType = PFD_TYPE_RGBA;
+
+ pfi->pfd.cColorBits = color->redbits + color->greenbits + color->bluebits;
+ pfi->pfd.cRedBits = color->redbits;
+ pfi->pfd.cRedShift = color->redshift;
+ pfi->pfd.cGreenBits = color->greenbits;
+ pfi->pfd.cGreenShift = color->greenshift;
+ pfi->pfd.cBlueBits = color->bluebits;
+ pfi->pfd.cBlueShift = color->blueshift;
+ pfi->pfd.cAlphaBits = color->alphabits;
+ pfi->pfd.cAlphaShift = color->alphashift;
+ pfi->pfd.cAccumBits = 0;
+ pfi->pfd.cAccumRedBits = 0;
+ pfi->pfd.cAccumGreenBits = 0;
+ pfi->pfd.cAccumBlueBits = 0;
+ pfi->pfd.cAccumAlphaBits = 0;
+ pfi->pfd.cDepthBits = depth->depthbits;
+ pfi->pfd.cStencilBits = depth->stencilbits;
+ pfi->pfd.cAuxBuffers = 0;
+ pfi->pfd.iLayerType = 0;
+ pfi->pfd.bReserved = 0;
+ pfi->pfd.dwLayerMask = 0;
+ pfi->pfd.dwVisibleMask = 0;
+ pfi->pfd.dwDamageMask = 0;
+
+ if(multisampled) {
+ /* FIXME: re-enable when we can query this */
+#if 0
+ pfi->numSampleBuffers = 1;
+ pfi->numSamples = 4;
+#else
+ return;
+#endif
+ }
+
++stw_dev->pixelformat_extended_count;
if(!extended) {
@@ -64,7 +109,8 @@ stw_pixelformat_add(
static void
stw_add_standard_pixelformats(
struct stw_device *stw_dev,
- uint flags,
+ boolean doublebuffer,
+ boolean multisampled,
boolean extended )
{
const struct stw_pixelformat_color_info color24 = { 8, 0, 8, 8, 8, 16, 0, 0 };
@@ -72,22 +118,22 @@ stw_add_standard_pixelformats(
const struct stw_pixelformat_depth_info depth24s8 = { 24, 8 };
const struct stw_pixelformat_depth_info depth16 = { 16, 0 };
- stw_pixelformat_add( stw_dev, flags, &color24, &depth24s8, extended );
+ stw_pixelformat_add( stw_dev, &color24, &depth24s8, doublebuffer, multisampled, extended );
- stw_pixelformat_add( stw_dev, flags, &color24a8, &depth24s8, extended );
+ stw_pixelformat_add( stw_dev, &color24a8, &depth24s8, doublebuffer, multisampled, extended );
- stw_pixelformat_add( stw_dev, flags, &color24, &depth16, extended );
+ stw_pixelformat_add( stw_dev, &color24, &depth16, doublebuffer, multisampled, extended );
- stw_pixelformat_add( stw_dev, flags, &color24a8, &depth16, extended );
+ stw_pixelformat_add( stw_dev, &color24a8, &depth16, doublebuffer, multisampled, extended );
}
void
stw_pixelformat_init( void )
{
- stw_add_standard_pixelformats( stw_dev, STW_PF_FLAG_DOUBLEBUFFER | 0 , FALSE );
- stw_add_standard_pixelformats( stw_dev, 0 | 0, FALSE );
- stw_add_standard_pixelformats( stw_dev, STW_PF_FLAG_DOUBLEBUFFER | STW_PF_FLAG_MULTISAMPLED, TRUE );
- stw_add_standard_pixelformats( stw_dev, 0 | STW_PF_FLAG_MULTISAMPLED, TRUE );
+ stw_add_standard_pixelformats( stw_dev, FALSE, FALSE, FALSE );
+ stw_add_standard_pixelformats( stw_dev, TRUE, FALSE, FALSE );
+ stw_add_standard_pixelformats( stw_dev, FALSE, TRUE, TRUE );
+ stw_add_standard_pixelformats( stw_dev, TRUE, TRUE, TRUE );
assert( stw_dev->pixelformat_count <= STW_MAX_PIXELFORMATS );
assert( stw_dev->pixelformat_extended_count <= STW_MAX_PIXELFORMATS );
@@ -123,7 +169,7 @@ stw_pixelformat_describe(
{
uint count;
uint index;
- const struct stw_pixelformat_info *pf;
+ const struct stw_pixelformat_info *pfi;
(void) hdc;
@@ -135,36 +181,9 @@ stw_pixelformat_describe(
if (index >= count || nBytes != sizeof( PIXELFORMATDESCRIPTOR ))
return 0;
- pf = stw_pixelformat_get_info( index );
-
- ppfd->nSize = sizeof( PIXELFORMATDESCRIPTOR );
- ppfd->nVersion = 1;
- ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
- if (pf->flags & STW_PF_FLAG_DOUBLEBUFFER)
- ppfd->dwFlags |= PFD_DOUBLEBUFFER | PFD_SWAP_COPY;
- ppfd->iPixelType = PFD_TYPE_RGBA;
- ppfd->cColorBits = pf->color.redbits + pf->color.greenbits + pf->color.bluebits;
- ppfd->cRedBits = pf->color.redbits;
- ppfd->cRedShift = pf->color.redshift;
- ppfd->cGreenBits = pf->color.greenbits;
- ppfd->cGreenShift = pf->color.greenshift;
- ppfd->cBlueBits = pf->color.bluebits;
- ppfd->cBlueShift = pf->color.blueshift;
- ppfd->cAlphaBits = pf->color.alphabits;
- ppfd->cAlphaShift = pf->color.alphashift;
- ppfd->cAccumBits = 0;
- ppfd->cAccumRedBits = 0;
- ppfd->cAccumGreenBits = 0;
- ppfd->cAccumBlueBits = 0;
- ppfd->cAccumAlphaBits = 0;
- ppfd->cDepthBits = pf->depth.depthbits;
- ppfd->cStencilBits = pf->depth.stencilbits;
- ppfd->cAuxBuffers = 0;
- ppfd->iLayerType = 0;
- ppfd->bReserved = 0;
- ppfd->dwLayerMask = 0;
- ppfd->dwVisibleMask = 0;
- ppfd->dwDamageMask = 0;
+ pfi = stw_pixelformat_get_info( index );
+
+ memcpy(ppfd, &pfi->pfd, sizeof( PIXELFORMATDESCRIPTOR ));
return count;
}
@@ -188,23 +207,24 @@ int stw_pixelformat_choose( HDC hdc,
for (index = 0; index < count; index++) {
uint delta = 0;
- const struct stw_pixelformat_info *pf = stw_pixelformat_get_info( index );
+ const struct stw_pixelformat_info *pfi = stw_pixelformat_get_info( index );
if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
!!(ppfd->dwFlags & PFD_DOUBLEBUFFER) !=
- !!(pf->flags & STW_PF_FLAG_DOUBLEBUFFER))
+ !!(pfi->pfd.dwFlags & PFD_DOUBLEBUFFER))
continue;
- if (ppfd->cColorBits != pf->color.redbits + pf->color.greenbits + pf->color.bluebits)
+ /* FIXME: Take in account individual channel bits */
+ if (ppfd->cColorBits != pfi->pfd.cColorBits)
delta += 8;
- if (ppfd->cDepthBits != pf->depth.depthbits)
+ if (ppfd->cDepthBits != pfi->pfd.cDepthBits)
delta += 4;
- if (ppfd->cStencilBits != pf->depth.stencilbits)
+ if (ppfd->cStencilBits != pfi->pfd.cStencilBits)
delta += 2;
- if (ppfd->cAlphaBits != pf->color.alphabits)
+ if (ppfd->cAlphaBits != pfi->pfd.cAlphaBits)
delta++;
if (delta < bestdelta) {
@@ -256,21 +276,3 @@ stw_pixelformat_set(
return TRUE;
}
-
-
-
-/* XXX: this needs to be turned into queries on pipe_screen or
- * stw_winsys.
- */
-int
-stw_query_sample_buffers( void )
-{
- return 1;
-}
-
-int
-stw_query_samples( void )
-{
- return 4;
-}
-
diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h
index b33a688f5a..2cba844144 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h
@@ -32,9 +32,6 @@
#include "pipe/p_compiler.h"
-#define STW_PF_FLAG_DOUBLEBUFFER 0x00000001
-#define STW_PF_FLAG_MULTISAMPLED 0x00000002
-
struct stw_pixelformat_color_info
{
uint redbits;
@@ -55,9 +52,10 @@ struct stw_pixelformat_depth_info
struct stw_pixelformat_info
{
- uint flags;
- struct stw_pixelformat_color_info color;
- struct stw_pixelformat_depth_info depth;
+ PIXELFORMATDESCRIPTOR pfd;
+
+ unsigned numSampleBuffers;
+ unsigned numSamples;
};
void
@@ -72,8 +70,5 @@ stw_pixelformat_get_extended_count( void );
const struct stw_pixelformat_info *
stw_pixelformat_get_info( uint index );
-int stw_query_sample_buffers( void );
-int stw_query_samples( void );
-
#endif /* STW_PIXELFORMAT_H */