Skip to content

shader: compile native mesh interfaces and prewarm compute requests - #3091

Merged
R0Y00 merged 20 commits into
mainfrom
codex/native-shader-modules
Nov 28, 2026
Merged

R0Y00 merged 20 commits into
mainfrom
codex/native-shader-modules

Conversation

@R0Y00

@R0Y00 R0Y00 commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Integrate native compilation of the supported fixed mesh/pixel interfaces, descriptor waterfalls and reviewed resource layouts. The C++ frontend also accepts tagged compute state and scalar buffer windows, and can publish and validate a versioned compute frontend pack. Cache identity includes the new lowering sources. The compiler watcher invalidates entries when the slot-57 pixel input sidecar changes.

This is the compiler prerequisite for a separate runtime integration. Refs #2907 and #2981. All new fixture inputs are source-built.

Verified at a48d39d in a clean x64 Windows Release worktree, MSVC 19.51, Windows SDK 10.0.26100.0.

cmake --build --preset release --target compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump
ctest --preset release --no-tests=error --output-on-failure -R '^(native_direct_(container|mesh)|native_frozen_request|native_compute_pack|native_graphics_(interface_library|wqm_ir)|native_startup_request_cache_controls|native_salu_shift64_controls)$'

8 passed, 0 failed, 0 skipped. These controls check desktop bytecode generation, mesh input rejection, WQM IR, immutable request identity and cache publication. Runtime bindings and submitted GPU results are covered by the dependent runtime change.

R0Y00 commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

The trial merge of 94d2803f into main ca659396 has one conflict in src/gfx1013_compute_native.cpp. In symbolic transfer, please retain both main's _i64 high-word invalidation from #3067 and this PR's wave64 QuadCompare high-word invalidation. GitHub currently reports the PR as conflicted and has no check results for this head.

For GPU review, please cover the new RTV specialization against main, including the cache key change and RTV mismatch or missing-sidecar refusals; check that old and revised cache identities cannot reuse incompatible DXIL; and exercise the offline C++ request path through compile_dxil, including the sidecar-change invalidation and frozen request/pack controls. The dependent runtime PR still needs its own draw and GPU verification.

@R0Y00
R0Y00 requested a review from denn0x November 27, 2026 14:56

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

The current integration with main ca659396 (tree 3e49c5cfe4eef1784fcce70ef00ccf5a7d46ab10) retains both _i64 and wave64 QuadCompare pair invalidation. Debug and Release /O2 each passed nine compiler-only tests, including native_rtv_variant_controls and native_salu_shift64_controls. The RTV suite produced byte-identical cold and warm outputs for the base and four variants, and its 13 refusals preserved the expected failure markers.

One watcher behavior still needs a control. I used the source-built stream request in native_startup_request_cache_check.py, published it with compile_dxil --watch ... --once, then added a contradictory .ps57in with an older preserved timestamp. A second --watch --once kept the old .txt byte-identical and did not refuse the conflict. Giving the identical .ps57in a newer timestamp caused the watcher to withdraw the manifest and report conflicting stream and slot-57 pixel entry records. The cached-manifest fast path currently checks only the latest sidecar mtime. Please check the sidecar shape or identity before it accepts a cached graphics result, and cover the preserved-timestamp case.

R0Y00 commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

An updated trial merge of a48d39dc into main a9fd1488 found one new overlap in src/gfx1013_direct_compute.inl, where #3068 added explicit LOD gather. The earlier _i64/QuadCompare conflict is resolved. Please preserve the explicit-gather helper and its validation alongside the indexed pixel-heap path. Keep the explicit gather scoped to the fixed table-bound SRV from #3068 unless a separate indexed-gather case proves that extension. After the merge, rerun native_gather_lod_controls together with the slot-57 and RTV compiler checks.

R0Y00 commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

