feat(agc): implement 1D array textures #931

Merged
CnRJay merged 2 commits from upstream-pr/931 into main 2026-10-07 20:43:43 +00:00
CnRJay commented 2026-10-06 18:46:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-06T18:46:56Z.


What

A T# of type 12 (1D array) threw while it was decoded. Now:

  • It decodes to a 1D array dimension, is checked like a 2D array with a height of one, and holds depth + 1 layers laid out like a 2D array's.
  • Its Vulkan image is 1D with that many layers, viewed as VK_IMAGE_VIEW_TYPE_1D_ARRAY for both sampling and storage.
  • The recompiler declares a 1D array shape for arrayed 1D image resources instead of failing.
  • Only the linear, SW_64KB_Z_X and SW_64KB_R_X tile modes are accepted. 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 modes are rejected.

Tested

Windows 11, MinGW GCC Release build, ctest agc_driver_graphics and agc_driver_image_one_dimensional_array pass.

  • agc_driver_graphics (tests/GuestTextureResource.cpp): a type 12 T# decodes to a 1D array whose surface holds every array slice. A base array past the last slice, and a nonzero height, are rejected. Z_X and R_X decode, and SW_4KB_S and SW_64KB_S_X are rejected.
  • agc_driver_image_one_dimensional_array (new, on the GPU): image_sample_lz on a 3-layer 1D array returns each layer's texels, including fractional and out-of-range layer coordinates, which round and clamp to the first or last layer.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4763205277 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/931). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-06T18:46:56Z. --- ### What A T# of type 12 (1D array) threw while it was decoded. Now: - It decodes to a 1D array dimension, is checked like a 2D array with a height of one, and holds depth + 1 layers laid out like a 2D array's. - Its Vulkan image is 1D with that many layers, viewed as `VK_IMAGE_VIEW_TYPE_1D_ARRAY` for both sampling and storage. - The recompiler declares a 1D array shape for arrayed 1D image resources instead of failing. - Only the linear, SW_64KB_Z_X and SW_64KB_R_X tile modes are accepted. 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 modes are rejected. ### Tested Windows 11, MinGW GCC Release build, ctest `agc_driver_graphics` and `agc_driver_image_one_dimensional_array` pass. - `agc_driver_graphics` (`tests/GuestTextureResource.cpp`): a type 12 T# decodes to a 1D array whose surface holds every array slice. A base array past the last slice, and a nonzero height, are rejected. Z_X and R_X decode, and SW_4KB_S and SW_64KB_S_X are rejected. - `agc_driver_image_one_dimensional_array` (new, on the GPU): `image_sample_lz` on a 3-layer 1D array returns each layer's texels, including fractional and out-of-range layer coordinates, which round and clamp to the first or last layer. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
adriadam10 commented 2026-10-07 09:22:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T09:22:33Z.

Review: CHANGES_REQUESTED


Checked on hardware (gfx1035 HW oracle): image_load with dim:SQ_RSRC_IMG_1D_ARRAY against the same T# as a height-1 2D array, 32_UINT, widths 8 and 100, 3 layers, 1 and 4 mips, every tile mode resolveTileMode accepts. Build and ctest pass here (RADV, the new test runs), and the new tests need the change.

  • Linear, 64KB_Z_X (0x18) and 64KB_R_X (0x1b): the 1D array reads exactly the bytes of the height-1 2D array, so the layout in TextureTiling.cpp:386 / TextureCache.cpp:42 is right for them.
  • 256B_S (0x01), 4KB_S (0x05), 64KB_S (0x09), 64KB_S_X (0x19), 64KB_D_X (0x1a): the hardware does not address a 1D array like that. Layer 0, width 8, 0x01: x=7 reads byte 12 (the texel of x=3), the height-1 2D array reads byte 140; x=5 reads byte 4. 0x05, width 100: layer stride 4096 bytes, the 2D array's is 16384. addrlib doesn't allow these modes for 1D resources at all (Gfx10Rsrc1dSwModeMask = linear | Z | R in gfx10addrlib.h, checked in ValidateSwModeParams).
  • GuestTextureResource.cpp:154: the decoder accepts them and the driver then samples a 2D-array layout, a plausible but wrong result. Please reject 1D arrays whose tile mode is not linear, Z or R (a Require like the other cases) and add a reject row for one S mode to tests/GuestTextureResource.cpp.
  • Optional, separate PR: k1D on main has the same gap (GuestTextureResource.cpp:141).
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5440251701 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/931#pullrequestreview-5440251701). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T09:22:33Z. **Review:** CHANGES_REQUESTED --- Checked on hardware (gfx1035 HW oracle): `image_load` with `dim:SQ_RSRC_IMG_1D_ARRAY` against the same T# as a height-1 2D array, 32_UINT, widths 8 and 100, 3 layers, 1 and 4 mips, every tile mode `resolveTileMode` accepts. Build and ctest pass here (RADV, the new test runs), and the new tests need the change. - Linear, `64KB_Z_X` (0x18) and `64KB_R_X` (0x1b): the 1D array reads exactly the bytes of the height-1 2D array, so the layout in `TextureTiling.cpp:386` / `TextureCache.cpp:42` is right for them. - `256B_S` (0x01), `4KB_S` (0x05), `64KB_S` (0x09), `64KB_S_X` (0x19), `64KB_D_X` (0x1a): the hardware does not address a 1D array like that. Layer 0, width 8, 0x01: x=7 reads byte 12 (the texel of x=3), the height-1 2D array reads byte 140; x=5 reads byte 4. 0x05, width 100: layer stride 4096 bytes, the 2D array's is 16384. addrlib doesn't allow these modes for 1D resources at all (`Gfx10Rsrc1dSwModeMask` = linear | Z | R in `gfx10addrlib.h`, checked in `ValidateSwModeParams`). - `GuestTextureResource.cpp:154`: the decoder accepts them and the driver then samples a 2D-array layout, a plausible but wrong result. Please reject 1D arrays whose tile mode is not linear, Z or R (a `Require` like the other cases) and add a reject row for one S mode to `tests/GuestTextureResource.cpp`. - Optional, separate PR: `k1D` on `main` has the same gap (`GuestTextureResource.cpp:141`).
CnRJay commented 2026-10-07 17:56:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-07T17:56:24Z.


