Henri Verbeet : wined3d: Skip copying the depth stencil if it's discarded.

Alexandre Julliard julliard at winehq.org
Tue Sep 23 09:28:30 CDT 2008


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Mon Sep 22 14:52:52 2008 +0200

wined3d: Skip copying the depth stencil if it's discarded.

This gives a small performance improvement for applications that are
smart enough to set the D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL flag, or
to create depth stencils with Discard set to TRUE.

---

 dlls/wined3d/device.c          |   11 ++++++++---
 dlls/wined3d/swapchain.c       |    7 +++++++
 dlls/wined3d/wined3d_private.h |    1 +
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index d83fdcc..08ef2e1 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -6647,9 +6647,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDepthStencilSurface(IWineD3DDevice *
          ******************************************************/
 
         if (This->stencilBufferTarget) {
-            ActivateContext(This, This->render_targets[0], CTXUSAGE_RESOURCELOAD);
-            surface_load_ds_location(This->stencilBufferTarget, SFLAG_DS_OFFSCREEN);
-            surface_modify_ds_location(This->stencilBufferTarget, SFLAG_DS_OFFSCREEN);
+            if (((IWineD3DSwapChainImpl *)This->swapchains[0])->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
+                    || ((IWineD3DSurfaceImpl *)This->stencilBufferTarget)->Flags & SFLAG_DISCARD) {
+                surface_modify_ds_location(This->stencilBufferTarget, SFLAG_DS_DISCARDED);
+            } else {
+                ActivateContext(This, This->render_targets[0], CTXUSAGE_RESOURCELOAD);
+                surface_load_ds_location(This->stencilBufferTarget, SFLAG_DS_OFFSCREEN);
+                surface_modify_ds_location(This->stencilBufferTarget, SFLAG_DS_OFFSCREEN);
+            }
         }
 
         tmp = This->stencilBufferTarget;
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 1a82ab8..a9a5787 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -259,6 +259,13 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
         }
     }
 
+    if (This->wineD3DDevice->stencilBufferTarget) {
+        if (This->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
+                || ((IWineD3DSurfaceImpl *)This->wineD3DDevice->stencilBufferTarget)->Flags & SFLAG_DISCARD) {
+            surface_modify_ds_location(This->wineD3DDevice->stencilBufferTarget, SFLAG_DS_DISCARDED);
+        }
+    }
+
     if(This->presentParms.PresentationInterval != WINED3DPRESENT_INTERVAL_IMMEDIATE && GL_SUPPORT(SGI_VIDEO_SYNC)) {
         retval = GL_EXTCALL(glXGetVideoSyncSGI(&sync));
         if(retval != 0) {
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 967cec6..95da129 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1449,6 +1449,7 @@ void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back);
 
 #define SFLAG_DS_LOCATIONS  (SFLAG_DS_ONSCREEN | \
                              SFLAG_DS_OFFSCREEN)
+#define SFLAG_DS_DISCARDED   SFLAG_DS_LOCATIONS
 
 BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]);
 




More information about the wine-cvs mailing list