dxvk
dxvk copied to clipboard
[RFC] Rework D3D9 alpha test
In order to get rid of the alphaTestWiggleRoom
option and have more better behaviour out of the box without floating point math inaccuracies, we should pass in the alpha reference as an integer and quantize the oC0
alpha value on the GPU.
The way this behaves right now is as if the old alphaTestWiggleRoom
option was enabled by default, always using 12 bits of accuracy, but changing the accuracy depending on bound render target format is simple now since it's part of the alpha ref push constant.
If necessary, we can also relatively easily add a path to restore the previous behaviour, e.g. something like
if (rs.alphaBits == some_magic_value) {
alphaRef = float(rs.alphaRef) / 255.0f;
alpha = oC0.w;
} else {
alphaRef = float((rs.alphaRef << rs.alphaBits // etc.
alpha = oC0.w * float((256 << rs.alphaBits) - 1);
}
This will obviously require a lot of testing in D3D9 games, but I'd like to get rid of the alpha test option before the 2.0 release.
Fixes https://github.com/doitsujin/dxvk/issues/1899 Found by @WinterSnowfall