From 6fa7b36a24e63e0881d620b1c756d119f89d6d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Wed, 2 Dec 2009 15:43:09 +0100 Subject: [PATCH 06/19] WineD3D: Render to fbo when the size mismatches at creation time This is needed because the window(and thus the GL drawable) might be smaller than the D3D backbuffer. If we waited for the FBO switch until Present is called we'd lose data in the first frame. --- dlls/wined3d/device.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 43 insertions(+), 5 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1edd71c..7e3cf72 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1043,6 +1043,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface, BOOL displaymode_set = FALSE; WINED3DDISPLAYMODE Mode; const struct GlPixelFormatDesc *format_desc; + RECT client_rect; TRACE("(%p) : Created Additional Swap Chain\n", This); @@ -1116,20 +1117,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface, object->orig_fmt = Mode.Format; format_desc = getFormatDescEntry(Mode.Format, &This->adapter->gl_info); + GetClientRect(object->win_handle, &client_rect); if (pPresentationParameters->Windowed && ((pPresentationParameters->BackBufferWidth == 0) || (pPresentationParameters->BackBufferHeight == 0) || (pPresentationParameters->BackBufferFormat == WINED3DFMT_UNKNOWN))) { - RECT Rect; - GetClientRect(object->win_handle, &Rect); - if (pPresentationParameters->BackBufferWidth == 0) { - pPresentationParameters->BackBufferWidth = Rect.right; + pPresentationParameters->BackBufferWidth = client_rect.right; TRACE("Updating width to %d\n", pPresentationParameters->BackBufferWidth); } if (pPresentationParameters->BackBufferHeight == 0) { - pPresentationParameters->BackBufferHeight = Rect.bottom; + pPresentationParameters->BackBufferHeight = client_rect.bottom; TRACE("Updating height to %d\n", pPresentationParameters->BackBufferHeight); } if (pPresentationParameters->BackBufferFormat == WINED3DFMT_UNKNOWN) { @@ -1138,6 +1137,23 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface, } } + if(wined3d_settings.offscreen_rendering_mode == ORM_FBO) + { + if(pPresentationParameters->BackBufferWidth != client_rect.right || + pPresentationParameters->BackBufferHeight != client_rect.bottom) + { + TRACE("Rendering to FBO. Backbuffer %ux%u, window %ux%u\n", + pPresentationParameters->BackBufferWidth, + pPresentationParameters->BackBufferHeight, + client_rect.right, client_rect.bottom); + object->render_to_fbo = TRUE; + } + else + { + TRACE("Rendering directly to GL_BACK\n"); + } + } + /* Put the correct figures in the presentation parameters */ TRACE("Copying across presentation parameters\n"); object->presentParms = *pPresentationParameters; @@ -1211,6 +1227,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface, TRACE("Context created (HWND=%p, glContext=%p)\n", object->win_handle, object->context[0]->glCtx); } + object->context[0]->render_offscreen = object->render_to_fbo; } else { @@ -6910,6 +6927,27 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRE } hr = create_primary_opengl_context(iface, (IWineD3DSwapChain *) swapchain); + + if(wined3d_settings.offscreen_rendering_mode == ORM_FBO) + { + RECT client_rect; + GetClientRect(swapchain->win_handle, &client_rect); + + if(swapchain->presentParms.BackBufferWidth != client_rect.right || + swapchain->presentParms.BackBufferHeight != client_rect.bottom) + { + TRACE("Rendering to FBO. Backbuffer %ux%u, window %ux%u\n", + swapchain->presentParms.BackBufferWidth, + swapchain->presentParms.BackBufferHeight, + client_rect.right, client_rect.bottom); + swapchain->render_to_fbo = TRUE; + } + else + { + TRACE("Rendering directly to GL_BACK\n"); + swapchain->render_to_fbo = FALSE; + } + } if(SUCCEEDED(hr)) { swapchain->context[0]->render_offscreen = swapchain->render_to_fbo; -- 1.6.4.4