On Sunday 20 August 2006 18:36, you wrote:
(I forgot if I verified this, but) I think that when a state is beeing set This->stateBlock->renderState[State] has the previous value and only Value has the one to be set. From a quick glance it seems the code for this renderstate (and maybe more renderstates) wrongly assumes the contrary.
The top of the function has: This->updateStateBlock->renderState[State] = Value; before entering the main switch.
The problem with relying on Value is, that code block can be entered when State is WINED3DRS_ALPHATESTENABLE, WINED3DRS_ALPHAFUNC, WINED3DRS_ALPHAREF, or WINED3DRS_COLORKEYENABLE. And if it's not WINED3DRS_ALPHAFUNC, then Value isn't the same as This->stateBlock->renderState[WINED3DRS_ALPHAFUNC]. which would cause the wrong value to be reported.
Without this patch, Morrowind reports that 1 and 8 are unrecognized D3DCMPFUNC values, which is odd since they are recognized and handled properly. It turns out that 1 and 8 are being set for D3DRS_ALPHATESTENABLE and D3DRS_ALPHAREF respectively, and the unrecognized D3DCMPFUNC value is actually 0 (this was verified via trace+d3d). With the patch, Wine properly reports that 0 is the unrecognized D3DCMPFUNC value (which the game seems to set temporarilly for some reason).