diff --git a/dxvk.conf b/dxvk.conf index bde5a7e4..2bd54596 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -191,6 +191,15 @@ # d3d11.samplerLodBias = 0.0 # d3d9.samplerLodBias = 0.0 + +# Clamps any negative LOD bias to 0. Applies after samplerLodBias has been +# applied. May help with games that use a high negative LOD bias by default. +# +# Supported values: True, False + +# d3d9.clampNegativeLodBias = False + + # Declares vertex positions as invariant in order to solve # potential Z-fighting issues at a small performance cost. # diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 1dd5bbd7..33c724dc 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -6243,7 +6243,11 @@ namespace dxvk { info.mipmapMode = mipFilter.MipFilter; info.maxAnisotropy = float(cKey.MaxAnisotropy); info.useAnisotropy = cKey.MaxAnisotropy > 1; + info.mipmapLodBias = cKey.MipmapLodBias + m_d3d9Options.samplerLodBias; + if (m_d3d9Options.clampNegativeLodBias) + info.mipmapLodBias = std::max(info.mipmapLodBias, 0.0f); + info.mipmapLodMin = mipFilter.MipsEnabled ? float(cKey.MaxMipLevel) : 0; info.mipmapLodMax = mipFilter.MipsEnabled ? FLT_MAX : 0; info.reductionMode = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE; diff --git a/src/d3d9/d3d9_options.cpp b/src/d3d9/d3d9_options.cpp index 61a817b8..d8d7734e 100644 --- a/src/d3d9/d3d9_options.cpp +++ b/src/d3d9/d3d9_options.cpp @@ -75,6 +75,7 @@ namespace dxvk { this->textureMemory = config.getOption ("d3d9.textureMemory", 100) << 20; this->deviceLossOnFocusLoss = config.getOption ("d3d9.deviceLossOnFocusLoss", false); this->samplerLodBias = config.getOption ("d3d9.samplerLodBias", 0.0f); + this->clampNegativeLodBias = config.getOption ("d3d9.clampNegativeLodBias", false); // Clamp LOD bias so that people don't abuse this in unintended ways this->samplerLodBias = dxvk::fclamp(this->samplerLodBias, -2.0f, 1.0f); diff --git a/src/d3d9/d3d9_options.h b/src/d3d9/d3d9_options.h index 3984d0b1..f5b1fce4 100644 --- a/src/d3d9/d3d9_options.h +++ b/src/d3d9/d3d9_options.h @@ -141,6 +141,9 @@ namespace dxvk { /// Enforces the given LOD bias for all samplers. float samplerLodBias; + /// Clamps negative LOD bias + bool clampNegativeLodBias; + /// How much virtual memory will be used for textures (in MB). int32_t textureMemory;