Stefan Dösinger : wined3d: Present does not clear the depth stencil.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Jun 14 07:47:03 CDT 2007
Module: wine
Branch: master
Commit: 078523f73e7b708dab06e888c24a1595bb5a63d8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=078523f73e7b708dab06e888c24a1595bb5a63d8
Author: Stefan Dösinger <stefandoesinger at gmx.at>
Date: Thu Jun 14 11:18:03 2007 +0200
wined3d: Present does not clear the depth stencil.
---
dlls/d3d8/tests/visual.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
dlls/d3d9/tests/visual.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/swapchain.c | 18 ++------------
3 files changed, 113 insertions(+), 15 deletions(-)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index f755679..e4178f2 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -116,6 +116,8 @@ static IDirect3DDevice8 *init_d3d8(void)
present_parameters.BackBufferWidth = 640;
present_parameters.BackBufferHeight = 480;
present_parameters.BackBufferFormat = D3DFMT_X8R8G8B8;
+ present_parameters.EnableAutoDepthStencil = TRUE;
+ present_parameters.AutoDepthStencilFormat = D3DFMT_D16;
hr = IDirect3D8_CreateDevice(d3d8_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, present_parameters.hDeviceWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
ok(hr == D3D_OK, "IDirect3D_CreateDevice returned: %s\n", DXGetErrorString8(hr));
@@ -441,6 +443,58 @@ static void fog_test(IDirect3DDevice8 *device)
ok(hr == D3D_OK, "Turning off fog calculations returned %s\n", DXGetErrorString8(hr));
}
+static void present_test(IDirect3DDevice8 *device)
+{
+ struct vertex quad[] =
+ {
+ {-1.0f, -1.0f, 0.9f, 0xffff0000},
+ {-1.0f, 1.0f, 0.9f, 0xffff0000},
+ { 1.0f, -1.0f, 0.1f, 0xffff0000},
+ { 1.0f, 1.0f, 0.1f, 0xffff0000},
+ };
+ HRESULT hr;
+ DWORD color;
+
+ /* Does the Present clear the depth stencil? Clear the depth buffer with some value != 0,
+ * then call Present. Then clear the color buffer to make sure it has some defined content
+ * after the Present with D3DSWAPEFFECT_DISCARD. After that draw a plane that is somewhere cut
+ * by the depth value.
+ */
+ hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 0.75, 0);
+ ok(hr == D3D_OK, "IDirect3DDevice8_Clear returned %s\n", DXGetErrorString8(hr));
+ hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
+ hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.4, 0);
+
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
+ ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_GREATER);
+ ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
+ hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
+ ok(hr == D3D_OK, "IDirect3DDevice8_SetFVF returned %s\n", DXGetErrorString8(hr));
+
+ hr = IDirect3DDevice8_BeginScene(device);
+ ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed with %s\n", DXGetErrorString8(hr));
+ if(hr == D3D_OK)
+ {
+ /* No lights are defined... That means, lit vertices should be entirely black */
+ hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2 /*PrimCount */, quad, sizeof(quad[0]));
+ ok(hr == D3D_OK, "IDirect3DDevice8_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString8(hr));
+
+ hr = IDirect3DDevice8_EndScene(device);
+ ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed with %s\n", DXGetErrorString8(hr));
+ }
+
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
+ ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState returned %s\n", DXGetErrorString8(hr));
+
+ hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+ color = getPixelColor(device, 512, 240);
+ ok(color == 0x00ffffff, "Present failed: Got color 0x%08x, expected 0x00ffffff.\n", color);
+ color = getPixelColor(device, 64, 240);
+ ok(color == 0x00ff0000, "Present failed: Got color 0x%08x, expected 0x00ff0000.\n", color);
+}
+
START_TEST(visual)
{
IDirect3DDevice8 *device_ptr;
@@ -492,6 +546,7 @@ START_TEST(visual)
lighting_test(device_ptr);
clear_test(device_ptr);
fog_test(device_ptr);
+ present_test(device_ptr);
cleanup:
if(device_ptr) IDirect3DDevice8_Release(device_ptr);
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index d961d80..3ab45e1 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -116,6 +116,8 @@ static IDirect3DDevice9 *init_d3d9(void)
present_parameters.BackBufferWidth = 640;
present_parameters.BackBufferHeight = 480;
present_parameters.BackBufferFormat = D3DFMT_X8R8G8B8;
+ present_parameters.EnableAutoDepthStencil = TRUE;
+ present_parameters.AutoDepthStencilFormat = D3DFMT_D16;
hr = IDirect3D9_CreateDevice(d3d9_ptr, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, present_parameters.hDeviceWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present_parameters, &device_ptr);
ok(hr == D3D_OK, "IDirect3D_CreateDevice returned: %s\n", DXGetErrorString9(hr));
@@ -1114,6 +1116,58 @@ static void texbem_test(IDirect3DDevice9 *device)
}
}
+static void present_test(IDirect3DDevice9 *device)
+{
+ struct vertex quad[] =
+ {
+ {-1.0f, -1.0f, 0.9f, 0xffff0000},
+ {-1.0f, 1.0f, 0.9f, 0xffff0000},
+ { 1.0f, -1.0f, 0.1f, 0xffff0000},
+ { 1.0f, 1.0f, 0.1f, 0xffff0000},
+ };
+ HRESULT hr;
+ DWORD color;
+
+ /* Does the Present clear the depth stencil? Clear the depth buffer with some value != 0,
+ * then call Present. Then clear the color buffer to make sure it has some defined content
+ * after the Present with D3DSWAPEFFECT_DISCARD. After that draw a plane that is somewhere cut
+ * by the depth value.
+ */
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 0.75, 0);
+ ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %s\n", DXGetErrorString9(hr));
+ hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.4, 0);
+
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
+ ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_GREATER);
+ ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
+ hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
+ ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF returned %s\n", DXGetErrorString9(hr));
+
+ hr = IDirect3DDevice9_BeginScene(device);
+ ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %s\n", DXGetErrorString9(hr));
+ if(hr == D3D_OK)
+ {
+ /* No lights are defined... That means, lit vertices should be entirely black */
+ hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2 /*PrimCount */, quad, sizeof(quad[0]));
+ ok(hr == D3D_OK, "IDirect3DDevice9_DrawIndexedPrimitiveUP failed with %s\n", DXGetErrorString9(hr));
+
+ hr = IDirect3DDevice9_EndScene(device);
+ ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %s\n", DXGetErrorString9(hr));
+ }
+
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
+ ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", DXGetErrorString9(hr));
+
+ hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+ ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
+ color = getPixelColor(device, 512, 240);
+ ok(color == 0x00ffffff, "Present failed: Got color 0x%08x, expected 0x00ffffff.\n", color);
+ color = getPixelColor(device, 64, 240);
+ ok(color == 0x00ff0000, "Present failed: Got color 0x%08x, expected 0x00ff0000.\n", color);
+}
+
START_TEST(visual)
{
IDirect3DDevice9 *device_ptr;
@@ -1169,6 +1223,7 @@ START_TEST(visual)
clear_test(device_ptr);
fog_test(device_ptr);
test_cube_wrap(device_ptr);
+ present_test(device_ptr);
if (caps.VertexShaderVersion >= D3DVS_VERSION(2, 0))
{
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index e7a3173..b449856 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -148,7 +148,6 @@ static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion, DWORD dwFlags) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
- DWORD clear_flags = 0;
unsigned int sync;
int retval;
@@ -298,22 +297,11 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
LEAVE_GL();
- if (This->wineD3DDevice->stencilBufferTarget) {
- clear_flags |= WINED3DCLEAR_STENCIL|WINED3DCLEAR_ZBUFFER;
- }
-
- /* Although this is not strictly required, a simple demo showed this does occur
- on (at least non-debug) d3d */
if (This->presentParms.SwapEffect == WINED3DSWAPEFFECT_DISCARD) {
+ TRACE("Clearing the color buffer with pink color\n");
- TRACE("Clearing\n");
-
- IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, clear_flags|WINED3DCLEAR_TARGET, 0x00, 1.0, 0);
-
- } else if (clear_flags) {
- TRACE("Clearing z/stencil buffer\n");
-
- IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL, clear_flags, 0x00, 1.0, 0);
+ IWineD3DDevice_Clear((IWineD3DDevice*)This->wineD3DDevice, 0, NULL,
+ WINED3DCLEAR_TARGET, 0xff00ffff, 1.0, 0);
}
if(((IWineD3DSurfaceImpl *) This->frontBuffer)->Flags & SFLAG_INSYSMEM ||
More information about the wine-cvs
mailing list