feat(shader): decode more GCN instructions and take a GCN image's dimension from its T# #9889

Merged
savvaniss merged 28 commits from upstream-pr/9889 into main 2026-11-14 17:32:53 +00:00
savvaniss commented 2026-10-22 20:49:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-22T20:49:13Z.


What

The shader half of Get-fix/AnyPS5#1, moved upstream. #9430 has merged, so it goes straight on main, as the maintainers asked on #6977. These are GCN decoder and translation gaps that the Hasbro Family Fun Pack (CUSA03312) hit on #6977's branch. The s_setreg_imm32_b32 fix from the same pull request is already in #9430. The AGC half is in its own pull request on #9431, #9891.

  1. MTBUF. GCN MTBUF is the RDNA encoding, but its DFMT and NFMT sit in word 0 bits 19-25 instead of the unified format. The opcodes are the same, ADDR64 still throws, word 1 bit 21 is cleared, and the format comes from GcnBufferFormats().
  2. V_RSQ_CLAMP_F32 (VOP1 0x2c, VOP3 0x1ac) has no RDNA opcode. It decodes as V_RSQ_F32 tagged VRsqClampF32, and an infinite result becomes the largest finite float of the same sign.
  3. SOPK 0x03 to 0x0f (s_cmpk_*, s_addk_i32) have the same opcodes on RDNA. They are now in the GCN table.
  4. SMRD literal offsets. With IMM 0 and OFFSET 255, a GCN SMRD takes a 32-bit literal that counts dwords. It becomes the RDNA SMEM byte offset with a null SOFFSET. A literal past the 20-bit positive range throws. Monopoly Plus uses s_buffer_load_dwordx4 with a literal.
  5. Image dimension from the T#, array index from DA. GCN MIMG has no DIM field.
    • The translation still infers 2D, or 2D array with DA, but now reads up to three more address VGPRs.
    • The materializer takes the dimension from the T#. An array T# without DA takes its non-array dimension, at slice 0.
    • The emitter counts the address's coordinates and gradients for that dimension. With DA, a non-indexed 1D or 2D T# keeps the slot of the index it ignores.
    • A cube is a 2D array of faces and reads x, y and face_id with or without DA, for samples and for stores. image_get_resinfo reports its depth as 6 times its slices.
    • Refused: a 3D T# with DA, a depth comparison through a 1D or 1D-array T#, a sample through a 2D MSAA T#, and a gather or depth comparison through a 1D or 3D T#. A converted format keeps the inferred dimension.
    • A new ImageResource::gathered flag records the gather.
    • Risk samples a cube T# and a 2D T# under DA samples. Monopoly Plus samples a 3D T# under a 2D-inferred sample.

Shader disk cache FormatVersion is 51, the next number above main's 50. 48 and 49 were used on main for other layouts. It must stay unique: if another pull request that changes the schema lands first, this one takes the next free number again before it merges. MarcZX10's coordination note is https://github.com/boykopovar/AnyPS5/pull/9889#issuecomment-6357420480. ImageResource keeps both gathered and main's optionalDescriptor, which gives 47 serialized fields. gathered no longer fits in the padding before byElements, so sizeof(ImageResource) is 100, up from main's 96.

Sources

I read each source below. "ISA" is AMD Sea Islands Series Instruction Set Architecture Reference Guide, revision 1.3, December 2013. LLVM links are at commit 48d0dc8f61. Nothing here was measured on GCN hardware, because none is available to me: the RX 9070 XT has no such opcodes. The same sources are in docs/dev/debt/shader.md.

Semantics Source Not settled by the source
MTBUF word 0: ADDR64 [15], OP [18:16], DFMT [22:19], NFMT [25:23]; word 1 bit 21 (Inst[53]) reserved ISA section 13.6, MTBUF format (pages 13-45, 13-46). LLVM GFX6/7
Clearing word 1 bit 21 The bit is opcode bit 3 on GFX10: LLVM
SMRD with IMM 0 and OFFSET 255 takes a 32-bit literal ISA table 7.1 (SQ_SRC_LITERAL). LLVM's CI encoding
The literal counts dwords getSMRDEncodedLiteralOffset32 and its CI test, where index 256 encodes 0x100 The ISA does not give the literal's unit. LLVM is the only source
V_RSQ_CLAMP_F32 clamps ±inf to ±max float ISA section 12.8 (page 12-103): "The clamp prevents infinite results, clamping infinities to max_float. D.f = 1.0 / sqrt(S0.f), result clamped to +-max_float." VOP1 44, VOP3a 428. LLVM's expansion for later GPUs NaN and negative inputs. No source states them. They follow V_RSQ_F32, because the ISA gives the same formula and names only infinities as clamped. LLVM's fminnum expansion would turn a NaN into the largest float. A measurement on GCN hardware would settle it
MIMG has no DIM field ISA section 13.7 (page 13-48)
The address body by dimension: 3D is x, y, z; cube is x, y, face_id; 2D array is x, y, slice ISA section 8.2.4 and tables 8.8 and 8.9 (pages 8-14 to 8-16); the T# type is in table 8.11 The ISA gives no sentence saying "the T# decides". It follows from the missing DIM field
DA decides the array index ISA section 8.2.5 (page 8-18): "When DA is zero, the hardware does not send an array index to the texture cache. If the texture map was indexed, the hardware supplies an index value of zero. Indices sent for non-indexed texture maps are ignored." Table 8.7. LLVM's DA by dimension Where a LOD or mip goes after a non-indexed T# with DA. It follows table 8.7, "the shader provides an array-index with the instruction", so the slot stays. Whether DA 0 changes a cube: table 8.9 has no DA condition, and section 8.2.5 speaks of array textures. A 3D T# with DA is refused, because the ISA does not say whether an index follows z
image_get_resinfo ISA table 8.8 (address is the mip) and section 12.16: "For cubemaps, depth = 6 * Number_of_array_slices" Whether DA changes the depth of another T#. Without DA an array T# keeps main's RDNA rule and reports no layers

What the sources changed. Reading section 8.2.5 showed this pull request was wrong before: it read a stray VGPR as the slice for an array T# without DA, and it read a LOD from the index's slot for a non-indexed T# with DA. It also pinned the first of these in a test. Both now follow the ISA.

Reconciled with main