Updated conflict diagnosis for a48d39dc. My local trial over main 55669240 (tree af03ca4c6a2b8cdcea1e1094da54fe4a5fc45c96) resolves two files and preserves all three overlapping behaviors. In gfx1013_compute_native.cpp, keep wave64 QuadCompare and main's _i64/_u64 high-word rules, including #3073's _i32_ destination exception. In gfx1013_direct_compute.inl, keep the #3068 explicit LOD gather helper with fixed table-bound SRV validation, the merged #3007 unfused MAD/MAC path, and both SCC overwrite classifications (s_andn2_wrexec_b64 and the #3073 bit counts).

Built compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump in dev and release. ctest --test-dir <build> --no-tests=error -j 1 -V -R '^(native_(direct_(container|mesh)|frozen_request|compute_pack|graphics_(interface_library|wqm_ir)|startup_request_cache_controls|salu_shift64_controls|rtv_variant_controls|gather_lod_controls|mad32_controls))$' passed 11/11 in each configuration with no skips. This is a local conflict trial. The published PR still needs an updated head and the preserved-timestamp .ps57in watcher case remains open.

@legacy-code-archaeologist

Copy link
Copy Markdown
Contributor

Opened #3138 targeting codex/native-shader-modules for the #3133 preserved/older-mtime .ps57in/.psin watcher invalidation case (verified native_compile_dxil_watch and ^native_.*_(controls|ir)$ 26/26). AI-assisted.

@lambirou

Copy link
Copy Markdown
Contributor

Cross-reference: an independent Windows receipt of the stacked compiler+runtime branch at b80513fd (compiler at a48d39dc) is posted in #3094. A 300 s diagnostic run reaches neither ExecuteIndirect nor a translated compute dispatch, so the runtime effect of the stack is not yet visible in the title path. The compiler-side fixture suite is unaffected by that caveat.

@lambirou

Copy link
Copy Markdown
Contributor

Independent compiler-side receipt for this branch at its head a48d39dc, run inside the stacked runtime worktree at b80513fd (Release, Windows 11 build 26300, MSVC 19.44.35228, Windows SDK/DXC 10.0.26100.0, AMD Radeon RX 9060 XT driver 32.0.32029.2010, debug layer unavailable).

native_direct_container, native_direct_mesh, native_frozen_request, native_compute_pack, native_graphics_interface_library, native_graphics_wqm_ir, native_salu_shift64_controls and native_startup_request_cache_controls all pass. The full fixed-mesh suite (20/20, WARP and hardware) is reported in #3094.

Copy link
Copy Markdown
Contributor

I independently tested the masked resource-selection path for #3210 on a48d39dc. A source-built raw gfx1013 PS selected between two 2D textures with distinct colors at each mip. The mixed and empty-arm draws each matched all 64 pixels (256 channels), in both guest wave32 and wave64, on RTX 4070 (32.0.16.2124) and in-box WARP (10.0.26100.10068). D3D12 reported zero errors and warnings. DXC 1.9.2602.17 emitted one nonuniform heap handle and one SampleGrad with coarse derivatives. The no-progress backedge refused. Changing only the horizontal helper's U in a desktop control changed (6,0) from green (mip 1) to red (mip 0) on both adapters.

I found one acceptance boundary in the implicit sample proof. When image_sample writes a VGPR that is also an input to the gradient, an earlier arm can replace that VGPR in the neighboring lanes before a later arm samples. The desktop projection computes the gradients from the entry values. In the fixture, changing the sample destination from v[8:11] to v[2:5] (UV is v[2:3]) and updating the export produces byte-identical desktop DXIL. This is a compiler observation and an unproven guest dependency. The original hardware behavior of the overlap case was outside my verification.

Source-built repro

Write these little-endian dwords to waterfall.bin. Use waterfall.pslayout with meshps1 256 256 64 guest_root and a waterfall.root compiled with rootsig_1_1 from RootFlags(CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED).

be9a047e befe0a7e be890380 100400ff 3e800000 7e0602f0 7e0c0f00 be8403ff
00000012 be8503ff 00fff000 be8603ff 04500000 be870380 00000000 360c0c81
be9c047e be98047e 7e3c0506 7d240c1e 8f1e851e f40c0404 3c000000 bf8cc07f
f0800f08 00240802 bf8c3f70 be983a18 bf85fff5 befe041c befe041a f800180f
0b0a0908 bf810000

