Skip to content

shader: lower ds_write_*_d16_hi and ds_read_{u8,i8}_d16* in native compute - #3784

Open
R0D4X wants to merge 2 commits into
R0Y00:mainfrom
R0D4X:shader/native-lds-d16-subdword
Open

R0D4X wants to merge 2 commits into
R0Y00:mainfrom
R0D4X:shader/native-lds-d16-subdword

Conversation

@R0D4X

@R0D4X R0D4X commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Refs #3224, #2935

Summary

Completes the GFX10 D16 sub-DWORD LDS family alongside ds_read_u16_d16 / ds_read_u16_d16_hi (0xa6, 0xa7) in gfx1013_compute_ir and the direct C++ compute frontend:

  • 0xa0 (ds_write_b8_d16_hi): writes (v[data0] >> 16) & 0xff to LDS byte address.
  • 0xa1 (ds_write_b16_d16_hi): writes (v[data0] >> 16) & 0xffff to even LDS halfword address (skipping odd effective addresses, matching ds_write_b16).
  • 0xa2 (ds_read_u8_d16) / 0xa3 (ds_read_u8_d16_hi): zero-extends 1 LDS byte to 16 bits into the low/high half of v[dst], preserving the untouched 16-bit half.
  • 0xa4 (ds_read_i8_d16) / 0xa5 (ds_read_i8_d16_hi): sign-extends 1 LDS byte to 16 bits into the low/high half of v[dst], preserving the untouched 16-bit half.

Changes

  • src/gfx1013_compute_ir.h and src/gfx1013_compute_ir.cpp:
    • Add bool store_d16_hi to LocalDataAccess and decode 0xa0..0xa5 in decode_local_data.
    • Shift v[data0] right by 16 bits in lower_lds when store_d16_hi is set; mask signed field to 16 bits and clear the full 16-bit destination half (~(0xffffu << bit)) when read_d16 is set.
  • src/gfx1013_direct_compute.inl:
    • Mirror both behaviors in the direct DXIL LDS lowering (leaving 0xa6 / 0xa7 DXIL bit-for-bit unchanged).
  • tests/native_lds_subword_read_check.py:
    • Verify exact DXIL shape for 0xa2..0xa5 alongside 0xa6, 0xa7, 0x39..0x3c; update the unsupported-opcode refusal control from 0xa2 (162) to 0xa8 (168).
    • Add hardware execution cases for 0xa2, 0xa3, 0xa4, 0xa5 (including sign-extension of 0xb3 -> 0xffb3 with preserved high/low halves), 0xa0 (ds_write_b8_d16_hi), 0xa1 (ds_write_b16_d16_hi), and the odd-offset skip control for 0xa1.

Verification

  • Commit: f4882407 (based on main 158ef794)
  • Environment: Windows 11 x64 (10.0.26300.9974), MSVC 19.44.35230, Windows SDK / DXC 10.0.26100.0, NVIDIA GeForce RTX 5080 (10de:2c02, driver 32.0.16.2140), Microsoft Basic Render Driver (10.0.26100.9818), D3D12 debug layer enabled (debug_errors=0 debug_warnings=0).

Commands and results

ctest --preset dev --no-tests=error -R '^(native_lds_subword_read|gfx1013_compute_ir)' -V
ctest --preset release --no-tests=error -R '^(native_lds_subword_read|gfx1013_compute_ir_all)' -V
  • dev (Debug): 92/92 Passed (89/89 gfx1013_compute_ir_* unit + mutation tests PASS; native_lds_subword_read_controls PASS; native_lds_subword_read_hardware PASS in 3.92 s on RTX 5080, all 10 cases × 336 texture words matched; native_lds_subword_read_warp Skipped (77) — shader wave32 fixture requires SM 6.6, WaveOps, and a 32-lane wave).
  • release (/O2): gfx1013_compute_ir_all (83/83) Passed, native_lds_subword_read_controls Passed, native_lds_subword_read_hardware Passed (3.72 s on RTX 5080), native_lds_subword_read_warp Skipped (77).

Fail-first / mutation control

Disabling if (op.store_d16_hi) in src/gfx1013_direct_compute.inl and rebuilding compile_dxil fails native_lds_subword_read_hardware (exit 8) on the 0xa0 case (expected=654300a2 actual=654300c0).

Pure-Python checks

.\out\pe-env\Scripts\python.exe -B tests\docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py
  • Both PASS.

Scope note

This verifies source-built gfx1013 LDS subword compute fixtures through compile_dxil and offscreen_check on the RTX 5080 and WARP; it does not establish full-title startup or frame rate.

AI-assisted.

R0Y00 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

The reviewed head passed Windows and Linux CI, but GitHub reports a merge conflict against current main. Please rebase and retain the LocalDataAccess default initializers from #3794 when adding store_d16_hi. Please rerun the subword LDS controls on the new head.

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.

2 participants