[6/7] WineD3D: Disable depth stencil related states without a depth
stencil buffer
Stefan Dösinger
stefan at codeweavers.com
Tue Mar 6 08:00:06 CST 2007
-------------- next part --------------
From e638bb37df11284514bd09aec5be56ce715f4855 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Tue, 6 Mar 2007 13:54:05 +0100
Subject: [PATCH] WineD3D: Disable depth stencil related states without a depth stencil buffer
Except with fbos, it is not possible to remove the depth stencil buffer from the opengl frame buffer, so when
the d3d app sets a NULL depth stencil disable all states that work with the depth stencil buffer.
---
dlls/wined3d/device.c | 7 +++++++
dlls/wined3d/state.c | 20 +++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 7436ecb..654bf13 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5175,6 +5175,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDepthStencilSurface(IWineD3DDevice *
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
set_depth_stencil_fbo(iface, pNewZStencil);
}
+
+ if((!tmp && pNewZStencil) || (!pNewZStencil && tmp)) {
+ /* Swapping NULL / non NULL depth stencil affects the depth and tests */
+ IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_ZENABLE));
+ IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_STENCILENABLE));
+ IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_STENCILWRITEMASK));
+ }
}
return hr;
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index c56ce67..00f4876 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -105,6 +105,13 @@ static void state_lighting(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
}
static void state_zenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
+ /* No z test without depth stencil buffers */
+ if(stateblock->wineD3DDevice->stencilBufferTarget == NULL) {
+ glDisable(GL_DEPTH_TEST); /* This also disables z writing in gl */
+ checkGLcall("glDisable GL_DEPTH_TEST");
+ return;
+ }
+
switch ((WINED3DZBUFFERTYPE) stateblock->renderState[WINED3DRS_ZENABLE]) {
case WINED3DZB_FALSE:
glDisable(GL_DEPTH_TEST);
@@ -611,6 +618,13 @@ state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *c
GLint depthFail_ccw = GL_KEEP;
GLint stencilPass_ccw = GL_KEEP;
+ /* No stencil test without a stencil buffer */
+ if(stateblock->wineD3DDevice->stencilBufferTarget == NULL) {
+ glDisable(GL_STENCIL_TEST);
+ checkGLcall("glDisable GL_STENCIL_TEST");
+ return;
+ }
+
if( stateblock->set.renderState[WINED3DRS_STENCILENABLE] )
onesided_enable = stateblock->renderState[WINED3DRS_STENCILENABLE];
if( stateblock->set.renderState[WINED3DRS_TWOSIDEDSTENCILMODE] )
@@ -664,7 +678,11 @@ state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *c
}
static void state_stencilwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
- glStencilMask(stateblock->renderState[WINED3DRS_STENCILWRITEMASK]);
+ if(stateblock->wineD3DDevice->stencilBufferTarget) {
+ glStencilMask(stateblock->renderState[WINED3DRS_STENCILWRITEMASK]);
+ } else {
+ glStencilMask(0);
+ }
checkGLcall("glStencilMask");
}
--
1.4.4.3
More information about the wine-patches
mailing list