Stefan Dösinger wrote:
/*****
- Get / Set Render States
- TODO: Verify against dx9 definitions
As Henri said, this needs a test case. So far we have not found any Set* function that returns an error. For SetTexture, SetSamplerState, ..., if the sampler index is out of bounds, the native implementation happily corrupts memory and returns D3D_OK rather than checking anything.
Also even if tests confirm it is correct, I don't think this patch is a good idea unless we have a game that breaks because it expects an error from this function back. The setter functions are highly performance critical. Those value checks add a lot of code(if-then-else constructs in the compiled code) which slows things down. In benchmarks every single if statement in the setter function hurts.
Oh I also forgot... I believe that set render state is primarily called at the init of the app so should not overly effect the performance of the application. When EQ2 is loading it sets fogcolor to FFFFFF the maximum allowed value for fog color according to MSDN is :
+ case WINED3DRS_FOGCOLOR: + /* Valid Values are between 0 and FFFF (4 bytes alpha, red, green, and blue)) */ + if ((Value >= 0) || + (Value <= 0xFFFF)) break;
So when EQ2 sets the fog color to FFFFFF its an invalid value and should return WINED3DERR_INVALIDCALL. Without this EQ2 gives the pixel format error and crashes wine. I could change the patch to just catch this.
Chris