Merged with main df58e736c8 (merge commits; no rebase or force-push). Each rule the review named:

  • Short cubes and six-face sampling (787b6a6720, #11507). The rejection runs for GCN too, and GcnImageWords puts last_array in the depth field it reads. A store through a short cube is refused and a sample through one selects its cube mode, both tested. The GCN branch had also dropped main's cube mode for stores, which table 8.8 lists; it is back.
  • 1D storage modes for 2D-array stores (b9d00c5d80). The emitter's slice guard does not apply on GCN. The hardware measurement behind it is RDNA's, while on GCN section 8.2.5 says the index is ignored for a non-indexed T#, and a test pins that.
  • Packed 11_11_10 float stores (e3f644040c). The conversion mode exists in the inferred dimension only. A store through a 2D T# of that format selects it, and a 3D one is refused, both tested.
  • adjustedSample (f27177dd9b). It cannot arise on GCN, because the GCN opcode table has no _a opcodes (0xa0 and up).
  • MSAA sample 0 (0a3ea213e1). It no longer applies on GCN: it was measured on RDNA, and table 8.9 has no 2D MSAA row.

Tested

Windows 11 Pro 26300, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT (driver 32.0.31041.1004), ANYPS5_GPU=AMD, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.

Head 25d1c6c20b (30 Oct, test-only, no merge): TechLevelZero's NVIDIA run, built with -DANYPS5_ENABLE_SPIRV_TOOLS=ON, showed agc_shader_memory failing on GCN store address: a 2D T# without DA. It reproduces on Windows with that option, also on this head merged with main 91db3f79f7, and passes without it: the optimizer folds the constant address into an OpConstantComposite, which the test's module walker did not read. The walker now reads it. Rerun at this head with the option on, RX 9070 XT, validation layer: agc_gcn_decode, agc_shader_memory, agc_shader_disk_cache, agc_driver_gcn_rsq_clamp and agc_driver, 5 of 5, no VUID- line. NVIDIA and Linux were not rerun at this head; the merge with main was not pushed.

Validation layer. agc_gcn_decode, agc_shader_memory, agc_shader_disk_cache and agc_driver ran three times each on main fd41cca5d9, and those four plus the new agc_driver_gcn_rsq_clamp ran three times each on this branch at 27b568f3fb.

  • All tests passed in every run on both.
  • No log has a VUID- line or was not found but was requested by env var VK_INSTANCE_LAYERS.
  • Only agc_driver and agc_driver_gcn_rsq_clamp open a Vulkan device, and every Selected GPU line names the RX 9070 XT. The other three are recompiler tests with no Vulkan instance, so the layer says nothing about them.
  • The head b9f70328fd adds only a shader.md commit to 27b568f3fb.
  • main has since moved to 5abba98955, with no change under core/shader and FormatVersion still 50.

New and changed tests.

  • agc_gcn_decode gains MTBUF (including the reserved bit), V_RSQ_CLAMP_F32, SOPK and SMRD literal cases.
  • agc_shader_memory gains tables over 1D, 2D, 3D, cube, 1D-array and 2D-array T#s with and without DA, for the selected mode, for image_sample_l (each coordinate and the LOD traced back to its VGPR) and for image_store (each coordinate). It also covers cube and 2D image_get_resinfo, the refusals, short cubes, 11_11_10 stores and the tracker's gathered.
  • agc_driver_gcn_rsq_clamp is a new execution test that runs on the GPU, in VOP1 and VOP3 form. rsq_clamp(+0) is 0x7f7fffff and rsq_clamp(-0) is 0xff7fffff. Denormals, ±inf, ±1, a quiet NaN and a signaling NaN match v_rsq_f32, except that an infinite result clamps.

Each part removed on its own at a16b8cd7a6 (only the test built and run, same environment). Every removal fails:

Removed Test Fails with
MTBUF re-encoding agc_gcn_decode GCN MTBUF opcode 7 at program counter 0 is not implemented
Clearing MTBUF word 1 bit 21 agc_gcn_decode MTBUF word 1 bit 21, reserved on GCN, changed the RDNA opcode
VRsqClampF32 tag agc_gcn_decode VOP1 v_rsq_clamp_f32 did not decode as VRsqClampF32
SOPK 0x03-0x0f table rows agc_gcn_decode GCN SOPK opcode 15 at program counter 0 is not implemented
SMRD literal offset agc_gcn_decode GCN SMRD literal-offset opcode 10 at program counter 0 is not implemented
SMRD literal counted in dwords agc_gcn_decode an SMRD literal offset is not counted in dwords
GCN run-time dimension modes agc_shader_memory GCN dimensions: an image with DA does not offer every T# dimension at run time
No 1D or 3D under a gather agc_shader_memory GCN dimensions: a gathered image offered a dimension SPIR-V cannot gather
No 1D or 3D under a comparison agc_shader_memory GCN dimensions: a depth comparison offered a volume mode
Array index from DA agc_shader_memory image descriptor is incompatible with the static runtime image interface (a 2D-array T# without DA)
Cube mode for stores agc_shader_memory image descriptor is incompatible with the static runtime image interface (a store through a cube T#)
Emitter's coordinate count agc_shader_memory GCN volume sample: a sample through a 3D T# does not take its z from the third address VGPR
The index's slot with DA agc_shader_memory GCN sample address: a 1D T# with DA
Three extra address VGPRs agc_shader_memory GCN volume sample: a sample through a 3D T# does not take its z from the third address VGPR
Tracker's gathered flag agc_shader_memory GCN volume sample: only the image of the GCN gather is marked as gathered
Cube depth in image_get_resinfo agc_shader_memory GCN resinfo: a cube T# without DA does not report six faces per slice as depth
gathered in the disk cache codec agc_shader_disk_cache entry round trip: shader info differs
The clamp agc_driver_gcn_rsq_clamp GCN rsq clamp, VOP1 of 0x00000000: 0x7f800000 with v_rsq_f32 0x7f800000, expected the largest positive float
The clamp's sign agc_driver_gcn_rsq_clamp GCN rsq clamp, VOP1 of 0x80000000: 0x7f7fffff with v_rsq_f32 0xff800000, expected the largest negative float

Linux. WSL Ubuntu, g++ 15.2.0, CMake 4.2.3, Unix Makefiles, Release, at b9f70328fd.

  • Built and run, once, on llvmpipe (LLVM 21.1.8, host subgroup 8) with ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1: agc_gcn_decode, agc_shader_memory, agc_shader_disk_cache, agc_driver_gcn_rsq_clamp and agc_driver. All 5 pass. The validation layer was not on for this run.
  • The dev packages SDL's configure checks want are not installed here, and I did not install any. So in that copy only, I turned the two SDL configure errors (XRandR, audio output) into messages. Nothing else in the tree differs, and this change is not in the pull request.
  • The Linux-only guards are evaluated: with sizeof(ImageResource) == 96 restored, ShaderDiskCache.cpp fails with static assertion failed.
  • PipelineJournal.cpp is built as part of libSceAgcDriver, and this pull request adds no field to State or ShaderStages.

CUSA03312, not rerun on this head. Each fix removed a stop in Risk or Monopoly Plus on ps4/limbo-gpu at 93eeee0141 (#6977's head then), with Get-fix/AnyPS5#2 and local stand-ins for sceGnmDrawInitDefaultHardwareState200 and sceGnmUpdate*Shader (Get-fix/AnyPS5#1 has the details). The array-index and refusal changes above came after those runs, so a title that reaches a newly refused case now stops with that case's message. The titles also need #9431 and #9432.

Tools.

  • tools/check_conventions.py --base origin/main passes with no findings.

  • tools/pr_overlap.py --branch feat/gcn-cusa03312-instructions lists these as conflicting:

    • #10867 (compute implicit LOD, Felipebmaitan) changes neighbouring lines of the materializer's dimension decode and RuntimeImageModes.
    • #9671 (v_cmpx, ntamas94) changes neighbouring lines of GcnInstructionDecoder.cpp and shader.md.
    • #9897 (ours) changes the ImageResource sizeof and field-count lines in ShaderDiskCache.cpp.
    • #6290 changes a neighbouring line of the ShaderMemory.cpp test.

    Many others could not be compared because they conflict with main, among them several that change FormatVersion. All of the listed ones compose. Whichever lands second resolves the conflict and takes the next free FormatVersion.

Test-only change, 1 Nov. Head aadcd7d1a2, at oneandonlydean's request. It removes the expectFailure assertions for a 3D T# with DA, a sample through a 2D MSAA T# and a depth comparison through a 1D or 1D-array T#, plus GcnType2DMsaa, which nothing else used. The production refusals and their debt entry are unchanged, and those three rows left the table above. agc_shader_memory passes in a fresh Release build on Windows with ANYPS5_GPU=AMD, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and the validation layer, 1 of 1, no VUID- line. This test selects no Vulkan device, so it names no GPU. Not rerun at this head: agc_gcn_decode, agc_shader_disk_cache, agc_driver_gcn_rsq_clamp, agc_driver, NVIDIA, Linux, any title. No product code changed since 25d1c6c20b.

Merge of main a4eca2a056, 2 Nov. Head dcd79190d6. Conflicts: ImageResource (this branch's gathered next to main's layerRowsCompatible, layerRows and maxArrayLayers, all kept, in the struct, codec and agc_shader_disk_cache sample), the ImageResource guards (sizeof 108, unchanged by gathered because it fills padding, measured with a probe built by MinGW GCC 15.2; field count 50), FormatVersion 52 (both sides had 51), and inspectImageDescriptor, which keeps main's layer-rows block and this branch's removal of the address-count throw. Run on the RX 9070 XT with the environment above: agc_gcn_decode, agc_shader_disk_cache and its 4 option runs, agc_shader_memory and 21 option runs of agc_shader_memory_tests, agc_driver_gcn_rsq_clamp and main's agc_driver_image_array_rows_past_layer_limit: 29 passed, 1 skipped (agc_driver_image_array_rows_past_layer_limit: the device allows every array a T# can describe), no VUID- line, every Selected GPU line names the RX 9070 XT. Not rerun: agc_driver, Linux (the sizeof guard is Linux-only and was not compiled there), CUSA03312. check_conventions.py passes.

Merge of main d1ae628bc2, 3 Nov. Head 4d2e2907e4. Conflicts: GcnOpcodeTables.hpp Vop3 size (this branch's v_rsq_clamp_f32 entry plus main's 36 new entries, 361; entries checked sorted with no duplicate key) and tests/GcnDecode.cpp (main's Vop3FormsOfMappedVop2AndVopcDecode kept next to this branch's four cases). FormatVersion stays 52 (main 51). No Linux sizeof guard changed on either side. Windows, WinLibs GCC, Release, AMD RX 9070 XT, validation layer, ANYPS5_NO_SHADER_CACHE=1: agc_gcn_decode, agc_driver_gcn_rsq_clamp, agc_shader_disk_cache* (5) and agc_shader_memory with the other built agc_shader_* tests, 41/41 pass, no VUID-. check_conventions.py passed. Not rerun: the other execution tests, Linux, CUSA03312.

Merge of main 4f41f4c375, 3 Nov. Head 6e939dea9b. Conflicts: DecodeGcnInstruction keeps this branch's v_rsq_clamp_f32 override next to main's v_cmpx second destination, and docs/dev/debt/shader.md keeps main's new GCN v_cmpx entry under this branch's GCN entries. Main moved FormatVersion to 52, the value this branch used, so it is now 53. No Linux sizeof or field-count guard changed on main. Windows, WinLibs GCC, Release, RX 9070 XT, validation layer, ANYPS5_NO_SHADER_CACHE=1: agc_driver_gcn_compare_exec_writes (main's, which runs the decoder path this merge touched), agc_driver_gcn_rsq_clamp, agc_gcn_decode, agc_shader_disk_cache and agc_shader_memory pass, 3 of 3 runs, no VUID- line, no skip. Not rerun: the other focused tests, Linux, games.

Merge of main 5b1d381d5a, 4 Nov. Head 5d76f19c0f. Conflict: FormatVersion, which main moved to 56, so it is now 57. Main also added ImageResource::volumeGather and set the ImageResource field count to 50, the value this branch used for gathered, so git merged the count without a conflict and the Windows build stopped at that assert (51 fields). The count is now 51; both fields are in the info encoder and decoder. Linux: ShaderDiskCache.cpp compiles with -fsyntax-only on WSL Ubuntu g++ 15.2 (x86-64, libstdc++), so its sizeof guards hold; nothing was linked or run there. Windows, WinLibs GCC, Release, RX 9070 XT, validation layer, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1: agc_gcn_decode, agc_driver_gcn_rsq_clamp, the 5 agc_shader_disk_cache* tests and the 36 agc_shader_memory_tests tests pass, 43 of 43, one run, no VUID- line; Selected GPU names the RX 9070 XT. Not rerun: agc_driver, agc_driver_gcn_compare_exec_writes, the per-part removals, Linux tests, games.

Merge of main 4180951e90, 5 Nov. Head 409358e59b. A clean merge to rerun CI.

  • Why. The relinker (macos-latest, clang++, x86_64) job on 5d76f19c0f failed only because guest_none_relocations hit its 20 s limit. This PR doesn't touch core/relinker, and main now runs that test as two halves (#15526). FormatVersion stays 57 (main is at 56).
  • Runs. Windows, WinLibs GCC, Release, RX 9070 XT, with the validation layer, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1: agc_gcn_decode, agc_driver_gcn_rsq_clamp, the 5 agc_shader_disk_cache* tests and agc_shader_memory pass, 8 of 8, in one run. There is no VUID- line, and the Selected GPU line names the RX 9070 XT.
  • Not rerun: Linux and games. check_conventions.py passes.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: CUSA03312 #7198
  • GPUs tested: AMD Radeon RX 9070 XT, driver 32.0.31041.1004, Windows 11 Pro 26300
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4973924507 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9889). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-22T20:49:13Z. --- ### What The shader half of Get-fix/AnyPS5#1, moved upstream. #9430 has merged, so it goes straight on `main`, as the maintainers asked on #6977. These are GCN decoder and translation gaps that the Hasbro Family Fun Pack (CUSA03312) hit on #6977's branch. The `s_setreg_imm32_b32` fix from the same pull request is already in #9430. The AGC half is in its own pull request on #9431, #9891. 1. **MTBUF.** GCN MTBUF is the RDNA encoding, but its DFMT and NFMT sit in word 0 bits 19-25 instead of the unified format. The opcodes are the same, ADDR64 still throws, word 1 bit 21 is cleared, and the format comes from `GcnBufferFormats()`. 2. **`V_RSQ_CLAMP_F32`** (VOP1 0x2c, VOP3 0x1ac) has no RDNA opcode. It decodes as `V_RSQ_F32` tagged `VRsqClampF32`, and an infinite result becomes the largest finite float of the same sign. 3. **SOPK 0x03 to 0x0f** (`s_cmpk_*`, `s_addk_i32`) have the same opcodes on RDNA. They are now in the GCN table. 4. **SMRD literal offsets.** With IMM 0 and OFFSET 255, a GCN SMRD takes a 32-bit literal that counts dwords. It becomes the RDNA SMEM byte offset with a null SOFFSET. A literal past the 20-bit positive range throws. Monopoly Plus uses `s_buffer_load_dwordx4` with a literal. 5. **Image dimension from the T#, array index from DA.** GCN MIMG has no DIM field. - The translation still infers 2D, or 2D array with DA, but now reads up to three more address VGPRs. - The materializer takes the dimension from the T#. An array T# without DA takes its non-array dimension, at slice 0. - The emitter counts the address's coordinates and gradients for that dimension. With DA, a non-indexed 1D or 2D T# keeps the slot of the index it ignores. - A cube is a 2D array of faces and reads x, y and face_id with or without DA, for samples and for stores. `image_get_resinfo` reports its depth as 6 times its slices. - Refused: a 3D T# with DA, a depth comparison through a 1D or 1D-array T#, a sample through a 2D MSAA T#, and a gather or depth comparison through a 1D or 3D T#. A converted format keeps the inferred dimension. - A new `ImageResource::gathered` flag records the gather. - Risk samples a cube T# and a 2D T# under DA samples. Monopoly Plus samples a 3D T# under a 2D-inferred sample. Shader disk cache `FormatVersion` is **51**, the next number above main's 50. 48 and 49 were used on `main` for other layouts. It must stay unique: if another pull request that changes the schema lands first, this one takes the next free number again before it merges. MarcZX10's coordination note is https://github.com/boykopovar/AnyPS5/pull/9889#issuecomment-6357420480. `ImageResource` keeps both `gathered` and main's `optionalDescriptor`, which gives 47 serialized fields. `gathered` no longer fits in the padding before `byElements`, so `sizeof(ImageResource)` is **100**, up from main's 96. ### Sources I read each source below. "ISA" is [AMD Sea Islands Series Instruction Set Architecture Reference Guide, revision 1.3, December 2013](https://docs.amd.com/api/khub/documents/YO8RUh~LIQ5Cx3M_Kq9qkg/content). LLVM links are at commit `48d0dc8f61`. Nothing here was measured on GCN hardware, because none is available to me: the RX 9070 XT has no such opcodes. The same sources are in `docs/dev/debt/shader.md`. | Semantics | Source | Not settled by the source | |---|---|---| | MTBUF word 0: ADDR64 [15], OP [18:16], DFMT [22:19], NFMT [25:23]; word 1 bit 21 (Inst[53]) reserved | ISA section 13.6, MTBUF format (pages 13-45, 13-46). [LLVM GFX6/7](https://github.com/llvm/llvm-project/blob/48d0dc8f61a7680190a144ef89bd80543c0ec4f9/llvm/lib/Target/AMDGPU/BUFInstructions.td#L3376-L3385) | | | Clearing word 1 bit 21 | The bit is opcode bit 3 on GFX10: [LLVM](https://github.com/llvm/llvm-project/blob/48d0dc8f61a7680190a144ef89bd80543c0ec4f9/llvm/lib/Target/AMDGPU/BUFInstructions.td#L3345-L3354) | | | SMRD with IMM 0 and OFFSET 255 takes a 32-bit literal | ISA table 7.1 (`SQ_SRC_LITERAL`). [LLVM's CI encoding](https://github.com/llvm/llvm-project/blob/48d0dc8f61a7680190a144ef89bd80543c0ec4f9/llvm/lib/Target/AMDGPU/SMInstructions.td#L781-L796) | | | The literal counts dwords | [`getSMRDEncodedLiteralOffset32`](https://github.com/llvm/llvm-project/blob/48d0dc8f61a7680190a144ef89bd80543c0ec4f9/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp#L3326-L3334) and [its CI test](https://github.com/llvm/llvm-project/blob/48d0dc8f61a7680190a144ef89bd80543c0ec4f9/llvm/test/CodeGen/AMDGPU/smrd.ll#L32-L40), where index 256 encodes `0x100` | The ISA does not give the literal's unit. LLVM is the only source | | `V_RSQ_CLAMP_F32` clamps ±inf to ±max float | ISA section 12.8 (page 12-103): "The clamp prevents infinite results, clamping infinities to max_float. D.f = 1.0 / sqrt(S0.f), result clamped to +-max_float." VOP1 44, VOP3a 428. [LLVM's expansion for later GPUs](https://github.com/llvm/llvm-project/blob/48d0dc8f61a7680190a144ef89bd80543c0ec4f9/llvm/lib/Target/AMDGPU/SIISelLowering.cpp#L11406-L11419) | **NaN and negative inputs.** No source states them. They follow `V_RSQ_F32`, because the ISA gives the same formula and names only infinities as clamped. LLVM's `fminnum` expansion would turn a NaN into the largest float. A measurement on GCN hardware would settle it | | MIMG has no DIM field | ISA section 13.7 (page 13-48) | | | The address body by dimension: 3D is x, y, z; cube is x, y, face_id; 2D array is x, y, slice | ISA section 8.2.4 and tables 8.8 and 8.9 (pages 8-14 to 8-16); the T# type is in table 8.11 | The ISA gives no sentence saying "the T# decides". It follows from the missing DIM field | | DA decides the array index | ISA section 8.2.5 (page 8-18): "When DA is zero, the hardware does not send an array index to the texture cache. If the texture map was indexed, the hardware supplies an index value of zero. Indices sent for non-indexed texture maps are ignored." Table 8.7. [LLVM's DA by dimension](https://github.com/llvm/llvm-project/blob/48d0dc8f61a7680190a144ef89bd80543c0ec4f9/llvm/include/llvm/IR/IntrinsicsAMDGPU.td#L1109-L1123) | Where a LOD or mip goes after a non-indexed T# with DA. It follows table 8.7, "the shader provides an array-index with the instruction", so the slot stays. **Whether DA 0 changes a cube:** table 8.9 has no DA condition, and section 8.2.5 speaks of array textures. A 3D T# with DA is refused, because the ISA does not say whether an index follows z | | `image_get_resinfo` | ISA table 8.8 (address is the mip) and section 12.16: "For cubemaps, depth = 6 * Number_of_array_slices" | Whether DA changes the depth of another T#. Without DA an array T# keeps main's RDNA rule and reports no layers | **What the sources changed.** Reading section 8.2.5 showed this pull request was wrong before: it read a stray VGPR as the slice for an array T# without DA, and it read a LOD from the index's slot for a non-indexed T# with DA. It also pinned the first of these in a test. Both now follow the ISA. ### Reconciled with `main` Merged with `main` `df58e736c8` (merge commits; no rebase or force-push). Each rule the review named: - **Short cubes and six-face sampling (787b6a6720, #11507).** The rejection runs for GCN too, and `GcnImageWords` puts `last_array` in the depth field it reads. A store through a short cube is refused and a sample through one selects its cube mode, both tested. The GCN branch had also dropped main's cube mode for stores, which table 8.8 lists; it is back. - **1D storage modes for 2D-array stores (b9d00c5d80).** The emitter's slice guard does not apply on GCN. The hardware measurement behind it is RDNA's, while on GCN section 8.2.5 says the index is ignored for a non-indexed T#, and a test pins that. - **Packed 11_11_10 float stores (e3f644040c).** The conversion mode exists in the inferred dimension only. A store through a 2D T# of that format selects it, and a 3D one is refused, both tested. - **`adjustedSample` (f27177dd9b).** It cannot arise on GCN, because the GCN opcode table has no `_a` opcodes (0xa0 and up). - **MSAA sample 0 (0a3ea213e1).** It no longer applies on GCN: it was measured on RDNA, and table 8.9 has no 2D MSAA row. ### Tested Windows 11 Pro 26300, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT (driver 32.0.31041.1004), `ANYPS5_GPU=AMD`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. Head `25d1c6c20b` (30 Oct, test-only, no merge): TechLevelZero's NVIDIA run, built with `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`, showed `agc_shader_memory` failing on `GCN store address: a 2D T# without DA`. It reproduces on Windows with that option, also on this head merged with `main` `91db3f79f7`, and passes without it: the optimizer folds the constant address into an `OpConstantComposite`, which the test's module walker did not read. The walker now reads it. Rerun at this head with the option on, RX 9070 XT, validation layer: `agc_gcn_decode`, `agc_shader_memory`, `agc_shader_disk_cache`, `agc_driver_gcn_rsq_clamp` and `agc_driver`, 5 of 5, no `VUID-` line. NVIDIA and Linux were not rerun at this head; the merge with `main` was not pushed. **Validation layer.** `agc_gcn_decode`, `agc_shader_memory`, `agc_shader_disk_cache` and `agc_driver` ran three times each on `main` `fd41cca5d9`, and those four plus the new `agc_driver_gcn_rsq_clamp` ran three times each on this branch at `27b568f3fb`. - All tests passed in every run on both. - No log has a `VUID-` line or `was not found but was requested by env var VK_INSTANCE_LAYERS`. - Only `agc_driver` and `agc_driver_gcn_rsq_clamp` open a Vulkan device, and every `Selected GPU` line names the RX 9070 XT. The other three are recompiler tests with no Vulkan instance, so the layer says nothing about them. - The head `b9f70328fd` adds only a `shader.md` commit to `27b568f3fb`. - `main` has since moved to `5abba98955`, with no change under `core/shader` and `FormatVersion` still 50. **New and changed tests.** - `agc_gcn_decode` gains MTBUF (including the reserved bit), `V_RSQ_CLAMP_F32`, SOPK and SMRD literal cases. - `agc_shader_memory` gains tables over 1D, 2D, 3D, cube, 1D-array and 2D-array T#s with and without DA, for the selected mode, for `image_sample_l` (each coordinate and the LOD traced back to its VGPR) and for `image_store` (each coordinate). It also covers cube and 2D `image_get_resinfo`, the refusals, short cubes, 11_11_10 stores and the tracker's `gathered`. - `agc_driver_gcn_rsq_clamp` is a new execution test that runs on the GPU, in VOP1 and VOP3 form. `rsq_clamp(+0)` is `0x7f7fffff` and `rsq_clamp(-0)` is `0xff7fffff`. Denormals, ±inf, ±1, a quiet NaN and a signaling NaN match `v_rsq_f32`, except that an infinite result clamps. **Each part removed on its own** at `a16b8cd7a6` (only the test built and run, same environment). Every removal fails: | Removed | Test | Fails with | |---|---|---| | MTBUF re-encoding | `agc_gcn_decode` | GCN MTBUF opcode 7 at program counter 0 is not implemented | | Clearing MTBUF word 1 bit 21 | `agc_gcn_decode` | MTBUF word 1 bit 21, reserved on GCN, changed the RDNA opcode | | `VRsqClampF32` tag | `agc_gcn_decode` | VOP1 v_rsq_clamp_f32 did not decode as VRsqClampF32 | | SOPK 0x03-0x0f table rows | `agc_gcn_decode` | GCN SOPK opcode 15 at program counter 0 is not implemented | | SMRD literal offset | `agc_gcn_decode` | GCN SMRD literal-offset opcode 10 at program counter 0 is not implemented | | SMRD literal counted in dwords | `agc_gcn_decode` | an SMRD literal offset is not counted in dwords | | GCN run-time dimension modes | `agc_shader_memory` | GCN dimensions: an image with DA does not offer every T# dimension at run time | | No 1D or 3D under a gather | `agc_shader_memory` | GCN dimensions: a gathered image offered a dimension SPIR-V cannot gather | | No 1D or 3D under a comparison | `agc_shader_memory` | GCN dimensions: a depth comparison offered a volume mode | | Array index from DA | `agc_shader_memory` | image descriptor is incompatible with the static runtime image interface (a 2D-array T# without DA) | | Cube mode for stores | `agc_shader_memory` | image descriptor is incompatible with the static runtime image interface (a store through a cube T#) | | Emitter's coordinate count | `agc_shader_memory` | GCN volume sample: a sample through a 3D T# does not take its z from the third address VGPR | | The index's slot with DA | `agc_shader_memory` | GCN sample address: a 1D T# with DA | | Three extra address VGPRs | `agc_shader_memory` | GCN volume sample: a sample through a 3D T# does not take its z from the third address VGPR | | Tracker's `gathered` flag | `agc_shader_memory` | GCN volume sample: only the image of the GCN gather is marked as gathered | | Cube depth in `image_get_resinfo` | `agc_shader_memory` | GCN resinfo: a cube T# without DA does not report six faces per slice as depth | | `gathered` in the disk cache codec | `agc_shader_disk_cache` | entry round trip: shader info differs | | The clamp | `agc_driver_gcn_rsq_clamp` | GCN rsq clamp, VOP1 of 0x00000000: 0x7f800000 with v_rsq_f32 0x7f800000, expected the largest positive float | | The clamp's sign | `agc_driver_gcn_rsq_clamp` | GCN rsq clamp, VOP1 of 0x80000000: 0x7f7fffff with v_rsq_f32 0xff800000, expected the largest negative float | **Linux.** WSL Ubuntu, g++ 15.2.0, CMake 4.2.3, Unix Makefiles, Release, at `b9f70328fd`. - Built and run, once, on llvmpipe (LLVM 21.1.8, host subgroup 8) with `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`: `agc_gcn_decode`, `agc_shader_memory`, `agc_shader_disk_cache`, `agc_driver_gcn_rsq_clamp` and `agc_driver`. All 5 pass. The validation layer was not on for this run. - The dev packages SDL's configure checks want are not installed here, and I did not install any. So in that copy only, I turned the two SDL configure errors (XRandR, audio output) into messages. Nothing else in the tree differs, and this change is not in the pull request. - The Linux-only guards are evaluated: with `sizeof(ImageResource) == 96` restored, `ShaderDiskCache.cpp` fails with `static assertion failed`. - `PipelineJournal.cpp` is built as part of `libSceAgcDriver`, and this pull request adds no field to `State` or `ShaderStages`. **CUSA03312, not rerun on this head.** Each fix removed a stop in Risk or Monopoly Plus on `ps4/limbo-gpu` at `93eeee0141` (#6977's head then), with Get-fix/AnyPS5#2 and local stand-ins for `sceGnmDrawInitDefaultHardwareState200` and `sceGnmUpdate*Shader` (Get-fix/AnyPS5#1 has the details). The array-index and refusal changes above came after those runs, so a title that reaches a newly refused case now stops with that case's message. The titles also need #9431 and #9432. **Tools.** - `tools/check_conventions.py --base origin/main` passes with no findings. - `tools/pr_overlap.py --branch feat/gcn-cusa03312-instructions` lists these as conflicting: - #10867 (compute implicit LOD, Felipebmaitan) changes neighbouring lines of the materializer's dimension decode and `RuntimeImageModes`. - #9671 (`v_cmpx`, ntamas94) changes neighbouring lines of `GcnInstructionDecoder.cpp` and `shader.md`. - #9897 (ours) changes the `ImageResource` `sizeof` and field-count lines in `ShaderDiskCache.cpp`. - #6290 changes a neighbouring line of the `ShaderMemory.cpp` test. Many others could not be compared because they conflict with `main`, among them several that change `FormatVersion`. All of the listed ones compose. Whichever lands second resolves the conflict and takes the next free `FormatVersion`. **Test-only change, 1 Nov.** Head `aadcd7d1a2`, at `oneandonlydean`'s request. It removes the `expectFailure` assertions for a 3D T# with DA, a sample through a 2D MSAA T# and a depth comparison through a 1D or 1D-array T#, plus `GcnType2DMsaa`, which nothing else used. The production refusals and their debt entry are unchanged, and those three rows left the table above. `agc_shader_memory` passes in a fresh Release build on Windows with `ANYPS5_GPU=AMD`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and the validation layer, 1 of 1, no `VUID-` line. This test selects no Vulkan device, so it names no GPU. Not rerun at this head: `agc_gcn_decode`, `agc_shader_disk_cache`, `agc_driver_gcn_rsq_clamp`, `agc_driver`, NVIDIA, Linux, any title. No product code changed since `25d1c6c20b`. **Merge of `main` `a4eca2a056`, 2 Nov.** Head `dcd79190d6`. Conflicts: `ImageResource` (this branch's `gathered` next to main's `layerRowsCompatible`, `layerRows` and `maxArrayLayers`, all kept, in the struct, codec and `agc_shader_disk_cache` sample), the `ImageResource` guards (`sizeof` 108, unchanged by `gathered` because it fills padding, measured with a probe built by MinGW GCC 15.2; field count 50), `FormatVersion` 52 (both sides had 51), and `inspectImageDescriptor`, which keeps main's layer-rows block and this branch's removal of the address-count throw. Run on the RX 9070 XT with the environment above: `agc_gcn_decode`, `agc_shader_disk_cache` and its 4 option runs, `agc_shader_memory` and 21 option runs of `agc_shader_memory_tests`, `agc_driver_gcn_rsq_clamp` and main's `agc_driver_image_array_rows_past_layer_limit`: 29 passed, 1 skipped (`agc_driver_image_array_rows_past_layer_limit`: the device allows every array a T# can describe), no `VUID-` line, every `Selected GPU` line names the RX 9070 XT. Not rerun: `agc_driver`, Linux (the `sizeof` guard is Linux-only and was not compiled there), CUSA03312. `check_conventions.py` passes. **Merge of `main` `d1ae628bc2`, 3 Nov.** Head `4d2e2907e4`. Conflicts: `GcnOpcodeTables.hpp` `Vop3` size (this branch's `v_rsq_clamp_f32` entry plus main's 36 new entries, 361; entries checked sorted with no duplicate key) and `tests/GcnDecode.cpp` (main's `Vop3FormsOfMappedVop2AndVopcDecode` kept next to this branch's four cases). `FormatVersion` stays 52 (main 51). No Linux `sizeof` guard changed on either side. Windows, WinLibs GCC, Release, AMD RX 9070 XT, validation layer, `ANYPS5_NO_SHADER_CACHE=1`: `agc_gcn_decode`, `agc_driver_gcn_rsq_clamp`, `agc_shader_disk_cache*` (5) and `agc_shader_memory` with the other built `agc_shader_*` tests, 41/41 pass, no `VUID-`. `check_conventions.py` passed. Not rerun: the other execution tests, Linux, CUSA03312. **Merge of `main` `4f41f4c375`, 3 Nov.** Head `6e939dea9b`. Conflicts: `DecodeGcnInstruction` keeps this branch's `v_rsq_clamp_f32` override next to main's `v_cmpx` second destination, and `docs/dev/debt/shader.md` keeps main's new `GCN v_cmpx` entry under this branch's GCN entries. Main moved `FormatVersion` to 52, the value this branch used, so it is now 53. No Linux `sizeof` or field-count guard changed on main. Windows, WinLibs GCC, Release, RX 9070 XT, validation layer, `ANYPS5_NO_SHADER_CACHE=1`: `agc_driver_gcn_compare_exec_writes` (main's, which runs the decoder path this merge touched), `agc_driver_gcn_rsq_clamp`, `agc_gcn_decode`, `agc_shader_disk_cache` and `agc_shader_memory` pass, 3 of 3 runs, no `VUID-` line, no skip. Not rerun: the other focused tests, Linux, games. **Merge of `main` `5b1d381d5a`, 4 Nov.** Head `5d76f19c0f`. Conflict: `FormatVersion`, which main moved to 56, so it is now 57. Main also added `ImageResource::volumeGather` and set the `ImageResource` field count to 50, the value this branch used for `gathered`, so git merged the count without a conflict and the Windows build stopped at that assert (51 fields). The count is now 51; both fields are in the info encoder and decoder. Linux: `ShaderDiskCache.cpp` compiles with `-fsyntax-only` on WSL Ubuntu g++ 15.2 (x86-64, libstdc++), so its `sizeof` guards hold; nothing was linked or run there. Windows, WinLibs GCC, Release, RX 9070 XT, validation layer, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1`: `agc_gcn_decode`, `agc_driver_gcn_rsq_clamp`, the 5 `agc_shader_disk_cache*` tests and the 36 `agc_shader_memory_tests` tests pass, 43 of 43, one run, no `VUID-` line; `Selected GPU` names the RX 9070 XT. Not rerun: `agc_driver`, `agc_driver_gcn_compare_exec_writes`, the per-part removals, Linux tests, games. **Merge of `main` `4180951e90`, 5 Nov.** Head `409358e59b`. A clean merge to rerun CI. - **Why.** The `relinker (macos-latest, clang++, x86_64)` job on `5d76f19c0f` failed only because `guest_none_relocations` hit its 20 s limit. This PR doesn't touch `core/relinker`, and `main` now runs that test as two halves (#15526). `FormatVersion` stays 57 (`main` is at 56). - **Runs.** Windows, WinLibs GCC, Release, RX 9070 XT, with the validation layer, `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1`: `agc_gcn_decode`, `agc_driver_gcn_rsq_clamp`, the 5 `agc_shader_disk_cache*` tests and `agc_shader_memory` pass, 8 of 8, in one run. There is no `VUID-` line, and the `Selected GPU` line names the RX 9070 XT. - **Not rerun:** Linux and games. `check_conventions.py` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: CUSA03312 #7198 - [x] GPUs tested: AMD Radeon RX 9070 XT, driver 32.0.31041.1004, Windows 11 Pro 26300 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
XairRrR commented 2026-10-29 03:56:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T03:56:44Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The head builds, its focused tests pass and fail correctly when the behaviour is reverted, but it no longer merges with main (5 files, including the disk cache schema), and the PR does not name a source for the new instruction semantics.

What I ran

  • Head: 68a68256b3e322dc1a15f017206e6dcebf497312
  • main: b433c40f2f46aa2e59e19806010a839ac8572d64
  • PR merge base: 07da04f94713ed0f780c16e6cee2aa59d2221d75

The merge with main conflicted, so I aborted it and built and tested the head on its own. Arch Linux 7.2.11-zen, GCC 16.2.1, Release, Ninja, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08), in a clean worktree.

git fetch origin main pull/9889/head:refs/review/9889
git checkout --detach origin/main
git merge --no-ff --no-edit refs/review/9889        # conflicts, aborted
git checkout --detach refs/review/9889
git diff --check origin/main...refs/review/9889
python3 tools/check_conventions.py --base origin/main
cmake --build build -j10 --target agc_gcn_decode_tests agc_shader_memory_tests agc_shader_disk_cache_tests
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
  ctest --test-dir build -R '^(agc_gcn_decode|agc_shader_memory|agc_shader_disk_cache)$' -j4 -V --output-on-failure
# negative controls: see below

Results

Check Result
Merge with main b433c40f2f Conflicts in 5 files
git diff --check clean
tools/check_conventions.py --base origin/main All conventions checks passed.
Build of the 3 test targets at the head OK; 2 -Wstringop-overflow warnings from GCC 16, in code this PR does not change
agc_gcn_decode Passed
agc_shader_memory Passed (0.26 s)
agc_shader_disk_cache Passed (1.21 s)
VUID- lines / was not found but was requested by env var VK_INSTANCE_LAYERS 0 / 0. None of the three tests creates a Vulkan instance: the loader printed nothing. So this run says nothing about validation.
Conflicting files
CONFLICT (content): core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
CONFLICT (content): core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hpp
CONFLICT (content): core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
CONFLICT (content): core/shader/recompiler/ShaderDiskCache.cpp
CONFLICT (content): core/shader/recompiler/ShaderDiskCache.hpp

main side of each conflict:

  • ImageResource gained sampledOnly and optionalDescriptor: the field count is 45 and FormatVersion is 49.
  • ResourceMaterializer.cpp gained descriptorIsShortCube (#11507) at the place where this PR adds gcnDescriptorDimension.
ctest at the head
1/3 Test #1446: agc_gcn_decode ...................   Passed    0.00 sec
2/3 Test  #643: agc_shader_memory ................   Passed    0.26 sec
3/3 Test  #658: agc_shader_disk_cache ............   Passed    1.21 sec
100% tests passed out of 3

Negative control

The PR conflicts with main, and main has 160 commits under core/shader since the merge base, so I reverted to the merge base 07da04f947 instead of to main.

  1. I reverted the behaviour in ResourceMaterializer.cpp, ResourceTracker.cpp, GcnInstructionDecoder.cpp, GcnOpcodeTables.hpp, SpirvImageEmitter.cpp, TranslationContext.hpp, FloatInstructions.cpp, MemoryResourceHelpers.cpp and VectorInstructions.cpp. I kept the new gathered field, the VRsqClampF32 enum and its decoder lists, and the disk cache changes, so the tests still compile. Results:
    • agc_gcn_decode failed: GCN MTBUF opcode 7 at program counter 0 is not implemented.
    • agc_shader_memory failed: GCN dimensions: a 2D-inferred image does not offer every T# dimension at run time.
    • agc_shader_disk_cache passed, as expected, because its encoder was kept.
  2. I reverted only SpirvImageEmitter.cpp. agc_shader_memory failed: GCN volume sample: a sample through a 3D T# does not take its z from the third address VGPR.

After I restored the head files, both tests passed again. I did not repeat the other single-part removals in the description's table.

Findings

Blocking

  1. The PR conflicts with main, and FormatVersion 48 is already taken.

    • ShaderDiskCache.hpp:16 sets 48. main is now at 49.
    • main already used 48 for other ImageResource layouts: #8077 added optionalDescriptor and #11507 added sampledOnly, each under 48, and b9f4f65904 then moved both to 49. A cache entry written as 48 by one layout would be decoded with another layout's field order. This is the case MarcZX10 warned about.
    • To fix:
      • Merge main again.
      • In Resources.hpp, keep both optionalDescriptor and gathered.
      • Set the fieldCount<ImageResource>() assertion to 46.
      • Encode and decode both fields, and set sampleVariant() in the disk cache test for both.
      • Take the next free FormatVersion above 49.
      • Check that sizeof(ImageResource) is still what the description says.
  2. No source is given for the new instruction semantics. CONTRIBUTING.md:8 asks a PR that adds or changes shader instruction semantics to name an exact source (ISA section, LLVM, ACO or Mesa file) or a hardware measurement. The description and the debt entries give none for these:

    The existing debt entry cites shadPS4's opcodes.h only for opcode numbers. Please cite the Sea Islands ISA sections (SMRD, MTBUF, VOP1 opcode list, MIMG address) or an LLVM/Mesa file for each item, in the description and in the shader.md entry.

Non-blocking

  1. Re-check the GCN paths against the materializer changes on main when you resolve the conflict. Since the merge base, main has added rules that this PR's GCN branches either skip or rewrite:

    • the short-cube rejection and six-face sampling (787b6a6720, #11507), applied when decoded.cube && (storage || !base.sampledOnly);
    • 1D storage modes for 2D-array stores (b9d00c5d80);
    • packed 11_11_10 float stores (e3f644040c).

    Two places need checking:

    A GCN case for a cube T# under a 2D-inferred sample, and one for a store, would show whether the merged rules compose.

  2. One known-wrong case runs without an error. The new debt line says that a 1D depth-comparison T# reads the VGPR after x as y, where the hardware would use the centre of row 0. The behaviour is known, so the GCN path could throw for remappedDepth1D until the address is rebuilt, rather than sample at an arbitrary y. The same gap exists on the merge base. It is recorded in debt, which is why this is not blocking.

  3. The V_RSQ_CLAMP_F32 translation is untested. The description says so. A agc_gcn_decode-style or execution case for rsq_clamp(+0) == 0x7f7fffff and rsq_clamp(-0) == 0xff7fffff would pin the clamp. floatUnaryClampInfinity also repeats floatUnary line for line before the clamp; a shared helper would keep their NaN handling the same.

Not verified

  • The merged tree. It does not merge, so nothing was built or run on it. I did not run the focused tests on main either: with the merge failing there was no merged result to compare against, and these three tests open no Vulkan device.
  • agc_driver, or any test that creates a Vulkan device. The validation-layer comparison asked for AGC and shader recompiler changes therefore has no data from this machine.
  • Any of the semantics on a PS4 or GCN hardware, and the CUSA03312 claims. I launched no title.
  • The four single-part removals I did not repeat: SOPK rows, SMRD literal, VRsqClampF32 tag and the tracker's gathered. Revert 1 covered them together. I also did not repeat the disk cache encoder removal.

To get this to a good state

  1. Merge current main.
  2. Resolve the 5 conflicts as described in Blocking 1: keep both new ImageResource fields, set the field count to 46, and take a FormatVersion above 49.
  3. Re-check the GCN branches of RuntimeImageModes and the emitter against main's short-cube and 1D-store rules.
  4. Add the ISA or LLVM/Mesa sources for the MTBUF, SMRD literal, V_RSQ_CLAMP_F32 and MIMG address semantics.
  5. Rerun agc_gcn_decode, agc_shader_memory and agc_shader_disk_cache on the merged tree.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5692662418 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9889#pullrequestreview-5692662418). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-29T03:56:44Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The head builds, its focused tests pass and fail correctly when the behaviour is reverted, but it no longer merges with `main` (5 files, including the disk cache schema), and the PR does not name a source for the new instruction semantics. ## What I ran - Head: `68a68256b3e322dc1a15f017206e6dcebf497312` - `main`: `b433c40f2f46aa2e59e19806010a839ac8572d64` - PR merge base: `07da04f94713ed0f780c16e6cee2aa59d2221d75` The merge with `main` conflicted, so I aborted it and built and tested the head on its own. Arch Linux 7.2.11-zen, GCC 16.2.1, Release, Ninja, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08), in a clean worktree. ```sh git fetch origin main pull/9889/head:refs/review/9889 git checkout --detach origin/main git merge --no-ff --no-edit refs/review/9889 # conflicts, aborted git checkout --detach refs/review/9889 git diff --check origin/main...refs/review/9889 python3 tools/check_conventions.py --base origin/main cmake --build build -j10 --target agc_gcn_decode_tests agc_shader_memory_tests agc_shader_disk_cache_tests VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \ ctest --test-dir build -R '^(agc_gcn_decode|agc_shader_memory|agc_shader_disk_cache)$' -j4 -V --output-on-failure # negative controls: see below ``` ## Results | Check | Result | |---|---| | Merge with `main` `b433c40f2f` | **Conflicts** in 5 files | | `git diff --check` | clean | | `tools/check_conventions.py --base origin/main` | `All conventions checks passed.` | | Build of the 3 test targets at the head | OK; 2 `-Wstringop-overflow` warnings from GCC 16, in code this PR does not change | | `agc_gcn_decode` | Passed | | `agc_shader_memory` | Passed (0.26 s) | | `agc_shader_disk_cache` | Passed (1.21 s) | | `VUID-` lines / `was not found but was requested by env var VK_INSTANCE_LAYERS` | 0 / 0. None of the three tests creates a Vulkan instance: the loader printed nothing. So this run says nothing about validation. | <details><summary>Conflicting files</summary> ``` CONFLICT (content): core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp CONFLICT (content): core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hpp CONFLICT (content): core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp CONFLICT (content): core/shader/recompiler/ShaderDiskCache.cpp CONFLICT (content): core/shader/recompiler/ShaderDiskCache.hpp ``` `main` side of each conflict: - `ImageResource` gained `sampledOnly` and `optionalDescriptor`: the field count is 45 and `FormatVersion` is 49. - `ResourceMaterializer.cpp` gained `descriptorIsShortCube` (#11507) at the place where this PR adds `gcnDescriptorDimension`. </details> <details><summary>ctest at the head</summary> ``` 1/3 Test #1446: agc_gcn_decode ................... Passed 0.00 sec 2/3 Test #643: agc_shader_memory ................ Passed 0.26 sec 3/3 Test #658: agc_shader_disk_cache ............ Passed 1.21 sec 100% tests passed out of 3 ``` </details> ## Negative control The PR conflicts with `main`, and `main` has 160 commits under `core/shader` since the merge base, so I reverted to the merge base `07da04f947` instead of to `main`. 1. I reverted the behaviour in `ResourceMaterializer.cpp`, `ResourceTracker.cpp`, `GcnInstructionDecoder.cpp`, `GcnOpcodeTables.hpp`, `SpirvImageEmitter.cpp`, `TranslationContext.hpp`, `FloatInstructions.cpp`, `MemoryResourceHelpers.cpp` and `VectorInstructions.cpp`. I kept the new `gathered` field, the `VRsqClampF32` enum and its decoder lists, and the disk cache changes, so the tests still compile. Results: - `agc_gcn_decode` failed: `GCN MTBUF opcode 7 at program counter 0 is not implemented`. - `agc_shader_memory` failed: `GCN dimensions: a 2D-inferred image does not offer every T# dimension at run time`. - `agc_shader_disk_cache` passed, as expected, because its encoder was kept. 2. I reverted only `SpirvImageEmitter.cpp`. `agc_shader_memory` failed: `GCN volume sample: a sample through a 3D T# does not take its z from the third address VGPR`. After I restored the head files, both tests passed again. I did not repeat the other single-part removals in the description's table. ## Findings ### Blocking 1. **The PR conflicts with `main`, and `FormatVersion` 48 is already taken.** - [`ShaderDiskCache.hpp:16`](https://github.com/boykopovar/AnyPS5/blob/68a68256b3e322dc1a15f017206e6dcebf497312/core/shader/recompiler/ShaderDiskCache.hpp#L16-L16) sets 48. `main` is now at [49](https://github.com/boykopovar/AnyPS5/blob/b433c40f2f46aa2e59e19806010a839ac8572d64/core/shader/recompiler/ShaderDiskCache.hpp#L16-L16). - `main` already used 48 for other `ImageResource` layouts: #8077 added `optionalDescriptor` and #11507 added `sampledOnly`, each under 48, and b9f4f65904 then moved both to 49. A cache entry written as 48 by one layout would be decoded with another layout's field order. This is the case MarcZX10 warned about. - To fix: - Merge `main` again. - In `Resources.hpp`, keep both `optionalDescriptor` and `gathered`. - Set the `fieldCount<ImageResource>()` assertion to 46. - Encode and decode both fields, and set `sampleVariant()` in the disk cache test for both. - Take the next free `FormatVersion` above 49. - Check that `sizeof(ImageResource)` is still what the description says. 2. **No source is given for the new instruction semantics.** [CONTRIBUTING.md:8](https://github.com/boykopovar/AnyPS5/blob/b433c40f2f46aa2e59e19806010a839ac8572d64/CONTRIBUTING.md#L8-L8) asks a PR that adds or changes shader instruction semantics to name an exact source (ISA section, LLVM, ACO or Mesa file) or a hardware measurement. The description and the debt entries give none for these: - the MTBUF word 0 DFMT [22:19], NFMT [25:23] and ADDR64 [15] layout, and the clearing of word 1 bit 21 ([`GcnInstructionDecoder.cpp:292-308`](https://github.com/boykopovar/AnyPS5/blob/68a68256b3e322dc1a15f017206e6dcebf497312/core/shader/recompiler/RdnaDecoder/src/GcnInstructionDecoder.cpp#L292-L308)); - the SMRD literal counting dwords rather than bytes ([`GcnInstructionDecoder.cpp:113-124`](https://github.com/boykopovar/AnyPS5/blob/68a68256b3e322dc1a15f017206e6dcebf497312/core/shader/recompiler/RdnaDecoder/src/GcnInstructionDecoder.cpp#L113-L124)); - `V_RSQ_CLAMP_F32` turning ±inf into ±max float, with NaN and negative inputs handled like `V_RSQ_F32` ([`FloatInstructions.cpp:614-625`](https://github.com/boykopovar/AnyPS5/blob/68a68256b3e322dc1a15f017206e6dcebf497312/core/shader/recompiler/Translation/src/FloatInstructions.cpp#L614-L625)); - the T# type deciding how many address VGPRs a GCN MIMG reads. The existing debt entry cites shadPS4's `opcodes.h` only for opcode numbers. Please cite the Sea Islands ISA sections (SMRD, MTBUF, VOP1 opcode list, MIMG address) or an LLVM/Mesa file for each item, in the description and in the [`shader.md` entry](https://github.com/boykopovar/AnyPS5/blob/68a68256b3e322dc1a15f017206e6dcebf497312/docs/dev/debt/shader.md#L27-L28). ### Non-blocking 1. **Re-check the GCN paths against the materializer changes on `main` when you resolve the conflict.** Since the merge base, `main` has added rules that this PR's GCN branches either skip or rewrite: - the short-cube rejection and six-face sampling (787b6a6720, #11507), applied when `decoded.cube && (storage || !base.sampledOnly)`; - 1D storage modes for 2D-array stores (b9d00c5d80); - packed 11_11_10 float stores (e3f644040c). Two places need checking: - The GCN branch in `RuntimeImageModes` ([`ResourceMaterializer.cpp:1909-1927`](https://github.com/boykopovar/AnyPS5/blob/68a68256b3e322dc1a15f017206e6dcebf497312/core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp#L1909-L1927)) returns before every rule after it. - The emitter rewrites the address whenever `mem.imageDimension != image.dimension` ([`SpirvImageEmitter.cpp:1941-1952`](https://github.com/boykopovar/AnyPS5/blob/68a68256b3e322dc1a15f017206e6dcebf497312/core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp#L1941-L1952)). That is also true for `main`'s intended remaps, such as a 1D mode under a 2D or 2D-array store. A GCN case for a cube T# under a 2D-inferred sample, and one for a store, would show whether the merged rules compose. 2. **One known-wrong case runs without an error.** The new debt line says that a 1D depth-comparison T# reads the VGPR after x as y, where the hardware would use the centre of row 0. The behaviour is known, so the GCN path could throw for `remappedDepth1D` until the address is rebuilt, rather than sample at an arbitrary y. The same gap exists on the merge base. It is recorded in debt, which is why this is not blocking. 3. **The `V_RSQ_CLAMP_F32` translation is untested.** The description says so. A `agc_gcn_decode`-style or execution case for `rsq_clamp(+0) == 0x7f7fffff` and `rsq_clamp(-0) == 0xff7fffff` would pin the clamp. `floatUnaryClampInfinity` also repeats `floatUnary` line for line before the clamp; a shared helper would keep their NaN handling the same. ## Not verified - **The merged tree.** It does not merge, so nothing was built or run on it. I did not run the focused tests on `main` either: with the merge failing there was no merged result to compare against, and these three tests open no Vulkan device. - `agc_driver`, or any test that creates a Vulkan device. The validation-layer comparison asked for AGC and shader recompiler changes therefore has no data from this machine. - Any of the semantics on a PS4 or GCN hardware, and the CUSA03312 claims. I launched no title. - The four single-part removals I did not repeat: SOPK rows, SMRD literal, `VRsqClampF32` tag and the tracker's `gathered`. Revert 1 covered them together. I also did not repeat the disk cache encoder removal. ## To get this to a good state 1. Merge current `main`. 2. Resolve the 5 conflicts as described in Blocking 1: keep both new `ImageResource` fields, set the field count to 46, and take a `FormatVersion` above 49. 3. Re-check the GCN branches of `RuntimeImageModes` and the emitter against `main`'s short-cube and 1D-store rules. 4. Add the ISA or LLVM/Mesa sources for the MTBUF, SMRD literal, `V_RSQ_CLAMP_F32` and MIMG address semantics. 5. Rerun `agc_gcn_decode`, `agc_shader_memory` and `agc_shader_disk_cache` on the merged tree.
XairRrR commented 2026-11-02 20:04:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T20:04:07Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

This pull request does not merge cleanly into main (096c45570f): head dcd79190d6 conflicts in

  • core/libs/prx/libSceAgcDriver/tests/GcnDecode.cpp
  • core/shader/recompiler/RdnaDecoder/src/GcnOpcodeTables.hpp

Please rebase it onto current main. I will review the change once it merges cleanly.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5742594384 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9889#pullrequestreview-5742594384). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-02T20:04:07Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested This pull request does not merge cleanly into `main` (096c45570f516de76a43bbe1b97781381c84f55f): head dcd79190d60a4187c09ae0be3505cb8d5cb97bb0 conflicts in - `core/libs/prx/libSceAgcDriver/tests/GcnDecode.cpp` - `core/shader/recompiler/RdnaDecoder/src/GcnOpcodeTables.hpp` Please rebase it onto current `main`. I will review the change once it merges cleanly. <!-- anyps5-bots job=2219 head=dcd79190d60a4187c09ae0be3505cb8d5cb97bb0 -->
XairRrR commented 2026-11-03 07:34:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T07:34:17Z.

Review: APPROVED


Re-checked — approved

Since my last review the author merged main several times, made DA decide the array index, added ISA and LLVM sources to the description and to docs/dev/debt/shader.md, made a 1D depth comparison throw and added the agc_driver_gcn_rsq_clamp execution test. All four previous findings are resolved, and the merged tree builds and passes the focused tests. The negative controls fail as they should.

What changed since my last review

  • Commits after 68a68256b3:
    • de3f97fa8b: array-ness now comes from DA (Sea Islands ISA §8.2.5). Two new refusals: a 3D T# with DA, and a depth comparison through a 1D or 1D-array T#. Cube mode for stores is back, and image_get_resinfo reports a cube's depth as 6 × slices.
    • a16b8cd7a6: a test for the reserved MTBUF word 1 bit.
    • b9f70328fd: the GCN debt entries are split, each stating its gap first and citing its sources.
    • 25d1c6c20b: the test's module walker now follows OpConstantComposite. This fixes the -DANYPS5_ENABLE_SPIRV_TOOLS=ON failure TechLevelZero reported.
    • aadcd7d1a2: removes the expectFailure assertions that pinned unimplemented forms, as oneandonlydean asked.
    • Four merges of main. The last one was d1ae628bc2.
  • floatUnary and floatUnaryClampInfinity now share floatUnaryValue.
  • FormatVersion is 52, and main has 51. ImageResource has 50 fields, and sizeof is still 108.
  • The description now has a sources table, a "Reconciled with main" section and a per-part removal table.

What I ran

  • Head 4d2e2907e4101d50543455eb2fe99246b81bb526, main d1ae628bc2f62459cce1e9872ba5632c938c71f2, merged with --no-ff into tree 0fe3d2b272620320358ed4e40f2380936faf5dac.
  • Machine: Debian 13 VM (32 vCPU Xeon Gold 6136), GCC 14.2.0, Release, Ninja, Vulkan on lavapipe (Mesa 26.1.6, LLVM 19). No GPU.
git diff --check d1ae628bc2f62459cce1e9872ba5632c938c71f2...4d2e2907e4101d50543455eb2fe99246b81bb526
python3 tools/check_conventions.py --base d1ae628bc2f62459cce1e9872ba5632c938c71f2
ctest --test-dir build -j8 --test-load 32 --output-on-failure \
  -R '^(agc_driver_gcn_rsq_clamp|agc_gcn_decode|agc_shader_disk_cache|agc_shader_memory)$'
# negative control 1: restore 9 production files from main (list below), then
ninja -C build -j32 -l32 agc_gcn_decode_tests agc_shader_memory_tests agc_driver_gcn_rsq_clamp_tests
ctest --test-dir build --output-on-failure -R '^(agc_driver_gcn_rsq_clamp|agc_gcn_decode|agc_shader_memory)$'
# negative control 2: merged tree, minus the two Value(image.gathered) lines in ShaderDiskCache.cpp
ninja -C build -j32 -l32 agc_shader_disk_cache_tests
ctest --test-dir build --output-on-failure -R '^agc_shader_disk_cache$'
# restore the merged files, rebuild, rerun the four tests, then git status --porcelain (empty)

The script's selected run on the merged tree (build.json) ran 2141 tests:

Check Result
git diff --check clean
check_conventions.py All conventions checks passed.
Configure, build, libs OK
Selected tests (2141) No new failures and no timeouts. The 7 failures (agc_driver_division, the denormal-mode tests, vector_constant_factor_tininess, one unwrap_self case) also fail on main. 113 skips, all expected.
Validation layer, 768 tests vs main Layer loaded in 767, layer_missing_in empty, 0 tests with a new VUID-
agc_gcn_decode, agc_driver_gcn_rsq_clamp, agc_shader_disk_cache, agc_shader_memory 4/4 passed (0.01 s, 0.40 s, 4.9 s, 9.0 s)

Negative control

  1. I restored GcnInstructionDecoder.cpp, GcnOpcodeTables.hpp, ResourceMaterializer.cpp, ResourceTracker.cpp, SpirvImageEmitter.cpp, TranslationContext.hpp, FloatInstructions.cpp, MemoryResourceHelpers.cpp and VectorInstructions.cpp from main. I kept the gathered field, the VRsqClampF32 enum and its decoder lists so the tests still compile. All three tests failed:
    • agc_driver_gcn_rsq_clamp: GCN VOP3-promoted opcode 428 at program counter 8 is not implemented
    • agc_gcn_decode: failed
    • agc_shader_memory: GCN dimensions: an image with DA does not offer every T# dimension at run time
  2. I removed only the gathered encode and decode lines from the merged ShaderDiskCache.cpp. agc_shader_disk_cache failed with entry round trip: shader info differs.

After that I restored the merged files and rebuilt. All four tests passed again, and git status --porcelain was empty.

Previous findings

  1. Blocking: conflict with main, FormatVersion 48 already taken. Resolved.
    • The PR merges cleanly into d1ae628bc2.
    • ShaderDiskCache.hpp:16 sets 52, above main's 51.
    • gathered is encoded and decoded next to main's fields, and the field-count assertion is 50.
    • Negative control 2 shows the codec is covered.
  2. Blocking: no source for the new semantics. Resolved.
    • The description and the split entries in shader.md cite Sea Islands ISA 1.3 sections and LLVM at a fixed commit for each item: MTBUF §13.6, SMRD table 7.1 plus LLVM for the dword unit, V_RSQ_CLAMP_F32 §12.8, MIMG §13.7, §8.2.4/8.2.5 and tables 8.7–8.11, resinfo §12.16.
    • Each entry says what the sources leave open: NaN and negative rsq_clamp inputs, a cube without DA, and the LOD slot after a non-indexed T# with DA.
    • Reading §8.2.5 also led the author to find and fix a real bug: a stray VGPR was read as the slice when DA was 0.
    • I had no network, so I did not open the ISA PDF or the LLVM files myself.
  3. Non-blocking: re-check the GCN paths against main's materializer rules. Resolved.
    • The cube mode for stores is restored.
    • Short cubes run for GCN.
    • 11_11_10 and other converted formats keep the inferred dimension: ResourceMaterializer.cpp:2089-2107 returns before offering other dimensions.
    • The MSAA sample-0 rule is taken off GCN.
    • agc_shader_memory now has cube, store, short-cube and 11_11_10 cases, and negative control 1 makes it fail.
  4. Non-blocking: the known-wrong 1D depth comparison ran without an error. Resolved. It is now refused at ResourceMaterializer.cpp:243-245.
  5. Non-blocking: the V_RSQ_CLAMP_F32 translation was untested and duplicated floatUnary. Resolved.
    • The two functions now share floatUnaryValue.
    • agc_driver_gcn_rsq_clamp runs VOP1 and VOP3 forms on the device. It passes on lavapipe here and fails when the translation is reverted.

New findings

Blocking

None.

Non-blocking

None. I also checked these parts of the new code and found nothing to report:

  • The VRsqClampF32 tag: VOP1 bits [31:25] = 0x3f with opcode [16:9] = 0x2c, and VOP3 bits [31:26] = 0x34 with opcode [25:17] = 0x1ac. Every switch on VRsqF32 also lists VRsqClampF32.
  • The MTBUF field layout and the clearing of word 1 bit 21.
  • The SMRD literal range check against GFX10's 21-bit signed SMEM offset.
  • The emitter's coordinate and gradient rewrite. At most +3 components (3D with derivatives), which matches the +3 VGPRs the translation reads.

Not verified

  • Behaviour on any GPU other than lavapipe, on a PS4 or on GCN hardware. The NaN and negative-input behaviour of v_rsq_clamp_f32 is recorded as unmeasured in debt.
  • CUSA03312. I launched no title. The author also says the newer refusals came after their title runs.
  • The cited ISA and LLVM passages themselves (no network here).
  • A build with -DANYPS5_ENABLE_SPIRV_TOOLS=ON. TechLevelZero's NVIDIA and AMD runs at earlier heads used it and passed after 25d1c6c20b.
  • The author's Windows RX 9070 XT runs are author-reported.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5748582881 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9889#pullrequestreview-5748582881). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T07:34:17Z. **Review:** APPROVED --- # Re-checked — approved Since my last review the author merged `main` several times, made DA decide the array index, added ISA and LLVM sources to the description and to `docs/dev/debt/shader.md`, made a 1D depth comparison throw and added the `agc_driver_gcn_rsq_clamp` execution test. All four previous findings are resolved, and the merged tree builds and passes the focused tests. The negative controls fail as they should. ## What changed since my last review - Commits after `68a68256b3`: - `de3f97fa8b`: array-ness now comes from DA (Sea Islands ISA §8.2.5). Two new refusals: a 3D T# with DA, and a depth comparison through a 1D or 1D-array T#. Cube mode for stores is back, and `image_get_resinfo` reports a cube's depth as 6 × slices. - `a16b8cd7a6`: a test for the reserved MTBUF word 1 bit. - `b9f70328fd`: the GCN debt entries are split, each stating its gap first and citing its sources. - `25d1c6c20b`: the test's module walker now follows `OpConstantComposite`. This fixes the `-DANYPS5_ENABLE_SPIRV_TOOLS=ON` failure TechLevelZero reported. - `aadcd7d1a2`: removes the `expectFailure` assertions that pinned unimplemented forms, as oneandonlydean asked. - Four merges of `main`. The last one was `d1ae628bc2`. - `floatUnary` and `floatUnaryClampInfinity` now share `floatUnaryValue`. - `FormatVersion` is 52, and `main` has 51. `ImageResource` has 50 fields, and `sizeof` is still 108. - The description now has a sources table, a "Reconciled with `main`" section and a per-part removal table. ## What I ran - Head `4d2e2907e4101d50543455eb2fe99246b81bb526`, `main` `d1ae628bc2f62459cce1e9872ba5632c938c71f2`, merged with `--no-ff` into tree `0fe3d2b272620320358ed4e40f2380936faf5dac`. - Machine: Debian 13 VM (32 vCPU Xeon Gold 6136), GCC 14.2.0, Release, Ninja, Vulkan on lavapipe (Mesa 26.1.6, LLVM 19). No GPU. ```sh git diff --check d1ae628bc2f62459cce1e9872ba5632c938c71f2...4d2e2907e4101d50543455eb2fe99246b81bb526 python3 tools/check_conventions.py --base d1ae628bc2f62459cce1e9872ba5632c938c71f2 ctest --test-dir build -j8 --test-load 32 --output-on-failure \ -R '^(agc_driver_gcn_rsq_clamp|agc_gcn_decode|agc_shader_disk_cache|agc_shader_memory)$' # negative control 1: restore 9 production files from main (list below), then ninja -C build -j32 -l32 agc_gcn_decode_tests agc_shader_memory_tests agc_driver_gcn_rsq_clamp_tests ctest --test-dir build --output-on-failure -R '^(agc_driver_gcn_rsq_clamp|agc_gcn_decode|agc_shader_memory)$' # negative control 2: merged tree, minus the two Value(image.gathered) lines in ShaderDiskCache.cpp ninja -C build -j32 -l32 agc_shader_disk_cache_tests ctest --test-dir build --output-on-failure -R '^agc_shader_disk_cache$' # restore the merged files, rebuild, rerun the four tests, then git status --porcelain (empty) ``` The script's selected run on the merged tree (build.json) ran 2141 tests: | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | `All conventions checks passed.` | | Configure, build, `libs` | OK | | Selected tests (2141) | No new failures and no timeouts. The 7 failures (`agc_driver_division`, the denormal-mode tests, `vector_constant_factor_tininess`, one `unwrap_self` case) also fail on `main`. 113 skips, all expected. | | Validation layer, 768 tests vs `main` | Layer loaded in 767, `layer_missing_in` empty, 0 tests with a new `VUID-` | | `agc_gcn_decode`, `agc_driver_gcn_rsq_clamp`, `agc_shader_disk_cache`, `agc_shader_memory` | 4/4 passed (0.01 s, 0.40 s, 4.9 s, 9.0 s) | ## Negative control 1. I restored `GcnInstructionDecoder.cpp`, `GcnOpcodeTables.hpp`, `ResourceMaterializer.cpp`, `ResourceTracker.cpp`, `SpirvImageEmitter.cpp`, `TranslationContext.hpp`, `FloatInstructions.cpp`, `MemoryResourceHelpers.cpp` and `VectorInstructions.cpp` from `main`. I kept the `gathered` field, the `VRsqClampF32` enum and its decoder lists so the tests still compile. All three tests failed: - `agc_driver_gcn_rsq_clamp`: `GCN VOP3-promoted opcode 428 at program counter 8 is not implemented` - `agc_gcn_decode`: failed - `agc_shader_memory`: `GCN dimensions: an image with DA does not offer every T# dimension at run time` 2. I removed only the `gathered` encode and decode lines from the merged `ShaderDiskCache.cpp`. `agc_shader_disk_cache` failed with `entry round trip: shader info differs`. After that I restored the merged files and rebuilt. All four tests passed again, and `git status --porcelain` was empty. ## Previous findings 1. **Blocking: conflict with `main`, `FormatVersion` 48 already taken.** Resolved. - The PR merges cleanly into `d1ae628bc2`. - [`ShaderDiskCache.hpp:16`](https://github.com/boykopovar/AnyPS5/blob/4d2e2907e4101d50543455eb2fe99246b81bb526/core/shader/recompiler/ShaderDiskCache.hpp#L16-L16) sets 52, above `main`'s 51. - `gathered` is encoded and decoded next to `main`'s fields, and the field-count assertion is 50. - Negative control 2 shows the codec is covered. 2. **Blocking: no source for the new semantics.** Resolved. - The description and the split entries in [`shader.md`](https://github.com/boykopovar/AnyPS5/blob/4d2e2907e4101d50543455eb2fe99246b81bb526/docs/dev/debt/shader.md#L30-L36) cite Sea Islands ISA 1.3 sections and LLVM at a fixed commit for each item: MTBUF §13.6, SMRD table 7.1 plus LLVM for the dword unit, `V_RSQ_CLAMP_F32` §12.8, MIMG §13.7, §8.2.4/8.2.5 and tables 8.7–8.11, resinfo §12.16. - Each entry says what the sources leave open: NaN and negative `rsq_clamp` inputs, a cube without DA, and the LOD slot after a non-indexed T# with DA. - Reading §8.2.5 also led the author to find and fix a real bug: a stray VGPR was read as the slice when DA was 0. - I had no network, so I did not open the ISA PDF or the LLVM files myself. 3. **Non-blocking: re-check the GCN paths against `main`'s materializer rules.** Resolved. - The cube mode for stores is restored. - Short cubes run for GCN. - 11_11_10 and other converted formats keep the inferred dimension: [`ResourceMaterializer.cpp:2089-2107`](https://github.com/boykopovar/AnyPS5/blob/4d2e2907e4101d50543455eb2fe99246b81bb526/core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp#L2089-L2107) returns before offering other dimensions. - The MSAA sample-0 rule is taken off GCN. - `agc_shader_memory` now has cube, store, short-cube and 11_11_10 cases, and negative control 1 makes it fail. 4. **Non-blocking: the known-wrong 1D depth comparison ran without an error.** Resolved. It is now refused at [`ResourceMaterializer.cpp:243-245`](https://github.com/boykopovar/AnyPS5/blob/4d2e2907e4101d50543455eb2fe99246b81bb526/core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp#L243-L245). 5. **Non-blocking: the `V_RSQ_CLAMP_F32` translation was untested and duplicated `floatUnary`.** Resolved. - The two functions now share [`floatUnaryValue`](https://github.com/boykopovar/AnyPS5/blob/4d2e2907e4101d50543455eb2fe99246b81bb526/core/shader/recompiler/Translation/src/FloatInstructions.cpp#L639-L660). - `agc_driver_gcn_rsq_clamp` runs VOP1 and VOP3 forms on the device. It passes on lavapipe here and fails when the translation is reverted. ## New findings ### Blocking None. ### Non-blocking None. I also checked these parts of the new code and found nothing to report: - The `VRsqClampF32` tag: VOP1 bits [31:25] = 0x3f with opcode [16:9] = 0x2c, and VOP3 bits [31:26] = 0x34 with opcode [25:17] = 0x1ac. Every switch on `VRsqF32` also lists `VRsqClampF32`. - The MTBUF field layout and the clearing of word 1 bit 21. - The SMRD literal range check against GFX10's 21-bit signed SMEM offset. - The emitter's coordinate and gradient rewrite. At most +3 components (3D with derivatives), which matches the +3 VGPRs the translation reads. ## Not verified - Behaviour on any GPU other than lavapipe, on a PS4 or on GCN hardware. The NaN and negative-input behaviour of `v_rsq_clamp_f32` is recorded as unmeasured in debt. - CUSA03312. I launched no title. The author also says the newer refusals came after their title runs. - The cited ISA and LLVM passages themselves (no network here). - A build with `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`. TechLevelZero's NVIDIA and AMD runs at earlier heads used it and passed after `25d1c6c20b`. - The author's Windows RX 9070 XT runs are author-reported. <!-- anyps5-bots job=3165 head=4d2e2907e4101d50543455eb2fe99246b81bb526 -->
XairRrR commented 2026-11-03 15:56:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T15:56:30Z.

Review: APPROVED


Re-checked — approved

The only new commit is 6e939dea9b, a merge of main 4f41f4c375. It resolves the conflicts in DecodeGcnInstruction and docs/dev/debt/shader.md correctly and moves FormatVersion to 53, one above main's 52. The merged tree builds and passes the focused tests.

What changed since my last review

  • No PR commit was rewritten. delta.patch shows commits 1–14 unchanged, and the only new commit is the merge 6e939dea9b.

  • DecodeGcnInstruction: GcnInstructionDecoder.cpp:374-378 now has both pieces:

    • this branch's v_rsq_clamp_f32 opcode override;
    • main's v_cmpx destination2.

    They are independent. The override only changes op for VOP1 0x2c and VOP3 0x1ac, which are not VOPC compares. The compareDestination line still runs after it.

  • docs/dev/debt/shader.md: main's new GCN v_cmpx entry sits next to this branch's split GCN entries. Nothing from either side was lost.

  • FormatVersion: ShaderDiskCache.hpp:16 is 53. main 4f41f4c375 is at 52, so the bump is still unique.

  • Description: it gained a "Merge of main 4f41f4c375" paragraph that matches what I see in the merge.

What I ran

Head 6e939dea9bb49ed64e8778ee4b17be71bc466f81, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree 2182aab91a4150b58d6236980a23d3d109da8e36. Debian 13 VM, GCC 14.2.0, Release, Ninja, lavapipe (Mesa 26.1.6, LLVM 19).

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...6e939dea9bb49ed64e8778ee4b17be71bc466f81
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
git show --cc 6e939dea9bb49ed64e8778ee4b17be71bc466f81
ctest --test-dir build -j8 --test-load 32 --output-on-failure \
  -R '^(agc_driver_gcn_rsq_clamp|agc_gcn_decode|agc_shader_disk_cache|agc_shader_memory|agc_driver_gcn_compare_exec_writes)$'
# negative control: delete the VRsqClampF32 override line in GcnInstructionDecoder.cpp
ninja -C build -j32 -l32 agc_gcn_decode_tests agc_driver_gcn_rsq_clamp_tests
ctest --test-dir build --output-on-failure -R '^(agc_gcn_decode|agc_driver_gcn_rsq_clamp)$'
# restore the merged file, rebuild, rerun, git status --porcelain (empty)
Check Result
git diff --check clean
check_conventions.py All conventions checks passed.
Configure, build, libs (script) OK
Selected tests (script, 2156) 2035 passed, no new failures, no timeouts. The 7 failures also fail on main. 114 skips, all expected.
Validation layer (script, 771 tests vs main) Layer loaded in 770 tests and layer_missing_in is empty. 0 tests have a new VUID- line.
agc_gcn_decode, agc_driver_gcn_rsq_clamp, agc_shader_disk_cache, agc_shader_memory 4/4 passed
agc_driver_gcn_compare_exec_writes (main's test, runs the merged decoder path) Skipped on lavapipe: "the device's subgroups are narrower than the 32 lanes a wave64 run needs (8 lanes)"

Negative control. I removed only the VRsqClampF32 override line, which is the line the merge conflict touched, and rebuilt. Both tests failed:

  • agc_gcn_decode failed with VOP1 v_rsq_clamp_f32 did not decode as VRsqClampF32 and the same message for VOP3.
  • agc_driver_gcn_rsq_clamp failed with VOP1 of 0x00000000: 0x7f800000 ... expected the largest positive float.

After restoring the merged file and rebuilding, both pass and git status --porcelain is empty.

Previous findings

My previous review (at 4d2e2907e4) had no open findings. Its four earlier findings were already resolved, and this merge leaves them resolved:

  1. Conflict with main / FormatVersion already taken: Resolved. The PR merges cleanly, and 53 is above main's 52.
  2. No source for the new semantics: Resolved. The sourced debt entries are still in shader.md after the merge.
  3. Re-check the GCN paths against main's materializer rules: Resolved. The merge does not touch ResourceMaterializer.cpp, and agc_shader_memory passes.
  4. The 1D depth comparison ran without an error: Resolved. It is still refused.
  5. V_RSQ_CLAMP_F32 untested and duplicated: Resolved. The negative control above shows the tests still cover it after the merge.

New findings

Blocking

None.

Non-blocking

None.

Not verified

  • main's agc_driver_gcn_compare_exec_writes: it skips here (lavapipe has 8-lane subgroups), so this machine does not run the v_cmpx path next to the new override. The author reports it passing on an RX 9070 XT.
  • Hardware: I ran nothing on a GPU other than lavapipe, on a PS4 or on GCN hardware. I launched no title (CUSA03312).
  • -DANYPS5_ENABLE_SPIRV_TOOLS=ON: I did not build with this option at this head.
  • The author's Windows runs are author-reported.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5755347246 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9889#pullrequestreview-5755347246). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T15:56:30Z. **Review:** APPROVED --- # Re-checked — approved The only new commit is `6e939dea9b`, a merge of `main` `4f41f4c375`. It resolves the conflicts in `DecodeGcnInstruction` and `docs/dev/debt/shader.md` correctly and moves `FormatVersion` to 53, one above `main`'s 52. The merged tree builds and passes the focused tests. ## What changed since my last review - No PR commit was rewritten. delta.patch shows commits 1–14 unchanged, and the only new commit is the merge `6e939dea9b`. - **`DecodeGcnInstruction`**: [`GcnInstructionDecoder.cpp:374-378`](https://github.com/boykopovar/AnyPS5/blob/6e939dea9bb49ed64e8778ee4b17be71bc466f81/core/shader/recompiler/RdnaDecoder/src/GcnInstructionDecoder.cpp#L374-L378) now has both pieces: - this branch's `v_rsq_clamp_f32` opcode override; - `main`'s `v_cmpx` `destination2`. They are independent. The override only changes `op` for VOP1 0x2c and VOP3 0x1ac, which are not VOPC compares. The `compareDestination` line still runs after it. - **`docs/dev/debt/shader.md`**: `main`'s new `GCN v_cmpx` entry sits next to this branch's split GCN entries. Nothing from either side was lost. - **`FormatVersion`**: [`ShaderDiskCache.hpp:16`](https://github.com/boykopovar/AnyPS5/blob/6e939dea9bb49ed64e8778ee4b17be71bc466f81/core/shader/recompiler/ShaderDiskCache.hpp#L16-L16) is 53. `main` `4f41f4c375` is at 52, so the bump is still unique. - **Description**: it gained a "Merge of `main` `4f41f4c375`" paragraph that matches what I see in the merge. ## What I ran Head `6e939dea9bb49ed64e8778ee4b17be71bc466f81`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged tree `2182aab91a4150b58d6236980a23d3d109da8e36`. Debian 13 VM, GCC 14.2.0, Release, Ninja, lavapipe (Mesa 26.1.6, LLVM 19). ```sh git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...6e939dea9bb49ed64e8778ee4b17be71bc466f81 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 git show --cc 6e939dea9bb49ed64e8778ee4b17be71bc466f81 ctest --test-dir build -j8 --test-load 32 --output-on-failure \ -R '^(agc_driver_gcn_rsq_clamp|agc_gcn_decode|agc_shader_disk_cache|agc_shader_memory|agc_driver_gcn_compare_exec_writes)$' # negative control: delete the VRsqClampF32 override line in GcnInstructionDecoder.cpp ninja -C build -j32 -l32 agc_gcn_decode_tests agc_driver_gcn_rsq_clamp_tests ctest --test-dir build --output-on-failure -R '^(agc_gcn_decode|agc_driver_gcn_rsq_clamp)$' # restore the merged file, rebuild, rerun, git status --porcelain (empty) ``` | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | `All conventions checks passed.` | | Configure, build, `libs` (script) | OK | | Selected tests (script, 2156) | 2035 passed, no new failures, no timeouts. The 7 failures also fail on `main`. 114 skips, all expected. | | Validation layer (script, 771 tests vs `main`) | Layer loaded in 770 tests and `layer_missing_in` is empty. 0 tests have a new `VUID-` line. | | `agc_gcn_decode`, `agc_driver_gcn_rsq_clamp`, `agc_shader_disk_cache`, `agc_shader_memory` | 4/4 passed | | `agc_driver_gcn_compare_exec_writes` (`main`'s test, runs the merged decoder path) | Skipped on lavapipe: "the device's subgroups are narrower than the 32 lanes a wave64 run needs (8 lanes)" | **Negative control.** I removed only the `VRsqClampF32` override line, which is the line the merge conflict touched, and rebuilt. Both tests failed: - `agc_gcn_decode` failed with `VOP1 v_rsq_clamp_f32 did not decode as VRsqClampF32` and the same message for VOP3. - `agc_driver_gcn_rsq_clamp` failed with `VOP1 of 0x00000000: 0x7f800000 ... expected the largest positive float`. After restoring the merged file and rebuilding, both pass and `git status --porcelain` is empty. ## Previous findings My previous review (at `4d2e2907e4`) had no open findings. Its four earlier findings were already resolved, and this merge leaves them resolved: 1. **Conflict with `main` / `FormatVersion` already taken**: Resolved. The PR merges cleanly, and 53 is above `main`'s 52. 2. **No source for the new semantics**: Resolved. The sourced debt entries are still in `shader.md` after the merge. 3. **Re-check the GCN paths against `main`'s materializer rules**: Resolved. The merge does not touch `ResourceMaterializer.cpp`, and `agc_shader_memory` passes. 4. **The 1D depth comparison ran without an error**: Resolved. It is still refused. 5. **`V_RSQ_CLAMP_F32` untested and duplicated**: Resolved. The negative control above shows the tests still cover it after the merge. ## New findings ### Blocking None. ### Non-blocking None. ## Not verified - **`main`'s `agc_driver_gcn_compare_exec_writes`**: it skips here (lavapipe has 8-lane subgroups), so this machine does not run the `v_cmpx` path next to the new override. The author reports it passing on an RX 9070 XT. - **Hardware**: I ran nothing on a GPU other than lavapipe, on a PS4 or on GCN hardware. I launched no title (CUSA03312). - **`-DANYPS5_ENABLE_SPIRV_TOOLS=ON`**: I did not build with this option at this head. - **The author's Windows runs** are author-reported. <!-- anyps5-bots job=3425 head=6e939dea9bb49ed64e8778ee4b17be71bc466f81 -->
MarcZX10 commented 2026-11-14 09:56:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T09:56:02Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected decoder, image materialization, SPIR-V emission, and cache changes show no verified blocking defect; I could not run checks at this head, so a formal approval is not justified.

What I ran

Reviewed head 5e18a55f603540af2f6aa329369cf2ab1e697286. I read the prepared description, commit list, manifest and diff, plus targeted repository code through repo_read.py. No commands or tests were run. The author reports earlier test runs, but those reports do not establish results for this exact head.

Results

Check Result Note
Code review passed Targeted changed logic inspected
Tests at this head not run No execution tool available
Build at this head not run No execution tool available

Findings

Blocking

None verified in the code inspected.

Non-blocking

None.

Sources

Reviewed the prepared diff and targeted head code for GCN instruction decoding, image dimension selection and coordinate emission, reciprocal square root translation, resource tracking, and shader disk cache serialization.

Not verified

ShaderMemory.cpp is listed as excluded because it is too large for the review folder; I inspected its added diff but not the full file. I did not read the full text of every changed file or run builds and tests at this head. The prepared description's validation reports are author-supplied and refer to earlier heads. No other exclusions were listed in the file listing.

To get this to a good state

Nothing is required. Optional: report focused build and test results for this exact head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5903566044 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9889#pullrequestreview-5903566044). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T09:56:02Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected decoder, image materialization, SPIR-V emission, and cache changes show no verified blocking defect; I could not run checks at this head, so a formal approval is not justified. ## What I ran Reviewed head `5e18a55f603540af2f6aa329369cf2ab1e697286`. I read the prepared description, commit list, manifest and diff, plus targeted repository code through `repo_read.py`. No commands or tests were run. The author reports earlier test runs, but those reports do not establish results for this exact head. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Targeted changed logic inspected | | Tests at this head | not run | No execution tool available | | Build at this head | not run | No execution tool available | ## Findings ### Blocking None verified in the code inspected. ### Non-blocking None. ## Sources Reviewed the prepared diff and targeted head code for GCN instruction decoding, image dimension selection and coordinate emission, reciprocal square root translation, resource tracking, and shader disk cache serialization. ## Not verified `ShaderMemory.cpp` is listed as excluded because it is too large for the review folder; I inspected its added diff but not the full file. I did not read the full text of every changed file or run builds and tests at this head. The prepared description's validation reports are author-supplied and refer to earlier heads. No other exclusions were listed in the file listing. ## To get this to a good state Nothing is required. Optional: report focused build and test results for this exact head.
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!9889
No description provided.