Skip to content

gpu: add targeted descriptor history filtering - #3772

Open
Vilify-13 wants to merge 3 commits into
R0Y00:mainfrom
Vilify-13:gpu/targeted-descriptor-history
Open

Vilify-13 wants to merge 3 commits into
R0Y00:mainfrom
Vilify-13:gpu/targeted-descriptor-history

Conversation

@Vilify-13

@Vilify-13 Vilify-13 commented Dec 1, 2026 •

Copy link
Copy Markdown

Summary

Refs #3310 and #3321.

Edits: Addressed SHOULDs and several NITs given by @Leyukaka and @Not-Saii

Extend descriptor history with optional heap-relative range filtering, allowing relevant descriptor operations to be captured without unrelated initialization activity consuming the diagnostic event budget.

The existing 8,192-record history limit can be exhausted during initialization or by a sufficiently large descriptor copy, preventing later operations relevant to GPU-written Mesh argument investigations from being recorded.

This contribution applies selection before event-budget consumption, validates descriptor attribution conservatively, and terminates diagnostic-only traversal after truncation.

Outstanding merge prerequisite — Not-Saii MUST 1

Coordination with #3321 remains unresolved. This follow-up addresses the technical review findings without changing the original contributor's attribution or the merge prerequisite. Publishing these improvements enables further technical review while coordination continues. This PR should not merge until either #3321 lands independently and this contribution is rebased, or an explicit agreement is found to supersede it.

The remaining application-integration acceptance criteria of #3310 and broader graphics-pipeline optimization remain separate work.

Dependency and integration status

This contribution depends on the descriptor-history implementation and Mesh argument provenance fixture introduced by @wish131400 in #3321.

The current branch contains three separately identifiable commits:

Commit Contribution
04a6c5a0 Conflict-resolved integration of #3321 against upstream main, preserving the original Git author identity and author date
390f5c1d Targeted descriptor-history filtering, regression coverage and documentation

The original contribution is based on #3321 revision 029dfefef4c273b5d9c5565fbff1ee2acfd9a3ca.

The original author was notified in #3321.

Outstanding findings specific to the original descriptor-history implementation remain separately identifiable from the filtering contribution.

Implementation

  • Select descriptor operations before event-budget consumption and guest-token sampling.
  • Match descriptor creation against the destination slot range.
  • Match descriptor copies against the union of source and destination ranges without duplicate records.
  • Calculate selected copy indices using bounded interval arithmetic.
  • Validate retained mappings, registration publication and shadow identities conservatively.
  • Reject unverifiable selected operations without consuming the history budget or preventing the native operation.
  • Stop diagnostic traversal and guest-token sampling after history truncation.
  • Preserve native descriptor-copy behavior, rendering, resource retirement, GPU submission and synchronization.
  • Add portable model checks, source-built GPU regression coverage and documentation.

Diagnostic bounds

Component Limit
Descriptor history records per process 8,192
Heap selectors 2
Retained logical heap registrations 1,024
Ordinary registration-discovery records 256
Filter configuration length 256 characters
Nonoverlapping selected windows per copy 2

Selected registrations beyond the ordinary discovery limit are still reported.

The portable model reports a retained registry size of 73,856 bytes. The registry is constructed lazily and exists only in filtered mode.

The registry retains mapping metadata rather than 1,024 live COM references.

Reaching exactly 8,192 records does not itself constitute truncation. The truncation marker is emitted when an additional admissible matching record would exceed the budget.

Registration and attribution failures are handled conservatively. An incomplete trace is not represented as a complete descriptor history.

Runtime behavior

The diagnostic is disabled by default.

When the master switch is unset, the filter environment variable is not read and the filtered registry is not constructed.

The contribution adds no GPU commands or GPU synchronization requirements. Descriptor shadow publication, reference accounting and native descriptor operations retain their existing behavior.

Registry attribution is performed under descriptor_lock. History admission and shadow publication operate under exclusive note_lock.

Registration planning precedes acquisition of note_lock. Publication checks before and after shadow-row validation prevent stale or concurrently changed mappings from being accepted as verified lineage.

Selected-row validation is bounded by the available history budget. Registration lookup is bounded by the retained registry capacity; this is not a claim of constant-time end-to-end descriptor lookup.

The disabled path retains cached configuration checks and diagnostic bookkeeping that returns early. Further reduction of this overhead is being evaluated separately in response to review feedback.

Configuration

Set both environment variables before starting the process:

$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'

Selector grammar:

TYPE:VISIBILITY:NODE_MASK:CAPACITY:ORDINAL:FIRST:COUNT
Field Meaning
TYPE view, sampler, rtv, or dsv
VISIBILITY cpu or visible; RTV and DSV must be CPU-only
NODE_MASK Requested node mask
CAPACITY Logical heap capacity
ORDINAL One-based registration ordinal among heaps of the same shape
FIRST Zero-based first selected descriptor slot
COUNT Number of selected descriptor slots

One or two selectors may be specified, separated by a semicolon.

Numeric fields use canonical unsigned 32-bit decimal values without whitespace, signs or leading zeroes. Capacity, ordinal and count must be positive. The selected interval must fit within the logical heap capacity.

Selectors must identify distinct heap keys, including their ordinals.

Mirrors are companions of their logical heaps rather than additional selector ordinals.

The filter is optional. Missing or empty input preserves legacy unfiltered recording behavior. Invalid nonempty input disables the diagnostic and reports a configuration error rather than falling back to unrestricted recording.

Configuration is cached for the lifetime of the process.

See docs/experiments/descriptor-history-filter.md for the complete configuration grammar, attribution rules, capacity limits and reproduction details.

Verification

Revision identity

Tested head: 390f5c1d1e1f460422fcf8ff3d78da8a8aa27877

Upstream base: 158ef79422f296c48873bfe8123e1e040125dc0a

The final local regression campaigns were executed against the exact committed outgoing revision. The source checkout was verified clean before and after testing.

Historical development and mutation results are reported separately below and are not attributed to this final head.

Local test environment

Component Version
Operating system Windows 11 Home 26H2, build 26300.9974
Physical GPU NVIDIA GeForce RTX 4060
NVIDIA driver 32.0.16.2114
Software adapter Microsoft Basic Render Driver
WARP driver 10.0.26100.9818
Visual Studio Build Tools 2022 v17.14.45
MSVC 19.44.35230
Windows SDK 10.0.26100.0
DXC 1.9.2602.17
CMake / CTest 3.31.6-msvc6
Ninja 1.12.1
Python 3.12.10
PowerShell Windows PowerShell 5.1
Build configurations Debug and Release
GPU test execution Serial

The local build used the installed Windows D3D12 runtime and locally provisioned project dependencies.

OFFSCREEN_AGILITY_620_DIR and OFFSCREEN_WARP_DIR were unset in both final build caches. No separately provisioned Agility SDK or app-local WARP package was required for this environment.

Final committed revision results

Suite Selected Passed Skipped Failed
Debug focused regression 59 59 0 0
Release focused regression 59 59 0 0
Local Windows PR smoke suite 261 258 3 0
Total test executions 379 376 3 0

The total includes overlapping tests executed under different configurations and presets; it does not represent 379 unique tests.

The three capability skips are existing Windows placeholder-fallback controls:

  • xmem_placeholder_split_control
  • xmem_placeholder_split_deployed
  • xmem_placeholder_split_partial

The operating system exposes the placeholder bit, so the fallback paths are not exercised. These skips are not counted as passes.

Documentation-link, bidirectional-control and Git whitespace checks also passed during publication validation.

Primary regression results by adapter and configuration

Test Debug Release Local PR smoke
startup_descriptor_history_model PASS PASS PASS
startup_descriptor_history_filter_warp PASS PASS PASS
startup_descriptor_history_filter_hardware PASS PASS Not selected
startup_descriptor_history_exhaustion_warp PASS PASS PASS
startup_descriptor_history_exhaustion_hardware PASS PASS Not selected
startup_mesh_argument_provenance_warp PASS PASS PASS
startup_mesh_argument_provenance_hardware PASS PASS Not selected

