crosire / d3d8to9

A D3D8 pseudo-driver which converts API calls and bytecode shaders to equivalent D3D9 ones.
BSD 2-Clause "Simplified" License
875 stars 77 forks source link

Disable YUV formats on textures #77

Closed elishacloud closed 6 years ago

elishacloud commented 6 years ago

This pull request fixes issue #42.

Overview

This change will return D3DERR_NOTAVAILABLE when an application queries using CheckDeviceFormat on any texture using a YUV format. ATI and Nvidia already return this value for textures, so it should have no affect on these GPUs. However, some Intel chips do not. It appears that these Intel chips attempt to handle the formats but do not handle them correctly.

I believe with Direct3D9 that YUV is supposed to be unsupported on textures. See comment on WineD3D:

    /* Some (all?) Windows drivers do not support YUV 3D textures, only 2D surfaces in
     * StretchRect. Thus use StretchRect to draw the YUV surface onto the screen instead
     * of drawPrimitive. */

Notes

I did think about implementing full support for these formats into d3d8to9, but since most video cards don't support them I did not see the need to do that.

I also thought about blocking the creation of textures that use these formats. I did some tests on Nvidia and it blocks the creation of a texture that use these formats. However this issue was fixed by simply telling the application they are unsupported so I did not add any block on the creation of textures with these formats.

We can always add more fixes here later if there is an issue with other games.

Testing

I tested with the following games:

crosire commented 6 years ago

I don't think the additional check to see if RType is a texture is necessary. A YUV vertex/index buffer doesn't make sense, so might as well always return the error for those formats, regardless of all other arguments. Or is it known to work with offscreen surfaces (that would surprise me)?

elishacloud commented 6 years ago

Yes, good point. Somehow I missed that! Updated in e4a0e32.