[d3d11] Add option to control sampler LOD bias

This commit is contained in:
Philip Rebohle 2022-08-01 12:08:11 +02:00
parent 9671055538
commit 727fd7ac33
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 26 additions and 3 deletions

View File

@ -169,6 +169,16 @@
# d3d9.samplerAnisotropy = -1
# Changes the mipmap LOD bias for all samplers. The given number will be
# added to the LOD bias provided by the application, rather than replacing
# it entirely. Positive values will reduce texture detail, while negative
# values may increase sharpness at the cost of shimmer.
#
# Supported values: Any number between -2.0 and 1.0
# d3d11.samplerLodBias = 0.0
# Declares vertex positions as invariant in order to solve
# potential Z-fighting issues at a small performance cost.
#

View File

@ -1,4 +1,4 @@
#include <unordered_map>
#include "../util/util_math.h"
#include "d3d11_options.h"
@ -13,6 +13,7 @@ namespace dxvk {
this->ignoreGraphicsBarriers = config.getOption<bool>("d3d11.ignoreGraphicsBarriers", false);
this->maxTessFactor = config.getOption<int32_t>("d3d11.maxTessFactor", 0);
this->samplerAnisotropy = config.getOption<int32_t>("d3d11.samplerAnisotropy", -1);
this->samplerLodBias = config.getOption<float>("d3d11.samplerLodBias", 0.0f);
this->invariantPosition = config.getOption<bool>("d3d11.invariantPosition", true);
this->floatControls = config.getOption<bool>("d3d11.floatControls", true);
this->disableMsaa = config.getOption<bool>("d3d11.disableMsaa", false);
@ -23,6 +24,9 @@ namespace dxvk {
this->syncInterval = config.getOption<int32_t>("dxgi.syncInterval", -1);
this->tearFree = config.getOption<Tristate>("dxgi.tearFree", Tristate::Auto);
// Clamp LOD bias so that people don't abuse this in unintended ways
this->samplerLodBias = dxvk::fclamp(this->samplerLodBias, -2.0f, 1.0f);
int32_t maxImplicitDiscardSize = config.getOption<int32_t>("d3d11.maxImplicitDiscardSize", 256);
this->maxImplicitDiscardSize = maxImplicitDiscardSize >= 0
? VkDeviceSize(maxImplicitDiscardSize) << 10

View File

@ -61,7 +61,12 @@ namespace dxvk {
/// Enforces anisotropic filtering with the
/// given anisotropy value for all samplers.
int32_t samplerAnisotropy;
/// Mipmap LOD bias
///
/// Enforces the given LOD bias for all samplers.
float samplerLodBias;
/// Declare vertex positions in shaders as invariant
bool invariantPosition;

View File

@ -44,6 +44,10 @@ namespace dxvk {
if (desc.MaxAnisotropy < 1) info.maxAnisotropy = 1.0f;
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)
info.mipmapLodBias += device->GetOptions()->samplerLodBias;
// Enforce anisotropy specified in the device options
int32_t samplerAnisotropyOption = device->GetOptions()->samplerAnisotropy;
@ -51,7 +55,7 @@ namespace dxvk {
info.useAnisotropy = samplerAnisotropyOption > 0;
info.maxAnisotropy = float(samplerAnisotropyOption);
}
m_sampler = device->GetDXVKDevice()->createSampler(info);
}