VideoCommon: Refactor TexMode0 mipmaps disabled test into a helper function

This commit is contained in:
EmptyChaos
2016-03-24 02:42:08 +00:00
parent 902e5cddf7
commit 0b9a72a62d
8 changed files with 35 additions and 15 deletions

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <algorithm>
#include "Common/BitSet.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
@ -186,7 +188,7 @@ D3D12_SAMPLER_DESC StateCache::GetDesc12(SamplerState state)
unsigned int mip = d3d_mip_filters[state.min_filter & 3];
sampdc.MaxAnisotropy = 1;
if (g_ActiveConfig.iMaxAnisotropy > 0 && !IsBpTexMode0PointFiltering(state))
if (g_ActiveConfig.iMaxAnisotropy > 0 && !SamplerCommon::IsBpTexMode0PointFiltering(state))
{
sampdc.Filter = D3D12_FILTER_ANISOTROPIC;
sampdc.MaxAnisotropy = 1 << g_ActiveConfig.iMaxAnisotropy;
@ -242,8 +244,8 @@ D3D12_SAMPLER_DESC StateCache::GetDesc12(SamplerState state)
sampdc.BorderColor[0] = sampdc.BorderColor[1] = sampdc.BorderColor[2] = sampdc.BorderColor[3] = 1.0f;
sampdc.MaxLOD = (mip == TexMode0::TEXF_NONE) ? 0.0f : static_cast<float>(state.max_lod) / 16.f;
sampdc.MinLOD = static_cast<float>(state.min_lod) / 16.f;
sampdc.MaxLOD = SamplerCommon::AreBpTexMode0MipmapsEnabled(state) ? state.max_lod / 16.f : 0.f;
sampdc.MinLOD = std::min(state.min_lod / 16.f, sampdc.MaxLOD);
sampdc.MipLODBias = static_cast<s32>(state.lod_bias) / 32.0f;
return sampdc;

View File

@ -39,6 +39,7 @@
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/PixelEngine.h"
#include "VideoCommon/PixelShaderManager.h"
#include "VideoCommon/SamplerCommon.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VideoConfig.h"
@ -1246,7 +1247,7 @@ void Renderer::SetSamplerState(int stage, int tex_index, bool custom_tex)
if (g_ActiveConfig.bForceFiltering)
{
// Only use mipmaps if the game says they are available.
new_state.min_filter = (tm0.min_filter & 3) == TexMode0::TEXF_NONE ? 4 : 6;
new_state.min_filter = SamplerCommon::AreBpTexMode0MipmapsEnabled(tm0) ? 6 : 4;
new_state.mag_filter = 1; // linear mag
}
else