wgl: Walk through the pixel formats combinations.

This commit is contained in:
José Fonseca
2009-04-10 17:22:21 +01:00
parent e5d700721b
commit 0bca413ce9
3 changed files with 93 additions and 67 deletions

View File

@@ -37,7 +37,7 @@
#include "stw_pixelformat.h" #include "stw_pixelformat.h"
#define STW_MAX_PIXELFORMATS 16 #define STW_MAX_PIXELFORMATS 128
struct pipe_screen; struct pipe_screen;

View File

@@ -26,6 +26,7 @@
**************************************************************************/ **************************************************************************/
#include "util/u_debug.h" #include "util/u_debug.h"
#include "util/u_memory.h"
#include "stw_device.h" #include "stw_device.h"
#include "stw_pixelformat.h" #include "stw_pixelformat.h"
@@ -33,21 +34,75 @@
#include "stw_tls.h" #include "stw_tls.h"
struct stw_pf_color_info
{
struct {
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char alpha;
} bits;
struct {
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char alpha;
} shift;
};
struct stw_pf_depth_info
{
struct {
unsigned char depth;
unsigned char stencil;
} bits;
};
static const struct stw_pf_color_info
stw_pf_color[] = {
{ {8, 8, 8, 0}, { 0, 8, 16, 0} },
{ {8, 8, 8, 8}, { 0, 8, 16, 24} }
};
static const struct stw_pf_depth_info
stw_pf_depth_stencil[] = {
{ {16, 0} },
{ {24, 8} }
};
static const boolean
stw_pf_doublebuffer[] = {
FALSE,
TRUE,
};
const unsigned
stw_pf_multisample[] = {
0,
4
};
static void static void
stw_pixelformat_add( stw_pixelformat_add(
struct stw_device *stw_dev, struct stw_device *stw_dev,
const struct stw_pixelformat_color_info *color, const struct stw_pf_color_info *color,
const struct stw_pixelformat_depth_info *depth, const struct stw_pf_depth_info *depth,
boolean doublebuffer, boolean doublebuffer,
boolean multisampled, unsigned samples )
boolean extended )
{ {
boolean extended = FALSE;
struct stw_pixelformat_info *pfi; struct stw_pixelformat_info *pfi;
assert(stw_dev->pixelformat_extended_count < STW_MAX_PIXELFORMATS); assert(stw_dev->pixelformat_extended_count < STW_MAX_PIXELFORMATS);
if(stw_dev->pixelformat_extended_count >= STW_MAX_PIXELFORMATS) if(stw_dev->pixelformat_extended_count >= STW_MAX_PIXELFORMATS)
return; return;
/* FIXME: re-enabled MSAA when we can query it */
if(samples)
return;
pfi = &stw_dev->pixelformats[stw_dev->pixelformat_extended_count]; pfi = &stw_dev->pixelformats[stw_dev->pixelformat_extended_count];
memset(pfi, 0, sizeof *pfi); memset(pfi, 0, sizeof *pfi);
@@ -65,22 +120,22 @@ stw_pixelformat_add(
pfi->pfd.iPixelType = PFD_TYPE_RGBA; pfi->pfd.iPixelType = PFD_TYPE_RGBA;
pfi->pfd.cColorBits = color->redbits + color->greenbits + color->bluebits; pfi->pfd.cColorBits = color->bits.red + color->bits.green + color->bits.blue;
pfi->pfd.cRedBits = color->redbits; pfi->pfd.cRedBits = color->bits.red;
pfi->pfd.cRedShift = color->redshift; pfi->pfd.cRedShift = color->shift.red;
pfi->pfd.cGreenBits = color->greenbits; pfi->pfd.cGreenBits = color->bits.green;
pfi->pfd.cGreenShift = color->greenshift; pfi->pfd.cGreenShift = color->shift.green;
pfi->pfd.cBlueBits = color->bluebits; pfi->pfd.cBlueBits = color->bits.blue;
pfi->pfd.cBlueShift = color->blueshift; pfi->pfd.cBlueShift = color->shift.blue;
pfi->pfd.cAlphaBits = color->alphabits; pfi->pfd.cAlphaBits = color->bits.alpha;
pfi->pfd.cAlphaShift = color->alphashift; pfi->pfd.cAlphaShift = color->shift.alpha;
pfi->pfd.cAccumBits = 0; pfi->pfd.cAccumBits = 0;
pfi->pfd.cAccumRedBits = 0; pfi->pfd.cAccumRedBits = 0;
pfi->pfd.cAccumGreenBits = 0; pfi->pfd.cAccumGreenBits = 0;
pfi->pfd.cAccumBlueBits = 0; pfi->pfd.cAccumBlueBits = 0;
pfi->pfd.cAccumAlphaBits = 0; pfi->pfd.cAccumAlphaBits = 0;
pfi->pfd.cDepthBits = depth->depthbits; pfi->pfd.cDepthBits = depth->bits.depth;
pfi->pfd.cStencilBits = depth->stencilbits; pfi->pfd.cStencilBits = depth->bits.stencil;
pfi->pfd.cAuxBuffers = 0; pfi->pfd.cAuxBuffers = 0;
pfi->pfd.iLayerType = 0; pfi->pfd.iLayerType = 0;
pfi->pfd.bReserved = 0; pfi->pfd.bReserved = 0;
@@ -88,14 +143,10 @@ stw_pixelformat_add(
pfi->pfd.dwVisibleMask = 0; pfi->pfd.dwVisibleMask = 0;
pfi->pfd.dwDamageMask = 0; pfi->pfd.dwDamageMask = 0;
if(multisampled) { if(samples) {
/* FIXME: re-enable when we can query this */
#if 0
pfi->numSampleBuffers = 1; pfi->numSampleBuffers = 1;
pfi->numSamples = 4; pfi->numSamples = samples;
#else extended = TRUE;
return;
#endif
} }
++stw_dev->pixelformat_extended_count; ++stw_dev->pixelformat_extended_count;
@@ -106,36 +157,29 @@ stw_pixelformat_add(
} }
} }
static void
stw_add_standard_pixelformats(
struct stw_device *stw_dev,
boolean doublebuffer,
boolean multisampled,
boolean extended )
{
const struct stw_pixelformat_color_info color24 = { 8, 0, 8, 8, 8, 16, 0, 0 };
const struct stw_pixelformat_color_info color24a8 = { 8, 0, 8, 8, 8, 16, 8, 24 };
const struct stw_pixelformat_depth_info depth24s8 = { 24, 8 };
const struct stw_pixelformat_depth_info depth16 = { 16, 0 };
stw_pixelformat_add( stw_dev, &color24, &depth24s8, doublebuffer, multisampled, extended );
stw_pixelformat_add( stw_dev, &color24a8, &depth24s8, doublebuffer, multisampled, extended );
stw_pixelformat_add( stw_dev, &color24, &depth16, doublebuffer, multisampled, extended );
stw_pixelformat_add( stw_dev, &color24a8, &depth16, doublebuffer, multisampled, extended );
}
void void
stw_pixelformat_init( void ) stw_pixelformat_init( void )
{ {
stw_add_standard_pixelformats( stw_dev, FALSE, FALSE, FALSE ); unsigned i, j, k, l;
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_count );
assert( !stw_dev->pixelformat_extended_count );
for(i = 0; i < Elements(stw_pf_multisample); ++i) {
unsigned samples = stw_pf_multisample[i];
for(j = 0; j < Elements(stw_pf_color); ++j) {
const struct stw_pf_color_info *color = &stw_pf_color[j];
for(k = 0; k < Elements(stw_pf_doublebuffer); ++k) {
unsigned doublebuffer = stw_pf_doublebuffer[k];
for(l = 0; l < Elements(stw_pf_depth_stencil); ++l) {
const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[l];
stw_pixelformat_add( stw_dev, color, depth, doublebuffer, samples );
}
}
}
}
assert( stw_dev->pixelformat_count <= stw_dev->pixelformat_extended_count );
assert( stw_dev->pixelformat_extended_count <= STW_MAX_PIXELFORMATS ); assert( stw_dev->pixelformat_extended_count <= STW_MAX_PIXELFORMATS );
} }

View File

@@ -32,24 +32,6 @@
#include "pipe/p_compiler.h" #include "pipe/p_compiler.h"
struct stw_pixelformat_color_info
{
uint redbits;
uint redshift;
uint greenbits;
uint greenshift;
uint bluebits;
uint blueshift;
uint alphabits;
uint alphashift;
};
struct stw_pixelformat_depth_info
{
uint depthbits;
uint stencilbits;
};
struct stw_pixelformat_info struct stw_pixelformat_info
{ {
PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR pfd;