shader: reading a scalar aperture source as a value refuses (Ghost of Yōtei PPSA26344, shader 0x8000356b00) #3803

Closed
opened 2026-10-11 16:51:27 +00:00 by Dextroid17 · 3 comments
Dextroid17 commented 2026-10-11 16:51:27 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-11T16:51:27Z.


Reading a scalar aperture source as a value refuses, and one shader of Ghost of Yōtei reads one

The four scalar aperture sources — src_shared_base (235), src_shared_limit (236), src_private_base (237), src_private_limit (238) — decode to their own operand kinds since #1940, but their value was left unmodelled: both the scalar-code read and the raw-operand read refuse with the source named, and TechnicalDebt.md records that as deliberate, because the wave's aperture bases and limits were unknown.

What that costs on a title. Ghost of Yōtei (PPSA26344) reads one. On a tree carrying the merged #3300 dispatch split, one shader is refused at registration, in two separate runs:

[Shaders/ShaderRegistry.cpp:600] Shader 0x8000356b00 could not be prepared after registration:
  ShaderRecompiler::Recompile: TranslationContext::readRawU32:
  the scalar aperture source src_shared_base is not modelled

To be exact about the evidence: that message appears once in each run that shows it, for that one shader. It is not a fleet of shaders — the counts that look larger in these logs belong to a different, by-design case (s_swappc_b64 call deferrals, 104 per run, which are expected and not related).

In a run of a build that rebuilt OperandAccess.cpp for this change (yotei-spike-aperture.log, from build-spike-aperture), no aperture refusal appears anywhere in the log and the title reaches a different wall (image descriptor is incompatible with the static runtime image interface, which is a separate matter). That is what that one run shows; it does not by itself prove the change is why it got there, since the runs end at different points. The later run that ends at the min/max wall is a different build — it rebuilt the image emitter and the materializer, not OperandAccess.cpp — so it is not evidence about this change either way.

The model, stated as a choice rather than a measurement. Both bases read as 0; the shared limit reads as the shader's LDS byte size and the private limit as its scratch size in bytes — the two sizes the IR already carries (ShaderInfo::sharedMemoryBytes, ShaderInfo::scratchDwords). The console's own aperture values are not measured, so a title that depends on a non-zero base, or on a limit other than the sizes this emulator allocates, would read a value the console does not have. The TechnicalDebt.md entry is rewritten to say exactly that rather than removed.

Test. core/libs/tests/ApertureSources.cpp asserted the refusal (CheckReadRefuses → ExpectRefusal); it now asserts the read is accepted, per source. Rebuilt and run: aperture sources tests passed, exit 0. That is all it asserts — it does not check the value emitted. It can: IrProgram::Blocks() → IrBlock::Instructions() gives the translated instructions and IrValue::HasImmediate() / ImmediateU32() the constant, so with program.Info().sharedMemoryBytes and scratchDwords set by the test the four values could be asserted directly. Worth doing when this becomes a patch rather than an issue.

Shape of the change — three files, five hunks:

core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp
  readRawU32      the four SrcShared*/SrcPrivate* kinds return their values
  readScalarCode  codes 235-238 route through the same values, via the decoded kind
core/libs/tests/ApertureSources.cpp
  CheckReadRefuses → CheckReadValues
docs/dev/TechnicalDebt.md
  the aperture entry now states the model and the unmeasured console values

On current main the same code sits 21 lines later (SrcSharedBase at 482, against 461 on this branch), so the hunks apply with a shift. Happy to send it as a PR based on main — the only reason this is an issue rather than a PR is that I have not run a main build, and this tree's commits are local work-in-progress ones that the repository's commit-subject check rejects.

