From ebc564a4659e663eabf40f8ba2bd5f083e6d1063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 27 Jun 2026 13:50:03 +0200 Subject: [PATCH] Centralize handling of another GPU flag --- Common/GPU/D3D11/thin3d_d3d11.cpp | 1 + Common/GPU/OpenGL/thin3d_gl.cpp | 2 ++ Common/GPU/Vulkan/thin3d_vulkan.cpp | 1 + Common/GPU/thin3d.h | 1 + GPU/Common/TextureCacheCommon.cpp | 2 +- GPU/D3D11/GPU_D3D11.cpp | 2 -- GPU/GLES/GPU_GLES.cpp | 4 ---- GPU/GLES/TextureCacheGLES.cpp | 4 ++-- GPU/GPUCommonHW.cpp | 6 ++++-- GPU/GPUState.h | 2 +- GPU/Vulkan/GPU_Vulkan.cpp | 7 ------- 11 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index cf1ca9229b..1dd6a13844 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -342,6 +342,7 @@ D3D11DrawContext::D3D11DrawContext(ComPtr device, ComPtr= 30) { caps_.fragmentShaderInt32Supported = true; } + caps_.samplerLodControl = true; } caps_.texture3DSupported = gl_extensions.GLES3 || gl_extensions.OES_texture_3D; caps_.textureDepthSupported = gl_extensions.GLES3 || gl_extensions.OES_depth_texture; @@ -576,6 +577,7 @@ OpenGLContext::OpenGLContext(bool canChangeSwapInterval) : renderManager_(frameT caps_.preferredDepthBufferFormat = DataFormat::D24_S8; caps_.texture3DSupported = true; caps_.textureDepthSupported = true; + caps_.samplerLodControl = true; } caps_.maxTextureSize = gl_extensions.maxTextureSize; diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index d7348f17a6..7b64accebf 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -952,6 +952,7 @@ VKContext::VKContext(VulkanContext *vulkan, bool useRenderThread) caps_.multiViewSupported = vulkan->GetDeviceFeatures().enabled.multiview.multiview != 0; caps_.sampleRateShadingSupported = vulkan->GetDeviceFeatures().enabled.standard.sampleRateShading != 0; caps_.textureSwizzleSupported = true; + caps_.samplerLodControl = true; // Note that it must also be enabled on the pipelines (which we do). caps_.provokingVertexLast = vulkan->GetDeviceFeatures().enabled.provokingVertex.provokingVertexLast; diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 32a184db96..5a60a05f1f 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -636,6 +636,7 @@ struct DeviceCaps { bool provokingVertexLast; // GL behavior, what the PSP does bool verySlowShaderCompiler; bool fullScreenExclusiveSupported; + bool samplerLodControl; // Old style, for older GL or Direct3D 9. u32 clipPlanesSupported; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index e02552437b..6e85e362aa 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2798,7 +2798,7 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt int lastW = gstate.getTextureWidth(i - 1); int lastH = gstate.getTextureHeight(i - 1); - if (gstate_c.Use(GPU_USE_TEXTURE_LOD_CONTROL)) { + if (gstate_c.Use(GPU_USE_SAMPLER_LOD_CONTROL)) { if (tw != 1 && tw != (lastW >> 1)) plan.badMipSizes = true; else if (th != 1 && th != (lastH >> 1)) diff --git a/GPU/D3D11/GPU_D3D11.cpp b/GPU/D3D11/GPU_D3D11.cpp index a62c08b8d3..9e9b5c7097 100644 --- a/GPU/D3D11/GPU_D3D11.cpp +++ b/GPU/D3D11/GPU_D3D11.cpp @@ -81,8 +81,6 @@ GPU_D3D11::~GPU_D3D11() {} u32 GPU_D3D11::CheckGPUFeatures() const { u32 features = GPUCommonHW::CheckGPUFeatures(); - features |= GPU_USE_TEXTURE_LOD_CONTROL; - uint32_t fmt4444 = draw_->GetDataFormatSupport(Draw::DataFormat::A4R4G4B4_UNORM_PACK16); uint32_t fmt1555 = draw_->GetDataFormatSupport(Draw::DataFormat::A1R5G5B5_UNORM_PACK16); uint32_t fmt565 = draw_->GetDataFormatSupport(Draw::DataFormat::R5G6B5_UNORM_PACK16); diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index 6810cf8ec0..1ffc7e334f 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -131,10 +131,6 @@ u32 GPU_GLES::CheckGPUFeatures() const { features |= GPU_USE_16BIT_FORMATS; - if (gl_extensions.GLES3 || !gl_extensions.IsGLES) { - features |= GPU_USE_TEXTURE_LOD_CONTROL; - } - if (!draw_->GetShaderLanguageDesc().bitwiseOps) { features |= GPU_USE_FRAGMENT_TEST_CACHE; } diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index 8519ac369e..5f6945478a 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -94,7 +94,7 @@ static constexpr GLuint MagFiltGL[2] = { }; void TextureCacheGLES::ApplySamplingParams(const SamplerCacheKey &key) { - if (gstate_c.Use(GPU_USE_TEXTURE_LOD_CONTROL)) { + if (gstate_c.Use(GPU_USE_SAMPLER_LOD_CONTROL)) { float minLod = (float)key.minLevel / 256.0f; float maxLod = (float)key.maxLevel / 256.0f; float lodBias = (float)key.lodBias / 256.0f; @@ -264,7 +264,7 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) { } } - if (!gstate_c.Use(GPU_USE_TEXTURE_LOD_CONTROL)) { + if (!gstate_c.Use(GPU_USE_SAMPLER_LOD_CONTROL)) { // If the mip chain is not full.. if (plan.levelsToCreate != plan.maxPossibleLevels) { // We need to avoid creating mips at all, or generate them all - can't be incomplete diff --git a/GPU/GPUCommonHW.cpp b/GPU/GPUCommonHW.cpp index a61f618f61..f64f2110c0 100644 --- a/GPU/GPUCommonHW.cpp +++ b/GPU/GPUCommonHW.cpp @@ -596,6 +596,10 @@ u32 GPUCommonHW::CheckGPUFeatures() const { features |= GPU_USE_DEPTH_TEXTURE; } + if (draw_->GetDeviceCaps().samplerLodControl) { + features |= GPU_USE_SAMPLER_LOD_CONTROL; + } + if (draw_->GetDeviceCaps().framebufferFetchSupported) { features |= GPU_USE_FRAMEBUFFER_FETCH; features |= GPU_USE_SHADER_BLENDING; // doesn't matter if we are buffered or not here. @@ -622,7 +626,6 @@ u32 GPUCommonHW::CheckGPUFeatures() const { u32 GPUCommonHW::CheckGPUFeaturesLate(u32 features) const { // If we already have a 16-bit depth buffer, we don't need to round. - bool prefer24 = draw_->GetDeviceCaps().preferredDepthBufferFormat == Draw::DataFormat::D24_S8; bool prefer16 = draw_->GetDeviceCaps().preferredDepthBufferFormat == Draw::DataFormat::D16; if (!prefer16) { if (PSP_CoreParameter().compat.flags().PixelDepthRounding) { @@ -632,7 +635,6 @@ u32 GPUCommonHW::CheckGPUFeaturesLate(u32 features) const { features |= GPU_ROUND_DEPTH_TO_16BIT; } } - return features; } diff --git a/GPU/GPUState.h b/GPU/GPUState.h index fe3cb1b6b2..c86b71e19f 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -478,7 +478,7 @@ enum : u32 { // Free bit: 10-12 GPU_USE_16BIT_FORMATS = FLAG_BIT(13), GPU_USE_DEPTH_CLAMP = FLAG_BIT(14), - GPU_USE_TEXTURE_LOD_CONTROL = FLAG_BIT(15), + GPU_USE_SAMPLER_LOD_CONTROL = FLAG_BIT(15), GPU_USE_DEPTH_TEXTURE = FLAG_BIT(16), // Free bit: 17 // Free bit: 18 diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index b8d0b0d1a3..bfb84d0de3 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -208,13 +208,6 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { features |= GPU_USE_PRE_ROTATION; } - // Might enable this later - in the first round we are mostly looking at depth/stencil/discard. - // if (!g_Config.bEnableVendorBugChecks) - // features |= GPU_USE_ACCURATE_DEPTH; - - // Mandatory features on Vulkan, which may be checked in "centralized" code - features |= GPU_USE_TEXTURE_LOD_CONTROL; - if (!draw_->GetBugs().Has(Draw::Bugs::PVR_BAD_16BIT_TEXFORMATS)) { // These are VULKAN_4444_FORMAT and friends. // Note that we are now using the correct set of formats - the only cases where some may be missing