diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index eef4bd906f9..9edbd737f04 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -119,9 +119,10 @@ static WineD3DContext *AddContextToArray(IWineD3DDeviceImpl *This, HWND win_hand * target: Surface this context will render to * win_handle: handle to the window which we are drawing to * create_pbuffer: tells whether to create a pbuffer or not + * pPresentParameters: contains the pixelformats to use for onscreen rendering * *****************************************************************************/ -WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, HWND win_handle, BOOL create_pbuffer) { +WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, HWND win_handle, BOOL create_pbuffer, const WINED3DPRESENT_PARAMETERS *pPresentParms) { HDC oldDrawable, hdc; HPBUFFERARB pbuffer = NULL; HGLRC ctx = NULL, oldCtx; @@ -222,18 +223,23 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;/*PFD_GENERIC_ACCELERATED*/ pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 32; - pfd.cDepthBits = 24; - pfd.cStencilBits = 8; + pfd.cDepthBits = 0; + pfd.cStencilBits = 0; pfd.iLayerType = PFD_MAIN_PLANE; /* Try to match the colorBits of the d3d format */ if(getColorBits(target->resource.format, &red, &green, &blue, &alpha, &colorBits)) pfd.cColorBits = colorBits; - /* TODO: get the depth/stencil format from auto depth stencil format */ - if(getDepthStencilBits(WINED3DFMT_D24S8, &depthBits, &stencilBits)) { - pfd.cDepthBits = depthBits; - pfd.cStencilBits = stencilBits; + /* Retrieve the depth stencil format from the present parameters. + * The choice of the proper format can give a nice performance boost + * in case of GPU limited programs. */ + if(pPresentParms->EnableAutoDepthStencil) { + TRACE("pPresentParms->EnableAutoDepthStencil=enabled; using AutoDepthStencilFormat=%s\n", debug_d3dformat(pPresentParms->AutoDepthStencilFormat)); + if(getDepthStencilBits(pPresentParms->AutoDepthStencilFormat, &depthBits, &stencilBits)) { + pfd.cDepthBits = depthBits; + pfd.cStencilBits = stencilBits; + } } iPixelFormat = ChoosePixelFormat(hdc, &pfd); @@ -696,7 +702,7 @@ static inline WineD3DContext *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurf */ This->pbufferContext = CreateContext(This, targetimpl, ((IWineD3DSwapChainImpl *) This->swapchains[0])->context[0]->win_handle, - TRUE /* pbuffer */); + TRUE /* pbuffer */, &((IWineD3DSwapChainImpl *)This->swapchains[0])->presentParms); This->pbufferWidth = targetimpl->currentDesc.Width; This->pbufferHeight = targetimpl->currentDesc.Height; } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 59bc35f2c22..b0c0b2050d6 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1302,7 +1302,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevic object->num_contexts = 1; ENTER_GL(); - object->context[0] = CreateContext(This, (IWineD3DSurfaceImpl *) object->frontBuffer, object->win_handle, FALSE /* pbuffer */); + object->context[0] = CreateContext(This, (IWineD3DSurfaceImpl *) object->frontBuffer, object->win_handle, FALSE /* pbuffer */, pPresentationParameters); LEAVE_GL(); if (!object->context[0]) { diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 7741b376b65..5d1edbe9022 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -205,7 +205,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO IWineD3DSurface_UnlockRect(This->backBuffer[0]); DestroyContext(This->wineD3DDevice, This->context[0]); - This->context[0] = CreateContext(This->wineD3DDevice, (IWineD3DSurfaceImpl *) This->frontBuffer, This->win_handle, FALSE /* pbuffer */); + This->context[0] = CreateContext(This->wineD3DDevice, (IWineD3DSurfaceImpl *) This->frontBuffer, This->win_handle, FALSE /* pbuffer */, &This->presentParms); IWineD3DSurface_LockRect(This->backBuffer[0], &r, NULL, WINED3DLOCK_DISCARD); memcpy(r.pBits, mem, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height); @@ -537,7 +537,7 @@ WineD3DContext *IWineD3DSwapChainImpl_CreateContextForThread(IWineD3DSwapChain * TRACE("Creating a new context for swapchain %p, thread %d\n", This, GetCurrentThreadId()); ctx = CreateContext(This->wineD3DDevice, (IWineD3DSurfaceImpl *) This->frontBuffer, - This->context[0]->win_handle, FALSE /* pbuffer */); + This->context[0]->win_handle, FALSE /* pbuffer */, &This->presentParms); if(!ctx) { ERR("Failed to create a new context for the swapchain\n"); return NULL; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b2fe1458207..c996b238958 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -535,7 +535,7 @@ typedef enum ContextUsage { } ContextUsage; void ActivateContext(IWineD3DDeviceImpl *device, IWineD3DSurface *target, ContextUsage usage); -WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, HWND win, BOOL create_pbuffer); +WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, HWND win, BOOL create_pbuffer, const WINED3DPRESENT_PARAMETERS *pPresentParms); void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context); void apply_fbo_state(IWineD3DDevice *iface);