All seven primary regression tests passed in both configurations without capability skips.

These seven tests are included in, rather than additional to, each 59-test focused regression campaign.

Each focused campaign contains:

Test-name classification Passed Skipped Failed
Hardware-qualified tests 23 0 0
WARP-qualified tests 26 0 0
Other tests and controls 10 0 0
Total per configuration 59 0 0

Every individual test in the complete focused inventory listed in the reproduction section below passed in both Debug and Release.

D3D12 debug-layer and info-queue verification

The archived verbose logs for the final committed revision were inspected for adapter debug-layer messages and the fixture's provenance debug info_queue= observations.

Fixture Debug: present / expected Release: present / expected Local PR smoke
startup_mesh_argument_provenance_warp 6/6 6/6 6/6
startup_mesh_argument_provenance_hardware 6/6 6/6 Not selected
startup_descriptor_history_filter_warp 19/19 19/19 19/19
startup_descriptor_history_filter_hardware 19/19 19/19 Not selected
startup_descriptor_history_exhaustion_warp 9/9 9/9 9/9
startup_descriptor_history_exhaustion_hardware 9/9 9/9 Not selected
Total 68/68 68/68 34/34

All 170 observed provenance info-queue records reported:

provenance debug info_queue=present

The corresponding adapter messages reported the debug layer enabled for all of these fixture executions.

No info_queue=absent observation was found in these final-head provenance campaigns.

Debug-layer enablement was also reported by the following focused regression fixtures in both configurations:

  • startup_resource_retire_views_warp_debug1
  • startup_resource_retire_views_hardware_debug1
  • startup_resource_retire_views_no_mirror_control_warp
  • startup_mesh57_runtime_warp
  • startup_mesh57_runtime_hardware

The debug0 resource-retirement cases intentionally exercise their corresponding debug-disabled configuration.

Debug-layer claims here are fixture-specific rather than a blanket claim that every test in the PR preset uses the debug layer.

Expected diagnostic errors in deliberately failing upstream controls are distinguished from unexpected errors in the positive provenance fixtures.

Regression coverage

Portable model

startup_descriptor_history_model verifies:

  • Selector grammar, configuration modes and invalid-input rejection.
  • Heap-relative range selection.
  • Source and destination interval union.
  • Retained registry capacity and registration identity.
  • Mirror-backed mappings, CPU tails and ambiguous endpoints.
  • Stale registration publication.
  • Transactional admission and budget preservation when a selected operation is refused.
  • Bounded secondary shadow lookups.
  • Exact budget and truncation boundaries.
  • No further admission traversal after truncation.

The final-head Debug and Release model output includes:

PASS selector and retained registry controls
PASS mirror registry assertions=300919 randomized=100000 registry_bytes=73856
PASS transactional admission assertions=88884 randomized=20000 post_stop=10000

Filtered GPU regression

Each startup_descriptor_history_filter_{warp,hardware} test executes 19 cases.

The five source-built Mesh provenance scenarios are exercised with source-only, destination-only and combined selectors. Additional positive cases cover an empty filter, disabled history, invalid configuration and an unmatched selector.

The regression checks exact descriptor-history sequences, registration selector masks, guest observations, resource backing identity, GPU argument records, fence observations and the existing pixel oracle.

History exhaustion regression

Each startup_descriptor_history_exhaustion_{warp,hardware} test executes nine cases.

The following results were verified against the archived final-head verbose logs:

Noise slots Mode Retained history records Truncated
4,093 Legacy 8,191 No
4,094 Legacy 8,192 Yes
5,000 Legacy 8,192 Yes
5,000 Target 5 No
5,000 Off 0 No
4,096 Noise 8,192 No
5,000 Noise 8,192 Yes
4,095 Mixed 8,192 Yes
5,000 Sparse 8 No

The targeted case generates 10,000 unrelated descriptor events before the Mesh provenance sequence.

Legacy recording exhausts its budget during those unrelated events. Targeted recording retains the five relevant Mesh history records without truncation.

The sparse case independently exercises disjoint source and destination copy windows.

The noise-only case with 4,096 slots establishes that reaching exactly 8,192 admitted records does not prematurely emit the truncation marker.

Mesh argument provenance controls

The underlying #3321 fixture supplies the following source-built GPU oracle:

Scenario Argument behavior Changed scene-color pixels
Correct descriptor binding Matching (2,1,1) records 8/8
Missing descriptor copy Zero-X launch arguments 0/8
Stale descriptor copy Zero-X launch arguments 0/8
Incorrect SRV offset Zero-X launch arguments 0/8
Incorrect argument offset Consumer reads the incorrect zero-X record 0/8

The fixture checks matching resource identity, byte offsets, 12-byte argument records, completed fence observations, preserved guards and rendered pixels.

The positive scenario also runs with descriptor history disabled.

These are source-built regression fixtures. They do not establish the corresponding behavior in an actual application integration run.

Reproduction

Prerequisites and execution notes

The following workflow is adapted from the successfully executed final-head publication validation.

The build and test selections, configuration options, serial execution order and native-command error handling follow that campaign. Machine-specific paths have been parameterized for independent reproduction; the public-facing adaptation has not itself been rerun as a standalone script.

Use:

  • A clean, user-owned checkout of the tested commit.
  • A non-elevated Windows PowerShell 5.1 session.
  • Visual Studio Build Tools with the x64 C++ toolchain.
  • Windows SDK including DXC, resource compiler and manifest tool.
  • CMake and CTest 3.31 or newer, including support for --tests-from-file.
  • Ninja.
  • A provisioned Python environment containing the repository's required packages.
  • The repository's pinned and patched SPIR-V tools.
  • Provisioned libopus 1.5.2 source.
  • D3D12 Graphics Tools for debug-layer verification.

Follow the repository's AGENTS.md, CONTRIBUTING.md and dependency provisioning instructions.

This reproduction uses offline CMake dependency configuration. Required dependencies must already be available locally.

Do not reuse build caches belonging to another checkout, another toolchain or another source revision.

Hardware without the required Mesh capabilities may produce capability skips. Such skips must be reported separately and do not constitute successful GPU validation.

If PowerShell execution policy prevents the reviewed repository scripts from running, and local policy permits it, a process-scoped setting can be used:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned

No system-wide execution-policy change, administrator privileges, Git ownership-check bypass or proprietary application materials are required.

Step 1 - Initialize and validate the environment

Run the following from the root of a clean checkout of the tested revision.

Replace the dependency-path values with the corresponding installations on the test machine.

$ErrorActionPreference = 'Stop'

if ($PSVersionTable.PSEdition -ne 'Desktop' -or
    $PSVersionTable.PSVersion.Major -ne 5) {
    throw 'Use Windows PowerShell 5.1 for this reproduction'
}

$expectedHead = '390f5c1d1e1f460422fcf8ff3d78da8a8aa27877'

# Machine-specific dependency paths.
$python = '<path-to-Python-virtual-environment>\Scripts\python.exe'
$opus = '<path-to-provisioned-opus-1.5.2-source>'
$spirv = '<path-to-pinned-SPIR-V-tools>\bin'
$gitBin = '<path-to-Git>\cmd'

$sdkBin = Join-Path `
    ${env:ProgramFiles(x86)} `
    'Windows Kits\10\bin\10.0.26100.0\x64'

$psExe = Join-Path `
    $env:SystemRoot `
    'System32\WindowsPowerShell\v1.0\powershell.exe'

# Explicit paths avoid dependence on incomplete PATH discovery.
$requiredFiles = @(
    $python
    "$opus\CMakeLists.txt"
    "$spirv\spirv-as.exe"
    "$spirv\spirv-val.exe"
    "$spirv\spirv-cross.exe"
    "$gitBin\git.exe"
    "$sdkBin\rc.exe"
    "$sdkBin\mt.exe"
    "$sdkBin\dxc.exe"
    $psExe
    '.\CMakePresets.json'
    '.\tools\dev.ps1'
)

