Skip to content

shader: add a compute fallback for indexed mesh draws - #606

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
Jess-Doit:shader/mesh-compute-fallback
Nov 23, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
Jess-Doit:shader/mesh-compute-fallback

Conversation

@Jess-Doit

@Jess-Doit Jess-Doit commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Change

Add --compute-fallback to the bounded mesh translator. An SM 6.0 compute dispatch writes positions, primitive indices and optional PARAM0 to a buffer. A vertex shader follows the generated indices and passes interpolated attributes to the translated pixel shader. This lets the source-built single-triangle fixture run on adapters without Mesh Shader Tier 1. Refs #498 and #546.

Verification

Tested 7477928 over f1f95cf on Windows 10 22H2 build 19045.6456 with MSVC 19.44.35230, SDK 10.0.26100.0 and DXC 1.9.2602.17. On GTX 1060 6 GB (32.0.15.6094) and in-box WARP (10.0.19041.5794), all six positive cases matched all 128 export bytes and all 1,024 pixels in Debug and Release, including independent changes to compute b0 and b1. The controls found a wrong guard at byte 76 with zero pixel differences, a collapsed index at byte 72 with 276 pixel differences, and a stale palette with 992 pixel differences and exact exports. The fallback reported zero D3D12 debug warnings and errors.

. .\tools\dev.ps1
$env:XBOX2WINDOWS_ADAPTER = 'GTX 1060'
foreach ($preset in 'dev', 'release') {
  cmake --build --preset $preset --target offscreen_check
  ctest --preset $preset --no-tests=error -V -R '^((mesh_.+|compute_mesh_texture|compute_to_pixel|pixel_aot_attribute)_(hardware|warp)|docs_links|offscreen_invalid_operation_warp)$'
}

Each preset had 8 passes and 18 native-mesh capability skips. The existing partial pixel-output checks each reported one D3D12 warning. With app-local Agility SDK 1.620.2 and WARP 1.0.22, all ten selected tests passed. The compute-produced texture fixture from #658 matched both palettes and caught the stale SRV at 276 pixels. The native depth fixture also passed its color and depth controls.

cmake --build out/build/app-local --target offscreen_check
ctest --test-dir out/build/app-local --no-tests=error -V -R '^(mesh_.+|compute_mesh_texture)_warp$'

The RTX 5070 and WARP review covers the pre-rebase commit 42d1b3d. On the original submission 951194c, freezing either compute binding caused the corresponding depth check to fail. The assembled indexed input produced identical fallback HLSL with the Windows LLVM disassembler, and DXC built it for an exact partial draw on both adapters.

Evidence and follow-up

The fixture uses existing source-built MIT-licensed inputs and validates the bounded one-group, one-triangle specialization. It compares full pixel and geometry readbacks with the existing CPU references.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the reproduction commands and results.
  • I included negative controls.
  • I updated the README and experiment notes.
  • The patch contains only source and documentation.

AI-assisted implementation and verification.

Copy link
Copy Markdown
Contributor

Independent verification on the submitted head 951194c1d804e7bc9d0df7a82da944daf37f4fd2. I tested Windows 11 build 26300.9974 with x64 MSVC 19.52.37029.0, Windows SDK 10.0.26100.0, and the D3D12 debug layer enabled. The adapters were RTX 4070 (32.0.16.2124) and WARP (10.0.26100.9818).

ctest --test-dir out/build/followup --no-tests=error -R '^mesh_(indexed_fallback|indexed_draw|attribute_draw)_(warp|hardware)$' -V
ctest --preset release --no-tests=error -R '^mesh_(indexed_fallback|indexed_draw|attribute_draw)_(warp|hardware)$' -V

All six tests passed in Debug and all six passed in Release (/O2), with zero skips. In both configurations, the negative controls detected the wrong guard at byte 76 with zero pixel differences, the collapsed index at byte 72 with 276 pixel differences, and the stale palette with 992 pixel differences and matching mesh exports.

I also tested the same six positive inputs through --mesh-indexed and --mesh-indexed-fallback, using the same source program and compiled pixel shader on both paths. This covered full and partial rasterization, independent b0/b1 changes, and both attribute palettes. On each adapter and in both configurations, each path matched all 1,024 reference pixels and its expected export trace. Those runs reported zero D3D12 debug errors or warnings. This verifies parity for the bounded, source-built profile.

