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 @@ -29,7 +29,7 @@
"d3d12_sdk_check", "era_heap_check", "xmem_shim", "offscreen_check", "startup_list_copy", "startup_list_copy_check",
"cpu_fuzz_lifted", "cpu_fuzz_lifted_o2", "pe_map", "intake_candidate",
"archive_gpu_reader", "archive_codec_gpu", "archive_texture_gpu_lifted", "startup_launch_probe",
"compile_dxil", "startup_indirect_dispatch", "startup_indirect_draw_indexed", "startup_present_readback_check",
"compile_dxil", "startup_indirect_dispatch", "startup_indirect_draw_indexed", "startup_descriptor_history_check", "startup_present_readback_check",
"startup_present_planes", "startup_present_composite_warp",
"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",
Expand All @@ -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_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)$"
"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_mesh_argument_provenance_warp|startup_descriptor_history_(model|(filter|exhaustion|incomplete)_warp)|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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ The control-flow CPU translator supports [source-built string memory transfers](
| gfx1030 formatted UINT buffer reads | Lower [indexed `buffer_load_format_*` with caller-declared RGBA32 UINT](docs/experiments.md#indexed-gfx1030-formatted-uint-buffer-reads) and verify one to four channels in the UAV readback. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_mubuf_format_'` |
| gfx1030 formatted D16 UINT writes | Lower [indexed packed `buffer_store_format_d16_x/xy/xyzw`](docs/experiments.md#indexed-gfx1030-formatted-d16-uint-buffer-writes) and verify the untouched halfword and record padding. The experimental `xyz` form requires a caller-verified W-preservation contract. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_mubuf_store_format_'` |
| gfx1030 formatted UINT buffer writes | Lower [indexed `buffer_store_format_*` with matching caller-declared UINT texels](docs/experiments.md#indexed-gfx1030-formatted-uint-buffer-writes) and compare full UAV readback with a CPU reference. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_mubuf_store_format_'` |
| Targeted descriptor history | [Select descriptor heap-relative ranges and verify history budget controls](docs/experiments/descriptor-history-filter.md) with source-built Mesh fixtures. | `ctest --preset dev --no-tests=error -j 1 -V -R '^startup_descriptor_history_'` |
| Descriptor-format buffer loads | Lower [gfx1013 indexed `buffer_load_format_x/xy/xyz/xyzw` and the d16 forms](docs/experiments.md#descriptor-format-buffer-loads), reading the GFX10 or legacy format from V# word 3 at run time with integer-exact conversions. An unsupported format or opcode width leaves the output unwritten. The descriptor itself is still static. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_descriptor_load_format_'` |
| Heap-view buffer loads | Lower [gfx1013 indexed `buffer_load_format_xy/xyzw` from a run-time view record](docs/experiments.md#heap-view-buffer-loads): base, stride, `num_records` and format come from the record at a chosen slot. An index past `num_records` reads zero; a view that is not live, a bad slot or a bad format leaves the output unwritten. The record table is a side table inside t0; the SM 6.6 heap lookup is not wired yet. | `ctest --preset dev --no-tests=error -R '^compute_(store_aot_heap_view_load_\|heap_view_controls$)'` |
| Descriptor-format buffer stores | Lower [indexed `buffer_store_format_x/xy/xyz/xyzw` and the d16 forms](docs/experiments.md#descriptor-format-buffer-stores), reading the GFX10 or legacy format from V# word 3. Unknown formats are refused. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_descriptor_store_format_'` |
Expand Down
172 changes: 172 additions & 0 deletions docs/experiments/descriptor-history-filter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Targeted descriptor history

This extends the [GPU-written Mesh argument provenance fixture](mesh-argument-provenance.md)
associated with [PR #3321](https://github.com/R0Y00/Xbox2Windows/pull/3321) and
[issue #3310](https://github.com/R0Y00/Xbox2Windows/issues/3310). It selects
intercepted descriptor operations before they consume the existing history
budget. It does not change rendering, native descriptor copies, resource
retirement, GPU submission or synchronization.

## Enable and select

Set both environment variables before starting the process; the configuration
is cached. For the source-built Mesh provenance fixture:

```powershell
$env:X2W_D3D12_DESCRIPTOR_HISTORY = '1'
$env:X2W_D3D12_DESCRIPTOR_HISTORY_FILTER = 'view:cpu:0:1:1:0:1;view:visible:0:1:1:0:1'
```

Each selector is `TYPE:VISIBILITY:NODE_MASK:CAPACITY:ORDINAL:FIRST:COUNT`.
Use one or two selectors separated by a semicolon (at most 256 characters in
total). Types are `view`, `sampler`, `rtv`, and `dsv`; visibility is
`cpu` or `visible` (RTV and DSV must be CPU-only). Numeric fields are
canonical unsigned 32-bit decimal values, without whitespace, signs or
leading zeroes. Capacity, ordinal and count must be positive. The zero-based
slot interval must fit within the requested logical capacity. An ordinal is
one-based among successful logical heap registrations of the exact type,
visibility, requested node mask and logical capacity. Selectors must identify
distinct heap keys (including ordinal).

The master switch being off ignores the filter. A missing or empty filter
preserves legacy unfiltered recording. Invalid nonempty input disables the
diagnostic and logs one configuration error, without a legacy fallback.

## Attribution and budget

A creation matches its destination. A copy matches the union of source and
destination slot intervals, with each copy index counted once. The arithmetic
produces at most two nonoverlapping windows. Only admitted indices are sampled
and logged; the budget is 8,192 records per process. Reaching exactly 8,192
is not by itself truncation; the first additional admissible matching record
emits the marker. No further history traversal or guest-token sampling is
performed after truncation.

With filtering enabled, registration lines show generation, mapping index,
heap shape, guest and desktop handle starts, strides, prefix, tail and
mirror information, and a selector bit mask. Bit 0 represents the first
selector and bit 1 the second. Discovery emits one line for every successfully
retained registration, including selected registrations, up to the registry
capacity of 1,024 logical registrations (not live COM references). There is
no independent discovery cutoff. Exceeding capacity or encountering an invalid
registration faults attribution and reports an incomplete trace; failed
registrations do not emit discovery lines. Mirrors are companions of their
logical heap, not additional selector ordinals.

Use the registration lines to identify the heap shape and count successful
registrations of that exact shape in generation order to obtain its ordinal.
Generation is a global registration number, not the per-shape ordinal.
Confirm the selected bit mask, mapping and shadow identity on the targeted
run. Ordinals can change across executions, configurations, adapters or
concurrent registrations; they are not stable title identifiers. A selector may
never become available. No end-of-process completeness receipt is supplied. Zero
records or absence of a truncation marker is not proof of a complete history.

Attribution is conservative. Ambiguous overlapping mappings, stale mapping
publication, untracked or opaque endpoints, untracked CPU tails and selected
view allocation failures can omit operations and report an incomplete trace.
A selected copy must validate both endpoints and the admitted rows in the
shadow snapshot; rejecting a chunk does not consume budget or gate the native
copy. Registration lookup is bounded by the retained registry size, and
selected-row shadow checks by the event budget; this is not a constant-time
end-to-end lookup claim.

Incomplete-history messages retain their reason and add a cumulative
`count=` for that reason. Each process counts refused operations by reason
(not omitted descriptor rows), or failed registrations for `registry-fault`.
Messages are emitted at counts 1, 2, 4, 8 and successive powers of two.
Counters saturate at the maximum 64-bit value, limiting each reason to 64
messages (576 across all nine reasons); they do not consume the
descriptor-record budget. The separate registry fault marker remains one-time.
Concurrent messages may appear out of count order. The highest reported
count is a lower bound, not a final total;
no shutdown summary is promised. Disabled or invalid history does not count
omissions; after truncation, history admission stops and registration failures
are not counted once truncation is observed.

With history disabled, the cached active check bypasses history-specific
shadow observations, reservation and sampling. This is a structural change
to the disabled path, not a claim of zero overhead or performance parity.

Trace fields describe CPU shadow publication and a pre-token-write guest
sample, not native descriptor bytes, guest copy completion, arbitrary guest
CPU stores or GPU execution order. View IDs can be reused. Filtered SRV
decoding uses the fixed guest record width; legacy decoding is unchanged.
The fixture supplies its own fences and pixel readback. This diagnostic
alone does not satisfy the remaining integration criteria of issue #3310.

## Reproduce

Use the ordinary Windows prerequisites in
[CONTRIBUTING.md](../../CONTRIBUTING.md#build-and-test), including DXC and the
Python environment prepared before configuring. Use a non-elevated x64
Windows PowerShell from the repository root. See the
[Mesh fixture prerequisites](mesh-argument-provenance.md#reproduce) for
adapter/runtime capability requirements. Configure and build both
configurations and run the GPU tests serially:

```powershell
. .\tools\dev.ps1
$env:X2W_D3D12_DEBUG = '1'
$selection = '^startup_(descriptor_history_(model|(filter|exhaustion|incomplete)_(warp|hardware))|mesh_argument_provenance_(warp|hardware))$'
foreach ($preset in @('dev', 'release')) {
cmake --preset $preset
if ($LASTEXITCODE -ne 0) { throw "Configure failed: $preset" }
cmake --build --preset $preset --target startup_descriptor_history_check startup_indirect_draw_indexed
if ($LASTEXITCODE -ne 0) { throw "Build failed: $preset" }
ctest --preset $preset -N -R $selection
ctest --preset $preset --no-tests=error -j 1 -V -R $selection
if ($LASTEXITCODE -ne 0) { throw "Tests failed: $preset" }
}
```

With all fixtures registered, the selection contains nine CTest tests:
the model, the filter/exhaustion/incomplete families on each adapter, and
the two Mesh argument provenance tests. Check the inventory printed by
`ctest -N` rather than interpreting a smaller registered subset as a pass.
The model check covers parsing, retained mappings, mirror/tail identities,
ambiguous endpoints, transactional admission, bounded secondary lookups,
publication changes, full-capacity discovery and independent omission counters,
including concurrent increments and saturation. The GPU check uses the original
provenance oracle, including positive pixels and four negative controls,
with source-only, destination-only, and combined filters. The exhaustion
check adds unrelated null SRV creation and bulk copies, checks the exact
admitted event sequence and truncation marker, and verifies that selecting
only the later Mesh heaps preserves their history. A sparse case checks
disjoint copy windows. The incomplete-history check runs three cases per
adapter:

| Case | Descriptor records | Incomplete messages | Discovery records |
|---|---:|---:|---:|
| Native CPU-only SRV source | 4 | 3 | 2 |
| Same native operations, history off | 0 | 0 | 0 |
| Full registry and overflow | 5 | 5 | 1,024 |

The native-source case copies five times from outside the guest registry.
The expected refusal reason is `selected-copy-untracked` at counts 1, 2
and 4. The GPU still reads the intended scalar, consumes the matching
`(2,1,1)` record and produces all eight expected pixels. A later valid
creation retains a contiguous history sequence. The guest token is unchanged
for the native-source copy, so this does not establish guest-token provenance.

The discovery case selects the final two of 1,024 real heap registrations
and checks their positive GPU oracle before overflow. Five further allocations
succeed natively, with one registry fault marker and `registry-fault` counts
1, 2 and 4. Subsequent view and copy operations exercise independent
`view-attribution` and `copy-attribution` counts; neither adds descriptor
records. Token equality and device status are checked after overflow, not
another GPU draw.

Report capability skips (77) separately. Record the adapter, driver, Windows
build, configuration, exact source revision and per-test result. A
`provenance debug info_queue=present` line supports the ERROR/CORRUPTION check;
an absent queue is not evidence of error-free debug output. These fixtures
do not establish full-game behavior.

## Credits

The underlying history and Mesh provenance fixture are from wish131400's
[PR #3321](https://github.com/R0Y00/Xbox2Windows/pull/3321). The event-budget
and post-truncation traversal findings discussed in that PR motivate this
follow-up. Original measured results remain tied to their original revisions;
current-branch verification is reported separately.
Loading
Loading