foreach ($file in $requiredFiles) {
    if (-not (Test-Path -LiteralPath $file -PathType Leaf)) {
        throw "Missing required file: $file"
    }
}

# Normalize dependency paths before configuring CMake.
$python = (Resolve-Path -LiteralPath $python).Path
$opus = (Resolve-Path -LiteralPath $opus).Path
$spirv = (Resolve-Path -LiteralPath $spirv).Path
$gitBin = (Resolve-Path -LiteralPath $gitBin).Path
$sdkBin = (Resolve-Path -LiteralPath $sdkBin).Path

$env:Path = "$gitBin;$env:SystemRoot\System32;" +
            "$env:SystemRoot\System32\WindowsPowerShell\v1.0;" +
            "$env:Path"

# Verify the exact source revision before building.
$actualHead = & "$gitBin\git.exe" rev-parse HEAD

if ($LASTEXITCODE -ne 0 -or $actualHead -ne $expectedHead) {
    throw 'Unexpected publication revision or Git failure'
}

$sourceStatus = & "$gitBin\git.exe" status --porcelain

if ($LASTEXITCODE -ne 0 -or $sourceStatus) {
    throw 'Working tree is not clean or Git status failed'
}

# Remove inherited runtime and diagnostic settings.
Get-ChildItem Env:X2W_* | ForEach-Object {
    Remove-Item "Env:$($_.Name)"
}

# Initialize the repository-supported x64 developer environment.
. .\tools\dev.ps1

if ($env:VSCMD_ARG_TGT_ARCH -ne 'x64') {
    throw 'Expected an x64 Visual Studio developer environment'
}

$env:Path = "$sdkBin;$spirv;$env:Path"

foreach ($tool in @('cl', 'link', 'ml64', 'cmake', 'ctest', 'ninja')) {
    if (-not (Get-Command $tool -CommandType Application -ErrorAction SilentlyContinue)) {
        throw "Required development tool not found: $tool"
    }
}

$env:X2W_REQUIRE_SPIRV_TOOLS = '1'

Write-Host 'PASS: Reproduction environment initialized'

The original local configuration used the Windows SDK paths shown above, MSVC x64, explicit Windows PowerShell discovery and provisioned offline dependencies.

Step 2 - Preserve existing evidence

Use a fresh report directory rather than overwriting existing validation artifacts.

$reports = Join-Path $PWD 'out\reports\descriptor-history-verification'

if (Test-Path -LiteralPath $reports) {
    throw 'Existing validation evidence must be preserved'
}

New-Item -ItemType Directory -Path $reports | Out-Null

$selection = Join-Path $reports 'consolidated-tests.txt'

Step 3 - Complete 59-test focused regression inventory

The following contains the exact test-name selection used for both final-head focused regression campaigns.

Every listed test passed in Debug and Release, with no failures or capability skips.

@'
startup_view_dimension
startup_view_dimension_control
startup_view_dimension_warp
startup_view_dimension_hardware
startup_view_dimension_off_control_warp
startup_view_census_warp
startup_view_census_off_warp
startup_view_census_vary_warp
startup_view_census_hardware
startup_view_census_off_hardware
startup_view_census_vary_hardware
startup_resource_retire_views_warp_debug0
startup_resource_retire_views_warp_debug1
startup_resource_retire_views_keep_warp
startup_resource_retire_views_noretire_warp
startup_resource_retire_views_hardware_debug0
startup_resource_retire_views_hardware_debug1
startup_resource_retire_views_keep_hardware
startup_resource_retire_views_noretire_hardware
startup_indirect_mesh_warp
startup_indirect_mesh_hardware
native_fixed_mesh57_warp
native_fixed_mesh57_mrt_warp
native_fixed_mesh57_published_pair_warp
native_fixed_mesh57_published_pair_refusal_warp
native_fixed_mesh57_hardware
native_fixed_mesh57_mrt_hardware
native_fixed_mesh57_published_pair_hardware
native_fixed_mesh57_published_pair_refusal_hardware
startup_compute_binding_trace_warp
startup_mesh_argument_provenance_warp
startup_mesh_argument_provenance_hardware
startup_d3d12_dred
startup_d3d12_dred_switch
startup_d3d12_dred_switch_off
startup_d3d12_dred_switch_control
startup_descriptor_heap_match
startup_descriptor_heap_match_first_contains_control
startup_descriptor_heap_match_oldest_first_control
startup_descriptor_history_model
startup_descriptor_history_filter_warp
startup_descriptor_history_exhaustion_warp
startup_descriptor_history_filter_hardware
startup_descriptor_history_exhaustion_hardware
startup_mesh57_runtime_warp
startup_mesh57_runtime_hardware
startup_view_alloc_records_warp
startup_view_alloc_records_control_warp
startup_view_alloc_materialized_warp
startup_view_alloc_materialized_control_warp
startup_view_alloc_ids_warp
startup_view_alloc_ids_control_warp
startup_view_alloc_records_hardware
startup_view_alloc_records_control_hardware
startup_view_alloc_materialized_hardware
startup_view_alloc_materialized_control_hardware
startup_view_alloc_ids_hardware
startup_view_alloc_ids_control_hardware
startup_resource_retire_views_no_mirror_control_warp
'@ | Set-Content -LiteralPath $selection -Encoding ASCII

$selectedNames = @(Get-Content -LiteralPath $selection)

if ($selectedNames.Count -ne 59 -or
    @($selectedNames | Sort-Object -Unique).Count -ne 59) {
    throw 'Invalid focused test selection'
}

The original archived selection file has SHA-256:

32557dbb4cdcd2fa701ed23c134235f3c99c0295b87c71a6f95d7602d445d643

The reproduced selection must contain the same 59 names. Its byte hash may differ due to text encoding or line-ending conventions.

Step 4 - Native-command handling

Windows PowerShell can treat redirected native stderr as PowerShell error records, including nonfatal compiler and configuration warnings.

The original successful publication validation used a checked native-command wrapper to retain diagnostic output while determining command success from the native exit code.

The following preserves that behavior and restores the caller's error-handling preference:

function Invoke-CheckedNative {
    param(
        [string]$Log,
        [scriptblock]$Command
    )

    $previousPreference = $ErrorActionPreference

    try {
        $ErrorActionPreference = 'Continue'

        & $Command 2>&1 | Tee-Object -FilePath $Log

        $result = $LASTEXITCODE

        if ($result -ne 0) {
            throw "FAIL: $Log (exit $result)"
        }
    }
    finally {
        $ErrorActionPreference = $previousPreference
    }
}

Step 5 - Configure, build and execute the complete validation campaign

This follows the final-head validation order:

  1. Debug configuration.
  2. Official PR build.
  3. Debug focused build and tests.
  4. Official PR smoke tests.
  5. Release configuration.
  6. Release focused build and tests.

The PR build and test presets use the Debug build directory.

$targets = @(
    'startup_indirect_draw_indexed'
    'startup_compute_binding_trace'
    'startup_view_alloc'
    'startup_view_census'
    'startup_view_dimension'
    'startup_view_dimension_device'
    'startup_resource_retire_views'
    'startup_descriptor_heap_match_check'
    'startup_d3d12_dred_check'
    'startup_descriptor_history_check'
    'compile_dxil'
)

