Stefan Dösinger : wined3d: Depthfill blits are allowed between BeginScene and Endscene.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jun 22 07:35:44 CDT 2007


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

Author: Stefan Dösinger <stefandoesinger at gmx.at>
Date:   Fri Jun  8 20:59:57 2007 +0200

wined3d: Depthfill blits are allowed between BeginScene and Endscene.

---

 dlls/ddraw/tests/d3d.c |   38 ++++++++++++++++++++++++++++++++++++++
 dlls/wined3d/surface.c |    6 ++++--
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
index 5de0e2f..35d6192 100644
--- a/dlls/ddraw/tests/d3d.c
+++ b/dlls/ddraw/tests/d3d.c
@@ -27,6 +27,7 @@
 static LPDIRECTDRAW7           lpDD = NULL;
 static LPDIRECT3D7             lpD3D = NULL;
 static LPDIRECTDRAWSURFACE7    lpDDS = NULL;
+static LPDIRECTDRAWSURFACE7    lpDDSdepth = NULL;
 static LPDIRECT3DDEVICE7       lpD3DDevice = NULL;
 static LPDIRECT3DVERTEXBUFFER7 lpVBufSrc = NULL;
 static LPDIRECT3DVERTEXBUFFER7 lpVBufDest1 = NULL;
@@ -88,6 +89,27 @@ static BOOL CreateDirect3D(void)
     if (!SUCCEEDED(rc))
 	return FALSE;
 
+    memset(&ddsd, 0, sizeof(ddsd));
+    ddsd.dwSize = sizeof(ddsd);
+    ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
+    ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
+    ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
+    ddsd.ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
+    ddsd.ddpfPixelFormat.dwZBufferBitDepth = 16;
+    ddsd.ddpfPixelFormat.dwZBitMask = 0x0000FFFF;
+    ddsd.dwWidth = 256;
+    ddsd.dwHeight = 256;
+    rc = IDirectDraw7_CreateSurface(lpDD, &ddsd, &lpDDSdepth, NULL);
+    ok(rc==DD_OK, "CreateSurface returned: %x\n", rc);
+    if (!SUCCEEDED(rc)) {
+        lpDDSdepth = NULL;
+    } else {
+        rc = IDirectDrawSurface_AddAttachedSurface(lpDDS, lpDDSdepth);
+        ok(rc == DD_OK, "IDirectDrawSurface_AddAttachedSurface returned %x\n", rc);
+        if (!SUCCEEDED(rc))
+            return FALSE;
+    }
+
     rc = IDirect3D7_CreateDevice(lpD3D, &IID_IDirect3DTnLHalDevice, lpDDS,
         &lpD3DDevice);
     ok(rc==D3D_OK || rc==DDERR_NOPALETTEATTACHED || rc==E_OUTOFMEMORY, "CreateDevice returned: %x\n", rc);
@@ -117,6 +139,12 @@ static void ReleaseDirect3D(void)
         lpD3DDevice = NULL;
     }
 
+    if (lpDDSdepth != NULL)
+    {
+        IDirectDrawSurface_Release(lpDDSdepth);
+        lpDDSdepth = NULL;
+    }
+
     if (lpDDS != NULL)
     {
         IDirectDrawSurface_Release(lpDDS);
@@ -569,6 +597,16 @@ static void SceneTest(void)
     ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed with %08x\n", hr);
     if(SUCCEEDED(hr))
     {
+        DDBLTFX fx;
+        memset(&fx, 0, sizeof(fx));
+        fx.dwSize = sizeof(fx);
+
+        if(lpDDSdepth) {
+            hr = IDirectDrawSurface7_Blt(lpDDSdepth, NULL, NULL, NULL, DDBLT_DEPTHFILL, &fx);
+            ok(hr == D3D_OK, "Depthfill failed in a BeginScene / EndScene pair\n");
+        } else {
+            skip("Depth stencil creation failed at startup, skipping\n");
+        }
         hr = IDirect3DDevice7_EndScene(lpD3DDevice);
         ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed with %08x\n", hr);
     }
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 4640bef..c8e961a 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3175,9 +3175,11 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, RECT *Dest
     TRACE("(%p)->(%p,%p,%p,%x,%p)\n", This, DestRect, SrcSurface, SrcRect, Flags, DDBltFx);
     TRACE("(%p): Usage is %s\n", This, debug_d3dusage(This->resource.usage));
 
-    /* Accessing the depth stencil is supposed to fail between a BeginScene and EndScene pair */
+    /* Accessing the depth stencil is supposed to fail between a BeginScene and EndScene pair,
+     * except depth blits, which seem to work
+     */
     if(iface == myDevice->stencilBufferTarget || (SrcSurface && SrcSurface == myDevice->stencilBufferTarget)) {
-        if(myDevice->inScene) {
+        if(myDevice->inScene && !(Flags & WINEDDBLT_DEPTHFILL)) {
             TRACE("Attempt to access the depth stencil surface in a BeginScene / EndScene pair, returning WINED3DERR_INVALIDCALL\n");
             return WINED3DERR_INVALIDCALL;
         } else if(IWineD3DSurfaceImpl_BltZ(This, DestRect, SrcSurface, SrcRect, Flags, DDBltFx) == WINED3D_OK) {




More information about the wine-cvs mailing list