Environment: lavapipe (Mesa 26.2.4 / LLVM 23.1.1), CachyOS, on a frontier tree carrying the merged #3300.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5803127095 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3803). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-11T16:51:27Z. --- **Reading a scalar aperture source as a value refuses, and one shader of Ghost of Yōtei reads one** The four scalar aperture sources — `src_shared_base` (235), `src_shared_limit` (236), `src_private_base` (237), `src_private_limit` (238) — decode to their own operand kinds since #1940, but their *value* was left unmodelled: both the scalar-code read and the raw-operand read refuse with the source named, and `TechnicalDebt.md` records that as deliberate, because the wave's aperture bases and limits were unknown. **What that costs on a title.** Ghost of Yōtei (PPSA26344) reads one. On a tree carrying the merged `#3300` dispatch split, one shader is refused at registration, in two separate runs: ``` [Shaders/ShaderRegistry.cpp:600] Shader 0x8000356b00 could not be prepared after registration: ShaderRecompiler::Recompile: TranslationContext::readRawU32: the scalar aperture source src_shared_base is not modelled ``` To be exact about the evidence: that message appears **once** in each run that shows it, for that one shader. It is not a fleet of shaders — the counts that look larger in these logs belong to a different, by-design case (`s_swappc_b64` call deferrals, 104 per run, which are expected and not related). In a run of a build that rebuilt `OperandAccess.cpp` for this change (`yotei-spike-aperture.log`, from `build-spike-aperture`), no aperture refusal appears anywhere in the log and the title reaches a different wall (`image descriptor is incompatible with the static runtime image interface`, which is a separate matter). That is what that one run shows; it does not by itself prove the change is why it got there, since the runs end at different points. The later run that ends at the min/max wall is a different build — it rebuilt the image emitter and the materializer, not `OperandAccess.cpp` — so it is not evidence about this change either way. **The model, stated as a choice rather than a measurement.** Both bases read as 0; the shared limit reads as the shader's LDS byte size and the private limit as its scratch size in bytes — the two sizes the IR already carries (`ShaderInfo::sharedMemoryBytes`, `ShaderInfo::scratchDwords`). The console's own aperture values are **not** measured, so a title that depends on a non-zero base, or on a limit other than the sizes this emulator allocates, would read a value the console does not have. The `TechnicalDebt.md` entry is rewritten to say exactly that rather than removed. **Test.** `core/libs/tests/ApertureSources.cpp` asserted the refusal (`CheckReadRefuses` → `ExpectRefusal`); it now asserts the read is accepted, per source. Rebuilt and run: `aperture sources tests passed`, exit 0. That is all it asserts — it does **not** check the value emitted. It can: `IrProgram::Blocks()` → `IrBlock::Instructions()` gives the translated instructions and `IrValue::HasImmediate()` / `ImmediateU32()` the constant, so with `program.Info().sharedMemoryBytes` and `scratchDwords` set by the test the four values could be asserted directly. Worth doing when this becomes a patch rather than an issue. **Shape of the change** — three files, five hunks: ``` core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp readRawU32 the four SrcShared*/SrcPrivate* kinds return their values readScalarCode codes 235-238 route through the same values, via the decoded kind core/libs/tests/ApertureSources.cpp CheckReadRefuses → CheckReadValues docs/dev/TechnicalDebt.md the aperture entry now states the model and the unmeasured console values ``` On current `main` the same code sits 21 lines later (`SrcSharedBase` at 482, against 461 on this branch), so the hunks apply with a shift. Happy to send it as a PR based on `main` — the only reason this is an issue rather than a PR is that I have not run a `main` build, and this tree's commits are local work-in-progress ones that the repository's commit-subject check rejects. **Environment:** lavapipe (Mesa 26.2.4 / LLVM 23.1.1), CachyOS, on a frontier tree carrying the merged `#3300`. Written with AI assistance.
MarcZX10 commented 2026-10-11 17:17:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T17:17:14Z.


I checked primary sources before carrying this into code. The AMD RDNA 2 ISA reference describes SHARED_BASE/LIMIT and PRIVATE_BASE/LIMIT as memory-aperture operands and says their values depend on 32-bit versus 64-bit system addressing. The LLVM AMDGPU backend guide says that for GFX9–GFX11 these sources provide aperture bases for flat/segment address conversion; in 64-bit mode the apertures are 2^32 bytes and their bases are 2^32-aligned.

That does not establish the PS5's exact returned values, but it does not support treating SHARED_LIMIT as the shader's LDS byte size or PRIVATE_LIMIT as its scratch allocation size. The recompiler currently models those memories as workgroup/function-local SPIR-V storage, so returning those guessed values could change shader calculations that use the aperture address.

