GS: Make hardware renderer trilinear consistent

Trilinear without bilinear was inconsistent previously.
This commit is contained in:
Connor McLaughlin 2022-03-26 14:00:26 +10:00 committed by refractionpcsx2
parent 1b83e17d60
commit ddbdfd47be
3 changed files with 15 additions and 32 deletions

View File

@ -354,6 +354,12 @@ struct alignas(16) GSHWDrawConfig
return (triln == static_cast<u8>(GS_MIN_FILTER::Nearest_Mipmap_Linear) ||
triln == static_cast<u8>(GS_MIN_FILTER::Linear_Mipmap_Linear));
}
/// Returns true if mipmaps should be used when filtering (i.e. LOD not clamped to zero).
__fi bool UseMipmapFiltering() const
{
return (triln >= static_cast<u8>(GS_MIN_FILTER::Nearest_Mipmap_Nearest));
}
};
struct DepthStencilSelector
{

View File

@ -829,40 +829,17 @@ GLuint GSDeviceOGL::CreateSampler(PSSamplerSelector sel)
GLuint sampler;
glCreateSamplers(1, &sampler);
// Bilinear filtering
if (sel.biln)
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, sel.IsMagFilterLinear() ? GL_LINEAR : GL_NEAREST);
if (!sel.UseMipmapFiltering())
{
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, sel.IsMinFilterLinear() ? GL_LINEAR : GL_NEAREST);
}
else
{
glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
switch (static_cast<GS_MIN_FILTER>(sel.triln))
{
case GS_MIN_FILTER::Nearest:
// Nop based on biln
break;
case GS_MIN_FILTER::Linear:
// Nop based on biln
break;
case GS_MIN_FILTER::Nearest_Mipmap_Nearest:
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
break;
case GS_MIN_FILTER::Nearest_Mipmap_Linear:
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
break;
case GS_MIN_FILTER::Linear_Mipmap_Nearest:
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
break;
case GS_MIN_FILTER::Linear_Mipmap_Linear:
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
break;
default:
break;
if (sel.IsMipFilterLinear())
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, sel.IsMinFilterLinear() ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_LINEAR);
else
glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, sel.IsMinFilterLinear() ? GL_LINEAR_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_NEAREST);
}
glSamplerParameterf(sampler, GL_TEXTURE_MIN_LOD, -1000.0f);

View File

@ -1014,8 +1014,8 @@ VkSampler GSDeviceVK::GetSampler(GSHWDrawConfig::SamplerSelector ss)
// for the reasoning behind 0.25f here.
const VkSamplerCreateInfo ci = {
VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, nullptr, 0,
ss.IsMinFilterLinear() ? VK_FILTER_LINEAR : VK_FILTER_NEAREST, // min
ss.IsMagFilterLinear() ? VK_FILTER_LINEAR : VK_FILTER_NEAREST, // mag
ss.IsMagFilterLinear() ? VK_FILTER_LINEAR : VK_FILTER_NEAREST, // min
ss.IsMinFilterLinear() ? VK_FILTER_LINEAR : VK_FILTER_NEAREST, // mag
ss.IsMipFilterLinear() ? VK_SAMPLER_MIPMAP_MODE_LINEAR : VK_SAMPLER_MIPMAP_MODE_NEAREST, // mip
static_cast<VkSamplerAddressMode>(
ss.tau ? VK_SAMPLER_ADDRESS_MODE_REPEAT : VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE), // u