From 176b460d7648df45386c1155ba373ba87645a74e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 26 Jul 2022 10:43:30 +0200 Subject: [PATCH] Quick attempt at fixing the Macross glitch --- GPU/Common/TextureCacheCommon.cpp | 1 + GPU/Common/TextureCacheCommon.h | 1 + GPU/Vulkan/TextureCacheVulkan.cpp | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 92605780a1..aa43ff87f0 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -162,6 +162,7 @@ SamplerCacheKey TextureCacheCommon::GetSamplingParams(int maxLevel, const TexCac key.sClamp = gstate.isTexCoordClampedS(); key.tClamp = gstate.isTexCoordClampedT(); key.aniso = false; + key.texture3d = gstate_c.curTextureIs3D; GETexLevelMode mipMode = gstate.getTexLevelMode(); bool autoMip = mipMode == GE_TEXLEVEL_MODE_AUTO; diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index 5c8630bb81..3bd49fb7f2 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -71,6 +71,7 @@ struct SamplerCacheKey { bool sClamp : 1; bool tClamp : 1; bool aniso : 1; + bool texture3d : 1; }; }; bool operator < (const SamplerCacheKey &other) const { diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 1b52ec5689..cf10aa30cb 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -119,7 +119,8 @@ VkSampler SamplerCache::GetOrCreateSampler(const SamplerCacheKey &key) { VkSamplerCreateInfo samp = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO }; samp.addressModeU = key.sClamp ? VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE : VK_SAMPLER_ADDRESS_MODE_REPEAT; samp.addressModeV = key.tClamp ? VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE : VK_SAMPLER_ADDRESS_MODE_REPEAT; - samp.addressModeW = samp.addressModeU; // irrelevant, but Mali recommends that all clamp modes are the same if possible. + // W addressing is irrelevant for 2d textures, but Mali recommends that all clamp modes are the same if possible so just copy from U. + samp.addressModeW = key.texture3d ? VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE : samp.addressModeU; samp.compareOp = VK_COMPARE_OP_ALWAYS; samp.flags = 0; samp.magFilter = key.magFilt ? VK_FILTER_LINEAR : VK_FILTER_NEAREST;