Checked on hardware (gfx1035 HW oracle): image_load with dim:SQ_RSRC_IMG_1D_ARRAY against the same T# as a height-1 2D array, 32_UINT, widths 8 and 100, 3 layers, 1 and 4 mips, every tile mode resolveTileMode accepts. Build and ctest pass here (RADV, the new test runs), and the new tests need the change.

  • Linear, 64KB_Z_X (0x18) and 64KB_R_X (0x1b): the 1D array reads exactly the bytes of the height-1 2D array, so the layout in TextureTiling.cpp:386 / TextureCache.cpp:42 is right for them.
  • 256B_S (0x01), 4KB_S (0x05), 64KB_S (0x09), 64KB_S_X (0x19), 64KB_D_X (0x1a): the hardware does not address a 1D array like that. Layer 0, width 8, 0x01: x=7 reads byte 12 (the texel of x=3), the height-1 2D array reads byte 140; x=5 reads byte 4. 0x05, width 100: layer stride 4096 bytes, the 2D array's is 16384. addrlib doesn't allow these modes for 1D resources at all (Gfx10Rsrc1dSwModeMask = linear | Z | R in gfx10addrlib.h, checked in ValidateSwModeParams).
  • GuestTextureResource.cpp:154: the decoder accepts them and the driver then samples a 2D-array layout, a plausible but wrong result. Please reject 1D arrays whose tile mode is not linear, Z or R (a Require like the other cases) and add a reject row for one S mode to tests/GuestTextureResource.cpp.
  • Optional, separate PR: k1D on main has the same gap (GuestTextureResource.cpp:141).

should be good now

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6043700496 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/931#issuecomment-6043700496). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-07T17:56:24Z. --- > Checked on hardware (gfx1035 HW oracle): `image_load` with `dim:SQ_RSRC_IMG_1D_ARRAY` against the same T# as a height-1 2D array, 32_UINT, widths 8 and 100, 3 layers, 1 and 4 mips, every tile mode `resolveTileMode` accepts. Build and ctest pass here (RADV, the new test runs), and the new tests need the change. > > * Linear, `64KB_Z_X` (0x18) and `64KB_R_X` (0x1b): the 1D array reads exactly the bytes of the height-1 2D array, so the layout in `TextureTiling.cpp:386` / `TextureCache.cpp:42` is right for them. > * `256B_S` (0x01), `4KB_S` (0x05), `64KB_S` (0x09), `64KB_S_X` (0x19), `64KB_D_X` (0x1a): the hardware does not address a 1D array like that. Layer 0, width 8, 0x01: x=7 reads byte 12 (the texel of x=3), the height-1 2D array reads byte 140; x=5 reads byte 4. 0x05, width 100: layer stride 4096 bytes, the 2D array's is 16384. addrlib doesn't allow these modes for 1D resources at all (`Gfx10Rsrc1dSwModeMask` = linear | Z | R in `gfx10addrlib.h`, checked in `ValidateSwModeParams`). > * `GuestTextureResource.cpp:154`: the decoder accepts them and the driver then samples a 2D-array layout, a plausible but wrong result. Please reject 1D arrays whose tile mode is not linear, Z or R (a `Require` like the other cases) and add a reject row for one S mode to `tests/GuestTextureResource.cpp`. > * Optional, separate PR: `k1D` on `main` has the same gap (`GuestTextureResource.cpp:141`). should be good now
adriadam10 commented 2026-10-07 20:43:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T20:43:40Z.

Review: APPROVED


Rechecked eb30830: build + ctest green on RADV, and the new tests need the change. Checked on the gfx1035 HW oracle (linear and 64KB_Z_X): the image_sample_lz 1D_ARRAY layer is round-to-nearest-even and clamped (ties 0.5/1.5/2.5, ±inf and huge values included), the same as for 2D arrays, which matches the test's expectations. Thanks for restricting the tile modes; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5448115510 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/931#pullrequestreview-5448115510). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T20:43:40Z. **Review:** APPROVED --- Rechecked eb30830: build + ctest green on RADV, and the new tests need the change. Checked on the gfx1035 HW oracle (linear and 64KB_Z_X): the `image_sample_lz` 1D_ARRAY layer is round-to-nearest-even and clamped (ties 0.5/1.5/2.5, ±inf and huge values included), the same as for 2D arrays, which matches the test's expectations. Thanks for restricting the tile modes; merging.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!931
No description provided.