Stefan Dösinger : Render to fbo when the size mismatches at creation time.

Alexandre Julliard julliard at winehq.org
Mon Dec 7 10:26:18 CST 2009


Module: wine
Branch: master
Commit: 740e2d403edc46529c2475d50a9ceab7c0c77f0c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=740e2d403edc46529c2475d50a9ceab7c0c77f0c

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Sun Dec  6 18:08:39 2009 +0100

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);
 




More information about the wine-cvs mailing list