From c630d365cdfd03147c2a158b28ffaedf0067a2d3 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 28 Jan 2021 01:03:02 -0800 Subject: [PATCH] Vulkan: Allow tex shaders to specify a max scale. --- GPU/Common/PostShader.cpp | 1 + GPU/Common/PostShader.h | 1 + GPU/Vulkan/TextureCacheVulkan.cpp | 4 ++++ GPU/Vulkan/TextureCacheVulkan.h | 1 + 4 files changed, 7 insertions(+) diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index 9971650ba5..e415aa9226 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -161,6 +161,7 @@ void LoadPostShaderInfo(const std::vector &directories) { info.section = section.name(); section.Get("Name", &info.name, section.name().c_str()); section.Get("Compute", &temp, ""); + section.Get("MaxScale", &info.maxScale, 255); info.computeShaderFile = path + "/" + temp; appendTextureShader(info); diff --git a/GPU/Common/PostShader.h b/GPU/Common/PostShader.h index 42aa30d4bc..b5c1f562f9 100644 --- a/GPU/Common/PostShader.h +++ b/GPU/Common/PostShader.h @@ -70,6 +70,7 @@ struct TextureShaderInfo { std::string name; std::string computeShaderFile; + int maxScale; bool operator == (const std::string &other) { return name == other; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 8563a88310..e568869b10 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -394,6 +394,7 @@ void TextureCacheVulkan::CompileScalingShader() { if (copyCS_ != VK_NULL_HANDLE) vulkan_->Delete().QueueDeleteShaderModule(copyCS_); textureShader_.clear(); + maxScaleFactor_ = 255; } else if (uploadCS_ || copyCS_) { // No need to recreate. return; @@ -417,6 +418,7 @@ void TextureCacheVulkan::CompileScalingShader() { _dbg_assert_msg_(copyCS_ != VK_NULL_HANDLE, "failed to compile copy shader"); textureShader_ = g_Config.sTextureShaderName; + maxScaleFactor_ = shaderInfo->maxScale; } void TextureCacheVulkan::ReleaseTexture(TexCacheEntry *entry, bool delete_them) { @@ -762,6 +764,8 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { VkFormat dstFmt = GetDestFormat(GETextureFormat(entry->format), gstate.getClutPaletteFormat()); int scaleFactor = standardScaleFactor_; + if (scaleFactor > maxScaleFactor_) + scaleFactor = maxScaleFactor_; // Rachet down scale factor in low-memory mode. if (lowMemoryMode_) { diff --git a/GPU/Vulkan/TextureCacheVulkan.h b/GPU/Vulkan/TextureCacheVulkan.h index 254efcd40b..7f8ae32d25 100644 --- a/GPU/Vulkan/TextureCacheVulkan.h +++ b/GPU/Vulkan/TextureCacheVulkan.h @@ -139,6 +139,7 @@ private: Vulkan2D *vulkan2D_; std::string textureShader_; + int maxScaleFactor_ = 255; VkShaderModule uploadCS_ = VK_NULL_HANDLE; VkShaderModule copyCS_ = VK_NULL_HANDLE;