foreach ($preset in @('dev', 'release')) {

    Write-Host "=== CONFIGURE $preset ===" -ForegroundColor Cyan

    Invoke-CheckedNative "$reports/$preset-configure.log" {
        cmake --preset $preset `
            "-DCMAKE_RC_COMPILER:FILEPATH=$sdkBin\rc.exe" `
            "-DCMAKE_MT:FILEPATH=$sdkBin\mt.exe" `
            "-DSTARTUP_POWERSHELL:FILEPATH=$psExe" `
            "-DINTAKE_PYTHON=$python" `
            "-DFETCHCONTENT_SOURCE_DIR_OPUS=$opus" `
            "-DSPIRV_WINDOW_AS=$spirv\spirv-as.exe" `
            "-DSPIRV_WINDOW_VAL=$spirv\spirv-val.exe" `
            "-DSPIRV_WINDOW_CROSS=$spirv\spirv-cross.exe" `
            -DFETCHCONTENT_FULLY_DISCONNECTED=ON `
            -DX2W_WITH_OPUS=ON `
            -DX2W_TRACY=OFF
    }

    if ($preset -eq 'dev') {
        Write-Host '=== OFFICIAL PR BUILD ===' -ForegroundColor Cyan

        Invoke-CheckedNative "$reports/pr-build.log" {
            cmake --build --preset pr --parallel 8
        }
    }

    Write-Host "=== FOCUSED BUILD $preset ===" -ForegroundColor Cyan

    Invoke-CheckedNative "$reports/$preset-build.log" {
        cmake --build --preset $preset --parallel 8 --target @targets
    }

    # Capture the exact selected test inventory before execution.
    ctest --preset $preset `
        --tests-from-file $selection `
        --show-only=json-v1 |
        Set-Content "$reports/$preset-inventory.json" -Encoding UTF8

    if ($LASTEXITCODE -ne 0) {
        throw "FAIL: $preset inventory"
    }

    $inventory = Get-Content "$reports/$preset-inventory.json" -Raw |
        ConvertFrom-Json

    $difference = Compare-Object `
        @(Get-Content $selection | Sort-Object) `
        @($inventory.tests.name | Sort-Object)

    if ($inventory.tests.Count -ne 59 -or $difference) {
        throw "Unexpected focused test inventory: $preset"
    }

    Write-Host "=== FOCUSED TESTS $preset ===" -ForegroundColor Cyan

    Invoke-CheckedNative "$reports/$preset-tests.log" {
        ctest --preset $preset `
            --tests-from-file $selection `
            --parallel 1 `
            --no-tests=error `
            --verbose `
            --output-junit "$reports/$preset-results.xml"
    }

    if ($preset -eq 'dev') {
        Write-Host '=== OFFICIAL PR SMOKE TESTS ===' -ForegroundColor Cyan

        ctest --preset pr --show-only=json-v1 |
            Set-Content "$reports/pr-inventory.json" -Encoding UTF8

        if ($LASTEXITCODE -ne 0) {
            throw 'FAIL: PR inventory'
        }

        Invoke-CheckedNative "$reports/pr-tests.log" {
            ctest --preset pr `
                --parallel 1 `
                --no-tests=error `
                --verbose `
                --output-junit "$reports/pr-results.xml"
        }
    }
}

# Verify that the tested revision and tracked source remain unchanged.
$actualHead = & "$gitBin\git.exe" rev-parse HEAD

if ($LASTEXITCODE -ne 0 -or $actualHead -ne $expectedHead) {
    throw 'Publication revision changed or Git verification failed'
}

$sourceStatus = & "$gitBin\git.exe" status --porcelain

if ($LASTEXITCODE -ne 0 -or $sourceStatus) {
    throw 'Publication source changed or Git status failed'
}

Write-Host 'PASS: Build and CTest commands completed' -ForegroundColor Green

Successful command completion is not, by itself, proof that all tests ran without capability skips. Inspect the JUnit reports as described below.

Step 6 - Verify individual test results

The following reporting step compares each JUnit result inventory with the corresponding pre-execution inventory and distinguishes passes, skips and failures.

foreach ($preset in @('dev', 'release', 'pr')) {

    $inventory = Get-Content "$reports/$preset-inventory.json" -Raw |
        ConvertFrom-Json

    [xml]$junit = Get-Content "$reports/$preset-results.xml" -Raw

    $cases = @($junit.SelectNodes('//testcase'))

    $difference = Compare-Object `
        @($inventory.tests.name | Sort-Object) `
        @($cases | ForEach-Object {
            $_.GetAttribute('name')
        } | Sort-Object)

    if ($difference -or $cases.Count -ne $inventory.tests.Count) {
        throw "Result inventory mismatch: $preset"
    }

    $results = @(
        foreach ($case in $cases) {

            $status = if (
                $case.SelectSingleNode('failure') -or
                $case.SelectSingleNode('error')
            ) {
                'FAILED'
            }
            elseif ($case.SelectSingleNode('skipped')) {
                'SKIPPED'
            }
            elseif ($case.GetAttribute('status') -eq 'run') {
                'PASSED'
            }
            else {
                'UNKNOWN'
            }

            [pscustomobject]@{
                Test = $case.GetAttribute('name')
                Status = $status
            }
        }
    )

    $passed = @($results | Where-Object Status -eq 'PASSED').Count
    $skipped = @($results | Where-Object Status -eq 'SKIPPED').Count
    $failed = @($results | Where-Object Status -eq 'FAILED').Count
    $unknown = @($results | Where-Object Status -eq 'UNKNOWN').Count

    Write-Host "`n=== $preset ==="

    $results | Format-Table -AutoSize

    Write-Host "Selected: $($cases.Count)"
    Write-Host "Passed:   $passed"
    Write-Host "Skipped:  $skipped"
    Write-Host "Failed:   $failed"
    Write-Host "Unknown:  $unknown"

    $results | Export-Csv `
        "$reports/$preset-test-summary.csv" `
        -NoTypeInformation

    if ($failed -ne 0 -or $unknown -ne 0) {
        throw "Unexpected test result: $preset"
    }
}

The expected local results are 59/59 passes in both focused configurations and 258 passes with three existing OS-dependent capability skips in the PR smoke suite.

Other supported environments may produce different capability-skip results. Report those independently rather than treating them as successful execution.

Step 7 - Inspect debug-layer and info-queue evidence

Verbose logs retain fixture observations that may be truncated in default JUnit output.

foreach ($preset in @('dev', 'release', 'pr')) {

    $log = Join-Path $reports "$preset-tests.log"

    Write-Host "`n=== $preset ==="

    $present = @(Select-String -LiteralPath $log `
        -Pattern 'provenance debug info_queue=present')

    $absent = @(Select-String -LiteralPath $log `
        -Pattern 'provenance debug info_queue=absent')

    Write-Host "Info queues present: $($present.Count)"
    Write-Host "Info queues absent:  $($absent.Count)"

    Select-String -LiteralPath $log `
        -Pattern 'provenance debug info_queue=' |
        ForEach-Object { $_.Line }

    Select-String -LiteralPath $log `
        -Pattern 'adapter: .*debug layer enabled' |
        ForEach-Object { $_.Line }

    Select-String -LiteralPath $log `
        -Pattern 'x2w-d3d12 debug layer:' |
        ForEach-Object { $_.Line }
}

The final local campaigns produced:

Preset Info queues present Info queues absent
dev 68 0
release 68 0
pr 34 0

The counts are specific to the observed test inventory and capability results.

An absent info queue must be reported as such and must not be represented as successful debug-layer error screening.

Step 8 - Preserve verification evidence

Get-ChildItem -LiteralPath $reports -File |
    Get-FileHash -Algorithm SHA256 |
    Select-Object Hash, Path |
    Export-Csv "$reports/artifact-hashes.csv" -NoTypeInformation

For independent review, retain the source revision, adapter information, configuration and build logs, exact test inventories, verbose test logs, JUnit reports and individual result summaries.

Only sanitized, source-built evidence should be shared publicly.

Minimal seven-test reproduction

For the descriptor-history and Mesh provenance test families only, the following shorter campaign may be used after the corresponding build presets have been successfully configured.

foreach ($preset in @('dev', 'release')) {

    Invoke-CheckedNative "$reports/$preset-minimal-build.log" {
        cmake --build --preset $preset `
            --target startup_descriptor_history_check `
            startup_indirect_draw_indexed
    }

    Invoke-CheckedNative "$reports/$preset-minimal-tests.log" {
        ctest --preset $preset `
            --no-tests=error `
            --parallel 1 `
            --verbose `
            -R '^startup_(descriptor_history_(model|(filter|exhaustion)_(warp|hardware))|mesh_argument_provenance_(warp|hardware))$' `
            --output-junit "$reports/$preset-minimal-results.xml"
    }
}

This selection contains seven tests per configuration. It is not the complete 59-test regression campaign reported above.

