Skip to content
Open
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
4 changes: 2 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"xmem_shim_test_controls", "startup_stub_xcrdapi", "startup_stub_xcrdapi_break_window_control",
"xmem_run_break_readers_check", "xmem_run_break_readers_control", "xmem_cross_call_merge_check",
"xmem_placeholder_split_check", "xmem_map_split_first_check", "startup_dstorage_break_window_check",
"xmem_page_runs_device_check", "linear_buffer_backing_check", "existing_heap_shared_buffer_check", "startup_request_publisher_check", "mesh86_typed_vsharp_check", "mesh86_typed_vsharp_wide_format_mut", "mesh86_typed_vsharp_any_map_mut", "mesh86_typed_vsharp_any_swizzle_mut", "mesh86_typed_vsharp_any_tid_mut",
"xmem_page_runs_device_check", "linear_buffer_backing_check", "startup_mesh86_material_backing", "existing_heap_shared_buffer_check", "startup_request_publisher_check", "mesh86_typed_vsharp_check", "mesh86_typed_vsharp_wide_format_mut", "mesh86_typed_vsharp_any_map_mut", "mesh86_typed_vsharp_any_swizzle_mut", "mesh86_typed_vsharp_any_tid_mut",
"bcpack_formats_check", "startup_stub_consumer", "startup_inline_retire", "startup_resource_retire_title", "startup_table_lock",
"native_compute_ir_dump", "native_pixel_ir_dump", "native_store_replay", "native_raw_buffer_view_check",
"native_direct_cache_check"
Expand All @@ -51,7 +51,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_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|existing_heap_shared_buffer(_offset_control)?_warp|startup_stage_package|startup_compute_packed_d16_x_uav_reference|native_.*_(ir|dxil|controls)|native_direct_mesh|native_mesh_readfirstlane_warp|startup_triage_run|mesh86_typed_vsharp_[a-z_]+|startup_request_publisher(_inline_control)?)$"
"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_mesh86_material_backing(_mutant)?_warp|existing_heap_shared_buffer(_offset_control)?_warp|startup_stage_package|startup_compute_packed_d16_x_uav_reference|native_.*_(ir|dxil|controls)|native_direct_mesh|native_mesh_readfirstlane_warp|startup_triage_run|mesh86_typed_vsharp_[a-z_]+|startup_request_publisher(_inline_control)?)$"
}
}
},
Expand Down
9 changes: 9 additions & 0 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -11322,6 +11322,15 @@ Run `python -B tests/startup_mesh86_srv_proof_check.py` to check the load count
without DXC. The synthetic DXIL dump passes with one DWORD load and is
rejected when a second identical load uses the same SRV handle.