Change 00240802 to 00240202 and 0b0a0908 to 05040302 for the overlap case. Compile both with compile_dxil <dxc-dir> <cache> gfx1013-raw-mesh-ps waterfall.bin waterfall.cso.

I tested a small follow-up in the image-coordinate decoder. For a projected implicit sample, refuse when a decoded spatial coordinate VGPR overlaps [VDATA, VDATA + popcount(DMASK)). This also checks NSA and packed coordinates at the point where their registers are decoded. With the guard, the overlap fixture refuses, the same eight GPU draws still match, and ctest --preset release --no-tests=error -R '^native_direct_container$' --output-on-failure passes with the new control. I used Codex to prepare the guard and ran verification locally.

@R0Y00
R0Y00 requested a review from KelboLive November 28, 2026 00:26
@R0Y00

R0Y00 commented Nov 28, 2026

Copy link
Copy Markdown
Owner Author

Integrated current compiler and graphics changes at 247530b. Debug and Release /O2 each passed all 12 selected source-built tests on Windows 11 26200.9974, including WARP 10.0.26100.9818 and RTX 4060 Laptop driver 32.0.16.1656 for the graphics sampler case. The new watcher control copies a conflicting slot-57 record with an older timestamp and verifies that the published manifest is withdrawn. The integration also preserves main's compute sampler fixture as a separate test.

cmake --build --preset dev --target compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump offscreen_check native_store_replay
ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^(native_direct_(container|mesh)|native_frozen_request|native_compute_pack|native_graphics_(interface_library|wqm_ir|sampler_heap_.*)|native_startup_request_cache_controls|native_compile_dxil_watch|native_salu_shift64_controls|native_rtv_variant_controls)$'

Repeat with the release preset. Please recheck the current head, in particular the merged compute operand and sampler paths.

Extract read_pixel_input_description() so watch/request paths share exact .psin/.ps57in parsing and conflict detection, compare canonical pixel-input descriptions against <key>.psdep, remove stale .psdep in batch compile_job when pixel inputs are empty, and verify stale preserved-mtime base/RTV sidecars and 0-byte .psdep retranslation in native_compile_dxil_watch_check.py.

Refs #3133

AI-assisted.
@lambirou

Copy link
Copy Markdown
Contributor

Independent check on the exact head 247530b0 in a clean worktree. No source changes were made for the verification.

cmake --build --preset dev --target compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump offscreen_check native_store_replay
ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^(native_direct_(container|mesh)|native_frozen_request|native_compute_pack|native_graphics_(interface_library|wqm_ir|sampler_heap_.*)|native_startup_request_cache_controls|native_compile_dxil_watch|native_salu_shift64_controls|native_rtv_variant_controls)$'

Repeated with --preset release.

  • Debug: 12/12 passed, 0 failed, 0 skipped.
  • Release: 12/12 passed, 0 failed, 0 skipped.
  • Includes native_graphics_sampler_heap_warp and _hardware, native_direct_container, native_direct_mesh, native_compute_pack, native_graphics_interface_library, native_graphics_wqm_ir, native_compile_dxil_watch, native_startup_request_cache_controls, native_salu_shift64_controls and native_rtv_variant_controls.

Environment: Windows 11 build 26300, MSVC 19.44.35228.0, Windows SDK/DXC 10.0.26100.0, WARP 10.0.26100.10068, AMD Radeon RX 9060 XT driver 32.0.32029.2010. The D3D12 debug layer was unavailable (0x887a002d). The head still needs a merge of newer main; this covers the compiler/compute/sampler paths requested on the current head. AI was used.

Bring main 57e9466 into #3091's 247530b head. Resolve the five overlapping
areas by retaining both features:

- keep compute request shape validation and derive wave32 from the packed state;
- serialize both sampler_heap and stride_srvs in the compute frontend cache;
- keep the current wave-size selection plus the packed-state virtual-wave path;
- prepare descriptor strides once and keep a single initialize call;
- keep the sidecar dependency retry and the native compute manifest revision check.
@lambirou

