From 37a51f1d091c7db91261e73462d4e67eee5f9252 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Sun, 6 Nov 2022 23:28:46 -0600 Subject: [PATCH] VideoCommon: Add an option to disable mipmaps Needed by M1 fifoci to work around a minor non-determinism bug --- Source/Core/Core/Config/GraphicsSettings.cpp | 3 +++ Source/Core/Core/Config/GraphicsSettings.h | 3 +++ Source/Core/VideoCommon/TextureCacheBase.cpp | 9 ++++++++- Source/Core/VideoCommon/VideoConfig.cpp | 3 +++ Source/Core/VideoCommon/VideoConfig.h | 3 +++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/Config/GraphicsSettings.cpp b/Source/Core/Core/Config/GraphicsSettings.cpp index beb2e6f017..5a9f7b0954 100644 --- a/Source/Core/Core/Config/GraphicsSettings.cpp +++ b/Source/Core/Core/Config/GraphicsSettings.cpp @@ -153,6 +153,9 @@ const Info GFX_HACK_MISSING_COLOR_VALUE{{System::GFX, "Hacks", "MissingColo 0xFFFFFFFF}; const Info GFX_HACK_FAST_TEXTURE_SAMPLING{{System::GFX, "Hacks", "FastTextureSampling"}, true}; +#ifdef __APPLE__ +const Info GFX_HACK_NO_MIPMAPPING{{System::GFX, "Hacks", "NoMipmapping"}, false}; +#endif // Graphics.GameSpecific diff --git a/Source/Core/Core/Config/GraphicsSettings.h b/Source/Core/Core/Config/GraphicsSettings.h index 426a038bd5..5e3dbb46ae 100644 --- a/Source/Core/Core/Config/GraphicsSettings.h +++ b/Source/Core/Core/Config/GraphicsSettings.h @@ -129,6 +129,9 @@ extern const Info GFX_HACK_EFB_EMULATE_FORMAT_CHANGES; extern const Info GFX_HACK_VERTEX_ROUNDING; extern const Info GFX_HACK_MISSING_COLOR_VALUE; extern const Info GFX_HACK_FAST_TEXTURE_SAMPLING; +#ifdef __APPLE__ +extern const Info GFX_HACK_NO_MIPMAPPING; +#endif // Graphics.GameSpecific diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 29f972a67b..f16bcc342a 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1544,8 +1544,15 @@ TextureCacheBase::GetTexture(const int textureCacheSafetyColorSampleSize, } } +#ifdef __APPLE__ + const bool no_mips = g_ActiveConfig.bNoMipmapping; +#else + const bool no_mips = false; +#endif // how many levels the allocated texture shall have - const u32 texLevels = hires_tex ? (u32)hires_tex->m_levels.size() : texture_info.GetLevelCount(); + const u32 texLevels = no_mips ? 1 : + hires_tex ? (u32)hires_tex->m_levels.size() : + texture_info.GetLevelCount(); // We can decode on the GPU if it is a supported format and the flag is enabled. // Currently we don't decode RGBA8 textures from TMEM, as that would require copying from both diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 760e185304..40d5841714 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -140,6 +140,9 @@ void VideoConfig::Refresh() iEFBAccessTileSize = Config::Get(Config::GFX_HACK_EFB_ACCESS_TILE_SIZE); iMissingColorValue = Config::Get(Config::GFX_HACK_MISSING_COLOR_VALUE); bFastTextureSampling = Config::Get(Config::GFX_HACK_FAST_TEXTURE_SAMPLING); +#ifdef __APPLE__ + bNoMipmapping = Config::Get(Config::GFX_HACK_NO_MIPMAPPING); +#endif bPerfQueriesEnable = Config::Get(Config::GFX_PERF_QUERIES_ENABLE); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 8b4cc40657..05d86a18f4 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -143,6 +143,9 @@ struct VideoConfig final int iSaveTargetId = 0; // TODO: Should be dropped u32 iMissingColorValue = 0; bool bFastTextureSampling = false; +#ifdef __APPLE__ + bool bNoMipmapping = false; // Used by macOS fifoci to work around an M1 bug +#endif // Stereoscopy StereoMode stereo_mode{};