Skip to content

kyty: bindless S#/T# loaded with s_buffer_load at a runtime offset stops resource tracking ("GetSamplerResource dword 0 is not a valid runtime value") #294

Done

Description

@Ryongen

What happens

The recompiler stops on a pixel shader that loads its S# and T# from a descriptor table at a runtime offset: shader resource tracking: hash=0x4937508ca7e6a749 stage=pixel pc=0x00000318 GetSamplerResource dword 0 is not a valid runtime value (ResourceTracking.cpp, GetHandle), and the title exits with 122.

Title, test or build step

Grand Theft Auto V, PPSA38500 01.002.001

AnyPS5 commit

AnyKyty 7de61e3451, with the two fixes it took to get this far on top (pull requests to follow): red-zone framing kept away from fs: accesses (relinker), and a fixed MAP_NO_OVERWRITE reserve inside an existing reservation (libkernel).

System

Windows 10 22H2 (19045), RTX 2070 SUPER, NVIDIA 617.42, WinLibs GCC 15.2.0 + LLVM 21.1.8

Host report

AnyPS5 host report (format 1)
commit: 7de61e3451c5
[system]
os: Windows 10.0.19045
cpu: AMD Ryzen 7 5800X3D 8-Core Processor
cpu_threads: 16
memory_mib: 32669
cpu_gate: passed
[sdl]
linked: 2.33.0
compiled: 2.33.0
[gpu]
device: NVIDIA GeForce RTX 2070 SUPER
type: discrete
vulkan_api: 1.4.351
driver: NVIDIA
driver_version: 617.42.0.0
subgroup_size: 32
device_local_mib: 7989

Steps to reproduce

relinker --windows --registry eboot.elf app.exe (with sce_module/), then APS5_NO_WGI=1 ./app.exe. The title renders for about 30 s (around 30 frames/s, 908 flips), then this shader is compiled and the run stops.

Log

--- Error ---
shader resource tracking: hash=0x4937508ca7e6a749 stage=pixel pc=0x00000318 GetSamplerResource dword 0 is not a valid runtime value in core/kyty/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp:772

The shape of the code before the sample (from KYTY_SHADER_LOG_DIRECTION=File):

0x2d4: S_MUL_I32 vcc_hi, s26, 0x130
0x2e4: S_BUFFER_LOAD_DWORD vcc_lo, s32, vcc_hi ; offset=88
0x2ec: S_BUFFER_LOAD_DWORD vcc_hi, s32, vcc_hi ; offset=0
0x2fc: S_LSHL_B32 vcc_lo, vcc_lo, 4
0x300: S_LSHL_B32 vcc_hi, vcc_hi, 5
0x304: S_BUFFER_LOAD_DWORDX4 s8, s16, vcc_lo  ; S# from table s16..s19 at index*16
0x30c: S_BUFFER_LOAD_DWORDX8 s0, s20, vcc_hi  ; T# from table s20..s23 at index*32
0x318: image_sample_a v4, v4, s0, s8

The sampler and image indices are read from a constant buffer (record s26 * 0x130), scaled to the descriptor size, and used as the s_buffer_load offset into two descriptor tables. Both indices are uniform (SGPR) but not known at translation time, so the descriptor words have no static source for resource tracking to intern. This is bindless indexing of samplers and images, not a lane-dependent descriptor.

What was checked

  • Same stop on every run (four runs), same hash and pc.
  • It is the first shader that does this in the run; about 50 other shaders compiled before it without errors.
  • What I think it needs: descriptor sources that are a load from a descriptor-table buffer at a runtime SGPR offset, resolved at draw time (like the existing GPU-selected buffer path) or through a descriptor-indexed binding, instead of a fixed user-data or immediate-offset source. I have not tried a fix; the recompiler is outside what I know well, so help is welcome.

