From d30d8bf35ce6c094b3804138124df0c6ee0f74c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 11 Oct 2022 16:09:57 +0200 Subject: [PATCH] Removes the option, autodetect instead - only enable if the GPU doesn't support bitwise ops. --- Core/Config.cpp | 1 - Core/Config.h | 1 - GPU/Common/FragmentShaderGenerator.cpp | 2 +- GPU/GLES/FragmentTestCacheGLES.cpp | 8 ++------ GPU/GLES/GPU_GLES.cpp | 4 ++++ GPU/GLES/StateMappingGLES.cpp | 2 +- GPU/GPUState.h | 8 +++++--- headless/Headless.cpp | 1 - 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 4eeca428ab..650e1812fa 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -937,7 +937,6 @@ static ConfigSetting graphicsSettings[] = { ConfigSetting("ShaderChainRequires60FPS", &g_Config.bShaderChainRequires60FPS, false, true, true), ReportedConfigSetting("MemBlockTransferGPU", &g_Config.bBlockTransferGPU, true, true, true), - ReportedConfigSetting("FragmentTestCache", &g_Config.bFragmentTestCache, true, true, true), ConfigSetting("GfxDebugOutput", &g_Config.bGfxDebugOutput, false, false, false), ConfigSetting("LogFrameDrops", &g_Config.bLogFrameDrops, false, true, false), diff --git a/Core/Config.h b/Core/Config.h index 65eaf74099..10748583a9 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -235,7 +235,6 @@ public: float fGameListScrollPosition; int iBloomHack; //0 = off, 1 = safe, 2 = balanced, 3 = aggressive bool bBlockTransferGPU; - bool bFragmentTestCache; int iSplineBezierQuality; // 0 = low , 1 = Intermediate , 2 = High bool bHardwareTessellation; bool bShaderCache; // Hidden ini-only setting, useful for debugging shader compile times. diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 2f8f248dbd..57253eb670 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -45,7 +45,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu bool highpFog = false; bool highpTexcoord = false; - bool enableFragmentTestCache = g_Config.bFragmentTestCache && ShaderLanguageIsOpenGL(compat.shaderLanguage); + bool enableFragmentTestCache = gstate_c.Supports(GPU_USE_FRAGMENT_TEST_CACHE); if (compat.gles) { // PowerVR needs highp to do the fog in MHU correctly. diff --git a/GPU/GLES/FragmentTestCacheGLES.cpp b/GPU/GLES/FragmentTestCacheGLES.cpp index 1206911f4d..1033f2a2a2 100644 --- a/GPU/GLES/FragmentTestCacheGLES.cpp +++ b/GPU/GLES/FragmentTestCacheGLES.cpp @@ -40,10 +40,6 @@ void FragmentTestCacheGLES::DeviceRestore(Draw::DrawContext *draw) { } void FragmentTestCacheGLES::BindTestTexture(int slot) { - if (!g_Config.bFragmentTestCache) { - return; - } - bool alphaNeedsTexture = gstate.isAlphaTestEnabled() && !IsAlphaTestAgainstZero() && !IsAlphaTestTriviallyTrue(); bool colorNeedsTexture = gstate.isColorTestEnabled() && !IsColorTestAgainstZero() && !IsColorTestTriviallyTrue(); if (!alphaNeedsTexture && !colorNeedsTexture) { @@ -156,7 +152,7 @@ void FragmentTestCacheGLES::Clear(bool deleteThem) { } } cache_.clear(); - lastTexture_ = 0; + lastTexture_ = nullptr; } void FragmentTestCacheGLES::Decimate() { @@ -173,5 +169,5 @@ void FragmentTestCacheGLES::Decimate() { decimationCounter_ = FRAGTEST_DECIMATION_INTERVAL; } - lastTexture_ = 0; + lastTexture_ = nullptr; } diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index abae5134f9..65dd71a539 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -205,6 +205,10 @@ u32 GPU_GLES::CheckGPUFeatures() const { features |= GPU_USE_DEPTH_RANGE_HACK; } + if (!draw_->GetShaderLanguageDesc().bitwiseOps) { + features |= GPU_USE_FRAGMENT_TEST_CACHE; + } + return features; } diff --git a/GPU/GLES/StateMappingGLES.cpp b/GPU/GLES/StateMappingGLES.cpp index cdcc9e5069..749cdf2fca 100644 --- a/GPU/GLES/StateMappingGLES.cpp +++ b/GPU/GLES/StateMappingGLES.cpp @@ -304,7 +304,7 @@ void DrawEngineGLES::ApplyDrawStateLate(bool setStencilValue, int stencilValue) // At this point, we know if the vertices are full alpha or not. // TODO: Set the nearest/linear here (since we correctly know if alpha/color tests are needed)? - if (!gstate.isModeClear()) { + if (!gstate.isModeClear() && gstate_c.Supports(GPU_USE_FRAGMENT_TEST_CACHE)) { // Apply last, once we know the alpha params of the texture. if (gstate.isAlphaTestEnabled() || gstate.isColorTestEnabled()) { fragmentTestCache_->BindTestTexture(TEX_SLOT_ALPHATEST); diff --git a/GPU/GPUState.h b/GPU/GPUState.h index fa9d4b575c..15b837e5ba 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -466,12 +466,14 @@ struct UVScale { #define FLAG_BIT(x) (1 << x) -// Some of these are OpenGL-specific even though this file is neutral, unfortunately. -// Might want to move this mechanism into the backend later. +// These flags are mainly to make sure that we make decisions on code path in a single +// location. Sometimes we need to take things into account in multiple places, it helps +// to centralize into flags like this. They're also fast to check since the cache line +// will be hot. enum { GPU_SUPPORTS_DUALSOURCE_BLEND = FLAG_BIT(0), GPU_USE_LIGHT_UBERSHADER = FLAG_BIT(1), - // Free bit: 2 + GPU_USE_FRAGMENT_TEST_CACHE = FLAG_BIT(2), GPU_SUPPORTS_VS_RANGE_CULLING = FLAG_BIT(3), GPU_SUPPORTS_BLEND_MINMAX = FLAG_BIT(4), GPU_SUPPORTS_LOGIC_OP = FLAG_BIT(5), diff --git a/headless/Headless.cpp b/headless/Headless.cpp index dcfad07e8d..5b2b8adfd3 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -437,7 +437,6 @@ int main(int argc, const char* argv[]) g_Config.bHighQualityDepth = true; g_Config.bMemStickInserted = true; g_Config.iMemStickSizeGB = 16; - g_Config.bFragmentTestCache = true; g_Config.bEnableWlan = true; g_Config.sMACAddress = "12:34:56:78:9A:BC"; g_Config.iFirmwareVersion = PSP_DEFAULT_FIRMWARE;