Historical mutation controls - prior upstream baseline

The following author-side mutation campaigns were performed during consolidated implementation validation against upstream base 959306d407e51781b8860d84b5060ab5a7113e58.

These are historical development results, not mutation campaigns rerun against published head 390f5c1d.

Portable mutations

Six isolated portable mutations were successfully detected by their intended semantic assertions:

Mutation Result
Drop source selection Detected
Drop destination selection Detected
Accept stale registration publication Detected
Premature budget consumption Detected
Accept ambiguous mapping Detected
Incorrect mirror offset Detected

The mutant executables compiled successfully using /O2 /W4 /WX and failed their intended semantic checks with exit code 1.

The accepted Debug and Release model executables passed again following the mutation campaign.

Integrated runtime mutations

Three representative runtime mutations were tested using the source-built fixture on both the physical RTX 4060 and WARP.

Mutation Baseline records Mutated records Restored records
Omit source selection 4 2 4
Omit destination selection 3 1 3
Reduce history budget by one 8,192 8,191 8,192

The integrated mutation campaign comprised 18 native fixture executions:

  • Six baseline executions.
  • Six executions with the intended semantic regression.
  • Six restored executions.

All 18 completed successfully at the native process level. The mutations were detected by descriptor-history assertions rather than compilation failures, crashes or unrelated GPU failures.

The positive GPU pixel result remained 8/8 throughout the campaign. Producer and consumer X dimensions remained 2, three fence observations were retained, and info queues were present.

These integrated runtime mutation tests were performed in Debug. No corresponding Release mutation campaign is claimed.

The historical results are retained as development evidence and are distinct from the final-head independent mutation results below.

Independent verification - published head

Not-Saii's independent review tested the exact published head:

390f5c1d1e1f460422fcf8ff3d78da8a8aa27877

The reviewer exported the committed tree using git archive into an isolated Windows Sandbox. The network probe reported unreachable.

Independent test environment

Component Configuration
OS Windows 11 Enterprise 10.0.26100, build 26100
Hardware adapter NVIDIA GeForce RTX 4090 sandbox vGPU
NVIDIA driver 32.0.16.1088
Software adapter Microsoft Basic Render Driver
WARP App-local 1.0.22.0
Agility SDK 1.620
Build configuration Debug
D3D12 debug layer Enabled
Network probe Unreachable

These are the reviewer's independently reported environment and results, rather than additional author-side test executions.

Independent baseline results

The reviewer reported 11 passed, zero failed and zero skipped:

Test Result
startup_descriptor_history_model PASS
startup_descriptor_history_filter_warp PASS
startup_descriptor_history_filter_hardware PASS
startup_descriptor_history_exhaustion_warp PASS
startup_descriptor_history_exhaustion_hardware PASS
startup_mesh_argument_provenance_warp PASS
startup_mesh_argument_provenance_hardware PASS
startup_indirect_mesh_warp PASS
startup_indirect_mesh_hardware PASS
startup_indirect_draw_indexed_warp PASS
startup_indirect_draw_indexed_hardware PASS

The same selection also passed the reviewer's --repeat until-fail:5 validation.

A separate five-test descriptor-history selection passed without failures or skips.

The reviewer explicitly enabled X2W_D3D12_DEBUG=1 and reported that the in-box debug-interface probe returned 0x00000000.

All 68 provenance info-queue observations in the reviewer's head validation reported present, with no reported debug-layer ERROR or CORRUPTION messages.

Independent current-head mutation tests

The reviewer independently introduced two reverted-behavior mutations in isolated copies of the published revision.

M1 - Drop source-window selection

File: src/startup_stubs/descriptor_history/retained_registry.h

Original behavior:

filter::merge(result, window(a), window(b))

Reviewer mutation:

merge(result, {}, window(b))

The reviewer verified that both d3d12_xs.dll and startup_descriptor_history_check.exe changed following rebuilding.

Five tests detected the regression:

Test Detection
startup_descriptor_history_model Source or mirror-backed destination union assertion
startup_descriptor_history_filter_warp Source-only case
startup_descriptor_history_filter_hardware Source-only case
startup_descriptor_history_exhaustion_warp Noise-selection case
startup_descriptor_history_exhaustion_hardware Noise-selection case

The remaining six tests passed.

After restoration, all 11 tests passed.

M2 - Bypass selection before budget consumption

File: src/startup_stubs/d3d12_capture.inl

Original condition:

if (history_legacy_enabled())

Reviewer mutation:

if (history_legacy_enabled() || history_filtered())

The reviewer verified that d3d12_xs.dll changed following rebuilding.

Four runtime tests detected the regression:

Test Detection
startup_descriptor_history_filter_warp Positive combined-selector history-sequence assertion
startup_descriptor_history_filter_hardware Positive combined-selector history-sequence assertion
startup_descriptor_history_exhaustion_warp 5,000-slot targeted-selection case
startup_descriptor_history_exhaustion_hardware 5,000-slot targeted-selection case

The portable model remained passing, as expected for a mutation confined to runtime integration.

After restoration, all five selected tests passed.

These independent results demonstrate that the published head's regression suite detects both loss of source-range selection and incorrect admission of unrelated events before budget consumption.

The reviewer's exact build commands, test selections, mutation details and environment observations are available in the linked review.

Hosted CI

Windows CI run 46710411577

As independently confirmed in the review, the hosted Windows PR smoke job reported:

  • 258 passed.
  • Three existing xmem_placeholder_split_* capability skips.
  • Zero failures.

The following directly relevant tests were included and passed:

  • startup_mesh_argument_provenance_warp
  • startup_descriptor_history_model
  • startup_descriptor_history_filter_warp
  • startup_descriptor_history_exhaustion_warp

The hosted PR preset does not select the corresponding hardware tests.

Hardware validation is reported separately from the author's physical RTX 4060 runs and the reviewer's RTX 4090 sandbox vGPU runs.

Scope and limitations

Heap-relative ordinals are not stable identifiers across executions, configurations, adapters or concurrent registrations. Attribution is deliberately conservative when mapping identity cannot be established.

The diagnostic records CPU shadow publication order and pre-token-write guest samples. It does not establish:

  • Arbitrary guest-memory writes.
  • Actual native descriptor contents.
  • Whether the guest descriptor copy completed.
  • The complete source guest-token contents carried by a copy.
  • Complete typed SRV byte-range interpretation.
  • GPU execution order or cross-queue visibility.

View IDs may be reused. Matching numeric IDs alone do not establish persistent resource identity across an entire execution.

Registration discovery ordinarily reports the first 256 registrations, with additional selected registrations reported separately. The retained registry faults attribution beyond its supported capacity.

Incomplete-history reporting currently emits the first omission reason per process. The absence of additional omission messages is not proof that no additional operations were refused.

There is no end-of-process completeness receipt. Zero records or absence of a truncation marker is not proof of a complete history.

The portable model covers incomplete admission and refusal paths. The current integrated GPU fixtures primarily exercise tracked descriptor endpoints; a GPU incomplete-path control remains a proposed refinement.

No dedicated PR test exercises X2W_D3D12_TABLE_LOCK=1 in combination with targeted history.

The original provenance fixture and targeted history provide diagnostic infrastructure relevant to #3310.

This contribution does not claim to satisfy the remaining application-integration acceptance criteria of #3310 or demonstrate full rendering compatibility.

Attribution

The underlying descriptor-history implementation and Mesh argument provenance fixture originate from @wish131400's PR #3321.

The original Git author identity and author date are preserved in the dependency integration commit.

Credit to:

  • @Leyukaka for identifying the event-budget limitation, disabled-path overhead and omission/discovery reporting limitations.
  • @Jess-Doit for identifying unnecessary traversal after truncation and additional provenance limitations.
  • @lukaslw-lab and @JohnConnorNPC for their descriptor attribution, identity and integration review findings.
  • @Not-Saii for independent runtime validation, current-head mutation testing, contribution-scope review and verification recommendations.

Follow-up review remediation — e2609c0e