AI-assisted.

@thepatrickworld

Copy link
Copy Markdown
Contributor

Independent AMD (RDNA4) result on 951194c. Not a code change; measurements only.

Environment

  • Windows 11 25H2, build 26200.9711
  • MSVC 19.44.35230 (toolset 14.44.35207), Windows SDK 10.0.26100.0, DXC 1.9.2602.17
  • AMD Radeon RX 9070 XT, vendor 1002, device 7550, driver 32.0.32029.2010
  • Preset dev, XBOX2WINDOWS_ADAPTER='AMD Radeon RX 9070 XT'
  • debug_layer=unavailable (Tools.Graphics.DirectX is NotPresent), so the negative controls ran without a clean debug layer — as the PR body already notes, they require one only when available.
  • Python environment built with Python 3.15.2 (requirements-dev.txt installs cleanly; the repository asks for 3.11 or newer).

Clean worktree of the PR head 951194c over 3f398b1.

Commands

out\pe-env\Scripts\python.exe -m pip install -r requirements-dev.txt
cmake --preset dev
cmake --build --preset dev --parallel 12 --target offscreen_check
set XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT
ctest --preset dev --no-tests=error -V -R "^mesh_indexed_fallback_(hardware|warp)$"

Observed — hardware, 9 cases, all as expected

full               mesh_exports bytes=128 matched=1  pixels=1024 mismatches=0
partial            mesh_exports bytes=128 matched=1  pixels=1024 mismatches=0
partial-change-b0  mesh_exports bytes=128 matched=1  pixels=1024 mismatches=0
partial-change-b1  mesh_exports bytes=128 matched=1  pixels=1024 mismatches=0
wrong-guard        matched=0  first_mesh_export_mismatch_byte=76  pixels=1024 mismatches=0
collapsed-index    matched=0  first_mesh_export_mismatch_byte=72  pixels=1024 mismatches=276
gradient-swap-False matched=1 pixels=1024 mismatches=0
gradient-swap-True  matched=1 pixels=1024 mismatches=0
stale-palette      matched=1  pixels=1024 mismatches=992

adapter=AMD Radeon RX 9070 XT vendor=1002 device=7550  driver=32.0.32029.2010
1/1 Test #220: mesh_indexed_fallback_hardware ... Passed  1.74 sec

Observed — WARP in the same build

Same nine cases, adapter=Microsoft Basic Render Driver vendor=1414 device=008c, driver 10.0.26100.9711: identical export bytes and pixel counts, including 276 for collapsed-index and 992 for stale-palette. mesh_indexed_fallback_warp Passed 1.10 sec.

Conclusion

On RDNA4 the compute + vertex fallback draws the source-built indexed triangle and matches the CPU reference on all 1,024 pixels in each of the four positive cases. The three negative controls reproduce exactly the byte offsets (76, 72) and pixel counts (0, 276, 992) reported on the GTX 1060, on a different vendor — so they detect the same faults rather than an adapter-specific artefact.

The run went through --compute-fallback, so it did not exercise the mesh pipeline: no mesh_shader_tier line appears in the log. This result therefore does not say whether this adapter supports Mesh Shader Tier 1.

AI-assisted.

@Jess-Doit
Jess-Doit force-pushed the shader/mesh-compute-fallback branch from 951194c to 42d1b3d Compare November 22, 2026 17:50

@MarlomMedeiros MarlomMedeiros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Community review + independent run on a newer adapter and OS than the reported GTX 1060 / Windows 10 setup.

Environment

  • Commit under test: 42d1b3d on base 8f57366 (current main at review time)
  • Windows 11 build 26300.10075, VS 2026 MSVC 19.52, Ninja, DXC from SDK 10.0.26100
  • ctest --preset dev --no-tests=error -R '^mesh_(indexed_fallback|indexed_draw|descriptor_swap)_(warp|hardware)$' -V: 6/6 passed
  • Hardware: NVIDIA GeForce RTX 5070 (vendor=10de device=2f04), driver 32.0.16.2135, D3D12 debug layer enabled, debug_errors=0 debug_warnings=0
  • mesh_indexed_fallback_hardware: mesh_exports bytes=128 matched=1, pixels=1024 mismatches=0 on every positive draw; wrong-guard, collapsed-index and stale-palette controls reported their expected mismatches
  • WARP: Microsoft Basic Render Driver, driver 10.0.26100.10068