The placed material-buffer backing has its own source-built fixture: one 64 KiB
placed buffer at an unaligned title address, two raw SRVs at different offsets,
a submitted GPU readback, a stale token, a UAV token and out-of-range records.
Run `ctest --preset release --no-tests=error -R
'^startup_mesh86_material_backing_(warp|hardware)$' --output-on-failure`; the
mutant entries keep the bytes visible at adoption and must fail. The fixture
reports refresh bytes (65,536 first, 4 per changed word) and the reused backing;
see [the mesh86 note](experiments/mesh86-pixel-execz.md#material-placed-buffer-backing).

On the Release worktree at `76aeef7f` plus these changes, the combined lease,
SRV proof, export and mapped-page selection passed eight tests. The two mesh
cases returned 77 on the adapters listed above. `dumpbin /exports` showed
Expand Down
50 changes: 47 additions & 3 deletions docs/experiments/mesh86-pixel-execz.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,52 @@ checks exact pixels with both native buffer descriptors and structured view
tokens, plus clear-only results for stride mismatches and missing backing.

A local runtime sample created and selected four desktop Mesh PSOs and
observed their direct dispatch calls. All sampled scene dispatches stopped at
resource binding. One needed a 128-byte root SRV with no mapped backing. The
other three needed a large placed buffer view whose desktop backing did not
observed their direct dispatch calls. At the time of that sample, all scene
dispatches stopped at resource binding. One needed a 128-byte root SRV with no
mapped backing. The other three needed a large placed buffer view whose desktop
backing did not
alias the guest memory or have a verified GPU producer. Visible scene output
remains unverified.

## Material placed-buffer backing

A native Mesh86 material SRV on a placed buffer whose desktop backing does not
alias title memory no longer stops the bind. The material path adopts the
existing committed desktop resource through the linear-buffer refresh path
(`linear_buffer_backing.h`): the first submission before a consumer copies the
title range, later submissions compare 4 KiB blocks and copy contiguous changed
runs (runs separated by at most one block are merged; more than 1024 runs fall
back to one span). The consumer queue waits for the refresh fence, and a refresh
waits for earlier tracked submissions. The placed backing is reused, so adoption
adds no default-heap VRAM. A submitted copy or bound UAV makes the
desktop bytes authoritative and stops the refreshes.

The source-built fixture places a 64 KiB buffer at an unaligned title address,
so slot 133 keeps a committed default backing. Two raw SRVs at offsets 0 and
`0x8000` are read by one compute dispatch; the readback distinguishes the two
values. Changing one title word changes only that SRV's value, and the refresh
copies four bytes; two disjoint changed words copy two four-byte runs. Sentinels
outside the placed range stay unchanged. The controls refuse an out-of-range
record, a record over the raw-SRV limit, a UAV view token and a released
resource. The fixture reports one adopted backing and no linear placement.

```powershell
ctest --preset release --no-tests=error -R '^startup_mesh86_material_backing_(warp|hardware)$' --output-on-failure
ctest --preset release --no-tests=error -R '^startup_mesh86_material_backing_mutant_(warp|hardware)$' --output-on-failure
ctest --preset release --no-tests=error -R '^startup_mesh86_material_backing_provenance_(warp|hardware)$' --output-on-failure
```

The mutant keeps the bytes visible at adoption; both normal tests must pass and
both mutant tests must fail (the CTest entries use `WILL_FAIL`).

A GPU write submitted before the first material bind is remembered by
`note_gpu_write` even when linear-buffer tracking is off; adoption then fails
closed with the named refusal instead of refreshing the GPU bytes from stale
title memory. The provenance control seeds a GPU copy while tracking is off,
resolves the first material view (refused) and verifies the GPU bytes survive.
A write performed outside the shim, for example through a desktop list that
bypasses the copy slots, is still not visible. The changed-run comparison runs at each submit
over the whole resource and the first refresh copies it whole, so a 174 MiB
resource still costs a 174 MiB compare per submission even when few bytes
changed. The fixture measures refresh bytes and the reused backing; it does not
measure frame time or peak VRAM against the DXGI budget on a title scene.
1 change: 1 addition & 0 deletions src/startup_stubs/d3d12_compute_dispatch.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,7 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch&
buffer_view(dest, view.resource, view.offset, static_cast<std::size_t>(view.bytes));
continue;
}
note_linear_gpu_write_resource(self, view.resource);
require_state(self, view.resource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
if (view.texture || view.described) {
device_of(the_device)->CreateUnorderedAccessView(view.resource, nullptr,
Expand Down
25 changes: 23 additions & 2 deletions src/startup_stubs/d3d12_draw.inl
Original file line number Diff line number Diff line change
Expand Up @@ -2777,7 +2777,7 @@ struct IndirectBufferView {
u64 offset = 0, bytes = 0;
UINT stride = 0;
bool upload = false;
int source = 0; // 0 aliased or any other backing, 1 a GPU copy this list made (X2W_TRANSLATED_INDIRECT_COPY_RANGES), 2 a snapshot of title memory, 3 zeros for a null descriptor
int source = 0; // 0 aliased or any other backing, 1 a GPU copy this list made (X2W_TRANSLATED_INDIRECT_COPY_RANGES) or a GPU-written backing, 2 a snapshot of title memory, 3 zeros for a null descriptor, 4 a placed material backing refreshed from title memory at submit
u64 snapshot_address = 0; // title address for a pending snapshot (source 2 with no resource)
};

Expand Down Expand Up @@ -2955,7 +2955,12 @@ IndirectBufferView indirect_table_buffer(Wrapper* self, const std::uint32_t* wor
if (!bytes) return refuse("an input buffer descriptor has zero records");
if (use == InputBufferUse::mesh_material) {
if (bytes > limit) return refuse("material buffer size exceeds the D3D12 raw SRV limit");
if (bytes % 4) return refuse("material buffer size is not a whole number of dwords");
// A material descriptor can be a byte view (stride 1). The material path builds a raw
// dword SRV, so bind the whole dwords the view covers; a tail smaller than one dword is
// not addressable by that SRV. The caller still checks the view against the shader's
// minimum read.
bytes &= ~u64{3};
if (!bytes) return refuse("material buffer range has no whole dwords");
} else if (bytes > limit || bytes % 4) {
return refuse(limit == (16u << 20)
? "an input buffer range is over 16 MiB or not whole dwords"
Expand Down Expand Up @@ -3004,6 +3009,21 @@ IndirectBufferView indirect_table_buffer(Wrapper* self, const std::uint32_t* wor
if (!placed.alias) {
if (native && indirect_table_copied_gpu_range(self, native, offset, bytes)) {
input_source = 1; // a GPU copy of this list filled the range: the GPU buffer is the truth
} else if (use == InputBufferUse::mesh_material && native && linear_buffers().written_by_gpu(native)) {
input_source = 1; // a submitted GPU write filled the backing: the desktop bytes are the truth
} else if (use == InputBufferUse::mesh_material && native) {
// The placed backing exists but does not alias title memory. Adopt that same resource: the
// linear-buffer path refreshes it from the title bytes before the recording executes, copies
// only the changed span after the first refresh, and orders the consumer behind its fence. No
// second default-heap buffer is allocated.
X2wLinearBufferInfo info{};
if (SUCCEEDED(linear_buffers().adopt(device_of(device), native, owner->own().title_memory,
native->GetDesc().Width, &info)))
input_source = 4;
else {
diag_placed_refusal(self, native, offset, bytes, placed_context);
return refuse("a placed material buffer has no coherent desktop backing");
}
} else if (allow_title_snapshot && title_input_snapshot_enabled() && bytes <= (u64{16} << 20)) {
// The desktop buffer does not alias title memory. Resolve the title range here and let the
// dispatch copy it after its outputs have been validated.
Expand Down Expand Up @@ -4163,6 +4183,7 @@ bool draw_translated(Wrapper* self, bool indexed, UINT count, UINT instances, UI
}
for (UINT j = 0; j < tr->uavs.size(); ++j) {
const D3D12_CPU_DESCRIPTOR_HANDLE dest{draw_heap->GetCPUDescriptorHandleForHeapStart().ptr + SIZE_T{first + n + j} * draw_heap_increment};
note_linear_gpu_write_resource(self, uav_bindings[j].resource);
require_state(self, uav_bindings[j].resource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
if (tr->uavs[j].raw) {
D3D12_RESOURCE_BARRIER barrier{};
Expand Down
Loading
Loading