Could you provide the PS5 address mode and oracle values for these four operands, ideally for dispatches with different LDS and scratch allocations? Then the regression can assert the emitted values as well as that the reads are accepted. Until then, keeping these operands unsupported matches the evidence currently available.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111606066 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3803#issuecomment-6111606066). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T17:17:14Z. --- I checked primary sources before carrying this into code. The [AMD RDNA 2 ISA reference](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) describes `SHARED_BASE/LIMIT` and `PRIVATE_BASE/LIMIT` as memory-aperture operands and says their values depend on 32-bit versus 64-bit system addressing. The [LLVM AMDGPU backend guide](https://rocm.docs.amd.com/projects/llvm-project/en/latest/LLVM/llvm/html/AMDGPUUsage.html#memory-spaces) says that for GFX9–GFX11 these sources provide aperture bases for flat/segment address conversion; in 64-bit mode the apertures are 2^32 bytes and their bases are 2^32-aligned. That does not establish the PS5's exact returned values, but it does not support treating `SHARED_LIMIT` as the shader's LDS byte size or `PRIVATE_LIMIT` as its scratch allocation size. The recompiler currently models those memories as workgroup/function-local SPIR-V storage, so returning those guessed values could change shader calculations that use the aperture address. Could you provide the PS5 address mode and oracle values for these four operands, ideally for dispatches with different LDS and scratch allocations? Then the regression can assert the emitted values as well as that the reads are accepted. Until then, keeping these operands unsupported matches the evidence currently available.
cookie42073-cmd commented 2026-10-12 23:52:46 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by cookie42073-cmd on 2026-10-12T23:52:46Z.


Hi, this is Blazing Cook. Following up on Marc's measurement request: #4706 now reports Ratchet & Clank (PPSA01474) reaching src_private_base after its call-linking change, so these values matter for that next stop too.

I checked the earlier evidence with a second review. Adrià's gfx1035 measurements in #1190 establish the Linux GPU result. The PS5 shared/private high-dword patterns used there, 0x80000000 / 0x70000000, were inferred from game shader addresses. I haven't found a published native PS5 readout of all four operands.

Could someone with a native PS5 shader test harness share a small reproducible capture? If this has already been measured, a link to that capture would help.

For each source below, please record a separate s_mov_b32 result and both destination words from s_mov_b64, explicitly labelled low/high:

Source code Operand
235 / 0xeb src_shared_base
236 / 0xec src_shared_limit
237 / 0xed src_private_base
238 / 0xee src_private_limit

That's 12 raw 32-bit words per run. The width matters: LLVM reads the 64-bit base and extracts its upper half; a 32-bit base read returns zero in that supported environment. That doesn't tell us the PS5 result.

Please include:

  • The probe source/revision, build commands, exact instruction words or disassembly, and the output-buffer layout/readback after GPU completion.
  • Console model/firmware, toolchain/runtime, shader stage, dispatch/workgroup dimensions, and wave32/wave64 setting.
  • The GPU PTR32 / aperture addressing mode and how it was established, if available. Otherwise mark it unknown. CPU executable bitness alone doesn't establish this; RDNA 2 §9.3 describes a per-wave mode. The SH_MEM_BASES state associated with that dispatch is useful too, if the harness can capture it.
  • A repeated baseline, then a change to LDS allocation alone and scratch allocation alone. Record the actual allocated sizes and units (LDS per workgroup, scratch per thread/wave as reported), checking they weren't optimized away. Zero/nonzero allocations and both wave sizes are useful where supported; a baseline capture is still welcome.

A standalone probe is enough; no game dump is needed. Existing title logs identify the unsupported read, but don't supply its console value. These measurements would let us check the emitted values and their consistency with FLAT routing; a later title run would still be needed to establish progress in Ratchet.

AI-assisted with Codex; sources and request independently cross-checked.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6134857108 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3803#issuecomment-6134857108). Originally posted by [cookie42073-cmd](https://github.com/cookie42073-cmd) on 2026-10-12T23:52:46Z. --- Hi, this is Blazing Cook. Following up on Marc's measurement request: #4706 now reports Ratchet & Clank (PPSA01474) reaching `src_private_base` after its call-linking change, so these values matter for that next stop too. I checked the earlier evidence with a second review. [Adrià's gfx1035 measurements in #1190](https://github.com/boykopovar/AnyPS5/pull/1190#pullrequestreview-5478410236) establish the Linux GPU result. The PS5 shared/private high-dword patterns used there, `0x80000000` / `0x70000000`, were [inferred from game shader addresses](https://github.com/boykopovar/AnyPS5/pull/1190#issuecomment-6096349491). I haven't found a published native PS5 readout of all four operands. Could someone with a native PS5 shader test harness share a small reproducible capture? If this has already been measured, a link to that capture would help. For each source below, please record a separate `s_mov_b32` result and both destination words from `s_mov_b64`, explicitly labelled low/high: | Source code | Operand | | --- | --- | | 235 / 0xeb | `src_shared_base` | | 236 / 0xec | `src_shared_limit` | | 237 / 0xed | `src_private_base` | | 238 / 0xee | `src_private_limit` | That's 12 raw 32-bit words per run. The width matters: [LLVM reads the 64-bit base and extracts its upper half](https://llvm.org/docs/doxygen/AMDGPULegalizerInfo_8cpp_source.html#l02477); a 32-bit base read returns zero in that supported environment. That doesn't tell us the PS5 result. Please include: - The probe source/revision, build commands, exact instruction words or disassembly, and the output-buffer layout/readback after GPU completion. - Console model/firmware, toolchain/runtime, shader stage, dispatch/workgroup dimensions, and wave32/wave64 setting. - The GPU `PTR32` / aperture addressing mode and how it was established, if available. Otherwise mark it unknown. CPU executable bitness alone doesn't establish this; [RDNA 2 §9.3](https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf) describes a per-wave mode. The `SH_MEM_BASES` state associated with that dispatch is useful too, if the harness can capture it. - A repeated baseline, then a change to LDS allocation alone and scratch allocation alone. Record the actual allocated sizes and units (LDS per workgroup, scratch per thread/wave as reported), checking they weren't optimized away. Zero/nonzero allocations and both wave sizes are useful where supported; a baseline capture is still welcome. A standalone probe is enough; no game dump is needed. Existing title logs identify the unsupported read, but don't supply its console value. These measurements would let us check the emitted values and their consistency with FLAT routing; a later title run would still be needed to establish progress in Ratchet. AI-assisted with Codex; sources and request independently cross-checked.
Tamalero commented 2026-10-13 00:13:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-13T00:13:14Z.


