Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2038,6 +2038,12 @@ if(TARGET compile_dxil AND EXISTS "${DXC_BIN_DIR}/dxcompiler.dll" AND EXISTS "${
add_test(NAME native_fixed_mesh57_buffers_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_buffers_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_TEST_NATIVE_MESH57_BUFFERS=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
add_test(NAME native_fixed_mesh57_published_pair_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_published_pair_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_TEST_NATIVE_MESH57_BUFFERS=1;X2W_TEST_NATIVE_MESH57_PUBLISHED_PAIR=1;X2W_ALLOW_PUBLISHED_MESH57_PAIR=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
add_test(NAME native_fixed_mesh57_published_pair_refusal_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_published_pair_refusal_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_TEST_NATIVE_MESH57_CBV_UAV=1;X2W_TEST_NATIVE_MESH57_PUBLISHED_PAIR=1;X2W_ALLOW_PUBLISHED_MESH57_PAIR=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
add_test(NAME native_fixed_mesh57_constant_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_constant_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_TEST_NATIVE_MESH57_CONSTANT=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
Expand Down
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"displayName": "Windows pull request smoke tests",
"filter": {
"include": {
"name": "^(bcpack_all_formats(_golden_control)?|startup_bcpack_storage|desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_mesh57_real_shape|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_(dispatch|constants|count)_inline_warp|startup_inline_retire_(on|control)_warp|startup_resource_retire_title_inline_warp_debug0|startup_table_lock_(control_)?warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_indirect_mesh_cache_heap(_wide)?_warp|runtime_mesh86_cache_cli_check|startup_shader_cache_key|startup_present_readback|startup_present_planes(_control)?|startup_present_composite_(warp|overlay_removed_control_warp)|startup_mesh_title_snapshot_warp|startup_list_copy_(warp|title_snapshot_warp|validation(_[a-z_]+_control)?)|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|startup_stage_package|startup_compute_packed_d16_x_uav_reference|native_.*_(ir|dxil|controls)|native_direct_mesh|startup_triage_run)$"
"name": "^(bcpack_all_formats(_golden_control)?|startup_bcpack_storage|desktop_root_signature|era_heap_(allocation|failure)|xmem_shim_mapped_pages|cpu_aot_fuzz_smoke|cpu_archive_texture_gpu_warp|dual_uav_warp|spirv_.*_warp|static_exe_intake|descriptor_heap_paging(_swapped)?_warp|startup_launch|startup_mesh57_real_shape|startup_mesh57_runtime(_[a-z]+)?_warp|native_fixed_mesh57_published_pair(_refusal)?_warp|startup_tools_lint|startup_gfx2hlsl_cvt_off_f32_i4_controls|startup_gfx2hlsl_sad_hi_msad_controls|startup_indirect_(dispatch|count_split|draw(_indexed)?|mesh(_xmem_arguments(_skip_wait)?)?|counts_control)_warp|startup_indirect_(dispatch|constants|count)_inline_warp|startup_inline_retire_(on|control)_warp|startup_resource_retire_title_inline_warp_debug0|startup_table_lock_(control_)?warp|startup_indirect_mesh_lease_warp_dual(-trace(-disabled)?)?|startup_indirect_mesh_cache_heap(_wide)?_warp|runtime_mesh86_cache_cli_check|startup_shader_cache_key|startup_present_readback|startup_present_planes(_control)?|startup_present_composite_(warp|overlay_removed_control_warp)|startup_mesh_title_snapshot_warp|startup_list_copy_(warp|title_snapshot_warp|validation(_[a-z_]+_control)?)|xmem_(run_break_readers|cross_call_merge|placeholder_split|map_split_first)(_[a-z_]+)?|startup_dstorage_break_window(_[a-z_]+)?|xmem_page_runs_device(_join)?_warp|linear_buffer_backing_share_warp|startup_stage_package|startup_compute_packed_d16_x_uav_reference|native_.*_(ir|dxil|controls)|native_direct_mesh|startup_triage_run)$"
}
}
},
Expand Down
19 changes: 16 additions & 3 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -10703,7 +10703,17 @@ colour pairs with `offscreen_check --mesh-indexed`; lanes whose flat attribute 0
red is at or below 0.5 are killed, so two of the four triangles are dropped.
Each draw must match the CPU rasteriser without them, and the same mesh with the
pixel stage that does not kill must differ at exactly the 115 killed pixels.
Nothing here shows that a runtime path loads the pair.
The published pair is legacy input and stays unavailable without
`X2W_ALLOW_PUBLISHED_MESH57_PAIR=1`; the default native-only run rethrows the
exact `mesh57_group_index` refusal before reading the manifest or either CSO.
The runtime path that loads the opted-in pair, the native-first fallback order,
the manifest-derived reads and the revision tie are described in
[fixed mesh pipelines through slot 57](experiments/native-fixed-mesh57.md#published-pair-for-the-r1-group-index-exchange);
`startup_mesh57_runtime_{warp,hardware}` exercises them. Its gate control runs
the same on-disk pair first without the opt-in and requires a cleared target,
no forwarded `DispatchMesh` and the native refusal, then with the opt-in and
requires 1,024 matching pixels. The native-priority and non-R1-refusal controls
also set the opt-in, so they exercise the gate rather than its default refusal.

The
`startup_mesh57_skeleton_depth_{warp,hardware}` CTest checks draw a
Expand All @@ -10719,8 +10729,11 @@ stage with a colour export before its null export, a pair whose pixel stage
does not match its key, and the mesh shapes the paired path refuses next to
the depth-only pixel stage; it checks that `pending_keys` keeps
the pair pending until both `.ms57.cso` and `.ps57.cso` are complete. The
runtime does not load slot 57 results yet, so these draws are not submitted
through the guest path.
`startup_mesh57_runtime_{warp,hardware}` guest path loads the published pair
for the buffer-view profile, after the one R1 native refusal, only when
`X2W_ALLOW_PUBLISHED_MESH57_PAIR=1` is set, and submits these draws; the
offline depth-only readback above remains a separate
`offscreen_check` comparison.

The pending scan checks the DXContainer header and file length for every
required slot 57 bytecode artifact. A `ps none` result needs the mesh artifact
Expand Down
2 changes: 1 addition & 1 deletion docs/experiments/native-compile-dxil-rekey.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This mode runs without `SDK_DIRECTORY` or DXC:
(`.txt`, `.fail`, `.cso`, `.psdep`).
- Validates and recomputes keys in parallel using the current output revision
strings (`x2w-startup-shader-29`, `x2w-startup-shader-29cs`,
`x2w-startup-mesh-57-3` via shared helpers in `src/shader_compute_request.cpp`),
`x2w-startup-mesh-57-4` via shared helpers in `src/shader_compute_request.cpp`),
while the readers retain `x2w-startup-shader-28` and `x2w-startup-shader-28cs`
input compatibility.
- Rewrites `.psin` and `.rtv` payloads under their updated keys while leaving all
Expand Down
62 changes: 62 additions & 0 deletions docs/experiments/native-fixed-mesh57.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,68 @@ cmake --build --preset dev --target startup_indirect_draw_indexed
ctest --preset dev --no-tests=error --output-on-failure -R '^(native_fixed_mesh57(_mask|_mrt)?|startup_indirect_mesh_(request|cache))_(warp|hardware)$'
```

## Published pair for the R1 group-index exchange

The native mesh frontend still refuses one R1 group-index exchange shape
(`0xbefe0481`, `native compute +0x...: mesh group-index exchange shape or entry
state is not covered`). For a buffer-view profile (`X2WM574`), native
translation is attempted first. The publisher's `.ms57.cso` / `.ps57.cso` pair
is legacy input, so it is disabled by default. Set
`X2W_ALLOW_PUBLISHED_MESH57_PAIR=1` to permit the fallback; native translation
still wins whenever it succeeds. Only the exact `mesh57_group_index` refusal
may fall back. A different native refusal is rethrown, as are profiles that
need pixel spans or a directly indexed resource heap. Without the opt-in, the
exact native refusal is rethrown before the manifest or either CSO is opened,
including in the launchers' default `X2W_NATIVE_SHADERS_ONLY=1` mode. With the
opt-in and no published pair, the pipeline is refused.

The fallback reads `<key>.ms57.txt`, a version 4 mesh manifest:

```text
x2w-manifest 4
stage ms
srv 0 buf table 1 0 bytes 388
```

The `srv` lines supply the reads in translated register order. Each carries
the table byte offset or `root` parameter and the accessed byte span computed
from the translated mesh stage's buffer loads. A descriptor whose usable range
is shorter than that span is refused, and each table offset resolves its own
record rather than aliasing the first descriptor. The profile's view entries
are checked for the root parameter and direct/table kind, but their order is not
used. The request-key revision is `x2w-startup-mesh-57-4`; an older pair or a
version 1 manifest is not loaded.

The `startup_mesh57_runtime_{warp,hardware}` fixture creates the guest root
from the exact serialized root the request publisher compiled against. The
request key, profile key and CSO names therefore agree. A GPU compute pass
writes the `DispatchMesh(1,1,1)` record, the direct queue waits on its fence,
and the readback is compared with the CPU rasteriser. The gate control runs the
same on-disk pair twice in native-only mode. Without
`X2W_ALLOW_PUBLISHED_MESH57_PAIR`, the target must stay cleared, the indirect
census must report no forwarded mesh call, and stderr must carry the native
`mesh group-index exchange shape or entry state is not covered` refusal. With
the opt-in, the same bytes must load, report `dispatchmesh 1` and match all
1,024 pixels. The control also checks that the pair bytes did not change between
the two runs; each subprocess gets an explicit environment with inherited
switches removed. The fixture expects `dispatchmesh 1` and 1,024 matching pixels
for the opted-in compiled pair and for a two-descriptor table whose second
record supplies the colours. A four-byte view against the 388-byte accessed
span and a version 1 manifest must each leave the target cleared and forward no
mesh call. Missing or truncated MS/PS bytecode does the same, and a restored
pair must draw again. The `native_fixed_mesh57_published_pair_{warp,hardware}`
control places an unusable pair beside a native-translatable profile with the
opt-in set: the native translation must still win. The
`native_fixed_mesh57_published_pair_refusal_{warp,hardware}` control places the
same pair beside a profile whose native refusal is not the R1 shape, also with
the opt-in set; that refusal must stay a refusal instead of falling back. Run
`ctest --preset dev --no-tests=error -R '^startup_mesh57_runtime_(warp|hardware)$' -V`
to reproduce the gate control.

Mesh pipelines no longer receive the vertex rectangle-list selector at the
start of their `cbuffer`. That word shifted the two mesh root constants by one
and made the shader read a zero vertex count, which rendered a black target.

The three fixture variants use one color target, six color targets with depth/stencil, and the same six with a red-only target-zero write mask. The six-target formats are 29, 28, 28, 28, 34 and 28, with depth/stencil format 20. Back-face culling, counterclockwise front faces, greater-or-equal depth, depth writes and stencil replacement are enabled. The four-by-two GPU readback has a single covered texel at (2,0). It is white with all channels enabled or red with the narrower write mask. Depth/stencil at that texel changes from 0.25/3 to 0.5/7. The other color attachments retain their clear values. Changing a fixed descriptor word or removing a color attachment produces no color or depth/stencil change.

The ten tests above passed on the working tree based on `671b9ac`, Windows build 26200, with the debug layer enabled on WARP and an NVIDIA GeForce RTX 4060 Laptop GPU (driver 32.0.16.1656).
Expand Down
4 changes: 3 additions & 1 deletion docs/startup-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ loop iteration after an EXEC write. The two cache keys advance together.
Revision 21 refuses a compute lane-mask form that revision 20 translated (`s_and_b32 M, X, exec_lo` with X data).
Revision 20 decodes MTBUF/MUBUF format 50 (`R10G10B10A2_UNORM`) in the run-time FORMAT switch.
Revision 19 folds `s_mov_b32` from a scalar register that holds a plain constant, so later reads of the copy use the constant word. The fixed slot 57 mesh
(`x2w-startup-mesh-57-3`) key stays, because that shader is not translated from guest code.
key stayed at its then-current revision because that shader is not translated from guest code; it is now `x2w-startup-mesh-57-4`, tied to the version 4
mesh manifest and its opt-in published-pair fallback.
Revisions before 19 read a register copied from a constant as a run-time value.
Revision 18 preserves the sign of zero in floating-point min, max, min3, max3 and med3.
Revisions before 17 lower `v_med3_f32` through a branchless median, which returns the smaller of the
Expand Down Expand Up @@ -1844,6 +1845,7 @@ ctest --preset dev --no-tests=error -R '^startup_hook_(window|overlap)$' -V
| `X2W_PIPELINE_COLOUR=1` | diagnostic only, debug switch, in render mode: a `DrawInstanced`, `DrawIndexedInstanced` or `ExecuteIndirect` draw that draws nothing gets one flat marker tile in render target 0, in a colour taken from its pipeline key, and logs `x2w-draw colour #rrggbb for <key> <reason>` once per key ([details](experiments/pipeline-colour-fallback.md)). Not a fallback: the refused draw still draws nothing, and the tiles can tint later passes. Unset, nothing is drawn or logged |
| `X2W_SHADER_CACHE=<dir>` | translation cache: the runtime writes source requests `req_<key>.{a,b,root}`, when needed RTV variants `req_<key>.rtv`, and for device slot 67 compute pipelines `req_<key>.{desc,sa,sb,data,root,c67}` (see [Compute pipeline requests](#compute-pipeline-requests)). A console pipeline that an `ExecuteIndirect` draw (list slot 61) refuses writes the same request as a direct draw, once per pipeline, and draws nothing (`startup_indirect_requests_warp`). Only direct draws poll for its manifest, so such a pipeline stays in the `missing` count until a direct draw uses it; the `x2w-render totals` line counts `pipelines first looked up by ExecuteIndirect N`. This is a per-process lookup count. Check for the ready marker `req_<key>.a` to confirm a complete request is available. Run `tools/startup/gfx2hlsl.py --pending <dir>` while the process is running, or start the run with `run.ps1 -Translate` (see [Translating shaders during a run](#translating-shaders-during-a-run)). Active draws poll for an absent manifest at most once per second per pipeline and use the published translation on a subsequent draw. The translator compiles `.vs.cso` and `.ps.cso` with `fxc.exe`: `X2W_FXC`, else the Windows SDK 10.0.26100.0 copy, else the newest `Windows Kits\10\bin\<version>\x64`, else `PATH`. When none exists it writes `<key>.fail` naming `X2W_FXC` without publishing a new manifest. `X2W_FXC=` (empty) publishes the manifest alone. Rerun `--pending` with compilation enabled to fill in missing bytecode for an existing manifest. At its first cache lookup the runtime starts a change feed on the directory (`ReadDirectoryChangesW`, top-level file names), then lists the directory's top-level file names once on the feed's thread and logs `x2w-draw cache index: <n> names in <ms> ms; change feed <state>` (`src/startup_stubs/cache_index.h`). A `<variant>.mesh57-state` profile is opened only when that listing has its name, so a profile written while the process runs is read by the next process. The request-part and compute-marker probes (`req_` names, which only runtimes write) skip the disk for a name that is absent from the listing and from this process's own writes. The probes for `<key>.txt` (graphics and compute manifests and the slot 57 base manifest) and `<key>.cs.hlsl` skip it only while the change feed is reading and was reading before the listing began, so a file the translator writes later is found once its change record arrives. After a dropped batch or a feed error they use the disk again. A compute manifest retry (an absent, stale or unmarked `<key>.txt`) whose `<key>.*` names have no change record from the feed since its last miss repeats that miss without a file-system call; the feed records created, removed, renamed and rewritten files, and without a reading feed every retry looks on disk. Every 10 s while probes run, `x2w-draw cache probes (skipped as absent/on disk): ...` gives each probe's counts (and the compute retries repeated without I/O), the feed state, records and added names, the lookups that found a name added after the listing, and contradictions (a write that found a file the index had reported absent). |
| `X2W_NATIVE_SHADERS=<dir>` (`run.ps1 -NativeShaders <dir>`) | experimental, in render mode: translates device slot 67 compute requests in the stand-in with the C++ compiler; `<dir>` holds `dxcompiler.dll` and `dxil.dll`. See [Translating compute programs in the stand-in](#translating-compute-programs-in-the-stand-in) |
| `X2W_ALLOW_PUBLISHED_MESH57_PAIR=1` | opt-in, in render mode with `X2W_NATIVE_SHADERS`: permits the buffer-view slot 57 path to load a publisher's `.ms57.cso` / `.ps57.cso` pair after native translation refuses with the exact `mesh57_group_index` code. Native translation still runs first. Unset, the pair is ignored and that native refusal is rethrown before the manifest or a CSO is opened, including with `X2W_NATIVE_SHADERS_ONLY=1`. See [fixed mesh pipelines through slot 57](experiments/native-fixed-mesh57.md#published-pair-for-the-r1-group-index-exchange) |
| `X2W_D3D12_LINEAR_BUFFERS=1` or `=copy` | opt-in backing for linear buffers placed at a title address (device slot 133, initial state `COMMON`): shared where the adapter, extent and memory allow it (private allocations larger than 256 MiB are skipped only with `X2W_D3D12_CAP_EXISTING_HEAP=1`), otherwise copied from title memory at each submission, otherwise the default backing is kept and the refusal recorded; `copy` never shares. Unset or `0`, slot 133 keeps its default backing. See [Linear buffer backing (device slot 133, opt-in)](#linear-buffer-backing-device-slot-133-opt-in) |
| `X2W_D3D12_CAP_EXISTING_HEAP=1` | opt-in 256 MiB (`unplaced_existing_heap_allowed`) allocation-size cap on `OpenExistingHeapFromAddress` in device slot 133 (`startup_slot133_heap_cap_*`). Unset (default), private allocations larger than 256 MiB keep the formerly aliased path: a capped copied placement is refused by `CopyBufferRegion` (list slot 15) as `title_backed_source`, losing a late guest write made after recording and before submit. Set, allocations larger than 256 MiB skip `OpenExistingHeapFromAddress` so multi-GiB startup blocks are not pinned in `WorkingSetSize` and `NonLocal` GPU memory |
| `X2W_D3D12_ROOT_SRV_AT_DRAW=1` | opt-in, render mode: a graphics root SRV (slot 44) without an upload mapping is not copied into the upload ring, since no draw reads that desktop binding (default: a 64 KiB copy at every slot 44 call). Translated draws copy the SRV themselves and are unaffected (`startup_root_srv_draw_*`). See [the experiment note](experiments/startup-root-srv-at-draw.md) |
Expand Down
Loading
Loading