Stefan Dösinger : wined3d: Disable depth stencil related states without a depth stencil buffer.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Mar 6 16:13:21 CST 2007
Module: wine
Branch: master
Commit: 6886b237ad71c58023a59caeba3c8ed177f4ebcb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6886b237ad71c58023a59caeba3c8ed177f4ebcb
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Tue Mar 6 13:54:05 2007 +0100
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");
}
More information about the wine-cvs
mailing list