mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
[d3d9] Scale depth bias value based on current format's r
value
This commit is contained in:
parent
2d7f4b1a2c
commit
b738c4220b
@ -1231,6 +1231,14 @@ namespace dxvk {
|
||||
FlushImplicit(FALSE);
|
||||
m_flags.set(D3D9DeviceFlag::DirtyFramebuffer);
|
||||
|
||||
if (ds != nullptr) {
|
||||
float rValue = GetDepthBufferRValue(ds->GetCommonTexture()->GetFormatMapping().FormatColor);
|
||||
if (m_depthBiasScale != rValue) {
|
||||
m_depthBiasScale = rValue;
|
||||
m_flags.set(D3D9DeviceFlag::DirtyDepthBias);
|
||||
}
|
||||
}
|
||||
|
||||
m_state.depthStencil = ds;
|
||||
|
||||
return D3D_OK;
|
||||
@ -5096,12 +5104,9 @@ namespace dxvk {
|
||||
void D3D9DeviceEx::BindDepthBias() {
|
||||
m_flags.clr(D3D9DeviceFlag::DirtyDepthBias);
|
||||
|
||||
// TODO: Can we get a specific non-magic number in Vulkan for this based on device/adapter?
|
||||
constexpr float DepthBiasFactor = float(1 << 23);
|
||||
|
||||
auto& rs = m_state.renderStates;
|
||||
|
||||
float depthBias = bit::cast<float>(rs[D3DRS_DEPTHBIAS]) * DepthBiasFactor;
|
||||
float depthBias = bit::cast<float>(rs[D3DRS_DEPTHBIAS]) * m_depthBiasScale;
|
||||
float slopeScaledDepthBias = bit::cast<float>(rs[D3DRS_SLOPESCALEDEPTHBIAS]);
|
||||
|
||||
DxvkDepthBias biases;
|
||||
|
@ -1025,6 +1025,8 @@ namespace dxvk {
|
||||
bool m_nvATOC = false;
|
||||
bool m_ffZTest = false;
|
||||
|
||||
float m_depthBiasScale = 0.0f;
|
||||
|
||||
D3D9ConstantLayout m_vsLayout;
|
||||
D3D9ConstantLayout m_psLayout;
|
||||
|
||||
|
@ -176,6 +176,22 @@ namespace dxvk {
|
||||
|
||||
void ConvertRect(RECT rect, VkOffset2D& offset, VkExtent2D& extent);
|
||||
|
||||
inline float GetDepthBufferRValue(VkFormat Format) {
|
||||
switch (Format) {
|
||||
case VK_FORMAT_D16_UNORM_S8_UINT:
|
||||
case VK_FORMAT_D16_UNORM:
|
||||
return float(1 << 16);
|
||||
|
||||
case VK_FORMAT_D24_UNORM_S8_UINT:
|
||||
return float(1 << 24);
|
||||
|
||||
default:
|
||||
case VK_FORMAT_D32_SFLOAT_S8_UINT:
|
||||
case VK_FORMAT_D32_SFLOAT:
|
||||
return float(1 << 23);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
UINT CompactSparseList(T* pData, UINT Mask) {
|
||||
uint32_t count = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user