From 212246e34c890a6fecb8ab6d901c7798d129604c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Sun, 29 Nov 2009 18:48:58 +0100 Subject: [PATCH 03/17] 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 | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 44 insertions(+), 5 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1e95f8b..9eddb45 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 { @@ -6897,6 +6914,28 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRE hr = create_primary_opengl_context(iface, (IWineD3DSwapChain *) swapchain); IWineD3DSwapChain_Release((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; + } + } + swapchain->context[0]->render_offscreen = swapchain->render_to_fbo; + /* All done. There is no need to reload resources or shaders, this will happen automatically on the * first use */ -- 1.6.4.4