Addresses technical recommendations from @Leyukaka and @Not-Saii across 14 files (506 insertions, 100 deletions), without introducing external dependencies or additional GPU synchronization requirements.

Disabled-history overhead — Leyukaka SHOULD 1

Introduced a cached history_active() check in note_view() and note_copy(), bypassing history-specific shadow observations, stride calculations, reservation, and token sampling when history is disabled. Ordinary descriptor operations and resource-reference accounting remain unchanged.

Optimized Release microbenchmarks against 390f5c1d comprised 72 isolated process executions, 61.2 million API calls, and 288 million descriptor operations.

Operation RTX 4060 cycles WARP cycles RTX 4060 time WARP time
View creation -2.52% -1.66% -3.10% -1.33%
Single-descriptor copy -6.86% -3.81% -5.14% -2.53%
64-descriptor copy +9.70% +11.64% +10.69% +10.46%

A secondary optimization reduced the compiled note_copy() function size from 2,398 to 1,727 bytes. However, further benchmarking across 384 million descriptor operations failed to resolve the bulk-copy regression, so the initial optimization was retained.

The SHOULD is addressed structurally, although complete performance parity with the underlying dependency has not been achieved.

Further optimization is intentionally deferred until the graphics-rendering pipeline reaches a significant, reproducible functional milestone. Representative workloads will then allow more meaningful profiling of descriptor-copy distributions, lock contention, resource streaming, and CPU/GPU utilization.

The long-term objective remains near-zero disabled-diagnostic overhead and elimination of the observed bulk-copy regression without compromising runtime correctness.

These are historical R1.1 synthetic CPU-side measurements, not application FPS or end-to-end performance measurements of e2609c0e.

Omission reporting and discovery — Leyukaka SHOULD 2 / Not-Saii NIT 3

  • Replaced first-reason-only reporting with nine independent, saturating 64-bit atomic counters.
  • Emit cumulative omission counts at powers of two, bounded to 64 messages per reason and 576 combined, excluding the separate registry fault marker.
  • Removed the 256-registration discovery cutoff. All successfully retained registrations are now discoverable up to the existing 1,024-registration capacity.
  • Preserved the existing 8,192-record history budget and registry storage capacity.

Portable model validation:

PASS omission counters reasons=9 occurrences_per_reason=10000 lines_per_reason=14 concurrent=10000
PASS full heap discovery retained=1024 discovered=1024 late_selectors=257,1024 fault=1025

Historical isolated mutation controls detected regressions involving first-occurrence-only reporting, shared counters, incorrect reason classification, and restoration of the previous discovery cutoff.

No end-of-process completeness guarantee is introduced.

Integrated incomplete-history controls — Leyukaka NIT

Added startup_descriptor_history_incomplete_{warp,hardware} with three source-built runtime controls:

Control History records Omission messages Discovery records
Untracked native-source copy 4 3 2
History disabled 0 0 0
Registry overflow 5 5 1,024

The untracked-source control verifies five native descriptor copies, omission counts of 1, 2, and 4, unchanged guest-token state, correct (2,1,1) argument records, and 8/8 scene-color pixels.

The overflow control verifies 1,024 retained registrations and five additional successful native heap allocations, with independent registry, view-attribution, and copy-attribution omission reporting.

The GPU oracle is verified before registry overflow; subsequent operations are checked through descriptor-token observations and device status.

All controls passed on hardware and WARP in Debug and optimized Release.

Documentation — Not-Saii NIT 4

Removed the redundant docs/experiments.md entry and updated the dedicated experiment note with revised diagnostic bounds, omission semantics, reproduction commands, and limitations.

Documentation-link, bidirectional-control, and Git whitespace checks passed.

Consolidated verification — Not-Saii SHOULD 2

Campaign Passed Skipped Failed
Debug focused regression 61 0 0
Optimized Release focused regression 61 0 0
Windows PR smoke 259 3 0
Total 381 3 0

Each focused configuration includes 24 hardware, 27 WARP, and 10 other tests. The smoke suite includes 54 WARP passes and 205 other passes.

The three existing capability skips remain:

  • xmem_placeholder_split_control
  • xmem_placeholder_split_deployed
  • xmem_placeholder_split_partial

These returned code 77 because the OS exposes the placeholder bit directly.

Primary regression results

Test Debug Release PR smoke
startup_descriptor_history_model PASS PASS PASS
startup_descriptor_history_filter_warp PASS PASS PASS
startup_descriptor_history_filter_hardware PASS PASS Not selected
startup_descriptor_history_exhaustion_warp PASS PASS PASS
startup_descriptor_history_exhaustion_hardware PASS PASS Not selected
startup_descriptor_history_incomplete_warp PASS PASS PASS
startup_descriptor_history_incomplete_hardware PASS PASS Not selected
startup_mesh_argument_provenance_warp PASS PASS PASS
startup_mesh_argument_provenance_hardware PASS PASS Not selected

D3D12 information-queue verification

Fixture family Debug Release PR smoke
Mesh argument provenance 12/12 12/12 6/6
Descriptor-history filtering 38/38 38/38 19/19
Descriptor-history exhaustion 18/18 18/18 9/9
Incomplete-history controls 6/6 6/6 3/3
Total 74/74 74/74 37/37

Twelve additional incomplete-history executions passed with complete decoded stdout and stderr retained separately.

Including these additional controls, all 197 provenance information-queue observations reported present, with no absent information queues.

Reproduction and evidence integrity

The original 59-test focused inventory was expanded by the two incomplete-history registrations. The updated nine-test minimal reproduction is distinct from the complete 61-test selection:

foreach ($preset in @('dev', 'release')) {
    ctest --preset $preset --no-tests=error -j 1 -V -R '^startup_(descriptor_history_(model|(filter|exhaustion|incomplete)_(warp|hardware))|mesh_argument_provenance_(warp|hardware))$'
    if ($LASTEXITCODE -ne 0) {
        throw "Regression failed: $preset"
    }
}

The full focused inventory, individual test results, compiler flags, binary hashes, JUnit reports, and diagnostic logs are retained locally, with SHA-256 verification covering 63 evidence artifacts.

The tested cumulative source candidate was independently verified against the committed tree of e2609c0e.

Historical mutation results against 959306d4, subsequent R1 development mutations, and Not-Saii's independent validation against 390f5c1d remain attributed to their respective tested revisions.

All contributed implementation and validation fixtures are source-built. No proprietary application content or SDK materials are included.

AI-assisted implementation, testing and verification.

wish131400 and others added 2 commits December 1, 2026 12:31
Integrate the original contribution from PR R0Y00#3321, including the author's subsequent conflict resolution, onto main 158ef79.

Original authored commit: 42a1855
Original resolved PR head: 029dfef
Refs R0Y00#3310 and R0Y00#3321.
Select heap-relative descriptor ranges before consuming the diagnostic event budget. Match copies by source or destination, validate retained mapping and shadow identity, and bound diagnostic traversal after truncation.

Add source-built model and Mesh regression checks for filtering, exhaustion, and sparse copy windows. Document selection syntax, conservative attribution, and completeness limits.

Builds on wish131400's provenance work in R0Y00#3321 and the review findings of Leyukaka and Jess-Doit. Refs R0Y00#3310 and R0Y00#3321. AI-assisted implementation, testing and verification.
@Vilify-13
Vilify-13 marked this pull request as ready for review December 1, 2026 18:27

@Leyukaka Leyukaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed 390f5c1d by reading the diff; not built or run.

Verdict: approve. No MUST. Two SHOULDs and two NITs below.

Integration. 04a6c5a0 combines 42a18553 and wish131400's merge 029dfefe into one commit, with the original author, author date and headline kept. Four of its files match 029dfefe byte for byte. In the other four, the added and removed lines match 029dfefe except where main changed the same lines: CMakePresets.json adds only startup_mesh_argument_provenance_warp to the new pr filter, and tests/startup_indirect_draw_indexed.cpp keeps runtime_mesh57. GitHub reports the branch mergeable into 158ef794.

