Repository navigation
rdna2spirv: zero the tfe/lwe status VGPR on image_load and image_load_mip (SHADER-1266) - #98
Mouad-Scriptz-0 wants to merge 2 commits into
Conversation
|
Tested at head
No game files. AI-assisted (Claude Code). |
tahffo68hk-hash
left a comment
There was a problem hiding this comment.
I reproduced a resident image_load ... tfe regression at f19ec5193 using the independent dense fixture from Reforge #9. The pass results above for the two inherited fixtures reproduce here; those fixtures expect the seeded status to be cleared.
Native RDNA2. On Windows 11 build 26200, AMD GFX1036, HIP runtime 60450101, LLVM 23.1.6, I checked the assembled code object and HIP readback path. For a resident R32_UINT texel at (62,0), the kernel seeds v13 = 0x000003e8, executes image_load v[12:13], v[2:3], s[8:15] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm tfe, waits for VM, then stores those VGPRs for device-to-host readback. Expected and observed (v12 data, v13 status) were (0x7eb9e229, 0x000003e8). This is one of 48 native kernels / 192 lane readbacks.
Translated Vulkan. On the same Windows build, RTX 5060 Ti / 617.42, LLVM 23.1.6, SPIRV-Tools 2026.4, Wave64 emulation enabled, I ran cs_image_tfe_dense on PR base 9ec34cdff, then applied the exact PR diff and verified its three changed blobs against f19ec5193. The fixture and Vulkan harness were identical between runs.
| R32_UINT, in bounds at (0,0) | Expected data / status | Readback |
|---|---|---|
| PR base | 0x00000064 / 0x5a5a03f5 |
0x00000064 / 0x5a5a03f5 |
| PR HEAD | same | 0x00000064 / 0x00000000 |
| Base + explicit zero of the fixture's status VGPRs after the loads | same | 0x00000064 / 0x00000000 |
HEAD and the explicit-zero control both failed the same 16 of 64 SINT word comparisons. D16 showed the same status regression, while its data word remained 0x5a5a0064. All translated modules in these targeted runs passed spirv-val.
Please resolve this resident TFE behavior before merging the lowering. The probe covers these plain dense image_load ... tfe forms. Sparse page NACK, LWE and other instruction variants were outside the measurement.
AI-assisted.
中文翻译
在 Windows 11 build 26200、AMD GFX1036、HIP 60450101 和 LLVM 23.1.6 上,检查了原生 code object 的指令及 HIP 读回路径。常驻 R32_UINT 的 (62,0) 用例先将 v13 置为 0x3e8,执行 image_load v[12:13] ... tfe,等待后直接写回两个 VGPR,读到 v12=0x7eb9e229、v13=0x000003e8。另有同组 48 个原生 kernel、192 个 lane 的证据,见上方 Reforge #9。
在同一 Windows 版本、RTX 5060 Ti / 617.42、LLVM 23.1.6、SPIRV-Tools 2026.4、Wave64 模拟开启下,独立对照在 PR 基线 9ec34cdff 通过。应用 #98 的 exact diff 并验证三个文件与 f19ec5193 一致后,正常坐标的读回为数据 0x64、状态 0,预期状态为 0x5a5a03f5。在基线上显式清零两个状态寄存器的负对照,和 PR HEAD 一样有 16 个 SINT 字失败。D16 数据字仍匹配,状态同样被清零。旧两项测试通过的现象也已复现。
建议在合入翻译规则前先解决常驻 TFE 的语义分歧。本次没有验证稀疏页 NACK、LWE 或其他指令变体。
AI-assisted(AI 辅助)。
…6, RADV) on Linux (GPU-4070TI, GPU-610M) run_gpu_tests.py on main 84347bb, native and LEONIDA_W64_EMULATE=1, CachyOS. RTX 4070 Ti: 197/248 native (wave64 fixtures skipped), 229/248 emulated. Radeon 610M (RDNA2 iGPU): 230/248 native and emulated. The only failures on both are cs_imgload_tfe and cs_imgload_d16_tfe (#31); #98 makes both pass on both GPUs. AI-assisted. No game files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…6.2.7) on main (GPU-INTEL-MTL) The first Intel entry in gpu-test-results/: Xe-LPG, subgroup 8..32, no 64-wide subgroup. On main 84347bb: build.py 279/279 translated and valid; check.py 177/219, 40 skipped; run_gpu_tests.py 194/248 native (52 skipped) and 226/248 with LEONIDA_W64_EMULATE=1 (20 skipped), where all 32 tests that need 64 lanes run and pass. The only failures, in every run, are cs_imgload_tfe and cs_imgload_d16_tfe (#31), with the 780M's words; both pass with #98 applied to the same main. The seven TEST-399 texture fixtures, recorded as crashing on Mesa 26.2.7 on Iris Xe, pass with Fedora's 26.2.7 here.
|
Thanks @tahffo68hk-hash, this is convincing, and I'm closing this PR. My runs only showed that this change makes LLVM agrees. So:
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 ece4ba5, 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 ece4ba5 调整设计文档表格的上下文并保留两份补丁的原始作者日期。在 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 mainFrom 337b3c0a3661ab0dfe57cd53f716ce1f87f7f2ea Mon Sep 17 00:00:00 2001
From: tahffo68hk-hash <tahffo68hk@gmail.com>
Date: Tue, 24 Nov 2026 10:21:30 +0800
Subject: [PATCH 1/2] Test dense image-load TFE with seeded status and
out-of-bounds coordinates
Record the dense GFX1036 observations and test the integer readback without changing the older fixtures.
AI-assisted.
---
docs/design.md | 1 +
runtime/test/shaders/check.py | 7 +++
runtime/test/shaders/cs_image_tfe_dense.asm | 48 +++++++++++++++++++++
3 files changed, 56 insertions(+)
create mode 100644 runtime/test/shaders/cs_image_tfe_dense.asm
diff --git a/docs/design.md b/docs/design.md
index 6bb4173..d6e444b 100644
--- a/docs/design.md
+++ b/docs/design.md
@@ -413,6 +413,7 @@ How the generated SPIR-V expects the runtime to work:
| LDS 2-address b64 (`ds_read2_b64`, `ds_write2_b64`, `ds_read2st64_b64`, `ds_write2st64_b64`) | Two elements at vaddr + offset0·unit and vaddr + offset1·unit, unit = 8 bytes (×64 for st64); each element is two consecutive dwords, low first. `read2_b64` fills v[d:d+3] after all four loads (a vdst overlapping vaddr is safe); `write2_b64` takes two VGPR pairs. The b32 forms share the code with unit 4. Source: RDNA2 ISA DS 2-address forms. CPU-checked by `tests/semantic/test_lds_read2_write2_b64.py` (compute listings, LDS as a Workgroup variable); GPU-checked by `runtime/test/shaders/cs_lds_b64_cmpst.asm` (unit 8 and the 512-byte st64 forms, plus vdst/vaddr overlap, on an RTX 3070, driver 621.01, Windows 11; the same eight words also on an AMD RX 7600 (`gfx1102`) and a Ryzen 5 9600X iGPU (`gfx1036`, RDNA2, RADV Mesa 27.0.0-devel)). |
| Compute workgroup IDs Y/Z | With four user SGPRs and only TGID_Y and TGID_Z enabled (RSRC2 `0x308`), s4 receives Y and s5 receives Z. The synthetic `cs_workgroup_yz.asm` fixture checks a 2 × 3 × 4 dispatch and each of its 24 origins against a CPU reference. |
| Typed image stores | `image_store` (2D, 2D array, 3D, cube) writes the dmask components (missing ones = 0). The image's numeric type lives in the T# (word 1 FORMAT [28:20], 512 GFX10 formats), so it is decided at run time. A 512-bit table built from `tools/gfx10_formats.json` (30 UINT and 15 SINT formats) picks a **sint**, **uint** or **float** view (bindings 8 + 3·dim + class; dim 0 = 2D, 1 = 2D array, 2 = 3D; class 0 float, 1 uint, 2 sint). Views have Unknown format (`shaderStorageImageWriteWithoutFormat`). **The runtime binds every storage image into all three arrays of its dimension, or at least the one matching its format.** The earlier path wrote only component 0 as `r32ui`, which was wrong for every other format. GPU-checked with `runtime/test/shaders/cs_imgstore.asm` through `runtime/test/vk_store_test.cpp`: rgba8 unorm, r32 uint and r32 sint images, every texel correct. A cube storage image is bound as a six-layer 2D array (bindings 11/12/13 for float/uint/sint, `OpTypeImage ... 2D 0 1 0 2 Unknown`, `%v3int` coordinates (x, y, face)); `tfe` and `lwe` are refused. CPU-checked by `tests/semantic/test_image_cube_store_glc.py`; **not GPU-verified**: no GPU fixture covers a cube store yet. |
+| Dense `image_load tfe` | RDNA2 ISA §8.2 associates the trailing status VGPR with a texture NACK. [LLVM](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/SIISelLowering.cpp) and [Mesa ACO](https://github.com/chaotic-cx/mesa-mirror/blob/main/src/amd/compiler/instruction_selection/aco_isel_helpers.cpp) initialize that register in the generated shader. Native gfx1036 kept a nonzero status seed for both in-bounds and out-of-bounds reads of resident R32 and R32G32 images. Out-of-bounds data was zero, the unused high half of a single D16 word was preserved, and an inactive lane kept its data and status. The status follows the packed data words (one word for two D16 components). `cs_image_tfe_dense` checks data and preserved status on Vulkan. Sparse page NACK behavior is outside this dense fixture. |
| Typed image loads | A noncoherent cube `image_load` reads the 2D-array sampled binding (3) with integer coordinates and layer. Its T# format selects the float, uint or sint alias, including for D16. The [RDNA2 ISA §8.2.1](https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture) assigns D16 conversion to the image format. The synthetic `cube_load_d16.asm` checks the generated views and format choices on the CPU. `image_load` on 1D/2D/2D-array/3D images uses the same T# FORMAT tables as stores, and fetches every format with `OpImageFetch` from the sampled array of its dimension (bindings 0, 3, 6, 5): UINT/SINT formats through **uint/sint aliases of that array** (same set and binding, an `OpTypeImage` of `%uint`/`%int`; Vulkan allows several variables on one binding when the descriptor type fits), everything else through the float array. A lookup miss (index 0) takes the float path, since the fallback there is RGBA8_UNORM. Results are the raw bits of the dmask components. **The runtime binds each image's view in its own format at its index of the sampled array** (what `bind_image` in `runtime/shims/d3d12_vulkan_device.cpp` already does for SRVs and UAVs), so the view's numeric type matches the alias that reads it. No storage image is read, so shaders that only load need neither `shaderStorageImageReadWithoutFormat` (missing on Intel Xe-LP, #619) nor `shaderStorageImageWriteWithoutFormat` (SHADER-151). Until 2026-11-22 integer formats were read with `OpImageRead` from the uint/sint storage arrays (bindings 8–19), which hold only unordered-access views and 256 entries: a read-only integer texture found the fallback there, or an index past the array's end. Like the float path, the fetch goes through the texture path, so it sees writes made before the dispatch, not ones made earlier in the same dispatch. **d16 loads take the same branch** (#1136) and pack the dmask components two per VGPR, low half first: f16 (round to nearest even, integer ops, no `PackHalf2x16`) from the float array, the low 16 bits of each value from the uint/sint aliases (truncated). **d16 loads take the same branch** (#1136) and pack the dmask components two per VGPR, low half first: f16 (round to nearest even, integer ops, no `PackHalf2x16`) from the float array, each value from the uint/sint aliases saturated to the 16-bit range of its signedness (`saturate_int16`). For odd component counts (1 or 3 in `dmask`), the trailing destination VGPR preserves its existing high 16 bits (`write_lo16`), matching native `gfx1036` hardware where a seeded `0x5a5a` high half survived 1-component UINT/SINT `image_load` and `image_load_mip`; until 2026-11-22 the unused high half was zeroed. Before #1136, a d16 load always read the float view, so a `Texture2D<min16uint>` `Load` returned garbage. CPU-checked by `tests/test_image_load_typed.py` (capabilities, bindings and component types for every dimension; the branch for all 512 FORMAT values, found and missed). GPU-checked with `runtime/test/shaders/cs_imgload.asm` through `vk_store_test load`, on a device made without `shaderStorageImageReadWithoutFormat`: r32 uint and r32 sint images filled before the dispatch, both read with `image_load` and their sum stored, every texel exact on an RTX 2080 Ti (NVIDIA 621.14, Windows 11), clean under the validation layer with GPU-assisted validation; the test fails a module that declares `StorageImageReadWithoutFormat`. d16: CPU-checked by `tests/test_image_load_d16_typed.py` (the uint/sint fetches go through the aliases, no storage image is read, the SPIR-V validates); GPU-checked with `runtime/test/shaders/cs_imgload_d16.asm` through `vk_store_test load`: both pre-filled texels read with d16 loads (the sint one sign-extended from bit 15 in the shader) and their sum stored, every texel exact on the RTX 2080 Ti with GPU-assisted validation (#1136 checked its first form, a store and d16 read-back in one dispatch, on an RTX 5070, and `cs_imgload_d16` passes unchanged on an AMD RX 7600 (gfx1102, RADV Mesa 27.0.0-devel) in `run_gpu_tests.py`). GPU-checked with `runtime/test/shaders/cs_imgload_d16.asm` through `vk_store_test load`: both pre-filled texels read with d16 loads (the sint one sign-extended from bit 15 in the shader) and their sum stored, every texel exact on the RTX 2080 Ti with GPU-assisted validation (#1136 checked its first form, a store and d16 read-back in one dispatch, on an RTX 5070). 2D `image_load_mip` uses the same numeric-type selection and passes the address register's mip to each fetch. Its D16 form packs the selected components in ascending order, two per VGPR. An RGBA8 two-level texture was checked on RTX 5080 and Radeon Graphics: all four exported halves matched the CPU reference for UINT, SINT and UNORM, and forcing level 0 changed every pixel. Checked on RTX 5080 and Radeon Graphics with R8G8B8A8 UINT, SINT and UNORM textures: level 1 matched the CPU reference at every pixel with GPU-assisted validation, and forcing level 0 changed all 4096 pixels for each format. Native gfx1036 saturated 32-bit UINT/SINT texels to the unsigned/signed 16-bit range in both D16 load forms; the translated 2D load matched both limits on RTX 5080 and Radeon Graphics. Native gfx1036 does the same on every dimension (SHADER-387, `tools/image_d16_probe.py`): 32_UINT and 32_32_UINT texels saturate to [0, 0xffff] and 32_SINT and 32_32_SINT texels to [-32768, 32767], never truncate, in 1D, 2D, 2D-array and 3D images, through `image_load` and `image_load_mip` alike; two-channel results pack x low and y high, and a one-channel result keeps the seeded high half. The translated d16 loads on 1D, 2D-array and 3D images still lack GPU checks. |
| Packed 2D mip-load addresses | For `image_load_mip` with `a16`, the first VGPR holds unsigned X (low half) and Y (high half). The low half of the second VGPR selects the mip and its high half is unused. Both ordinary and D16 results use the same address. LLVM gfx1030 assembles both forms in `tests/semantic/fixtures/packed_mip_load_2d.asm`. `tests/test_image_load_typed.py` checks the texel and mip operands of the float, UINT and SINT fetches, including noncontiguous address registers. [AMD RDNA 2 ISA, MIMG A16 field](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) |
| 3D explicit-mip loads | `image_load_mip` reads x, y, z and mip from four address VGPRs. T# FORMAT selects the float, UINT or SINT 3D sampled view at binding 6. D16 narrows the selected components before packing them low half first. The unit test `test_volume_mip_fetch_uses_xyz_level_and_descriptor_type` in `tests/test_image_load_typed.py` checks the four address registers and the RGBA32 format selection on the translated module. Native gfx1036 measured UINT and SINT saturation for 3D `image_load_mip` at mip zero. [Volume load measurements](https://github.com/ItsNotRexed/Leonida/pull/2217) |
diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py
index 7b37772..a6d6144 100644
--- a/runtime/test/shaders/check.py
+++ b/runtime/test/shaders/check.py
@@ -603,6 +603,13 @@ STORE_WORDS = {
"cs_resinfo": ({**dict(enumerate([16, 4, 0, 5, 8, 2, 0, 5, 2, 1, 0, 5, 4, 1, 0xABCD])), 16: 2, 17: 5, 18: 5,
20: 0, 21: 0, 22: 0, 23: 5},
{}, {}),
+ # TFE leaves both seeded status words intact. D16 updates only the low half of its single data word.
+ "cs_image_tfe_dense": ({}, dict(enumerate([
+ 0, 100, 101, 102, 0, 0, 0, 0,
+ *[0x5A5A03F5] * 8,
+ 0x5A5A0000, 0x5A5A0064, 0x5A5A0065, 0x5A5A0066, *[0x5A5A0000] * 4,
+ *[0x5A5A03F6] * 8,
+ ])), {}),
}
# TEST-184: image_get_lod on vk_texture_test's textures. Per fixture, its draws: S# word 1 (MIN_LOD [11:0], MAX_LOD
# [23:12], 4.8 fixed point), whether the two-mip texture is drawn, and mrt0, as derived in the .asm header:
diff --git a/runtime/test/shaders/cs_image_tfe_dense.asm b/runtime/test/shaders/cs_image_tfe_dense.asm
new file mode 100644
index 0000000..dfe475b
--- /dev/null
+++ b/runtime/test/shaders/cs_image_tfe_dense.asm
@@ -0,0 +1,48 @@
+; TFE on a resident R32_UINT image, measured with raw image_load on GFX1036.
+; vk_store_test words fills the 8x8 input with 100+i. Read row zero at x = -1,0,1,2,8,9,10,11.
+; Copy the full-width data and status and the D16 data and status to the first four rows of the SINT image.
+; Data rows 0 and 2 contain zero (preserving D16's high half) outside the image. The two status rows retain
+; their distinct seeds on all accesses. A coordinate outside a resident view does not give a residency NACK.
+; Run: vk_store_test cs_image_tfe_dense.spv words
+; mattr: +wavefrontsize32,-wavefrontsize64
+v_cmpx_gt_u32_e32 32, v0
+v_and_b32_e32 v1, 7, v0
+v_lshrrev_b32_e32 v2, 3, v0
+v_add_nc_u32_e32 v3, -1, v1
+v_add_nc_u32_e32 v4, 4, v1
+v_cmp_gt_u32_e32 4, v1
+v_cndmask_b32_e64 v3, v4, v3, vcc_lo
+v_mov_b32_e32 v4, 0
+
+s_mov_b32 s8, 0x2000
+s_mov_b32 s9, 0x1400000
+s_mov_b32 s10, 0x22
+s_mov_b32 s11, 0x22
+s_mov_b32 s12, 0x22
+s_mov_b32 s13, 0x22
+s_mov_b32 s14, 0x22
+s_mov_b32 s15, 0x22
+s_mov_b32 s16, 0x3000
+s_mov_b32 s17, 0x1500000
+s_mov_b32 s18, 0x33
+s_mov_b32 s19, 0x33
+s_mov_b32 s20, 0x33
+s_mov_b32 s21, 0x33
+s_mov_b32 s22, 0x33
+s_mov_b32 s23, 0x33
+
+v_mov_b32_e32 v8, 0x5a5a03f5
+v_mov_b32_e32 v9, 0x5a5a03f4
+v_mov_b32_e32 v10, 0x5a5a03f6
+image_load v[7:8], v[3:4], s[8:15] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm tfe
+image_load v[9:10], v[3:4], s[8:15] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm tfe d16
+s_waitcnt vmcnt(0)
+
+v_cmp_eq_u32_e32 2, v2
+v_cndmask_b32_e64 v11, v10, v9, vcc_lo
+v_cmp_eq_u32_e32 1, v2
+v_cndmask_b32_e64 v11, v11, v8, vcc_lo
+v_cmp_eq_u32_e32 0, v2
+v_cndmask_b32_e64 v11, v11, v7, vcc_lo
+image_store v11, v[1:2], s[16:23] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm
+s_endpgm
From ea9475da49364bd0d1ec0114f92f8fcf2296dbc7 Mon Sep 17 00:00:00 2001
From: tahffo68hk-hash <tahffo68hk@gmail.com>
Date: Tue, 24 Nov 2026 10:42:52 +0800
Subject: [PATCH 2/2] Check that resident TFE loads preserve the seeded status
words
Raw GFX1036 readback matched 48 cases covering D16 and D32, R32 and R32G32, three seeds, in-range and out-of-range coordinates, and inactive lanes. Check both words independently and signal corruption through the existing Vulkan readback.
AI-assisted.
---
runtime/test/shaders/cs_imgload_d16_tfe.asm | 18 +++++++++++-------
runtime/test/shaders/cs_imgload_tfe.asm | 18 +++++++++++-------
2 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/runtime/test/shaders/cs_imgload_d16_tfe.asm b/runtime/test/shaders/cs_imgload_d16_tfe.asm
index 0739810..0e24135 100644
--- a/runtime/test/shaders/cs_imgload_d16_tfe.asm
+++ b/runtime/test/shaders/cs_imgload_d16_tfe.asm
@@ -1,7 +1,7 @@
-; tfe status VGPR on a d16 image_load (SHADER-1266): cs_imgload_d16 with tfe on both loads. Under d16 one
-; component fills one VGPR, and with tfe the fetch status follows it, so vdata is v[7:8] and v[11:12]. Every texel is
-; resident, so the status is 0. Each status VGPR is seeded with 1000 and added into the result, so a stale status
-; moves every texel by 2000. The unpacking and the result are cs_imgload_d16's, checked by vk_store_test load-d16
+; tfe status VGPR on a d16 image_load (SHADER-1266): the status follows the packed data word, so vdata is
+; v[7:8] and v[11:12]. Raw gfx1036 reads of resident textures kept the status seeds 0, 1000 and 0xa5a5ffe1.
+; Compare both status registers against their seeds and store a sentinel on any mismatch.
+; The unpacking and the result are cs_imgload_d16's, checked by vk_store_test load-d16
; (including its saturation row). Suggested by @nnonno91, who ran the same companion on gfx1036 and an RTX 5090 in #8968.
v_and_b32_e32 v1, 7, v0
v_lshrrev_b32_e32 v2, 3, v0
@@ -38,14 +38,18 @@ s_mov_b32 s28, 0x33
s_mov_b32 s29, 0x33
s_mov_b32 s30, 0x33
s_mov_b32 s31, 0x33
-v_mov_b32_e32 v12, 0x3e8
+v_mov_b32_e32 v12, 0xa5a5ffe1
image_load v[11:12], v[1:2], s[24:31] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm tfe d16
s_waitcnt vmcnt(0)
v_and_b32_e32 v7, 0xffff, v7
v_bfe_i32 v11, v11, 0, 16
v_add_nc_u32_e32 v11, v7, v11
-v_add_nc_u32_e32 v11, v8, v11
-v_add_nc_u32_e32 v11, v12, v11
+v_xor_b32_e32 v8, 0x3e8, v8
+v_xor_b32_e32 v12, 0xa5a5ffe1, v12
+v_or_b32_e32 v8, v8, v12
+v_cmp_eq_u32_e32 0, v8
+v_mov_b32_e32 v8, 0x7fffffff
+v_cndmask_b32_e64 v11, v8, v11, vcc_lo
v_mov_b32_e32 v12, 0
v_mov_b32_e32 v13, 0
v_mov_b32_e32 v14, 0
diff --git a/runtime/test/shaders/cs_imgload_tfe.asm b/runtime/test/shaders/cs_imgload_tfe.asm
index 63ad9dc..996cbde 100644
--- a/runtime/test/shaders/cs_imgload_tfe.asm
+++ b/runtime/test/shaders/cs_imgload_tfe.asm
@@ -1,7 +1,7 @@
-; tfe status VGPR on image_load (SHADER-1266): cs_imgload with tfe on both loads. With tfe an MIMG read returns one
-; more dword after its data, the fetch status, at vdata[data_count] (RDNA2 ISA, MIMG TFE/LWE). Every texel here is
-; resident, so the status is 0. Each status VGPR is seeded with 1000 before its load and added into the result, so a
-; status that keeps its old value moves every texel by 1000 or 2000. vk_store_test fills the r32 uint image with
+; tfe status VGPR on image_load (SHADER-1266): the status follows the data and is written on a texture NACK
+; (RDNA2 ISA, MIMG). Every texel here is resident. Raw gfx1036 reads preserved the status seeds 0, 1000 and
+; 0xa5a5ffe1. Compare the two status registers separately against their seeds and store a sentinel on any mismatch.
+; vk_store_test fills the r32 uint image with
; 100 + 8y + x and the r32 sint image with -2 (8y + x) before the dispatch; the rgba8 image is stored as in
; cs_imgstore. Run: vk_store_test cs_imgload_tfe.spv load -> sint = 100 - (8y + x), uint unchanged.
v_and_b32_e32 v1, 7, v0
@@ -39,12 +39,16 @@ s_mov_b32 s28, 0x33
s_mov_b32 s29, 0x33
s_mov_b32 s30, 0x33
s_mov_b32 s31, 0x33
-v_mov_b32_e32 v12, 0x3e8
+v_mov_b32_e32 v12, 0xa5a5ffe1
image_load v[11:12], v[1:2], s[24:31] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm tfe
s_waitcnt vmcnt(0)
v_add_nc_u32_e32 v11, v7, v11
-v_add_nc_u32_e32 v11, v8, v11
-v_add_nc_u32_e32 v11, v12, v11
+v_xor_b32_e32 v8, 0x3e8, v8
+v_xor_b32_e32 v12, 0xa5a5ffe1, v12
+v_or_b32_e32 v8, v8, v12
+v_cmp_eq_u32_e32 0, v8
+v_mov_b32_e32 v8, 0x7fffffff
+v_cndmask_b32_e64 v11, v8, v11, vcc_lo
v_mov_b32_e32 v12, 0
v_mov_b32_e32 v13, 0
v_mov_b32_e32 v14, 0 |
…ation The record pointed at ProjectLeonida#31 as if the two tfe failures were a translator fault. The review on ProjectLeonida#98 reports native gfx1036 keeping the seeded status VGPR, and ProjectLeonida#98 was closed on that. Say so; the measured words and counts are unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…es' expectation (GPU-INTEL-MTL-TFE) The Meteor Lake record (ProjectLeonida#246) filed cs_imgload_tfe and cs_imgload_d16_tfe as the translator bug of ProjectLeonida#31 and noted that ProjectLeonida#98 made them pass. The review on ProjectLeonida#98 measured on native gfx1036 that a resident image_load tfe keeps the seeded status VGPR, and LLVM initializes the TFE/LWE result itself before the instruction for that reason: the translator, which keeps it, is exact, and the fixtures expect it cleared. ProjectLeonida#98 is closed. Reword the Failed line and the ProjectLeonida#84 note in gpu-test-results/IntelMTL.txt, and the table cell, the summary block and a short paragraph in docs/gpu_test_results.md. The measured words are unchanged.
|
@tahffo68hk-hash opened as #1271. Your first commit is applied with
On Intel Meteor Lake (ANV), AI-assisted (Claude Code). |
…es' expectation (GPU-INTEL-MTL-TFE) The Meteor Lake record (ubiquitarianism#246) filed cs_imgload_tfe and cs_imgload_d16_tfe as the translator bug of ubiquitarianism#31 and noted that ubiquitarianism#98 made them pass. The review on ubiquitarianism#98 measured on native gfx1036 that a resident image_load tfe keeps the seeded status VGPR, and LLVM initializes the TFE/LWE result itself before the instruction for that reason: the translator, which keeps it, is exact, and the fixtures expect it cleared. ubiquitarianism#98 is closed. Reword the Failed line and the ubiquitarianism#84 note in gpu-test-results/IntelMTL.txt, and the table cell, the summary block and a short paragraph in docs/gpu_test_results.md. The measured words are unchanged.
RX7900XTX: emulated is 225/248 (3 failed) vs 226/248 (2 failed); the +31 native delta is +32 passes minus cs_w32_salu64; cs_w32_salu64 words 3..7 are the 0xEEEEEEEE fill. IntelARL: cs_signed_zero_nan word 2 is 0x80000000, want 0x80008000, beyond the documented word-5 NIR bug. RTX5060Laptop: ProjectLeonida#98 pass is recorded in IntelMTL.txt only; VK_HEADER_VERSION 275 is 1.3.275. AI-assisted (Claude Code).
…11.2, Windows 11 (GPU-RX9070-RAPHAEL-WIN) Two records from one Windows 11 box on main d0da7da, scripts/run_gpu_tests.py native and under LEONIDA_W64_EMULATE=1, LEONIDA_VK_DEVICE selecting each GPU: - RX 9070 (RDNA4, 32.0.32029.2010): 231/249 passed, 16 skipped, 2 failed, native and emulated alike. ms_wave_info_s3 passes, which the 9070 XT record on the same 26.11.2 driver fails on every native run. - Ryzen 5 7600X iGPU (gfx1036, 32.0.21045.29003): 224/249 passed, 23 skipped, 2 failed. The 7 extra skips are no VK_EXT_mesh_shader (6) and no required 64-wide fragment subgroup (1). This is gfx1036 under AMD's Windows compiler; Raphael-610M.txt is the same silicon under RADV. On both, the two failures are cs_imgload_tfe and cs_imgload_d16_tfe, the fixtures' expectation measured on #98, not the translator. 258/258 shaders translated and spirv-val clean. Counts only.
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 9c4c5f9) 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 ontomain9ec34cd.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.main9ec34cdtests/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:
python3 -m unittest discover -s tests/semantic -p test_image_load_tfe.py python3 -I scripts/run_semantic_tests.py tests/semantic cmake -S runtime -B runtime/build/linux -G Ninja && cmake --build runtime/build/linux --parallel LEONIDA_VK_DEVICE=Intel python3 -I scripts/run_gpu_tests.py --build runtime/build/linux@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).