diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index 84d052bf..54b3fcc8 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -14,6 +14,8 @@ 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->clampLodBias = config.getOption("d3d11.clampLodBias", false); + this->useGlFilterModes = config.getOption("d3d11.useGlFilterModes", false); this->invariantPosition = config.getOption("d3d11.invariantPosition", true); this->floatControls = config.getOption("d3d11.floatControls", true); this->disableMsaa = config.getOption("d3d11.disableMsaa", false); diff --git a/src/d3d11/d3d11_options.h b/src/d3d11/d3d11_options.h index dcbef7c3..0782ba14 100644 --- a/src/d3d11/d3d11_options.h +++ b/src/d3d11/d3d11_options.h @@ -67,6 +67,19 @@ namespace dxvk { /// Enforces the given LOD bias for all samplers. float samplerLodBias; + /// Clamp negative LOD bias to 0 for all samplers. + bool clampLodBias; + + /// Emulate GL_LINEAR and GL_NEAREST minFilter. + /// + /// There are no Vulkan filter modes that directly + /// correspond to OpenGL minification filters of + /// GL_LINEAR or GL_NEAREST, but they can be emulated + /// using VK_SAMPLER_MIPMAP_MODE_NEAREST, minLod = 0, + /// and maxLod = 0.25, and using minFilter = VK_FILTER_LINEAR + /// or minFilter = VK_FILTER_NEAREST, respectively. + bool useGlFilterModes; + /// Declare vertex positions in shaders as invariant bool invariantPosition; diff --git a/src/d3d11/d3d11_sampler.cpp b/src/d3d11/d3d11_sampler.cpp index 8150c29c..215e3c54 100644 --- a/src/d3d11/d3d11_sampler.cpp +++ b/src/d3d11/d3d11_sampler.cpp @@ -44,6 +44,10 @@ namespace dxvk { if (desc.MaxAnisotropy < 1) info.maxAnisotropy = 1.0f; if (desc.MaxAnisotropy > 16) info.maxAnisotropy = 16.0f; + // Clamp negative LOD bias + if (device->GetOptions()->clampLodBias && info.mipmapLodBias < 0.0f) + info.mipmapLodBias = 0.0f; + // Enforce LOD bias specified in the device options if (info.minFilter == VK_FILTER_LINEAR && info.magFilter == VK_FILTER_LINEAR) info.mipmapLodBias += device->GetOptions()->samplerLodBias; @@ -56,6 +60,12 @@ namespace dxvk { info.maxAnisotropy = float(samplerAnisotropyOption); } + if (device->GetOptions()->useGlFilterModes && (info.minFilter == VK_FILTER_LINEAR || info.minFilter == VK_FILTER_NEAREST)) { + info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; + info.mipmapLodMin = 0.0f; + info.mipmapLodMax = 0.25f; + } + m_sampler = device->GetDXVKDevice()->createSampler(info); }