From eb30830da3ac3aefa6e2792d383e740bb1f53829 Mon Sep 17 00:00:00 2001 From: Chad Date: Wed, 7 Oct 2026 12:32:09 -0500 Subject: [PATCH] fix(agc): reject 1D arrays outside the linear, Z and R swizzles The hardware addresses a 1D array in the S and D swizzles differently from a height-1 2D array, and addrlib allows only linear, Z and R swizzles for 1D resources, so the other tile modes are rejected instead of being sampled with a 2D array layout. Co-Authored-By: Claude Opus 5.5 --- .../Graphics/src/GuestTextureResource.cpp | 1 + .../prx/libSceAgcDriver/tests/GuestTextureResource.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/GuestTextureResource.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/GuestTextureResource.cpp index c60a2913c..41fe6f452 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/GuestTextureResource.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/GuestTextureResource.cpp @@ -154,6 +154,7 @@ GuestTextureResource DecodeTextureResource(std::span words) case TextureDimension::k1DArray: Require(height == 1, "guest 1D array texture descriptor has a nonzero height"); Require(baseArray <= depth, "guest 1D array texture descriptor has a base array past its last array slice"); + Require(tileMode == TextureTileMode::kLinear || tileMode == TextureTileMode::kZ64KBX || tileMode == TextureTileMode::kR64KBX, "guest 1D array texture descriptor uses a tile mode other than linear, Z or R, which 1D resources cannot use"); break; case TextureDimension::kCube: Require(width == height, "guest cube texture descriptor is not square"); diff --git a/core/libs/prx/libSceAgcDriver/tests/GuestTextureResource.cpp b/core/libs/prx/libSceAgcDriver/tests/GuestTextureResource.cpp index d800b18c0..bb9345a2e 100644 --- a/core/libs/prx/libSceAgcDriver/tests/GuestTextureResource.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/GuestTextureResource.cpp @@ -159,6 +159,16 @@ void RunGuestTextureResourceTests() { oneDArray.baseArray = 0; oneDArray.height = 2; rejectFields(oneDArray, "1D array texture descriptor has a nonzero height"); + oneDArray.height = 1; + oneDArray.base40 = 0x120000ull; + oneDArray.tileModeRaw = 0x18; + Require(DecodeTextureResource(pack(oneDArray)).tileMode == TextureTileMode::kZ64KBX, "1D array in SW_64KB_Z_X decoded incorrectly"); + oneDArray.tileModeRaw = 0x1b; + Require(DecodeTextureResource(pack(oneDArray)).tileMode == TextureTileMode::kR64KBX, "1D array in SW_64KB_R_X decoded incorrectly"); + oneDArray.tileModeRaw = 0x05; + rejectFields(oneDArray, "tile mode other than linear, Z or R"); + oneDArray.tileModeRaw = 0x19; + rejectFields(oneDArray, "tile mode other than linear, Z or R"); Fields cube = base; cube.typeRaw = 11;