mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-11 07:03:33 +02:00
Move aniso to the sampler cache key.
This commit is contained in:
@@ -211,6 +211,7 @@ void TextureCacheCommon::UpdateSamplingParams(TexCacheEntry &entry, SamplerCache
|
||||
key.magFilt = magFilt & 1;
|
||||
key.sClamp = sClamp;
|
||||
key.tClamp = tClamp;
|
||||
key.aniso = false;
|
||||
|
||||
if (!key.mipEnable) {
|
||||
key.maxLevel = 0;
|
||||
@@ -222,7 +223,10 @@ void TextureCacheCommon::UpdateSamplingParams(TexCacheEntry &entry, SamplerCache
|
||||
key.maxLevel = entry.maxLevel * 256;
|
||||
key.minLevel = 0;
|
||||
key.lodBias = (int)(lodBias * 256.0f);
|
||||
break;
|
||||
if (gstate_c.Supports(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) {
|
||||
key.aniso = true;
|
||||
break;
|
||||
}
|
||||
case GE_TEXLEVEL_MODE_CONST:
|
||||
key.maxLevel = (int)(lodBias * 256.0f);
|
||||
key.minLevel = (int)(lodBias * 256.0f);
|
||||
@@ -232,7 +236,7 @@ void TextureCacheCommon::UpdateSamplingParams(TexCacheEntry &entry, SamplerCache
|
||||
// It's incorrect to use the slope as a bias. Instead it should be passed
|
||||
// into the shader directly as an explicit lod level, with the bias on top. For now, we just kill the
|
||||
// lodBias in this mode, working around #9772.
|
||||
key.maxLevel = entry.maxLevel;
|
||||
key.maxLevel = entry.maxLevel * 256;
|
||||
key.minLevel = 0;
|
||||
key.lodBias = 0;
|
||||
break;
|
||||
|
||||
@@ -72,6 +72,7 @@ struct SamplerCacheKey {
|
||||
bool magFilt : 1;
|
||||
bool sClamp : 1;
|
||||
bool tClamp : 1;
|
||||
bool aniso : 1;
|
||||
};
|
||||
};
|
||||
bool operator < (const SamplerCacheKey &other) const {
|
||||
|
||||
@@ -64,7 +64,7 @@ ID3D11SamplerState *SamplerCacheD3D11::GetOrCreateSampler(ID3D11Device *device,
|
||||
samp.AddressU = key.sClamp ? D3D11_TEXTURE_ADDRESS_CLAMP : D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samp.AddressV = key.tClamp ? D3D11_TEXTURE_ADDRESS_CLAMP : D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samp.AddressW = samp.AddressU; // Mali benefits from all clamps being the same, and this one is irrelevant.
|
||||
if (gstate_c.Supports(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) {
|
||||
if (key.aniso) {
|
||||
samp.MaxAnisotropy = (float)(1 << g_Config.iAnisotropyLevel);
|
||||
} else {
|
||||
samp.MaxAnisotropy = 1.0f;
|
||||
@@ -81,7 +81,7 @@ ID3D11SamplerState *SamplerCacheD3D11::GetOrCreateSampler(ID3D11Device *device,
|
||||
D3D11_FILTER_MIN_MAG_MIP_LINEAR,
|
||||
};
|
||||
// Only switch to aniso if linear min and mag are set.
|
||||
if (samp.MaxAnisotropy > 1.0f && key.magFilt != 0 && key.minFilt != 0)
|
||||
if (key.aniso && key.magFilt != 0 && key.minFilt != 0)
|
||||
samp.Filter = D3D11_FILTER_ANISOTROPIC;
|
||||
else
|
||||
samp.Filter = filters[filterKey];
|
||||
|
||||
@@ -86,13 +86,12 @@ VkSampler SamplerCache::GetOrCreateSampler(const SamplerCacheKey &key) {
|
||||
samp.addressModeU = key.sClamp ? VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE : VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samp.addressModeV = key.tClamp ? VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE : VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samp.addressModeW = samp.addressModeU; // irrelevant, but Mali recommends that all clamp modes are the same if possible.
|
||||
samp.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
|
||||
samp.compareOp = VK_COMPARE_OP_ALWAYS;
|
||||
samp.flags = 0;
|
||||
samp.magFilter = key.magFilt ? VK_FILTER_LINEAR : VK_FILTER_NEAREST;
|
||||
samp.minFilter = key.minFilt ? VK_FILTER_LINEAR : VK_FILTER_NEAREST;
|
||||
samp.mipmapMode = key.mipFilt ? VK_SAMPLER_MIPMAP_MODE_LINEAR : VK_SAMPLER_MIPMAP_MODE_NEAREST;
|
||||
if (gstate_c.Supports(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) {
|
||||
if (key.aniso) {
|
||||
// Docs say the min of this value and the supported max are used.
|
||||
samp.maxAnisotropy = 1 << g_Config.iAnisotropyLevel;
|
||||
samp.anisotropyEnable = true;
|
||||
|
||||
Reference in New Issue
Block a user