-
Notifications
You must be signed in to change notification settings - Fork 865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
D3D9 Depth bias Mega-issue #2892
Comments
According to Wine, Mass Effect 2 relies on it as well. I haven't personally noticed that yet, maybe the current solution is good enough for that particular game. |
So, guessing everything "-1" for NV it could be just separate detector inline float GetNVDepthBufferRValue(VkFormat Format) {
switch (Format) {
case VK_FORMAT_D16_UNORM_S8_UINT:
case VK_FORMAT_D16_UNORM:
return float(1 << 15);
case VK_FORMAT_D32_SFLOAT_S8_UINT:
case VK_FORMAT_D32_SFLOAT:
return float(1 << 22);
default:
case VK_FORMAT_D24_UNORM_S8_UINT:
return float(1 << 23);
}
} |
That's not what was being said. Also ideally we'd have a more generic, forward-looking fix rather than just hard-coding some random values that might break with any new hardware generation. |
Fixed by #3501 |
Depth bias issues are exceedingly rare in D3D11 games because depth bias in Vulkan works very similarly to D3D11 anyway, even without the extension. So I wouldn't expect that to be the issue. |
Alright, I'll do some captures and open a proper issue tomorrow so it can be investigated. Thanks |
Depth bias in Vulkan:
m * depthBiasSlopeFactor + r * depthBiasConstantFactor
where r is:
Depth bias in D3D9:
m * depthBiasSlopeFactor + depthBiasConstantFactor
r-Value
The constant part of the final depth bias value is scaled by the smallest resolvable difference in Vulkan and unscaled in D3D9. There is no way to make the driver switch to an unscaled depth bias mode or query the factor.
Right now DXVK uses a hardcoded r-value for each depth image format. Microsofts d3d9on12 curiously uses the exact same values. While that seems to work for 9on12, testing shows that it doesn't for DXVK, leading to various issues listed below.
Wine does a few off screen draws when initializing the graphics device to determine the depth bias factor for each depth format.
Nine just falls back to an r-value of 1 << 23 when the underlying driver doesn't support the unscaled depth bias.
On my RTX 3090, the r-value for 16 bit formats is 1 << 15 and 1 << 23 for everything else according to Wine.
Floating point formats
This adds the additional problem that we emulate D24 formats with D32 on AMD hardware. So the scaling behavior is different.
This also prevents us from simply doing a few quick draws to determine the scaling factor and then apply that.
The text was updated successfully, but these errors were encountered: