Skip to content

shader: accept GLC and DLC cache flags on direct read-only image ops - #3244

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
legacy-code-archaeologist:shader/direct-image-cache-flags
Nov 28, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
legacy-code-archaeologist:shader/direct-image-cache-flags

Conversation

@legacy-code-archaeologist

Copy link
Copy Markdown
Contributor

Accept MIMG cache-policy flags GLC (word 0 bit 13, 0x2000) and DLC (word 0 bit 7, 0x0080) on read-only image operations in DirectCompute::image_io(), addressing #3224 (Rank 8: "direct image opcode or descriptor modifiers") and #2935.

Fixes #3242
Refs #2935
Refs #3224

Summary

  • src/gfx1013_direct_compute.inl:
    • In DirectCompute::image_io(), updated the word 0 modifier check from (i.a & 0x3e0c0u) to (i.a & (store ? 0x3e0c0u : 0x3c040u)).
    • Read-only image ops (image_load, image_load_mip, image_sample*, image_gather4*, image_getlod, image_getresinfo) now ignore GLC (0x2000) and DLC (0x0080), matching SLC (0x02000000) cache-policy handling.
    • Preserved all existing refusals: image_store with GLC/DLC (0x3e0c0u), LWE (0x20000), TFE (0x10000), R128 (0x8000), reserved word 0 bits (0x4040), reserved word 1 bits (0x3c000000u), and image_atomic_* explicit policy checks in image_atomic().
  • tests/native_image_cache_flags_check.py & tests/cmake/native_image_cache_flags.cmake:
    • Added controls verification across Compute and Pixel stages for image_load, image_load_mip, image_getresinfo, image_sample_lz, image_gather4_lz, and image_gather4_l with GLC, DLC, SLC, and GLC|DLC|SLC (48 compiled DXIL modules matching plain flags=0 baselines), plus 16 refusal checks (image_store with GLC/DLC, R128, TFE, LWE, reserved word 0 bits 6/14, reserved word 1 bit 26).
    • Added ps and cs hardware/WARP readback tests via offscreen_check using image_gather4_l with GLC, DLC, and GLC|DLC|SLC.
  • docs/experiments/native-image-cache-flags.md:
    • Recorded verification, sensitivity mutants, and limits.

Verification

Host: Windows 10.0.26100, dev preset, DXC 10.0.26100.0.

  • cmake --build --preset dev --target compile_dxil offscreen_check native_compute_ir_dump: passed.
  • ctest --preset dev --no-tests=error -R '^(native_image_cache_flags_|native_gather_|native_image_atomic_|native_sample_ssamp_)' -V:
    • native_image_cache_flags_controls: Passed (48 flagged DXIL modules matched plain baselines; 16 refusals matched).
    • native_image_cache_flags_ps_warp: Passed (12 cached-flag cases matched on Microsoft Basic Render Driver 10.0.26100.9711).
    • native_image_cache_flags_ps_hardware: Passed (12 cached-flag cases matched on NVIDIA Quadro M1000M 32.0.15.7371; debug_layer=unavailable).
    • native_image_cache_flags_cs_hardware: Passed (12 cached-flag cases matched on NVIDIA Quadro M1000M 32.0.15.7371; debug_layer=unavailable).
    • native_image_cache_flags_cs_warp: Skipped (77, Microsoft Basic Render Driver lacks SM 6.6 wave32).
    • Neighbor suites (native_gather_compare_warp, native_gather_lod_*, native_image_atomic_controls/hardware, native_sample_ssamp_hardware) passed (_cs_warp / _warp wave32 tests skipped 77; pre-existing native_image_atomic_runtime_hardware fails on this dual-GPU host because startup_stream_consumer uses adapter 0 Intel(R) HD Graphics 530 which lacks SM 6.6 wave32).
  • ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure: 67/67 passed (0 skips).
  • Sensitivity mutants against native_image_cache_flags_controls:
    • revert_ro_cache_flags ((i.a & 0x3e0c0u)): failed (rc=8).
    • drop_r128_refusal ((i.a & (store ? 0x3e0c0u : 0x34040u))): failed (rc=8).
  • python -B tests/docs_links_check.py: passed (131 Markdown files, 631 links).

AI-assisted.

Copy link
Copy Markdown

For 9863d469, I compared the relevant behavior with shadPS4 #5739. Keep image operand flags separate from operand liveness. Compare identical fetch coordinates with a tested cache hint, and a second address operand kept alive across legalization. This is a pinned source comparison; the suggested case still needs a receiving-side run.

@legacy-code-archaeologist

Copy link
Copy Markdown
Contributor Author

Thanks for the pointer @akimfomin — that matches what our image_load_mip (v0..v2) and image_gather4_l (v0..v2) cases in tests/native_image_cache_flags_check.py exercise, asserting both multi-dword coordinate liveness and byte-identical DXIL compared with the unflagged baseline (glc=0, dlc=0).

AI-assisted.

@legacy-code-archaeologist

Copy link
Copy Markdown
Contributor Author

Rebased onto upstream/main (fdb6faaa) as 12a6640b to resolve the conflict in DirectCompute::image_io() after #3243 (exact_store), keeping all #3243 prefix-mask store changes intact alongside (i.a & (store ? 0x3e0c0u : 0x3c040u)).

Re-verified in dev and release (/O2, Windows 10.0.26100):

  • native_image_cache_flags_controls: Passed (48 flagged DXIL modules matched plain baselines; 16 refusals matched).
  • native_image_cache_flags_ps_warp: Passed (12 cases matched on WARP).
  • native_image_cache_flags_ps_hardware & native_image_cache_flags_cs_hardware: Passed (12 cases each on NVIDIA Quadro M1000M 32.0.15.7371, debug_layer=unavailable).
  • native_image_cache_flags_cs_warp: Skipped (77) (Microsoft Basic Render Driver 10.0.26100.9711 4-lane wave).
  • python -B tests/docs_links_check.py: self-test passed (134 Markdown files, 638 links).

AI-assisted.

@legacy-code-archaeologist
legacy-code-archaeologist force-pushed the shader/direct-image-cache-flags branch from 9863d46 to 12a6640 Compare November 28, 2026 02:41

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independently reviewed 12a6640b. The masking is limited to GLC/DLC on the admitted read-only MIMG operations. Reserved bits, TFE, LWE, R128, stores and the separate atomic route retain their existing checks. The result checks cover synchronized value equivalence on desktop, with guest cache policy outside their scope.

On Windows 11 26200.9974 and RTX 4060 Laptop (32.0.16.1656), using inbox WARP 10.0.26100.9818 and DXC 10.0.26100.0, Debug and Release /O2 each recorded 10 passes and one WARP compute capability skip on integration tree db07621c. Controls covered 48 accepted containers and 16 refusals. RTX compute and pixel, WARP pixel, the runtime atomic, and exact-width store controls passed. The offscreen checks requested the debug layer.

After #3245, Release /O2 on main 0637fced plus this head (tree b6e49bed) passed five tests with one WARP compute capability skip:

ctest --test-dir out/b/release --no-tests=error --output-on-failure -j 1 -R '^(native_image_cache_flags_.*|native_wave64_exec_salu_hardware)$'

The hosted Windows build and test check passed.

@R0Y00
R0Y00 merged commit 9872074 into R0Y00:main Nov 28, 2026
5 checks passed
@pigalot

pigalot commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Independently tested 12a6640b integrated over main 0637fced (tree b6e49bed). This is the head that was merged as 9872074a, so I'm posting it as a comment. The trial merge was clean and git diff --cached --check was clean.

What I traced. On gfx10, MIMG word 0 puts DLC at bit 7, GLC at bit 13, R128/A16 at bit 15, TFE at bit 16 and LWE at bit 17. The read-only mask 0x3c040 frees bits 7 and 13 and still refuses 6, 14, 15, 16 and 17. Stores keep 0x3e0c0. Every non-store path here binds a texture_srv, and the dispatch side refuses an output texture that is also an input. So dropping GLC on a read can't hide a same-dispatch coherence need.

What I ran. I built everything in dev and in release, then ran

ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^native_image_cache_flags_.+$'

The _hardware tests ran at -j 1. In Debug and in Release /O2:

  • _controls: "48 flagged DXIL modules matched plain baselines; 16 refusals matched".
  • _ps_warp, _ps_hardware and _cs_hardware: "12 cached-flag cases matched".
  • _cs_warp is a capability skip (77): WARP has no 32-lane waves.

Neighbours in dev also pass:

  • ^(native_.*_(controls|ir)|native_(gather|image|sample)_.*_warp)$: 77/77 pass. 4 are WARP wave32 capability skips.
  • native_(gather|image|sample)_*_hardware: 7/7 pass.

Negative control and mutants. Each mutant was rebuilt in dev and run against all five tests.

Mutant Result
src/gfx1013_direct_compute.inl back to main 0637fced killed in _controls, _ps_warp, _ps_hardware, _cs_hardware ("direct image opcode or descriptor modifiers" on GLC)
store mask accepts GLC (0x3c0c0) killed (_controls store_glc)
read-only mask accepts TFE (0x2c040) killed (_controls sample_tfe)
read-only mask accepts reserved bit 6 (0x3c000) killed (_controls sample_res_bit6)
read-only mask still refuses DLC (0x3c0c0) killed in all four
read-only mask accepts LWE (0x1c040) killed (_controls sample_lwe)

Afterwards I restored and rebuilt; git diff --quiet is clean.

Non-blocking. The R128, TFE, LWE and reserved-bit refusals are pinned only on image_sample_lz, and the GPU cases only use image_gather4_l. The mask is shared by every read-only opcode, so this covers it today. A per-opcode split of the check would not be caught.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.28000.0 DXC (the one CTest picked up); Python 3.12.10; wave32.

This reply was AI-assisted.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shader: accept GLC and DLC cache flags on direct read-only image ops

4 participants