Copy link
Copy Markdown
Contributor

Opened #3241 to refresh this branch onto current main 57e94668. It is a merge-only PR targeting codex/native-shader-modules; your branch was not modified directly.

The merge keeps both sides in the five overlapping areas (compute request shape + wave32, sampler_heap + stride_srvs cache fields, wave-size selection + packed-state virtual waves, descriptor stride preparation once, sidecar retry + native compute manifest revision check). Validation at cead019e: 12/12 selected compiler/compute/sampler tests in Debug and 12/12 in Release, zero skips.

AI was used.

read_compute_request indexed state block A for the wave-size bit before validate_compute_request_shape enforced its 28-byte length. Build the request with the default wave32 value, run the shape check, and only then decode the bit.

Add a source-built request with a correctly keyed 24-byte state A to native_compute_clear and require the existing shape diagnostic.
Keep both the exact-width texture cases and the compiler stack's test registrations. In gfx1013_compute_native.h keep main's float/float2/float3 kinds, append packed_d16_x_uav and indexed_raw_srv, and keep both exact_texture_uav_channels and accepts_cbv_window. Use indexed_raw_srv as the decode upper bound. In gfx1013_direct_compute.inl keep exact_store and indexed, with the exact_store exception in the store gate and the indexed exception in the descriptor gate.
@R0Y00

R0Y00 commented Nov 28, 2026

Copy link
Copy Markdown
Owner Author

I refreshed the #3241 trial locally against main 9872074a after #2981, #3245 and #3244. The resolved compiler tree b4508b8a passed 12/12 Release /O2 checks, including direct containers and mesh, the compute pack, WQM IR, both RTX image cache-flag readbacks, and the wave64 EXEC scalar regression. The cache-mask resolution retains the indexed-pixel modifier checks and keeps the newly admitted hints on the existing fixed-descriptor read path.

ctest --test-dir out/build/release --no-tests=error --output-on-failure -j 1 -R '^(native_direct_(container|mesh)|native_frozen_request|native_compute_pack|native_graphics_(interface_library|wqm_ir)|native_startup_request_cache_controls|native_salu_shift64_controls|native_image_cache_flags_(controls|ps_hardware|cs_hardware)|native_wave64_exec_salu_hardware)$'

Windows 11 26200.9974, RTX 4060 Laptop driver 32.0.16.1656 and SDK/DXC 10.0.26100.0.