Activity

  1. Ryongen commented on Nov 25, 2026

    @Ryongen
    ContributorAuthor

    The two fixes mentioned above are now #295 (relinker) and #296 (libkernel).

    KYTY_FALLBACKS=1 does not get past this shader on Windows. The failing translation is a compile-ahead job, and Fallback::Containable() is false on Windows, so it is not guarded and the stop ends the run as before. Forcing Containable() to true (local experiment only) turns it into terminate called after throwing an instance of 'Common::SoftExitError': the throw goes through the guest libc.prx __cxa_throw, whose unwinder does not find the handler in libSceAgcDriver.prx. So skipping the draw is not an option there until exceptions cross the guest libc, and the title needs this shape handled in resource tracking.

  2. simnJS commented on Nov 25, 2026

    @simnJS
    Owner

    @Ryongen thanks for the very complete report and for #295 / #296 (both in review). We're taking this one: the shape you decoded (sampler and image indices read from a constant buffer, scaled to the descriptor size and used as a uniform s_buffer_load offset into two descriptor tables) is a generic bindless pattern, so it belongs in the recompiler, not in a per-title fix. We're building it against a synthetic test with that exact shape, then we'll ask you to try the branch on your setup, since you have the title and the Windows path. Your note on KYTY_FALLBACKS not containing the stop on Windows (the soft exit going through the guest __cxa_throw) is useful too: that's a separate issue, and we'll open it so it doesn't get lost.

  3. self-assigned this
    on Nov 25, 2026
  4. added
    bug
    area: shaders
    hard
    on Nov 25, 2026
  5. simnJS commented on Nov 25, 2026

    @simnJS
    Owner

    @Ryongen a first fix is on AnyKyty: 7bdcb4bad7 lets an adjusted image sample (image_sample_a) take its S# from the descriptor table at a runtime offset, through the existing indirect sampler path. A synthetic shader with your exact shape (two tables, record indices read from a constant buffer, scaled offsets) reproduced the stop and now passes. Your #295 and #296 are in too. Could you try the current AnyKyty on your title and tell us whether it gets past that shader?

  6. Ryongen commented on Nov 25, 2026

    @Ryongen
    ContributorAuthor

    Tested 7bdcb4b on PPSA38500 01.002.001 (Windows, RTX 2070 SUPER, AnyKyty at 441382e). The GetSamplerResource stop in PS 0x4937508ca7e6a749 is gone. The game now runs about 55 s and stops on the next bindless case, a buffer this time:

    shader resource tracking: hash=0x95b4ea51e43c1825 stage=compute pc=0x00005514 buffer descriptor is not a valid runtime value; GPU-selected access requires a scalar, raw 8/16-bit, raw DWORD x1/x2/x3/x4, or 32-bit formatted load, or a raw DWORD store or 32-bit integer atomic from a user-data base in core/kyty/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp:772
    

    It's one of the ray-tracing compute shaders (the log also has [RT] cs 0x95b4ea51e43c1825: 8 of 8 BVH intersections run empty).

  7. Ryongen commented on Nov 25, 2026

    @Ryongen
    ContributorAuthor

    Tested AnyKyty 441382ef20 (with 7bdcb4bad7) on Grand Theft Auto V PPSA38500 01.002.001, Windows 10, RTX 2070 SUPER.

    0x4937508ca7e6a749 now compiles and the title gets further: about 900 flips instead of the old stop at the same point, with a new pipeline manifest of 155 modules and 132 pipelines and no failures. Runs stop in one of two shaders, whichever comes first:

    1. Pixel shader 0x3716055a6324671b, pc 0x580, same message: GetSamplerResource dword 0 is not a valid runtime value. Same tables and the same image_sample_a, but the record index comes out of a waterfall loop instead of a fixed constant-buffer offset:
    0x500: S_FF1_I32_B64 vcc_lo, s0
    0x504: V_READLANE_B32 vcc_hi, v47, vcc_lo
    0x50c: V_CMP_EQ_U32 s94, vcc_hi, v47
    0x514: S_AND_SAVEEXEC_B64 s96, s94
    ...
    0x54c: S_LSHL4_ADD_U32 vcc_lo, vcc_hi, s98
    0x550: S_BUFFER_LOAD_DWORD vcc_hi, s44, vcc_lo ; offset=2192
    0x558: S_BUFFER_LOAD_DWORD s12, s44, vcc_lo   ; offset=2064
    0x564: S_LSHL_B32 vcc_lo, vcc_hi, 4
    0x568: S_LSHL_B32 vcc_hi, s12, 5
    0x56c: S_BUFFER_LOAD_DWORDX4 s20, s56, vcc_lo  ; S# from table s56
    0x574: S_BUFFER_LOAD_DWORDX8 s12, s52, vcc_hi  ; T# from table s52
    0x580: image_sample_a v5, v13, s12, s20
    

    The record is v_readlane(v47) * 16 + s98 into the constant buffer s44, so the index is uniform inside each loop iteration but read from a lane. The sample at 0x540 in the same shader, whose S# is at the fixed offset 1312 of s56, is accepted.

    1. Compute shader 0x95b4ea51e43c1825, pc 0x5514, as in the earlier comment above (the ray-tracing one).

    Before the stop, these fallbacks show up (KYTY_FALLBACKS at its Windows default):

    [HACK] bindless table texture bound as null image: first at RenderExecutor::ResolveTexture (conversion declined), shader=unknown, where=0x0
    [HACK]   ... +624 (total 625) in 10 s
    [HACK] draw or dispatch with unresolvable resources skipped: first at PipelineCache::GetProgram, shader=0x1b40c4c36dea3c5d, where=0x0
    

    The frame rate also drops as these start: 26, 30 and 19 frames/s in the first three 10 s windows, then 139 frames in the 19.5 s before the stop. The picture is still at a quarter size in the top-left (#298).

  8. simnJS commented on Nov 25, 2026

    @simnJS
    Owner

    @Ryongen great, thanks for testing so fast. Both new stops are on us: the waterfall-selected record index (S_FF1 + V_READLANE loop) for the sampler, and the GPU-selected buffer descriptor in the compute shader at 0x5514. We're on it now and will post a branch here. If you can, the instructions around 0x5514 in that compute shader (how its V# is loaded and the access that uses it) would save us a guess.

  9. simnJS commented on Nov 25, 2026

    @simnJS
    Owner

    @Ryongen both cases are on AnyKyty now (8bf7cc52cf):

    • Waterfall-selected sampler (pixel shader at 0x580): 1ee757719f keeps the texture/sampler selection inside the waterfall loop, so each iteration samples with its own record. A synthetic shader whose even and odd lanes select different pairs reproduced your stop and now passes.
    • Compute shader at 0x5514: the same commit handles typed buffer loads (tbuffer_load_format_*) through a GPU-selected V#, which produced exactly that diagnostic in a synthetic shader. We can't be sure it's your instruction, so if it still stops there, the disassembly around 0x5514 would settle it: the instruction at that PC with its operands and format flags, the instructions that last wrote its four V# registers, and how the table offset is computed. A future stop of this kind also prints the IR opcode, width and format flags now.

    Could you retry the same scene on the current AnyKyty?

  10. Ryongen commented on Nov 25, 2026

    @Ryongen
    ContributorAuthor

    With #299 (Windows KYTY_FALLBACKS fix for #297) and KYTY_FALLBACKS=1, one run of PPSA38500 01.002.001 gets past these stops and lists every shader it reaches that fails, instead of ending at the first one. 441382ef20 plus the #299 change, Windows 10, RTX 2070 SUPER, about 2 minutes. 27 compute shaders fail; 14 of them were also needed at draw time, so those dispatches were skipped.

    26 stop in resource tracking with the same message as 0x95b4ea51e43c1825 (buffer descriptor is not a valid runtime value; GPU-selected access requires ... from a user-data base):

    0x0e56209edb00fb24 pc 0x1d4c
    0x2b55ba9a46aad409 pc 0x1ab8
    0x4e3da9ce61945840 pc 0x1e80
    0x54640c2c6a5a0c24 pc 0xdae8
    0x5551fc7359ce75e0 pc 0x77c
    0x647a53b0b183c5bc pc 0x1dc0
    0x65d95f5537ed2638 pc 0x1e80
    0x6afb4e2185c26272 pc 0x1acc
    0x6b1826ae54930a8b pc 0x54f4
    0x7085d671edcc68b5 pc 0x1acc
    0x849630c3bb480c32 pc 0x261c
    0x8a7dc87621fbf4be pc 0x1070
    0x8ddf93a8b283d4bb pc 0x1a98
    0x92f0a597f683405f pc 0x1ed0
    0x95b4ea51e43c1825 pc 0x5514
    0x9d22ec1f658c72a8 pc 0xcc0
    0xa329f206873d2f47 pc 0x1af8
    0xb0db632f7798dde0 pc 0x1ed8
    0xb9339e89688651c8 pc 0x19cc
    0xc599650c9c488d66 pc 0x1a48
    0xd263615ce477fc61 pc 0x13a0
    0xd2e1b0eb727015ce pc 0x1ab8
    0xdfe06a7ece31f9b9 pc 0x1e80
    0xe031a96c0f46c064 pc 0x11930
    0xf73e2bd639f04eec pc 0x1e9c
    0xf9b066286c6371dc pc 0xfc48
    

    Several share a pc (0x1e80 three times, 0x1ab8 and 0x1acc twice each), so they look like variants of a few programs.

    One stops earlier, in the CFG build: 0x10b76d3854f99f9e at pc 0x2324, unsupported family=VOPC opcode=0xec raw=[0x7dd900f9 0x8606000f] reason=VOPC SDWA modifier is not supported for opcode.

    The pixel shader 0x3716055a6324671b (the waterfall-indexed S#) was not reached in this run.

    After about 2 minutes the title ends itself on purpose in a worker thread (mov dword ptr [0], 0x21 at app.exe+0x8be3a40), probably because of the skipped dispatches.

  11. simnJS commented on Nov 25, 2026

    @simnJS
    Owner

    @Ryongen that list is gold, thank you, and thanks for #299 (reviewing it now). Your run was on 441382ef20 + #299, so it doesn't have 1ee757719f yet (typed loads through a GPU-selected V#, now on AnyKyty 8bf7cc52cf): on our side several of those 26 compute shaders already translate with it. Could you redo the same run on the current AnyKyty + #299? Whatever still fails there is what's left. The VOPC SDWA opcode 0xec in 0x10b76d3854f99f9e is on our list too. Good catch on the deliberate stop after ~2 min: skipped dispatches clearly aren't an option for this title.

  12. Ryongen commented on Nov 25, 2026

    @Ryongen
    ContributorAuthor

    Redid it on 8bf7cc52cf + #299 (ce1c67df6a), same KYTY_FALLBACKS=1 run, three times (the last two with the Vulkan pipeline cache already warm).

    Of the 27 compute shaders from the last list, 26 now translate. The only one still failing is the VOPC SDWA one:

    0x10b76d3854f99f9e pc 0x2324: unsupported family=VOPC opcode=0xec raw=[0x7dd900f9 0x8606000f] reason=VOPC SDWA modifier is not supported for opcode
    

    No "buffer descriptor is not a valid runtime value" stops at all.

    The title still ends itself at the same place (mov dword ptr [0], 0x21 at app.exe+0x8be3a40), about 3 minutes in. But in every run it comes right after a long wait on one ray-tracing compute dispatch:

    Pipeline stall: 1 pipelines left at 23 s
    [kyty-gpl] stall 26.163 s compute-sync 0x9d22ec1f658c72a8  why=writes-buffers
    [RT] cs 0x9d22ec1f658c72a8: 6 of 14 BVH intersections run empty: no form and no host query serves them, their rays miss
    

    (28.0 s in the first run.) It happens with the pipeline cache warm too, so it's the GPU work, not a compile. So I think the stop is the title's own hang watchdog firing after that wait, not a reaction to skipped dispatches. 0x95b4ea51e43c1825 also stalls 3.4 s just before the crash.

  13. simnJS commented on Nov 25, 2026

    @simnJS
    Owner

    @Ryongen thanks, that pins it down. Same picture on our side: 0x9d22ec1f658c72a8 keeps the GPU busy for ~26 s in its emulated BVH walk, the title's own hang watchdog then fires, and with the watchdog out of the way the main thread just waits on it. We're now on making that walk fast (getting its BVH served by native ray queries, and the 6 intersections that run empty). The VOPC SDWA opcode 0xec is next on the decoder side. FYI, on our NVIDIA 595 Linux driver that shader also crashed the driver's compiler; the fix for that is in CI (fix(kyty): read the first lane with a subgroup reduction instead of a shuffle).

  14. Ryongen commented on Nov 25, 2026

    @Ryongen
    ContributorAuthor

    An offline pass over the title's shaders.rpf (15,394 programs, each one run through PrepareShaderSource and TranslateProgram with its own compute registers, on AnyKyty ce1c67df6a) finds the same VOPC SDWA stop in two more shaders, all three from the same material:

    0x10b76d3854f99f9e pc 0x2324 raw=[0x7dd900f9 0x8606000f]  billboard_nobump:CS_RaytracingResolve_46ecf048
    0x871adfbb8b851fce pc 0x1374 raw=[0x7dd900f9 0x86050000]  billboard_nobump:CS_RaytracingResolve_4a8b422d
    0x7fed7e75c3b24fea pc 0x13a0 raw=[0x7dd900f9 0x86060002]  billboard_nobump:CS_RaytracingResolve_4c97744a
    

    It also finds 15 ray-tracing shaders that make resource tracking recurse forever, filed as #300.

    Every shader from the earlier lists, including 0x9d22ec1f658c72a8 behind the 26 s stall, is on the title's ray-tracing path (the program names in the archive are CS_RaytracingResolve_* per material, CS_RaytraceVBuffer_RayBinning_*, the light-probe gathers and CS_DummyResolve). I'll try a run in the title's graphics mode without ray tracing next and report what it reaches.

    Offline results for resource tracking itself are not reliable (they need the descriptor tables the SRT walker reads at run time), so only the decoder and CFG stops above and the recursion are reported from it.

  15. simnJS commented on Nov 26, 2026

    @simnJS
    Owner

    @Ryongen V_CMP_NLE_F16 (the VOPC SDWA opcode 0xec in the three billboard_nobump resolve shaders) is decoded on AnyKyty now (4401877673), and #300 is fixed too (180b1a9cbe). Next on our side: the title's own BVH build pass that Kyty skipped as "unresolvable resources", which leaves the following refit running on unwritten data.

  16. simnJS commented on Nov 26, 2026

    @simnJS
    Owner

    Closing this one: the stop it reports is fixed on AnyKyty, and you confirmed it on your setup, @Ryongen.

    What is left on that title is no longer resource tracking: a ray-tracing compute dispatch that keeps the GPU busy for about 26 s, after which the title's own watchdog fires. We are working on that one. If a new stop shows up on the current AnyKyty, a new issue with this level of detail is the fastest way to get it fixed. Thanks again for #295, #296 and #299.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: shadersbughard

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions