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
38 changes: 37 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,38 @@ endforeach()
get_filename_component(DXC_BIN_DIR "${DXC_EXECUTABLE}" DIRECTORY)

if(TARGET compile_dxil AND EXISTS "${DXC_BIN_DIR}/dxcompiler.dll" AND EXISTS "${DXC_BIN_DIR}/dxil.dll")
foreach(backend warp hardware)
add_test(NAME native_fixed_mesh57_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
add_test(NAME native_fixed_mesh57_mrt_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_mrt_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_TEST_NATIVE_MESH57_MRT=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
add_test(NAME native_fixed_mesh57_varying_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_varying_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_TEST_NATIVE_MESH57_MRT=1;X2W_TEST_NATIVE_MESH57_VARYING=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
add_test(NAME native_fixed_mesh57_uint_heap_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_uint_heap_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_TEST_NATIVE_MESH57_UINT_HEAP=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
add_test(NAME native_fixed_mesh57_pixel_heap_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_pixel_heap_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_TEST_NATIVE_MESH57_PIXEL_HEAP=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
add_test(NAME native_fixed_mesh57_waterfall_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_waterfall_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_TEST_NATIVE_MESH57_WATERFALL=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
add_test(NAME native_fixed_mesh57_waterfall_fine_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_waterfall_fine_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_TEST_NATIVE_MESH57_WATERFALL=1;X2W_TEST_NATIVE_MESH57_FINE_LOD=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
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_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}")
add_test(NAME native_fixed_mesh57_mask_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh)
set_tests_properties(native_fixed_mesh57_mask_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "X2W_TEST_NATIVE_MESH57=1;X2W_TEST_NATIVE_MESH57_MRT=1;X2W_TEST_NATIVE_MESH57_MASK=1;X2W_NATIVE_SHADERS=${DXC_BIN_DIR}")
endforeach()
add_executable(native_store_replay tests/native_store_replay.cpp tests/desktop_gpu.cpp)
target_include_directories(native_store_replay PRIVATE src tests)
target_link_libraries(native_store_replay PRIVATE x2w_shader_compiler d3d12 dxgi d3dcompiler)
Expand Down Expand Up @@ -1974,7 +2006,7 @@ if(TARGET compile_dxil AND EXISTS "${DXC_BIN_DIR}/dxcompiler.dll" AND EXISTS "${
foreach(adapter IN ITEMS warp hardware)
add_test(NAME startup_native_graphics_draw_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/startup_native_graphics_draw_check.py"
"$<TARGET_FILE:startup_stream_consumer>" "$<TARGET_FILE:compile_dxil>" "${DXC_BIN_DIR}" ${adapter})
"$<TARGET_FILE:startup_stream_consumer>" "${DXC_BIN_DIR}" ${adapter} "$<TARGET_FILE:compile_dxil>")
set_tests_properties(startup_native_graphics_draw_${adapter} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77)
endforeach()
foreach(backend IN ITEMS hardware warp)
Expand Down Expand Up @@ -2007,6 +2039,10 @@ if(TARGET compile_dxil AND EXISTS "${DXC_BIN_DIR}/dxcompiler.dll" AND EXISTS "${
add_test(NAME native_compute_pack COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/native_compute_pack_check.py" "$<TARGET_FILE:compile_dxil>"
"$<TARGET_FILE:native_compute_pack_check>" "${DXC_BIN_DIR}")
add_test(NAME native_compute_pack_hardware COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/native_compute_pack_check.py" hardware "$<TARGET_FILE:compile_dxil>"
"$<TARGET_FILE:startup_stream_consumer>" "${DXC_BIN_DIR}")
set_tests_properties(native_compute_pack_hardware PROPERTIES SKIP_RETURN_CODE 77)
foreach(adapter IN ITEMS warp hardware)
foreach(case IN ITEMS r rg rgb array volume rgba sparse)
add_test(NAME native_image_store_exact_width_${adapter}_${case}
Expand Down
2 changes: 2 additions & 0 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -17959,6 +17959,8 @@ python -B tests/docs_links_check.py
`startup_resource_retire_reasons` drives the `Held` attribution line; `startup_resource_retire_views` proves the
design-B keep cases (a live slot stays reboundable after final `Release()` and completed fences). The tables above record contributors' local executable runs. The fixtures validate the retention behavior independently. Refs #2379, #2679, #2719, #1199.

See [fixed mesh pipelines through slot 57](experiments/native-fixed-mesh57.md) for the source-built indirect-draw fixtures.

## Binary16 normalized integer conversions (`v_cvt_norm_i16_f16`, `v_cvt_norm_u16_f16`) across VOP1/VOP3/DPP16/DPP8/SDWA in pixel_aot

[The pixel shader translator](../tools/pixel_aot.py) adds 10 exact binary16 normalized integer conversion forms across all 5 encodings (counted in both `docs/coverage/gfx1013.tsv` and `docs/coverage/rdna2.tsv`):
Expand Down
82 changes: 82 additions & 0 deletions docs/experiments/native-fixed-mesh57.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Fixed mesh pipelines through device slot 57

The varying fixture sends two distinct values through PARAM12.xy to the pixel shader. With the six-attachment configuration the covered texel reads back as `0xffff00ff`. A mismatched fixed descriptor and a missing color attachment each preserve the clear color. Run `ctest --preset dev --no-tests=error -R '^native_fixed_mesh57_varying_(warp|hardware)$' -V` to reproduce.

For an independently supplied raw pixel stage, `compile_dxil SDK CACHE gfx1013-raw-mesh-ps INPUT OUTPUT` reads a sibling `.pslayout` containing `meshps1 ENABLE ADDRESS WAVE_SIZE` as decimal integers. ENABLE and ADDRESS are the pixel input masks. WAVE_SIZE is 32 or 64. Append `guest_root` to load the corresponding serialized 1.1 root signature from the sibling `.root` file. A raw mesh producer using the same interface specifies `packed_parameters` in its `.mslayout`. Each PARAM occupies one signature register, following position at register zero. Channels with conflicting interpolation modes in one PARAM require a different layout.

The source-built fixture creates a fixed pipeline with guest MS and PS instructions. The stand-in translates both to DXIL using its C++ shader library, creates a desktop mesh PSO and submits a guest command-list slot 61 indirect command. A GPU compute pass supplies the dispatch arguments. The tested interface uses an empty guest root, one to eight single-sample color attachments, explicit rasterizer, blend, depth and stencil state, and an MS with no resource bindings. The PS exports a constant to color target zero.

From the x64 Windows build environment:

```powershell
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)$'
```

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).

## Per-pixel texture selection

The `native_fixed_mesh57_waterfall_{warp,hardware}` fixture draws a triangle covering eight pixels. The guest PS uses READFIRSTLANE, CMPX, an indexed descriptor load, IMAGE_SAMPLE and a WREXEC retry. Neighboring pixels select different Texture2D views. With a unit UV gradient the two views return red and green from mip 1. The `waterfall_fine` variant holds UV constant and both views return blue from mip 0. The shader computes quad derivatives before sampling the per-pixel texture. Both gradient cases passed on WARP and the RTX 4060 Laptop with the debug layer enabled. Run `ctest --preset dev --no-tests=error -R '^native_fixed_mesh57_(pixel_heap|waterfall(_fine)?)_(warp|hardware)$'` to reproduce.

## Exact state records

Set `X2W_SHADER_CACHE` to the request cache and `X2W_MESH57_CAPTURE_STATE=1` to retain the fixed creation state when a matching root consumes a mesh pipeline. A `req_<variant>.s57` file contains the little-endian 64-bit stage/root request key, three little-endian 32-bit lengths, and the corresponding byte spans for the normalized descriptor, register block A and register block B. The stand-in clears only the captured root and span pointer fields at DWORD-pair indices 0, 1, 3, 5 and 13. It preserves the lengths and other fields. The variant key extends the existing stage/root key with those three length-prefixed spans. Distinct fixed states can coexist for one stage pair. The fixture overwrites both blocks after creation and checks their archived bytes for accepted and refused variants.

Native preparation reads a separately reviewed `<variant>.mesh57-state` profile from the cache. Its versioned Windows x64 header is defined by `Mesh57Profile` in `src/startup_stubs/mesh57_profile.h`. The header supplies the MS entry layout and desktop fixed-function state. The file ends with the exact descriptor, register blocks, serialized root and both guest programs. The stand-in compares every byte before building a PSO. The fixture authors this profile from its own known inputs. A captured register block alone does not establish the desktop rasterizer state or MS entry layout.

The source-built `native_fixed_mesh57_constant_{warp,hardware}` tests exercise
one reviewed MS root-constant block with a deferred guest root. The version 3
sidecar stores the physical SGPR, guest root index and DWORD count after the
pixel entry. Slot 61 packs all written words into desktop MS b0 after checking
the creation root and the compiler's binding metadata. Changing guest root 4
(b5, space 2) changes the rendered green channel from 64 to 191 on the same
PSO. A missing word preserves the clear color. This profile supports one block
of up to eight words.

Run `ctest --preset dev --no-tests=error -R '^native_fixed_mesh57_buffers_'`
for the version 4 fixed mesh raw SRV fixture. One slot 61 command reads root
table 0 at byte 2848, root table 1 at bytes 32 and 96, a root 3 byte buffer
at offset 4, and the root 4 constant. Each contributes distinct bits to an
exported value. The expected RGBA at (2,0) is (255,62,255,255). A four-byte
view for an eight-byte span, a readable CPU address outside a GPU allocation,
and a missing root 4 word each preserve the clear color. Static tables share
immutable descriptor pages with other recorded commands on the same desktop
allocator; its queue fences govern page reuse.

The version 5 mesh profile enables one directly indexed R32_UINT buffer read
alongside the static bindings. The compiler supplies the root word and mask.
Run `ctest --preset dev --no-tests=error -R '^native_fixed_mesh57_uint_heap_'`.
The fixture uses two different first elements in one GPU buffer. Selectors
147 and 151 yield RGBA (64,62,64,64) and (191,62,191,191). Replacing view
147 with the second view yields the latter color; shortening the view to one
element yields (0,62,0,0) when reading element 1. A float SRV, absent slot
and out-of-range selector preserve the clear color. The guest source heap
and resource are released after recording and before submission.

The version 6 mesh profile also binds pixel texture reads from the directly
indexed guest resource heap. An eight-DWORD descriptor load must select a
32-byte-aligned slot within a proven interval. At recording time, each slot
in that interval must contain a registered float or normalized texture SRV
of the expected dimension, or an explicit typed null. The private desktop
heap retains the selected views for the recording and reserves separate
slots for the mesh-stage buffer selector and static bindings.

Run `ctest --preset dev --no-tests=error -R '^native_fixed_mesh57_pixel_heap_'`.
With the same mesh and pixel programs, changing root 4 selects guest slot 32
or 36. The source-built test reads back red or green respectively. Both SRVs
expose mip 1 and both textures have a blue mip 0. A typed null reads as
transparent black. An unregistered slot or an array view in the Texture2D
interval preserves the opaque clear color.

For offline fixed mesh pixel translation, `tools/startup/mesh57_pixel_entry.py`
takes a `req_<key>.ps57`, its creation archive `req_<variant>.s57`, and a
reviewed `<variant>.mesh57-state`. It checks the two content keys and compares
all six input spans before printing the `meshps1` line for the offline
compiler. The enable mask, address mask and wave size come from the reviewed
pixel entry. A creation archive alone preserves the two register blocks but
does not assign hardware register meanings to their offsets. Reproduce the
source-built positive and altered-stage controls with
`ctest --preset dev --no-tests=error -R '^native_direct_mesh$'`.
38 changes: 38 additions & 0 deletions docs/experiments/native-startup-request-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,44 @@ and compute (`x2w-startup-shader-29cs`, `req_<key>.c67`) requests, publishes run
manifests (`<key>.vs.cso` / `<key>.ps.cso` or `<key>.cs.cso`, followed by `<key>.txt`), and loads directly through
the startup runtime cache loaders on WARP and hardware without manual renaming or conversion.

## First dispatch of a slot-67 compute request

With `X2W_NATIVE_SHADERS` enabled, the runtime retains the six immutable parts
used to publish each new compute key. First dispatch takes those bytes and checks
their extents before invoking the ordinary C++ translator. Evicted requests use
the disk reader, which also verifies the key. The capture files remain available
for independent replay.

`X2W_NATIVE_COMPUTE_REQUEST_CACHE_MIB` sets the per-process byte budget from 0
through 256 MiB. The default is 32 MiB. Zero selects disk reads. The queue holds
at most 4,096 keys, evicts the oldest retained request first and releases each
snapshot on consumption. The render totals report hits, misses, evictions,
retained bytes and retained requests every 300 frames. Run
`ctest --preset dev --no-tests=error -R '^native_frozen_request$'` for the
ownership, budget, eviction and malformed-description controls.

### Prewarming captured compute requests

`compile_dxil --prepare-compute-pack REQUEST_DIRECTORY CACHE_DIRECTORY 0` validates
the six capture parts and prepares the same entry-zero frontend used at first dispatch.
It writes `CACHE_DIRECTORY/compute-0.pack` atomically. Each record contains either
DXIL IR with its binding layout or the exact typed frontend refusal. Other errors
are printed per request, omitted from the pack, and cause a nonzero command status.
If every input fails with an ordinary error, an existing pack is preserved.

Set `X2W_NATIVE_COMPUTE_PACK` to the absolute pack path before startup. The runtime
loads the index once when native compute requests are published. At first use it
checks the frontend revision, entry offset and SHA-256 of all six frozen parts.
A miss takes the ordinary translation path. A matched refusal proceeds to the
existing published-translation loader. Successful hits run the usual binding
checks, device capability checks, bytecode compilation/cache lookup and PSO creation.
The heartbeat reports prepared hits, matched refusals and pack misses.

```powershell
cmake --build --preset release --target compile_dxil native_compute_pack_check startup_stream_consumer d3d12_xs_shim
ctest --preset release --no-tests=error -R '^native_compute_pack(_hardware)?$'
```

## Alignment between `compile_dxil --requests` and the startup cache

1. **Request keys and `.psin` stream descriptions (`src/shader_compute_request.cpp`):**
Expand Down
Loading
Loading