From 5df0c95e514d88b43d20dd1e10963aa129a6770d Mon Sep 17 00:00:00 2001
From: refractionpcsx2 <refraction@gmail.com>
Date: Sat, 26 Aug 2023 02:13:47 +0100
Subject: [PATCH] GS/HW: Don't use TEXA on 16/24 bit when TCC is set to Vertex
 alpha

---
 pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp
index 2e92f9772c..a3fa5c44f7 100644
--- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp
+++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp
@@ -4190,7 +4190,7 @@ __ri void GSRendererHW::EmulateTextureSampler(const GSTextureCache::Target* rt,
 
 		// Force a 32 bits access (normally shuffle is done on 16 bits)
 		// m_ps_sel.tex_fmt = 0; // removed as an optimization
-		m_conf.ps.aem = TEXA.AEM;
+
 		//ASSERT(tex->m_target);
 
 		// Require a float conversion if the texure is a depth otherwise uses Integral scaling
@@ -4200,10 +4200,19 @@ __ri void GSRendererHW::EmulateTextureSampler(const GSTextureCache::Target* rt,
 		}
 
 		// Shuffle is a 16 bits format, so aem is always required
-		GSVector4 ta(TEXA & GSVector4i::x000000ff());
-		ta /= 255.0f;
-		m_conf.cb_ps.TA_MaxDepth_Af.x = ta.x;
-		m_conf.cb_ps.TA_MaxDepth_Af.y = ta.y;
+		if (m_cached_ctx.TEX0.TCC)
+		{
+			m_conf.ps.aem = TEXA.AEM;
+			GSVector4 ta(TEXA & GSVector4i::x000000ff());
+			ta /= 255.0f;
+			m_conf.cb_ps.TA_MaxDepth_Af.x = ta.x;
+			m_conf.cb_ps.TA_MaxDepth_Af.y = ta.y;
+		}
+		else
+		{
+			m_conf.cb_ps.TA_MaxDepth_Af.x = 0;
+			m_conf.cb_ps.TA_MaxDepth_Af.y = 1.0f;
+		}
 
 		// The purpose of texture shuffle is to move color channel. Extra interpolation is likely a bad idea.
 		bilinear &= m_vt.IsLinear();