Review notes

  • emit_compute_draw keeps the same expression lowering and cbuffer bindings as the mesh path (b0/b1, float4 deduplicated between both emitters); the compute stage reproduces the native trace layout at stride 128 with optional PARAM0 attributes after byte 80, and the vertex shader replays the generated index buffer via SV_VertexID.
  • The harness plumbing is honest about fallback: a separate compute PSO dispatches 1x1x1, the draw PSO binds the generated buffer as t1, and the capability probe prints mesh_fallback_shader_model=unsupported rather than silently succeeding.
  • Negative controls pin the interesting failure modes: a corrupted guard byte reports the exact export offset (byte 76) with zero pixel differences, collapsing the primitive to (0,1,1) reports byte 72 plus 276 pixel differences, and the stale-palette case separates export-exact from draw-wrong. Negative draws also assert a clean debug layer, matching the PR's claim.
  • The indexed_program splice ordering (loads before first wait, dereference before first buffer load, adds before export) is exercised end-to-end by the b0/b1 rebinding cases.

No blockers found. This lands on a clean base and does not overlap the exec-masked-region work in #651.

AI-assisted: yes. All reported checks ran locally on the adapter and driver listed.

@Jess-Doit
Jess-Doit force-pushed the shader/mesh-compute-fallback branch from 42d1b3d to 7477928 Compare November 22, 2026 18:50
@Jess-Doit

Copy link
Copy Markdown
Contributor Author

Rebased onto f1f95cf and resolved the draw-fixture overlap with #658. On 7477928, the indexed fallback passes in Debug and Release on the GTX 1060 and Windows 10 in-box WARP. App-local WARP passes all 10 selected tests, including both GPU-produced palettes and the 276-pixel stale SRV control. The PR description has the updated commands and results. Thanks for the independent checks on the earlier heads.

Copy link
Copy Markdown
Contributor

Independent run on the rebased head 747792888426d3ef5b9b2d9e1fb00ed72c9bf031 (parent f1f95cf). Windows 10 22H2 build 19045.6466, MSVC 19.44.35230, Windows SDK 10.0.26100.0, DXC 1.8.2502.11, Debug with /MTd. D3D12 debug layer unavailable on both adapters.

cmake --preset dev "-DINTAKE_PYTHON=$((Get-Command python).Source)" "-DDXC_EXECUTABLE=$dxc" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug
cmake --build --preset dev --parallel 4 --target offscreen_check
$env:XBOX2WINDOWS_ADAPTER = 'RTX 3060 Ti'
ctest --preset dev --no-tests=error -V -R '^mesh_(indexed_fallback|indexed_draw)_(hardware|warp)$'
  • Hardware: RTX 3060 Ti (10de:2414), driver 621.24 (32.0.16.2124 via DXGI). Both fallback and native indexed CTests passed.
  • Software: In-box WARP (1414:008c), driver 10.0.19041.5794. Fallback passed.
  • Skipped: Only mesh_indexed_draw_warp, with mesh_shader_tier=unsupported.

On both adapters the fallback matched all 128 export bytes and 1,024 pixels in each of the six positive cases. Controls gave the expected results: wrong guard at byte 76 with zero pixel mismatches, collapsed index at byte 72 with 276 pixel mismatches, and stale palette with 992 pixel mismatches and matching exports.

I also used mesh_fallback_check.indexed_program() and its full and partial inputs to compare --mesh-indexed-fallback with traced --mesh-indexed on the RTX 3060 Ti, sharing the compiled pixel shader and using each path’s expected trace layout. Both paths matched the same 1,024-pixel references for both inputs and exited 0.

AI-assisted. All reported tests ran locally.

@Jess-Doit
Jess-Doit force-pushed the shader/mesh-compute-fallback branch from 7477928 to 28bbc42 Compare November 23, 2026 00:33
@R0Y00
R0Y00 merged commit b9d0b25 into R0Y00:main Nov 23, 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