A second Linux data point, not the PS5 measurement requested above. On gfx1030 (Radeon PRO V620) all four operands read exactly the gfx1035 values @adriadam10 measured in #1190. Both widths are below, in the 12-word layout @cookie42073-cmd asked for.

Source s_mov_b32 s_mov_b64 low s_mov_b64 high
235 src_shared_base 0x00000000 0x00000000 0x00010000
236 src_shared_limit 0xffffffff 0xffffffff 0x00010000
237 src_private_base 0x00000000 0x00000000 0x00020000
238 src_private_limit 0xffffffff 0xffffffff 0x00020000

Two cards gave identical results. A 32-bit read returns the same value as the low word of the 64-bit read. On Linux those low words are 0 for the bases and 0xffffffff for the limits, so this can't tell "a 32-bit read returns the low word" apart from "a 32-bit read returns a fixed value". A PS5 run would separate them only if its low words differ.

A note for whoever stubs these before a PS5 readout exists. Main's FLAT routing from #1190 (SplitAperture) treats a high word of 0x80000000 as the shared aperture and 0x70000000 as the private one, and those are the PS5's inferred bases. A stub returning the Linux values above would make a title build flat pointers with high words 0x00010000 or 0x00020000, and SplitAperture would send those to global memory. Values that agree with the existing routing would be:

  • shared: 0x80000000_00000000 / 0x80000000_ffffffff
  • private: 0x70000000_00000000 / 0x70000000_ffffffff

These are still inferred, not measured.

