WineD3D: Use less strict pixel format matching if the, match fails
Chris Ahrendt
celticht32 at aol.com
Mon Jul 21 20:35:54 CDT 2008
I was thinking of something a little different than what you proposed
but something similar... here is my diff of the same thing:
--- context.c 2008-07-21 21:33:01.000000000 -0400
+++ context_new.c 2008-07-21 21:32:38.000000000 -0400
@@ -120,6 +120,8 @@ static int WineD3D_ChoosePixelFormat(IWi
int i = 0;
int nCfgs = This->adapter->nCfgs;
WineD3D_PixelFormat *cfgs = This->adapter->cfgs;
+ BOOL exactDepthMatch = TRUE;
+ PIXELFORMATDESCRIPTOR pfd;
TRACE("ColorFormat=%s, DepthStencilFormat=%s, auxBuffers=%d,
numSamples=%d, pbuffer=%d, findCompatible=%d\n",
debug_d3dformat(ColorFormat),
debug_d3dformat(DepthStencilFormat), auxBuffers, numSamples, pbuffer,
findCompatible);
@@ -145,13 +147,10 @@ static int WineD3D_ChoosePixelFormat(IWi
DepthStencilFormat = WINED3DFMT_D24S8;
- if(DepthStencilFormat) {
- getDepthStencilBits(DepthStencilFormat, &depthBits, &stencilBits);
- }
-
+ getDepthStencilBits(DepthStencilFormat, &depthBits, &stencilBits);
+
/* Find a pixel format which EXACTLY matches our requirements
(except for depth) */
for(i=0; i<nCfgs; i++) {
- BOOL exactDepthMatch = TRUE;
cfgs = &This->adapter->cfgs[i];
/* For now only accept RGBA formats. Perhaps some day we will
@@ -184,7 +183,7 @@ static int WineD3D_ChoosePixelFormat(IWi
* depth it is no problem to emulate 16-bit using e.g. 24-bit,
so accept that. */
if(cfgs->depthSize < depthBits)
continue;
- else if(cfgs->depthSize > depthBits)
+ if(cfgs->depthSize > depthBits)
exactDepthMatch = FALSE;
/* In all cases make sure the number of stencil bits matches
our requirements
@@ -203,26 +202,18 @@ static int WineD3D_ChoosePixelFormat(IWi
* so there can easily be a dozen of pixel formats which
appear to be the 'same' but
* can still differ in things like multisampling, stereo, SRGB
and other flags.
*/
-
+ iPixelFormat = cfgs->iPixelFormat;
/* Exit the loop as we have found a format :) */
- if(exactDepthMatch) {
- iPixelFormat = cfgs->iPixelFormat;
- break;
- } else if(!iPixelFormat) {
- /* In the end we might end up with a format which doesn't
exactly match our depth
- * requirements. Accept the first format we found because
formats with higher iPixelFormat
- * values tend to have more extended capabilities (e.g.
multisampling) which we don't need. */
- iPixelFormat = cfgs->iPixelFormat;
- }
+ if(exactDepthMatch) break;
}
/* When findCompatible is set and no suitable format was found,
let ChoosePixelFormat choose a pixel format in order not to crash. */
if(!iPixelFormat && !findCompatible) {
ERR("Can't find a suitable iPixelFormat\n");
return FALSE;
- } else if(!iPixelFormat) {
- PIXELFORMATDESCRIPTOR pfd;
-
+ }
+ if(!iPixelFormat) {
+
TRACE("Falling back to ChoosePixelFormat as we weren't able to
find an exactly matching pixel format\n");
/* PixelFormat selection */
ZeroMemory(&pfd, sizeof(pfd));
@@ -239,7 +230,7 @@ static int WineD3D_ChoosePixelFormat(IWi
iPixelFormat = ChoosePixelFormat(hdc, &pfd);
if(!iPixelFormat) {
/* If this happens something is very wrong as
ChoosePixelFormat barely fails */
- ERR("Can't find a suitable iPixelFormat\n");
+ ERR("ChoosePixelFormat Failed Can't find a suitable
iPixelFormat\n");
return FALSE;
}
}
Chris
More information about the wine-patches
mailing list