rdna2spirv: zero the tfe/lwe status VGPR on image_load and image_load_mip (SHADER-1266) #98
Closed
leonida/mandy
Mouad-Scriptz-0 wants to merge 0 commits from
fix/shader-1266-tfe-status into main
pull from: fix/shader-1266-tfe-status
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!98
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/shader-1266-tfe-status"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Fixes #31 (SHADER-1266). Claimed in #14.
Problem
With
tfe(orlwe), an MIMG read returns one more dword after its data: the fetch status, atvdata[data_vgprs](RDNA2 ISA, MIMG TFE/LWE).tools/rdna2spirv.pyalready counts that VGPR as a destination (vgpr_dest_registers(ins, extra=int("tfe" in ins["mods"]))), butimage_loadandimage_load_mipemit only theOpImageFetch/OpImageReadof the data, so nothing writes the status VGPR and the shader reads back whatever it held before. The GPU fixturescs_imgload_tfeandcs_imgload_d16_tfe(onmainsince 9c4c5f92a) fail because of this, as #31 reports on an AMD 780M.Fix
This re-lands
old-pr/10022(n-romanovich, from the original repository; their commit is cherry-picked unchanged and keeps its authorship). The patch applied cleanly ontomain9ec34cdff.image_read_typedtakes astatusflag. When it is set, it writes0tovdata[r + data_vgprs]after the data, withdata_vgprs = (popcount(dmask) + 1) // 2underd16andpopcount(dmask)otherwise. The write goes throughself.dst, so inactive lanes keep their value.image_load/image_load_mippath that reachesimage_read_typed: the typed fetch, the coherent (glc) read, the 3D mip load and the 2D mip load.tfe/lwe(a16 mip, d16 3D mip, stores, sample_d on 3D) are unchanged.docs/design.md: the "Typed image loads" row gets the rule and its confirmation (second commit: the Intel GPU result below).tests/semantic/test_image_load_tfe.py: new CPU test (3 tests).Tested
Fedora Linux, Python 3.15.2, LLVM 23.1.5
llvm-mc. The GPU is Intel Meteor Lake graphics (Intel(R) Graphics (MTL), ANV, Mesa 26.2.7), selected withLEONIDA_VK_DEVICE=Intel.main9ec34cdfftests/semantic/test_image_load_tfe.pymain's translator)scripts/run_semantic_tests.py tests/semantictest_exec_computed(#15/#24),test_image_atomics_guard(#20)run_gpu_tests.py --filter imgloadcs_imgload_tfe,cs_imgload_d16_tfeFAILrun_gpu_tests.py(full)In the full GPU run, the only per-test difference between the two is
cs_imgload_tfeandcs_imgload_d16_tfegoing from FAIL to PASS. The one failure left iscs_w32_exec_computed, which is #15 (fixed in #24). Translation was 256/257 with all 256 passingspirv-val, the same on both. The one shader not translated is a computed I/J pair under--bary-fallback, because this GPU has noPerVertexKHR. It has nothing to do with this change.Also run, all OK:
pytest tests/test_image_load_typed.py tests/test_image_load_d16_typed.py(29 passed),python -m compileall -q make_game.py tools tests,tests/test_text_write_line_endings.py,tests/test_docs_links.py, andscripts/check_no_game_data.pyon every changed file.Commands:
@Mby159 offered in #15 to rerun the GPU suite on the 780M from #31. An AMD result would confirm the fix on the hardware the bug was reported on.
No game files and nothing online. AI-assisted (Claude Code).
Tested at head
f19ec5193on two more GPUs (CachyOS, kernel 7.3.3, llvm-mc 23.1.4, SPIRV-Tools v2026.4), reusing a runtime build of main84347bbb6(this PR doesn't touchruntime/):84347bbb6cs_imgload_tfeandcs_imgload_d16_tfeFAIL, native andLEONIDA_W64_EMULATE=1run_gpu_tests.py --filter tfegave 2/2 in all four runs, with implicit layers off and the device picked byVK_LOADER_DRIVERS_SELECT.python -m unittest discover -s tests/semantic -p test_image_load_tfe.pypasses 3/3. On main, these two fixtures were the only failures on either GPU in the full suite (records in #234).No game files. AI-assisted (Claude Code).
Thanks @tahffo68hk-hash, this is convincing, and I'm closing this PR.
My runs only showed that this change makes
cs_imgload_tfe/cs_imgload_d16_tfepass. They never tested whether those fixtures' expectation (status = 0 on a resident read) is what the hardware does. Your native GFX1036 readback says it isn't: 48 kernels, 192 lanes and three seeds, and every resident access kept its seed.LLVM agrees.
SIISelLowering.cppinitializes the TFE/LWE result itself before the instruction. With the default PRTStrictNull it zeroes every result register, and without it, "just the error indication register (VGPRn+1)". A compiler only does that if the hardware doesn't write the status on a successful fetch.So:
main's current translator is the hardware-exact one. It leaves the status VGPR as it was. This PR would make it less exact.cs_image_tfe_dense. If you can't open a PR here, I'm glad to open one with your commits and authorship kept. Just say so.old-pr/10022, the original of this change) has the same problem.Still open, as you note: the status on a real sparse-page NACK.
AI-assisted (Claude Code).
Thanks, @Mouad-Scriptz-0. I’d be glad to take you up on your offer to open the TFE fixture PR. Please preserve the original Git author and author date from both patches (author: tahffo68hk-hash). The original commits are 6dd337e07ff92bd6ddb90c1308820f424e05e8da (independent dense control, readback check and one documentation row) and a7d72f949791ae7218ecfc3f118e7d82c1b5e8c8 (legacy D16/D32 fixtures). The mbox below covers only the synthetic fixtures, checker and documentation. The inline mbox refreshes the design-table context against main ece4ba5b, preserving both original author dates. On RTX 5060 Ti (617.42), two legacy cases failed before the fixture update. After applying both patches, all three targeted TFE cases passed in Wave64 emulation and all three modules passed spirv-val.
The native GFX1036 evidence covers 48 kernels and 192 lane observations. The RTX 5060 Ti negative control shows that forcing zero changes the preserved seeded status without changing the fetched data. This scope is resident image_load TFE, including coordinate OOB. Sparse-page NACK and LWE were unverified.
Separately, if you are also interested in helping with the runner verdict fix (c178a889a), I’d appreciate a pointer or a separate PR. The TFE fixture PR can proceed independently.
AI-assisted.
中文翻译
谢谢你主动提出帮忙开 TFE 测试 PR。请保留两份补丁原始 Git 作者及作者日期,作者为 tahffo68hk-hash。6dd337e07 添加独立 dense 合成对照、读回检查和一行文档,a7d72f949 修正旧 D16/D32 测试。下方 mbox 不含翻译器修改。下方 mbox 已按 main ece4ba5b 调整设计文档表格的上下文并保留两份补丁的原始作者日期。在 RTX 5060 Ti(617.42)的 Wave64 模拟模式下,修改前两个旧用例均失败,修改后三个 TFE 用例均通过,三个模块均通过 spirv-val。
公开的 GFX1036 实验覆盖 48 个 kernel 和 192 个 lane 读回。RTX 5060 Ti 负对照显示强制清零会改变预置状态字,读取的数据保持一致。结论限于常驻资源的 image_load TFE,包括坐标越界。稀疏页 NACK 和 LWE 尚未验证。
另有一项独立的 runner 判定修复 c178a889a。如果你也愿意指点提交途径或代开单独 PR,非常感谢。TFE 测试 PR 可以独立推进。
AI-assisted(AI 辅助)。
Source-only git am mbox for Continued main
@tahffo68hk-hash opened as #1271. Your first commit is applied with
git am, so author and date are yours (2026-11-24 10:21:30 +0800). Two notes:mainat 17:15 UTC and already rewrotecs_imgload_tfe/cs_imgload_d16_tfeto expect the preserved status, with its own seeds. The PR says so.docs/design.md.mainhad since edited the "Typed image stores" row next to yours, so I keptmain's version of that row and added yours unchanged.On Intel Meteor Lake (ANV),
cs_image_tfe_densepasses natively and emulated. With #98's translator it fails with the same 16 of 64 sint words you saw on the 5060 Ti.AI-assisted (Claude Code).