From 12a67f596c650a1807142e3bd444d4eaa0d26257 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 16 Jul 2026 05:52:01 -0400 Subject: [PATCH] [Fix] (MG_Backend/DirectGLES): upload shadow mips with UNPACK_ALIGNMENT=1 - shadow rows are tightly packed but uploads ran with alignment 4, shifting every row of non-multiple-of-4-width textures by one pixel (R8 7-wide CTS gradients read back diagonally) --- MobileGL/MG_Backend/DirectGLES/Managers.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MobileGL/MG_Backend/DirectGLES/Managers.cpp b/MobileGL/MG_Backend/DirectGLES/Managers.cpp index 340627b7..f622dfb6 100644 --- a/MobileGL/MG_Backend/DirectGLES/Managers.cpp +++ b/MobileGL/MG_Backend/DirectGLES/Managers.cpp @@ -1405,7 +1405,11 @@ namespace MobileGL::MG_Backend::DirectGLES { m_prevSkipPixels = s_skipPixels; m_prevImageHeight = s_imageHeight; m_prevSkipImages = s_skipImages; - Apply(4, 0, 0, 0, 0, 0); + // Shadow mip data is tightly packed (ProcessTexturePixelsDataUnpack emits + // width * bpp rows with no padding), so uploads must use UNPACK_ALIGNMENT = 1. + // Alignment 4 made the driver read e.g. 7-byte R8 rows at an 8-byte stride, + // shifting every row of a non-multiple-of-4 upload by one pixel. + Apply(1, 0, 0, 0, 0, 0); } ~ScopedDefaultUnpackState() {