For Ratchet & Clank (see #4706), I stubbed the Linux values locally. The title gets past the read, but it stops later at an unrelated table shape, so that run says nothing about whether the values are right.

Probe, build and disassembly

ROCm 6.3.3 HIP on Linux (KFD, HSA 64-bit addressing), compute queue, --offload-arch=gfx1030 (wave32). One workgroup of 64 lanes; lane 0 of workgroup 0 writes the results; read back after hipMemcpy.

__global__ void k(unsigned long long* o, unsigned* w) {
    unsigned long long a, b, c, d; unsigned e, f, g, h;
    asm volatile("s_mov_b64 %0, src_shared_base" : "=s"(a));
    asm volatile("s_mov_b64 %0, src_shared_limit" : "=s"(b));
    asm volatile("s_mov_b64 %0, src_private_base" : "=s"(c));
    asm volatile("s_mov_b64 %0, src_private_limit" : "=s"(d));
    asm volatile("s_mov_b32 %0, src_shared_base" : "=s"(e));
    asm volatile("s_mov_b32 %0, src_shared_limit" : "=s"(f));
    asm volatile("s_mov_b32 %0, src_private_base" : "=s"(g));
    asm volatile("s_mov_b32 %0, src_private_limit" : "=s"(h));
    if (threadIdx.x == 0 && blockIdx.x == 0) { o[0]=a; o[1]=b; o[2]=c; o[3]=d; w[0]=e; w[1]=f; w[2]=g; w[3]=h; }
}

llvm-objdump --mcpu=gfx1030 of the device code:

s_mov_b64 s[6:7], src_shared_base     // BE8604EB
s_mov_b64 s[8:9], src_shared_limit    // BE8804EC
s_mov_b64 s[0:1], src_private_base    // BE8004ED
s_mov_b64 s[2:3], src_private_limit   // BE8204EE
s_mov_b32 s12, src_shared_base        // BE8C03EB
s_mov_b32 s13, src_shared_limit       // BE8D03EC
s_mov_b32 s11, src_private_base       // BE8B03ED
s_mov_b32 s10, src_private_limit      // BE8A03EE

Tested and written by Claude (AI assistant) on a contributor's machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135097663 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3803#issuecomment-6135097663). Originally posted by [Tamalero](https://github.com/Tamalero) on 2026-10-13T00:13:14Z. --- A second Linux data point, not the PS5 measurement requested above. On gfx1030 (Radeon PRO V620) all four operands read exactly the gfx1035 values @adriadam10 measured in #1190. Both widths are below, in the 12-word layout @cookie42073-cmd asked for. | Source | `s_mov_b32` | `s_mov_b64` low | `s_mov_b64` high | |---|---|---|---| | 235 `src_shared_base` | `0x00000000` | `0x00000000` | `0x00010000` | | 236 `src_shared_limit` | `0xffffffff` | `0xffffffff` | `0x00010000` | | 237 `src_private_base` | `0x00000000` | `0x00000000` | `0x00020000` | | 238 `src_private_limit` | `0xffffffff` | `0xffffffff` | `0x00020000` | Two cards gave identical results. A 32-bit read returns the same value as the low word of the 64-bit read. On Linux those low words are 0 for the bases and `0xffffffff` for the limits, so this can't tell "a 32-bit read returns the low word" apart from "a 32-bit read returns a fixed value". A PS5 run would separate them only if its low words differ. **A note for whoever stubs these before a PS5 readout exists.** Main's FLAT routing from #1190 (`SplitAperture`) treats a high word of `0x80000000` as the shared aperture and `0x70000000` as the private one, and those are the PS5's inferred bases. A stub returning the Linux values above would make a title build flat pointers with high words `0x00010000` or `0x00020000`, and `SplitAperture` would send those to global memory. Values that agree with the existing routing would be: - shared: `0x80000000_00000000` / `0x80000000_ffffffff` - private: `0x70000000_00000000` / `0x70000000_ffffffff` These are still inferred, not measured. For Ratchet & Clank (see #4706), I stubbed the Linux values locally. The title gets past the read, but it stops later at an unrelated table shape, so that run says nothing about whether the values are right. <details><summary>Probe, build and disassembly</summary> ROCm 6.3.3 HIP on Linux (KFD, HSA 64-bit addressing), compute queue, `--offload-arch=gfx1030` (wave32). One workgroup of 64 lanes; lane 0 of workgroup 0 writes the results; read back after `hipMemcpy`. ```cpp __global__ void k(unsigned long long* o, unsigned* w) { unsigned long long a, b, c, d; unsigned e, f, g, h; asm volatile("s_mov_b64 %0, src_shared_base" : "=s"(a)); asm volatile("s_mov_b64 %0, src_shared_limit" : "=s"(b)); asm volatile("s_mov_b64 %0, src_private_base" : "=s"(c)); asm volatile("s_mov_b64 %0, src_private_limit" : "=s"(d)); asm volatile("s_mov_b32 %0, src_shared_base" : "=s"(e)); asm volatile("s_mov_b32 %0, src_shared_limit" : "=s"(f)); asm volatile("s_mov_b32 %0, src_private_base" : "=s"(g)); asm volatile("s_mov_b32 %0, src_private_limit" : "=s"(h)); if (threadIdx.x == 0 && blockIdx.x == 0) { o[0]=a; o[1]=b; o[2]=c; o[3]=d; w[0]=e; w[1]=f; w[2]=g; w[3]=h; } } ``` `llvm-objdump --mcpu=gfx1030` of the device code: ``` s_mov_b64 s[6:7], src_shared_base // BE8604EB s_mov_b64 s[8:9], src_shared_limit // BE8804EC s_mov_b64 s[0:1], src_private_base // BE8004ED s_mov_b64 s[2:3], src_private_limit // BE8204EE s_mov_b32 s12, src_shared_base // BE8C03EB s_mov_b32 s13, src_shared_limit // BE8D03EC s_mov_b32 s11, src_private_base // BE8B03ED s_mov_b32 s10, src_private_limit // BE8A03EE ``` </details> *Tested and written by Claude (AI assistant) on a contributor's machine.*
Sign in to join this conversation.
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#3803
No description provided.