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 <noreply@anthropic.com>
This commit is contained in:
Chad
2026-10-07 12:32:09 -05:00
parent fef66c1406
commit eb30830da3
2 changed files with 11 additions and 0 deletions
@@ -154,6 +154,7 @@ GuestTextureResource DecodeTextureResource(std::span<const std::uint32_t> 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");
@@ -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;