sorry forgot to cut and paste some code =)

celticht32 at aol.com celticht32 at aol.com
Tue Jun 24 20:45:11 CDT 2008


the code is in :

wine-1.0/dlls/wined3d/context.c


here is the changed code :



/* This function takes care of WineD3D pixel format selection. */

static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc, WINED3DFORMAT ColorFormat, WINED3DFORMAT DepthStencilFormat, BOOL auxBuffers, int numSamples, BOOL pbuffer, BOOL findCompatible)
{
??? int iPixelFormat=0;
??? short redBits, greenBits, blueBits, alphaBits, colorBits;
??? short depthBits=0, stencilBits=0;
??? int i = 0;
??? int nCfgs = This->adapter->nCfgs;

??? WineD3D_PixelFormat *cfgs = This->adapter->cfgs;
??? BOOL exactDepthMatch = FALSE;? /*Changed june 23,08 */?? 
??? PIXELFORMATDESCRIPTOR pfd;???? /*Changed june 23,08 */


??? TRACE("ColorFormat=%s, DepthStencilFormat=%s, auxBuffers=%d, numSamples=%d, pbuffer=%d, findCompatible=%d\n",
????????? debug_d3dformat(ColorFormat), debug_d3dformat(DepthStencilFormat), auxBuffers, numSamples, pbuffer, findCompatible);

??? if (!getColorBits(ColorFormat, &redBits, &greenBits, &blueBits, &alphaBits, &colorBits)) 
???? {
??????? ERR("Unable to get color bits for format %s (%#x)!\n", debug_d3dformat(ColorFormat), ColorFormat);
??????? return 0;
??? }

??? /* In WGL both color, depth and stencil are features of a pixel format. In case of D3D they are separate.
???? * You are able to add a depth + stencil surface at a later stage when you need it.
???? * In order to support this properly in WineD3D we need the ability to recreate the opengl context and
???? * drawable when this is required. This is very tricky as we need to reapply ALL opengl states for the new
???? * context, need torecreate shaders, textures and other resources.
???? *
???? * The context manager already takes care of the state problem and for the other tasks code from Reset
???? * can be used. These changes are way to risky during the 1.0 code freeze which is taking place right now.
???? * Likely a lot of other new bugs will be exposed. For that reason request a depth stencil surface all the
???? * time. It can cause a slight performance hit but fixes a lot of regressions. A fixme reminds of that this
???? * issue needs to be fixed. */
??? if (DepthStencilFormat != WINED3DFMT_D24S8)
??????? FIXME("Add OpenGL context recreation support to SetDepthStencilSurface\n");

??? DepthStencilFormat = WINED3DFMT_D24S8;

/* Changed Section June 24,08 */

/*??? if(DepthStencilFormat) {???????????????????? Changed June 19,08*/
??? getDepthStencilBits(DepthStencilFormat, &depthBits, &stencilBits);
/*??? }?? This if will always be true because of the above? so just call getDepthStencilBits */

??? /* Find a pixel format which EXACTLY matches our requirements (except for depth) */
??? for(i=0; i<nCfgs; i++) 
????? {
??????? cfgs = &This->adapter->cfgs[i];
??????????????????? 
??????? /* For now only accept RGBA formats. Perhaps some day we will
???????? * allow floating point formats for pbuffers. */
??????? if (cfgs->iPixelType != WGL_TYPE_RGBA_ARB)
?????????? continue;

??????? /* In window mode (!pbuffer) we need a window drawable format and double buffering. */
??????? if (!pbuffer && !(cfgs->windowDrawable && cfgs->doubleBuffer))
?????????? continue;

?????? /* We like to have aux buffers in backbuffer mode */
??????? if (auxBuffers && !cfgs->auxBuffers)
?????????? continue;

??????? /* In pbuffer-mode we need a pbuffer-capable format but we don't want double buffering */
??????? if (pbuffer && (!cfgs->pbufferDrawable || cfgs->doubleBuffer))
???????????? continue;

/* This is faster and more efficient code wise since they are all related so evaluate them together Changed June 19,08 */

??????? if ((cfgs->redSize != redBits) || (cfgs->greenSize != greenBits) || (cfgs->blueSize != blueBits) || (cfgs->alphaSize != alphaBits))
???????????? continue;

??????? /* In all cases make sure the number of stencil bits matches our requirements
???????? * even when we don't need stencil because it could affect performance EXCEPT
???????? * on cards which don't offer depth formats without stencil like the i915 drivers
???????? * on Linux. */
??????? if ((stencilBits != cfgs->stencilSize) && !((This->adapter->brokenStencil && stencilBits) <= cfgs->stencilSize))
???????????? continue;

??????? /* Check multisampling support */
??????? if (cfgs->numSamples != numSamples)
???????????? continue;

??????? /* We try to locate a format which matches our requirements exactly. In case of
???????? * depth it is no problem to emulate 16-bit using e.g. 24-bit, so accept that. */
???????? if (cfgs->depthSize !=? depthBits)? /* Changed June 24,08 */
??????????? continue;

??????? /* Exit the loop as we have found a format :) */
??????? if (exactDepthMatch) 
?????????? {
??????????? TRACE("Exact Depth Match\n");
??????????? iPixelFormat = cfgs->iPixelFormat;
??????????? break;
?????????? } 

??????? 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. */
??????????? TRACE("Emulating %d\n",cfgs->iPixelFormat);
??????????? iPixelFormat = cfgs->iPixelFormat;
??????????? break; /* Added June 24,08 */
????????? }
??? }

??? /* 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;
????? } 
Remarked this out. Yes it will cycle through the 3 adapters (I am running dual head and for some reason it thinks I have 3 adapters not just the 2 for dual head) 
Why would findCompatible not be set for all adapters? this is what the DX 9c specs? say it should do then the application picks the best of all */
????? 
??? if (!iPixelFormat) 
????? {
??????? TRACE("iPixelFormat = %d FindCompatible=%d\n",iPixelFormat, findCompatible);

??????? TRACE("Falling back to ChoosePixelFormat as we weren't able to find an exactly matching pixel format\n");
??????? /* PixelFormat selection */
??????? ZeroMemory(&pfd, sizeof(pfd));
??????? pfd.nSize?????????? = sizeof(pfd);
??????? pfd.nVersion????? = 1; /* Should this be hard Coded or put into a #DEFINE so it can be changed later if needed */
??????? pfd.dwFlags????? = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;/*PFD_GENERIC_ACCELERATED*/
??????? pfd.iPixelType?? = PFD_TYPE_RGBA;
??????? pfd.cAlphaBits?? = alphaBits;
??????? pfd.cColorBits??? = colorBits;
??????? pfd.cDepthBits?? = depthBits;
??????? pfd.cStencilBits? = stencilBits;
??????? pfd.iLayerType? = PFD_MAIN_PLANE;

??????? 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");
?????????? return FALSE;
????????? }
????? }

??? TRACE("Found iPixelFormat\n");
??? return iPixelFormat;
}




Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winehq.org/pipermail/wine-devel/attachments/20080624/653df106/attachment-0001.htm 


More information about the wine-devel mailing list