diff --git a/dxvk.conf b/dxvk.conf index 2bd54596..842166a8 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -197,6 +197,7 @@ # # Supported values: True, False +# d3d11.clampNegativeLodBias = False # d3d9.clampNegativeLodBias = False diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index 7c33c88b..b1833fd0 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -21,6 +21,7 @@ namespace dxvk { this->maxTessFactor = config.getOption("d3d11.maxTessFactor", 0); this->samplerAnisotropy = config.getOption("d3d11.samplerAnisotropy", -1); this->samplerLodBias = config.getOption("d3d11.samplerLodBias", 0.0f); + this->clampNegativeLodBias = config.getOption("d3d11.clampNegativeLodBias", false); this->invariantPosition = config.getOption("d3d11.invariantPosition", true); this->floatControls = config.getOption("d3d11.floatControls", true); this->forceSampleRateShading = config.getOption("d3d11.forceSampleRateShading", false); diff --git a/src/d3d11/d3d11_options.h b/src/d3d11/d3d11_options.h index a0586f6b..d7e08008 100644 --- a/src/d3d11/d3d11_options.h +++ b/src/d3d11/d3d11_options.h @@ -63,6 +63,9 @@ namespace dxvk { /// Enforces the given LOD bias for all samplers. float samplerLodBias; + /// Clamps negative LOD bias + bool clampNegativeLodBias; + /// Declare vertex positions in shaders as invariant bool invariantPosition; diff --git a/src/d3d11/d3d11_sampler.cpp b/src/d3d11/d3d11_sampler.cpp index a80c9180..15ff92ab 100644 --- a/src/d3d11/d3d11_sampler.cpp +++ b/src/d3d11/d3d11_sampler.cpp @@ -47,9 +47,13 @@ namespace dxvk { if (desc.MaxAnisotropy > 16) info.maxAnisotropy = 16.0f; // Enforce LOD bias specified in the device options - if (info.minFilter == VK_FILTER_LINEAR && info.magFilter == VK_FILTER_LINEAR) + if (info.minFilter == VK_FILTER_LINEAR && info.magFilter == VK_FILTER_LINEAR) { info.mipmapLodBias += device->GetOptions()->samplerLodBias; + if (device->GetOptions()->clampNegativeLodBias) + info.mipmapLodBias = std::max(info.mipmapLodBias, 0.0f); + } + // Enforce anisotropy specified in the device options int32_t samplerAnisotropyOption = device->GetOptions()->samplerAnisotropy;