[WINED3D 2] Fix render state bugs
Ivan Gyurdiev
ivg231 at gmail.com
Thu Jul 13 19:19:26 CDT 2006
Fix bugs exposed by render state tests for D3D9 [see patch 3]
Each of the bugs below will cause a test to fail.
======================================
Bug: Do not always create a depth-stencil buffer (thereby forcing
ZENABLE state to TRUE always). Dereference
pPresentationParameters->EnableAutoDepthStencil pointer.
Bug: Do not return WINED3DERR_INVALIDCALL on attempt to set PHONG
shading. It may be claimed "unsupported" on msdn, but native does not
fail in this way.
Bug: Do not read pixel and vertex shader from updateStateBlock() on Get
requests. Instead, read from the active stateblock - this will work
properly in recording mode.
Bug: In ActiveRender(), do not restore recording, until after
Get/SetRender calls for CULLMODE. Otherwise the Get/Set will not have
the desired effect at all, and will interfer with the recording.
Bug: Default ALPHAREF state is 0, not 0xff
Bug: Default AMBIENTMATERIALSOURCE state is D3DMCS_MATERIAL, not
D3DMCS_COLOR2 (specular)
Bug: Default POINTSCALE A,B,C are: 1.0f, 0.0f, 0.0f respectively, not
TRUE, TRUE, TRUE
Bug: State returned 0xbaadcafe for DEBUGMONITORTOKEN, not D3DDMT_DISABLE.
-------------- next part --------------
---
dlls/wined3d/device.c | 54 ++++++++++++++++++++-------------------------
dlls/wined3d/stateblock.c | 17 ++++++++------
2 files changed, 34 insertions(+), 37 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 630d6d4..a92681c 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1743,7 +1743,7 @@ #endif
}
/* Under directX swapchains share the depth stencil, so only create one depth-stencil */
- if (pPresentationParameters->EnableAutoDepthStencil && hr == WINED3D_OK) {
+ if (*(pPresentationParameters->EnableAutoDepthStencil) && hr == WINED3D_OK) {
TRACE("Creating depth stencil buffer\n");
if (This->depthStencilBuffer == NULL ) {
hr = D3DCB_CreateDepthStencil((IUnknown *) This->parent,
@@ -3565,10 +3565,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl
checkGLcall("glShadeModel");
break;
case D3DSHADE_PHONG:
- FIXME("D3DSHADE_PHONG isn't supported?\n");
-
- LEAVE_GL();
- return WINED3DERR_INVALIDCALL;
+ FIXME("D3DSHADE_PHONG isn't supported\n");
+ break;
default:
FIXME("Unrecognized/Unhandled D3DSHADEMODE value %ld\n", Value);
}
@@ -4724,7 +4722,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
if (dstData == NULL || cnt < 0)
return WINED3DERR_INVALIDCALL;
- memcpy(dstData, &This->updateStateBlock->vertexShaderConstantB[start], cnt * sizeof(BOOL));
+ memcpy(dstData, &This->stateBlock->vertexShaderConstantB[start], cnt * sizeof(BOOL));
return WINED3D_OK;
}
@@ -4771,7 +4769,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
if (dstData == NULL || cnt < 0)
return WINED3DERR_INVALIDCALL;
- memcpy(dstData, &This->updateStateBlock->vertexShaderConstantI[start * 4], cnt * sizeof(int) * 4);
+ memcpy(dstData, &This->stateBlock->vertexShaderConstantI[start * 4], cnt * sizeof(int) * 4);
return WINED3D_OK;
}
@@ -4818,7 +4816,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
if (dstData == NULL || cnt < 0)
return WINED3DERR_INVALIDCALL;
- memcpy(dstData, &This->updateStateBlock->vertexShaderConstantF[start * 4], cnt * sizeof(float) * 4);
+ memcpy(dstData, &This->stateBlock->vertexShaderConstantF[start * 4], cnt * sizeof(float) * 4);
return WINED3D_OK;
}
@@ -4906,7 +4904,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
if (dstData == NULL || cnt < 0)
return WINED3DERR_INVALIDCALL;
- memcpy(dstData, &This->updateStateBlock->pixelShaderConstantB[start], cnt * sizeof(BOOL));
+ memcpy(dstData, &This->stateBlock->pixelShaderConstantB[start], cnt * sizeof(BOOL));
return WINED3D_OK;
}
@@ -4953,7 +4951,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
if (dstData == NULL || cnt < 0)
return WINED3DERR_INVALIDCALL;
- memcpy(dstData, &This->updateStateBlock->pixelShaderConstantI[start * 4], cnt * sizeof(int) * 4);
+ memcpy(dstData, &This->stateBlock->pixelShaderConstantI[start * 4], cnt * sizeof(int) * 4);
return WINED3D_OK;
}
@@ -5000,7 +4998,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl
if (dstData == NULL || cnt < 0)
return WINED3DERR_INVALIDCALL;
- memcpy(dstData, &This->updateStateBlock->pixelShaderConstantF[start * 4], cnt * sizeof(float) * 4);
+ memcpy(dstData, &This->stateBlock->pixelShaderConstantF[start * 4], cnt * sizeof(float) * 4);
return WINED3D_OK;
}
@@ -7293,6 +7291,8 @@ #endif
static HRESULT WINAPI IWineD3DDeviceImpl_ActiveRender(IWineD3DDevice* iface,
IWineD3DSurface *RenderSurface) {
HRESULT ret = WINED3DERR_INVALIDCALL;
+ BOOL oldRecording;
+ IWineD3DStateBlockImpl *oldUpdateStateBlock;
/**
* Currently only active for GLX >= 1.3
@@ -7512,23 +7512,14 @@ #endif
}
}
-#if 1 /* Apply the stateblock to the new context
-FIXME: This is a bit of a hack, each context should know it's own state,
-the directX current directX state should then be applied to the context */
- {
- BOOL oldRecording;
- IWineD3DStateBlockImpl *oldUpdateStateBlock;
- oldUpdateStateBlock = This->updateStateBlock;
- oldRecording= This->isRecordingState;
- This->isRecordingState = FALSE;
- This->updateStateBlock = This->stateBlock;
- IWineD3DStateBlock_Apply((IWineD3DStateBlock *)This->stateBlock);
-
- This->isRecordingState = oldRecording;
- This->updateStateBlock = oldUpdateStateBlock;
- }
-#endif
-
+ /* Disable recording, and apply the stateblock to the new context
+ * FIXME: This is a bit of a hack, each context should know it's own state,
+ * the directX current directX state should then be applied to the context */
+ oldUpdateStateBlock = This->updateStateBlock;
+ oldRecording= This->isRecordingState;
+ This->isRecordingState = FALSE;
+ This->updateStateBlock = This->stateBlock;
+ IWineD3DStateBlock_Apply((IWineD3DStateBlock *)This->stateBlock);
/* clean up the current rendertargets swapchain (if it belonged to one) */
if (currentSwapchain != NULL) {
@@ -7542,10 +7533,9 @@ #endif
IWineD3DSurface_AddRef(This->renderTarget);
IWineD3DSurface_Release(tmp);
-
-
{
DWORD value;
+
/* The surface must be rendered upside down to cancel the flip produce by glCopyTexImage */
/* Check that the container is not a swapchain member */
@@ -7566,6 +7556,10 @@ #endif
This->proj_valid = FALSE;
}
+ /* Restore recording state */
+ This->isRecordingState = oldRecording;
+ This->updateStateBlock = oldUpdateStateBlock;
+
ret = WINED3D_OK;
if (cfgs != NULL) {
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 5d26682..f87b717 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -650,7 +650,7 @@ static HRESULT WINAPI IWineD3DStateBloc
IWineD3DDevice_SetRenderState(device, WINED3DRS_CULLMODE, D3DCULL_CCW);
IWineD3DDevice_SetRenderState(device, WINED3DRS_ZFUNC, D3DCMP_LESSEQUAL);
IWineD3DDevice_SetRenderState(device, WINED3DRS_ALPHAFUNC, D3DCMP_ALWAYS);
- IWineD3DDevice_SetRenderState(device, WINED3DRS_ALPHAREF, 0xff); /*??*/
+ IWineD3DDevice_SetRenderState(device, WINED3DRS_ALPHAREF, 0);
IWineD3DDevice_SetRenderState(device, WINED3DRS_DITHERENABLE, FALSE);
IWineD3DDevice_SetRenderState(device, WINED3DRS_ALPHABLENDENABLE, FALSE);
IWineD3DDevice_SetRenderState(device, WINED3DRS_FOGENABLE, FALSE);
@@ -700,26 +700,29 @@ static HRESULT WINAPI IWineD3DStateBloc
IWineD3DDevice_SetRenderState(device, WINED3DRS_NORMALIZENORMALS, FALSE);
IWineD3DDevice_SetRenderState(device, WINED3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
IWineD3DDevice_SetRenderState(device, WINED3DRS_SPECULARMATERIALSOURCE, D3DMCS_COLOR2);
- IWineD3DDevice_SetRenderState(device, WINED3DRS_AMBIENTMATERIALSOURCE, D3DMCS_COLOR2);
+ IWineD3DDevice_SetRenderState(device, WINED3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
IWineD3DDevice_SetRenderState(device, WINED3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
IWineD3DDevice_SetRenderState(device, WINED3DRS_VERTEXBLEND, D3DVBF_DISABLE);
IWineD3DDevice_SetRenderState(device, WINED3DRS_CLIPPLANEENABLE, 0);
IWineD3DDevice_SetRenderState(device, WINED3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
tmpfloat.f = 1.0f;
IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSIZE, tmpfloat.d);
- tmpfloat.f = 0.0f;
+ tmpfloat.f = 1.0f;
IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSIZE_MIN, tmpfloat.d);
IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSPRITEENABLE, FALSE);
IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSCALEENABLE, FALSE);
- IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSCALE_A, TRUE);
- IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSCALE_B, TRUE);
- IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSCALE_C, TRUE);
+ tmpfloat.f = 1.0f;
+ IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSCALE_A, tmpfloat.d);
+ tmpfloat.f = 0.0f;
+ IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSCALE_B, tmpfloat.d);
+ tmpfloat.f = 0.0f;
+ IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSCALE_C, tmpfloat.d);
IWineD3DDevice_SetRenderState(device, WINED3DRS_MULTISAMPLEANTIALIAS, TRUE);
IWineD3DDevice_SetRenderState(device, WINED3DRS_MULTISAMPLEMASK, 0xFFFFFFFF);
IWineD3DDevice_SetRenderState(device, WINED3DRS_PATCHEDGESTYLE, D3DPATCHEDGE_DISCRETE);
tmpfloat.f = 1.0f;
IWineD3DDevice_SetRenderState(device, WINED3DRS_PATCHSEGMENTS, tmpfloat.d);
- IWineD3DDevice_SetRenderState(device, WINED3DRS_DEBUGMONITORTOKEN, D3DDMT_DISABLE);
+ IWineD3DDevice_SetRenderState(device, WINED3DRS_DEBUGMONITORTOKEN, 0xbaadcafe);
tmpfloat.f = 64.0f;
IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSIZE_MAX, tmpfloat.d);
IWineD3DDevice_SetRenderState(device, WINED3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
--
1.4.0
More information about the wine-patches
mailing list