From dfb2ba79d1ae0b7aa7c67c7cd25fa05aaa289ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Sun, 6 Dec 2009 18:08:39 +0100 Subject: [PATCH 06/20] 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 1f2cdac..eb5ad5b 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); @@ -1115,20 +1116,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) { @@ -1137,6 +1136,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; @@ -1210,6 +1226,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 { @@ -6911,6 +6928,27 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRE ERR("Resetting the stateblock failed with error 0x%08x\n", hr); } + 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; + } + } + hr = create_primary_opengl_context(iface, (IWineD3DSwapChain *) swapchain); IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain); -- 1.6.4.4