Earlier review points on #3321

  • Leyukaka 1 (conflict): addressed, see above.
  • Leyukaka 2 (the 8,192 cap is used up during initialization): addressed. Operations are selected by heap and slot range before they use the budget (d3d12_capture.inl:700-744, retained_registry.h:165-181). The exhaustion cases check the 4093/4094 boundary and a later heap kept after 5,000 unrelated slots.
  • Leyukaka 3 (info queue): addressed in 029dfefe. The fixture prints info_queue=present|absent and the check reads it (startup_mesh_argument_provenance_check.py:96).
  • Jess-Doit 3 (the walk continues after the cap): addressed. Once truncated, history_reserve returns at once (d3d12_capture.inl:705), legacy mode skips title_descriptor_stride (:943), and planning stops (xs_device.cpp:6265, 6501, 6541, 7717).
  • Jess-Doit 1 (guest token and whether the guest copy ran): not addressed. copy events still record shadow ids only (d3d12_capture.inl:962).
  • Jess-Doit 2 (byte range of typed buffer SRVs): not addressed (:809-816).
  • lukaslw-lab source_id=: partly addressed. In filtered mode, an untracked or opaque endpoint makes the record be refused and reported as incomplete (history_admission.h:58-63). Legacy mode still logs an untracked source as new=0 (:962).
  • JohnConnorNPC's id-reuse note: addressed in docs/startup-runtime.md and mesh-argument-provenance.md.

SHOULD

  1. Off path (d3d12_capture.inl). With X2W_D3D12_DESCRIPTOR_HISTORY unset, note_copy now calls history_legacy_enabled(), then, under exclusive note_lock, two history_shadow_observe() calls and a history_reserve() call (:943, 954-957); note_view does the same (:899-902). #3321 had one cached flag check. Each call returns early and allocates nothing, but a single cached "history active" check at the call sites would restore the old cost of the hot copy path.
  2. Omissions are reported once (history_runtime.inl:15-22). history_incomplete logs only the first reason per process, so later refused selected operations leave no trace, and a reader cannot tell one omission from thousands. A per-reason counter, or the first N lines, would make the history usable on a real run. Related: discovery logs only the first 256 registrations (heap_shape.h:14), so the ordinal needed to select a heap created later cannot be found from the log.

NIT

  • The PR body says "This draft integrates…", but the PR is not a draft.
  • The model check covers the refusal paths. No GPU case runs an incomplete path, such as a selected copy from an untracked source.

Checks

  • Off by default: an unset master switch skips the filter variable, and the registry is built only once filtering is active.
  • Memory is bounded: 1,024 registrations, 2 selectors, 8,192 events.
  • Locks: descriptor_lock is taken before or outside note_lock (history_runtime.inl:156-161, 172-179). Under note_lock, admission makes only shadow lookups and atomic reads.
  • No GPU commands are added. The truncation marker is written after the records admitted with it.
  • Tests use require() (exit 1) and Python assert. startup_descriptor_history_{model,filter_*,exhaustion_*} are registered, and CI at this head ran model, filter_warp and exhaustion_warp: Passed.
  • The body cites #3310 as Refs only and says the remaining criteria are still open.

@Vilify-13

Copy link
Copy Markdown
Author

Thank you for reviewing! I'm taking a look at both SHOULDs, would you rather I address these in this PR before merge or submit the changes in a follow up PR?

@Not-Saii Not-Saii 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.

Review of head 390f5c1d1e1f460422fcf8ff3d78da8a8aa27877 (base 158ef79422f296c48873bfe8123e1e040125dc0a).

The filtering code is careful, and it was tested well in an isolated build. Both reverted-behavior mutants were caught by the PR's own tests, and the restored tree passed again. One scope issue blocks approval. It concerns how the PR is put together, not the filter.

Findings

MUST

  1. Two behaviors from two authors, one of them still an open PR. Commit 04a6c5a0 is the change from #3321, rebased onto current main. I compared it with #3321's own diff, and only the context lines differ. #3321 is still open. That commit adds the opt-in descriptor history (d3d12_capture.inl trace_descriptor_history, note_view/note_copy hooks) and the Mesh argument provenance fixture (tests/startup_mesh_argument_provenance.inl, tests/startup_mesh_argument_provenance_check.py, tests/cmake/mesh_argument_provenance.cmake, docs/experiments/mesh-argument-provenance.md). Commit 390f5c1d adds the heap-relative filter. AGENTS.md and CONTRIBUTING.md:82 ask for one reviewable behavior per pull request, and CONTRIBUTING.md asks the description to "name any PR that must land first" rather than carry it. Commit 04a6c5a0 also brings along review points that are still open on #3321, among them that the trace does not record whether the guest copy ran, and that typed buffer SRVs log no byte range. Those belong in that thread. As it stands, merging either PR leaves the other conflicting or duplicated, and reviewers have to review #3321's code twice. Please do one of these:

    • land #3321 first and rebase this PR so it carries only 390f5c1d;
    • or get agreement in #3321 that it closes in favour of this PR, and record that here.

    The PR body defers landing order to maintainer coordination. This finding asks for that coordination to happen before merge.

SHOULD

  1. The PR body evidence does not match the head or the commands.
    • The body reports "Debug focused regression 59 / Release 59". Its reproduction regex selects 7 tests. Please list the 59 tests, or report the 7 tests that the command runs.
    • The mutation table was measured against base 959306d4, not this head. Please rerun it at 390f5c1d, or label it as historical. (For what it is worth, my two mutants below were caught at this head.)
    • "Debug layer: Enabled for relevant GPU fixtures" should name the fixtures. Report the provenance debug info_queue= result, which the fixture prints.
    • List the _hardware and _warp results per test, with any 77 skips kept separate. At the moment they are only totals.

NIT

  1. src/startup_stubs/descriptor_history/history_runtime.inl:19: history_incomplete logs only the first reason in each process. The doc (docs/experiments/descriptor-history-filter.md:61-63) lists several reasons that can omit operations. A later omission with a different cause is silent. A per-reason first-call flag, or a count at the first truncation, would make the trace easier to audit.
  2. docs/experiments.md:5-7 adds a new section at the top of the file that keeps the older notes. The folder guide sends new notes to docs/experiments/<topic>.md, "so two pull requests that each add a note do not edit the same lines". This PR already adds docs/experiments/descriptor-history-filter.md, and the README row links it, so the extra section in the old file only adds a conflict point.

What I checked and found sound

  • Opt-in and cost when off. With X2W_D3D12_DESCRIPTOR_HISTORY unset, the filter variable is never read (descriptor_history_config_win.h), and history_configuration() is a cached function-local static. The off path adds these checks:

    • each view creation and each copy chunk reads a cached flag and zero-initialises the history structs on the stack (d3d12_xs_device.cpp:6265,6501,6541,7717);
    • note_view (d3d12_capture.inl:900) and note_copy each call history_reserve once, and it returns at the plan.status == off check before touching GetLastError;
    • note_copy also calls history_legacy_enabled().

    None of these takes a lock, reads the environment or makes a syscall. The draw path reaches the change only through shadow_slot's two new defaulted parameters (shadow_id at d3d12_capture.inl:296,389), so a draw-time lookup gains one null check.

    The native copy, the shadow publication and the token writes run in the same order as before. device_create_descriptor_heap still pushes the same descriptor_ranges entry. The filter's off case and the provenance trace opt-out both assert that no history line appears.

  • Locks. The budget (d3d12_capture.inl:715) is used only under note_lock exclusive, in note_view, note_copy and drop_unrecorded_view. The registry and history_owners are used only under descriptor_lock. The history_plan_* functions take descriptor_lock shared before note_lock is taken, and the row lookups in admission use shadow_slot with no second lock, so no new nesting appears. A concurrent heap registration bumps history_publication, and admission checks it before and after the row probes, so a race drops the record and reports it as incomplete. With X2W_D3D12_TABLE_LOCK=1, heap table writers still take note_lock exclusive before table_lock (d3d12_capture.inl:181,194), so the shadow_slot reads made while holding note_lock stay consistent. No PR test runs with that switch.

  • Call sites. All 4 note_view callers and the one note_copy caller pass an expectation. descriptor_ranges is append-only: there is one push_back and no erase, which matches the registry's mapping_index == mapped_count_+1 rule.

  • Memory bounds.

    • The registry is a lazily built static of 1,024 registrations, 73,856 bytes as the model check prints it. It exists only in filtered mode.
    • history_owners is 8 KB of static storage.
    • The budget is O(1).
    • Admission probes only the admitted rows; the model asserts this up to a 1,000,000-descriptor copy.
    • Discovery logging stops after 256 registrations.
    • Past 1,024 registrations, the registry faults closed (retained_registry.h:104), as descriptor-history-filter.md:50 documents.

    In filtered mode, attribute() scans the retained registrations linearly for each view and each copy chunk (retained_registry.h:128). That cost matches the existing descriptor_ranges walk, and it is diagnostic-only.

  • Platform split. descriptor_history_config_win.h is the only new header that includes <windows.h>. The model check compiles the portable headers together with descriptor_heap_match.h.

  • Content. The diff names no title and contains no third-party assets.

  • CMakePresets.json. The change touches only the pr presets. It adds startup_descriptor_history_check to the pr build targets and adds startup_mesh_argument_provenance_warp|startup_descriptor_history_(model|(filter|exhaustion)_warp) to the pr test filter. The dev, release and runtime presets are unchanged. Nothing in the PR adds a download, a network call or a new build tool.

