Repository navigation
fix(translator): image_load outside the image returns zeros (EGEN-IMGLOAD-OOB) - #5307
evilclanker9000 wants to merge 3 commits into
Conversation
…LOAD-OOB) RDNA2 (gfx1036, tools/hw_oracle) returns 0 for an image_load at x/y past the edge, at -1 or at the row pitch. OpImageFetch and OpImageRead out of range are undefined in Vulkan, so each read is now behind an unsigned coordinate < OpImageQuerySize(Lod) test per axis (and level < levels for mip loads) and merged with a zero vector. A descriptor lookup miss keeps reading the fallback image.
|
Independent CPU verification on Linux (Python 3.13.5 + CI-breaking test regression found (
Everything else checked — pass:
|
|
Independent Windows GPU verification (AI-assisted), head
This checks the translated Vulkan path on NVIDIA, not native RDNA2 hardware or its oracle. The probe covers ordinary 2D uint loads only, not glc, d16, other dimensions or invalid mip levels. In particular it does not measure native behavior beyond the last mip. No game data/corpus was used. The separately reported d16 pytest regression was not retested here. |
|
Tested
Counts only, no game files. AI-assisted. |
Kam471
left a comment
There was a problem hiding this comment.
Head 99e7e0f5c. git diff --check clean.
python -I tests/semantic/test_image_load_bounds.py-> 2 tests OK (12 sub-cases: 1D/2D/2D-array/3D, sampled/d16 fetch and coherent read).- Same file against
origin/main's translator ->FAILED (failures=12),AssertionError: 0 != 1 : OpImageQuerySizeLod missing from the guard, as the PR says. python -I -m pytest tests/test_image_load_typed.py -q-> 23 passed, 53 subtests.python -I -m pytest tests/test_cube_sample.py tests/test_image_fuzz.py tests/test_image_load_d16_typed.py tests/test_translate.py tests/test_desc_cache.py -q-> 86 passed, 602 skipped.- semantic
test_image_coherent10 OK,test_mem_crash_forms1 OK,test_fspx_rules9 OK,test_isa_coverage20 (4 skipped),test_shader_profile38,test_docs_table_rows2. spirv-as+spirv-val --target-env vulkan1.3on translated 1D, 2D, 2D-array-d16 and 3D-glc loads -> 4/4 valid.
Verdict: approve. The guard is per-axis unsigned and merged with a zero OpPhi; the past-the-last-level mip rule is still unmeasured and docs/design.md now calls it an inference.
|
At
I also scanned all 26,503 retail listings from my Xbox 1.0.2.1 copy and translated every listing containing |
|
Update: the 3D case is now measured too, so the note "not measured on 3D" no longer applies. On gfx1036 (same driver), a 64x1x4 R32_UINT linear volume with 256-byte slices: image_load, image_store and image_atomic (umax/add/cmpswap) with x = 64, y = 1, z = 4 or z = -1 left every seeded word unchanged, and a load or a glc atomic returned 0; the in-range controls worked. |
|
Correction to my comment above: the docs commit I mentioned has not been pushed yet; my push was blocked in this environment. The 3D measurement itself stands (it is in the comment), and the matching |
|
Tested
No game files used. AI-assisted (Claude Code). |
Claimed in the coordination issue as: EGEN-IMGLOAD-OOB (#4933 (comment))
What and why
On RDNA2 an
image_loadwhose coordinate is outside the image returns 0. The translation emittedOpImageFetch(andOpImageReadfor the coherentglcread) with the raw coordinates; out of range both are undefined in Vulkan (the runtime does not enable robustImageAccess), so a lane could read another texel, padding or garbage.Every typed
image_load/image_load_mip/ coherent read now runs only when each coordinate is< OpImageQuerySizeLod(OpImageQuerySizefor the storage view), unsigned per axis so -1 is out too, and for a mip load the level is also below the level count; a lane outside gets a zero vector through anOpPhi. A descriptor lookup miss (index 0, the fallback image) is read as before, unguarded. Sibling PRs for the same family: #5059 (image atomics) and #5250 (image_store); this one does not depend on them (it touches other functions).Measurement (gfx1036, Windows driver 32.0.21045.16010,
tools/hw_oracle, linear 4x4 R32_UINT T#):image_loadat x = width, x = -1, y = height and x = row pitch returned 0; the in-range control returned the texel.Tested
python -I tests/semantic/test_image_load_bounds.py(new): before the change 12 of 12 sub-cases fail ("OpImageQuerySize(Lod) missing from the guard"); after, OK.tests/test_image_load_typed.pyfollows the fetch result through the newOpPhi(Module.texel); 23 tests OK.test_image_coherent,test_mem_crash_forms,test_fspx_rules,test_isa_coverage,test_shader_profile,test_docs_table_rows: OK. pytesttest_cube_sample,test_image_fuzz,test_image_load_d16_typed,test_translate,test_desc_cache: 86 passed, 602 skipped.spirv-as/spirv-val(vulkan1.3): 28/28 image_load forms (1D/2D/2D array/3D, plain/glc/d16,image_load_mip2D and 3D), plain and--wave64-emulate.spirv-valvalid; 150 listings that useimage_load: 150 valid before and 150 after.AI-assisted: yes
Notes
OpPhineeds the zero vector built before the branch (found by spirv-val), so a guarded read adds oneOpCompositeConstructper view class.image_gather4,image_samplepaths and the otherOpImageFetchuse (image_gather4mip fetches clamp their own addresses).docs/design.md's row only as "for a mip load also a level past the last one".Checklist
docs/design.md, with how it was confirmed.