Main subsequently advanced to 0fe4cebc (#3255). The trial now has three conflicts in gfx1013_direct_compute.inl. Two are adjacent state and lane initialization edits. The output conflict combines #3255's flat, consecutive compute-derivative quads with the branch's virtual-wave dispatch shape. Please refresh #3241's source branch and keep a control for both shapes before rerunning current-head CI and review. The dependent #3094 still needs reconciliation with #2981, including the first-draw fixture and PSO fallback tracked in #3139.

lambirou and others added 4 commits November 28, 2026 03:28
Keep both shapes in the compute output: virtual waves finish as 64x1x1, flat compute-derivative quads as x*y*z, and the original dimensions otherwise; complete_compute_quads is set before the lane setup. Keep main's heap offset analysis and the branch's graphics/sampler descriptor branches, and take main's WREXEC validation and EXEC update path.
Absorb #3262's scalar64 source validation for s_cselect_b64 and s_not_b64, including VCC and EXEC sources, while keeping the branch's direct-compute paths.
A packed slot-67 group with more than one guest wave64 enters the virtual-wave scheduler only when it also has a conditional branch and a synchronizing instruction. Implicit derivatives have no packed-scheduler readback, so refuse them at the image opcode instead of compiling a shader whose guest quads cannot be reconstructed.

Add native_wave_virtual_derivative_controls: source-built packed slot-67 requests where explicit LOD with a branch and barrier and ordinary implicit both compile, and the combination is refused.
…sidecar-content-invalidation

shader: invalidate watch manifests when sidecar content changes with an older mtime

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent Release retest on the published 0b505c1c after #3138 landed. I built compile_dxil native_compute_pack_check native_frozen_request_check native_pixel_ir_dump and ran ctest --preset release --no-tests=error --output-on-failure -j 1 -R '^(native_compile_dxil_watch|native_direct_(container|mesh)|native_compute_pack|native_frozen_request|native_graphics_(interface_library|wqm_ir)|native_startup_request_cache_controls|native_rtv_variant_controls)$'. All nine passed with no skips on Windows 11 build 26200 and SDK/DXC 10.0.26100. That includes changed older-mtime sidecar invalidation and the unchanged sidecar cache control.

Against main at 6a1968a1, the merge still has conflicts in CMake, the direct compiler/cache and shader request/CLI files. A read-only three-way merge with the current #3094 head did not show textual conflicts for the #3138 delta. The next compiler head still needs to incorporate newer main changes and rerun hosted Windows CI. #3014 now targets main and overlaps the request helpers and compile_dxil.cpp; please preserve the watcher content comparison when integrating it.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Thanks for this. I reviewed head 0b505c1c against current main (c3204a9c). The opcodes all match the DXIL table, and the older-mtime watcher control from #3138 is on the head. Two things need fixing before this can land:

  1. It conflicts with main, and no CI has run on this head. git merge-tree --write-tree --name-only origin/main 0b505c1c exits 1 with conflicts in 7 files (22 hunks): CMakeLists.txt, direct_compute_cache.cpp, compute_native.cpp/.h, direct_compute.inl, shader_compute_request.cpp and compile_dxil.cpp. gh pr checks 3091 reports no checks. The shader: merge current main into the native shader module stack #3241 refresh doesn't contain this head (git merge-base --is-ancestor 0b505c1c <#3241 head> → 1, so shader: invalidate watch manifests when sidecar content changes with an older mtime #3138 is missing there). A refresh that contains 0b505c1c, then CI on that sha, would settle it.
  2. The direct mesh path culls edge-flagged primitives. gfx1013_direct_mesh.inl decodes each index with ir.binary("and", ..., "1023"). The repo's format is "each a 9-bit index with the edge flag in bit 9" (docs/experiments.md), and gfx2hlsl uses & 511u. A Python model of both decodes gives packed=0x20280600 direct=culled gfx2hlsl=(0, 1, 2) for the startup_mesh57_skeleton triangle with its edge flags (bits 9, 19, 29) set. Hardware fills that triangle. Masking with 511 (keeping the bit-31 null check), plus an edge-flag case in native_direct_mesh, would fix it.

Also still open from the earlier reviews: the #3255 virtual-wave/derivative control from the 03:16 comment, and RonLogic's guard for a VDATA range that overlaps the coordinates (v[2:5] over UV v[2:3] gave byte-identical DXIL).

Non-blocking:

  • The 5 new tests (direct_mesh, frozen_request, compute_pack, indexed_pixel_texture_, graphics_sampler_heap_) aren't matched by the pr preset or named in windows.yml (grep -c → 0), and the PR doesn't list a mutation for any of them. A red-on-mutant result per new check, or the CPU-only ones added to pr, would help. They also have no docs/experiments.md row.
  • if (compute && n == "s_bcnt1_i32_b64") can't be reached after shader: lower 64-bit scalar bit counts and bit scans in the direct compute path #3073's block, and the s_ff1_i32_b32 special case gives the same output as the general scan.

Environment: Linux, static review only (merge-tree, greps, Python decode model). I did no build, WARP or GPU run.

This comment was AI-assisted.

lambirou and others added 6 commits November 28, 2026 10:01
Keep #3138's sidecar_changed invalidation and the branch's compute dependency_changed/lost checks in the watch request gate.
Keep the shared graphics/compute request key helpers and pixel-input reader, including the .ps57in sidecar. Keep the BCNT64 compute block alongside the shared scalar-mask combiner. Accept main's raw-store cache-policy naming. Keep both --rekey and --prepare-compute-pack in the usage text.
# Conflicts:
#	src/gfx1013_compute_native.cpp
@R0Y00
R0Y00 merged commit 221ed27 into main Nov 28, 2026
5 checks passed
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.

6 participants