What each test proves

  • startup_descriptor_history_model tests the shared headers without D3D12:
    • selector grammar and its rejections;
    • registry attribution of mirrors, tails, ambiguous and stale endpoints;
    • the union of source and destination windows;
    • transactional admission (rollback on a bad row, only admitted rows probed, the marker only after a valid omitted record, no work after the stop);
    • 20,000 randomized admission cases and 100,000 randomized registry cases.
  • startup_descriptor_history_filter_{warp,hardware} runs 19 cases. The five provenance cases each run with both, source and destination selectors, and positive also runs with an empty, off, invalid and unmatched filter. Each case checks:
    • the exact history sequence and the registry lines with their selector masks;
    • a positive result of 8/8 pixels, and negative controls that fail the oracle;
    • no debug-layer errors.
  • startup_descriptor_history_exhaustion_{warp,hardware} runs 9 cases with 4,093 to 5,000 unrelated slots. It covers:
    • the legacy budget boundary: 8,191 records with no marker, then 8,192 with the marker;
    • the exact boundary, 4,096 selected noise slots giving exactly 8,192 records and no marker;
    • target, which keeps the 5 Mesh records after 10,000 unrelated events;
    • mixed and sparse copy windows.
  • startup_mesh_argument_provenance_{warp,hardware} runs the #3321 oracle: the positive case, four negative controls, and the positive case with tracing off.

Mutation results (Windows Sandbox, network off, PR tree read-only)

  • M1: the copy plan drops the source window. In retained_registry.h:179, I changed filter::merge(result, window(a), window(b)) to merge(result, {}, window(b)).
    • Rebuild check: d3d12_xs.dll and startup_descriptor_history_check.exe both changed.
    • 5 tests failed, at the expected points:
      • startup_descriptor_history_model failed at "source or mirror-backed destination union";
      • filter_warp and filter_hardware failed at the first source case, after positive both passed;
      • exhaustion_warp and exhaustion_hardware failed at the first noise case, after the legacy, target and off cases passed.
    • The 6 other tests in the set still passed.
    • The restored tree passed 11/11.
  • M2: filtered mode uses the unfiltered plan before the budget. In d3d12_capture.inl:707, I changed the condition to if (history_legacy_enabled() || history_filtered()). This reverts "select before budget consumption".
    • Rebuild check: d3d12_xs.dll changed.
    • startup_descriptor_history_model still passed. That is expected, because this is a runtime-only revert.
    • 4 tests failed:
      • filter_warp and filter_hardware failed at the first case (positive both) on the history-sequence assertion;
      • exhaustion_warp and exhaustion_hardware failed at slots=5000 mode=target after the three legacy cases passed, so unrelated events consumed the budget before the selected Mesh records.
    • The restored tree passed 5/5.

Evidence (AGENTS.md fields)

  • Commit: 390f5c1d1e1f460422fcf8ff3d78da8a8aa27877. Both runs exported the head with git archive into Windows Sandbox. The network probe reported unreachable.
  • Commands (Debug):
    • environment: X2W_D3D12_DEBUG=1
    • configure: cmake --preset dev -DX2W_WITH_OPUS=OFF -DINTAKE_PYTHON=<venv python> -DOFFSCREEN_AGILITY_620_DIR=<Agility 1.620 dir> -DOFFSCREEN_WARP_DIR=<WARP 1.0.22 dir>
    • build: cmake --build --preset dev --target startup_descriptor_history_check startup_indirect_draw_indexed
    • run 1: ctest --preset dev --no-tests=error --output-on-failure -V -R '^startup_(descriptor_history_(model|(filter|exhaustion)_(warp|hardware))|mesh_argument_provenance_(warp|hardware)|indirect_mesh_(warp|hardware)|indirect_draw_indexed_(warp|hardware))$'. The leg ran again with --repeat until-fail:5.
    • run 2: ctest --preset dev --no-tests=error --output-on-failure -V -R '^startup_descriptor_history_(model|(filter|exhaustion)_(warp|hardware))$'.
  • Run 1 results at the head: 11 passed, 0 failed, 0 skipped (77). The --repeat until-fail:5 leg also passed 11/11. Tests:
    • startup_descriptor_history_model;
    • startup_descriptor_history_filter_warp, startup_descriptor_history_filter_hardware;
    • startup_descriptor_history_exhaustion_warp, startup_descriptor_history_exhaustion_hardware;
    • startup_mesh_argument_provenance_warp, startup_mesh_argument_provenance_hardware;
    • startup_indirect_mesh_warp, startup_indirect_mesh_hardware;
    • startup_indirect_draw_indexed_warp, startup_indirect_draw_indexed_hardware.
  • Run 2 results at the head: 5 passed, 0 failed, 0 skipped (77): startup_descriptor_history_model, filter_warp, filter_hardware, exhaustion_warp, exhaustion_hardware.
  • Adapters, as the fixtures print them:
    • Microsoft Basic Render Driver, driver: 1.0.22.0 (app-local WARP);
    • NVIDIA GeForce RTX 4090 (sandbox vGPU), driver: 32.0.16.1088.
  • OS: Windows 11 Enterprise 10.0.26100, build 26100.
  • Debug layer:
    • X2W_D3D12_DEBUG=1 was set, and the in-box probe returned D3D12GetDebugInterface hr=0x00000000;
    • each GPU fixture printed adapter: ..., debug layer enabled, and the shim printed x2w-d3d12 debug layer: 0x00000000 enabled;
    • all 68 provenance debug info_queue= lines in the head leg read present, and no debug ERROR or CORRUPTION message was reported.

CI

Run 46710411577: the Windows job ran the pr preset, with 258 passed, 3 skipped (the existing xmem_placeholder_split_* controls) and 0 failed. It ran and passed 4 of this PR's tests:

  • startup_mesh_argument_provenance_warp;
  • startup_descriptor_history_model;
  • startup_descriptor_history_filter_warp;
  • startup_descriptor_history_exhaustion_warp.

CI ran none of the _hardware tests. Those results come only from the sandbox runs above.

Verdict: request changes. The only blocking item is MUST 1, the bundled open #3321. The filter code passed every sandbox leg, and both mutants were caught.

@Vilify-13

Vilify-13 commented Dec 1, 2026 •

Copy link
Copy Markdown
Author

Thank you @Not-Saii for the extensive review, validation, and testing! I understand the blocking concern with #3321 regarding coordination. I intended to provide a conflict-resolved integration while preserving their original author attribution, but I agree that the landing order needs coordination before merge. I'll seek agreement with them still, but haven't gotten a hold of them yet so far since I originally reached out the other day.

I'll be updating the description to satisfy your SHOULD listed shortly.

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.

4 participants