gpu: test Xbox frame events and pipeline token wait semantics #1007

Merged
Holastor merged 2 commits from upstream-pr/1014 into main 2026-11-23 21:55:36 +00:00
Holastor commented 2026-11-23 21:16:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T21:16:37Z.


Summary

This pull request implements the source-built Xbox frame-event timing and token wait fixture requested in #874, updated per review feedback.

Call sequence and public citations

The fixture follows the public frame-pacing call sequence from Microsoft's Xbox GDK sample (InGameStore/DeviceResources.cpp):

  1. SetFrameIntervalX initializes cadence.
  2. ScheduleFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, 0, nullptr, 0) registers the frame origin once.
  3. WaitFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, ...) waits each frame and retrieves the pipeline token. Passing the token to PresentX is a cited follow-up (this caller verifies token delivery but does not call PresentX).

Contract boundaries and fixture choices

  • Established call shape: SetFrameIntervalX → ScheduleFrameEventX(ORIGIN) once → WaitFrameEventX(ORIGIN) each frame with nullptr event handle and token delivery.
  • Fixture choices (labeled as requiring separate evidence):
    • Exposing these methods as PE imports from d3d12_xs.dll is a fixture choice (the GDK sample invokes device methods).
    • Passing a null output to SetFrameIntervalX is a fixture choice (the sample passes an actual IDXGIOutput*).
    • Numeric constants (e.g. 60) and seeded token representation (monotonically advancing 64-bit integer 1, 2, ...).
    • Unused HANDLE signaling was dropped per review feedback.
    • Controlled tick timing driver: Registration injects two scheduled ticks from an internal thread, exercising real blocked waiters with an explicit witness (get_frame_events_blocked_waits() == 2) without relying on wall-clock timer resolution.
    • Bounded timeout before tick: Calling WaitFrameEventX before a tick arrives returns WAIT_TIMEOUT (0x00000102) and preserves the caller's output sentinel.
    • Refusal: Unrepresented event types other than D3D12XBOX_FRAME_EVENT_ORIGIN (value 0) return E_INVALIDARG (0x80070057), leaving the output sentinel intact.
    • Separated fault controls:
      • cpu_frame_events_provider_clobber simulates refusal sentinel overwrite, caught specifically at step 2 (asserted exit 0xE03).
      • cpu_frame_events_provider_early simulates premature release before tick, caught specifically at step 3 (asserted exit 0xE04).

Verification

Tested under Windows 10 (MSVC 19.44 x64) at commit 2b977cd:

cmake --build --preset dev --target cpu_frame_events_provider cpu_frame_events_provider_clobber cpu_frame_events_provider_early cpu_frame_events_caller
ctest --preset dev --no-tests=error -R '^cpu_native_frame_events$' -V
cmake --build --preset release --target cpu_frame_events_provider cpu_frame_events_provider_clobber cpu_frame_events_provider_early cpu_frame_events_caller
ctest --preset release --no-tests=error -R '^cpu_native_frame_events$' -V
.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
.\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py

Outputs:

  • Dev preset: cpu_native_frame_events passed in 0.31s (exit 0x874).
  • Release preset: cpu_native_frame_events passed in 0.31s (exit 0x874).
  • Mutation 1 (sentinel clobber): caught at step 2 with exit 0xE03.
  • Mutation 2 (early release): caught at step 3 with exit 0xE04.
  • Withholding d3d12_xs.dll stopped pe_map at import resolution (STATUS["unresolved"]).
  • All 217 markdown links, bidirectional control checks, form coverage, and hardware reports passed.

Refs #874.

AI-assisted (Antigravity).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6569003303 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1014). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T21:16:37Z. --- ### Summary This pull request implements the source-built Xbox frame-event timing and token wait fixture requested in #874, updated per review feedback. ### Call sequence and public citations The fixture follows the public frame-pacing call sequence from Microsoft's Xbox GDK sample ([`InGameStore/DeviceResources.cpp`](https://github.com/microsoft/Xbox-GDK-Samples/blob/41b5942c4fba910332123070e51827761f6040fd/Samples/Live/InGameStore/DeviceResources.cpp)): 1. `SetFrameIntervalX` initializes cadence. 2. `ScheduleFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, 0, nullptr, 0)` registers the frame origin once. 3. `WaitFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, ...)` waits each frame and retrieves the pipeline token. Passing the token to `PresentX` is a cited follow-up (this caller verifies token delivery but does not call `PresentX`). ### Contract boundaries and fixture choices - **Established call shape**: `SetFrameIntervalX → ScheduleFrameEventX(ORIGIN) once → WaitFrameEventX(ORIGIN) each frame` with `nullptr` event handle and token delivery. - **Fixture choices (labeled as requiring separate evidence)**: - Exposing these methods as PE imports from `d3d12_xs.dll` is a fixture choice (the GDK sample invokes device methods). - Passing a null output to `SetFrameIntervalX` is a fixture choice (the sample passes an actual `IDXGIOutput*`). - Numeric constants (e.g. 60) and seeded token representation (monotonically advancing 64-bit integer 1, 2, ...). - Unused `HANDLE` signaling was dropped per review feedback. - **Controlled tick timing driver**: Registration injects two scheduled ticks from an internal thread, exercising real blocked waiters with an explicit witness (`get_frame_events_blocked_waits() == 2`) without relying on wall-clock timer resolution. - **Bounded timeout before tick**: Calling `WaitFrameEventX` before a tick arrives returns `WAIT_TIMEOUT` (`0x00000102`) and preserves the caller's output sentinel. - **Refusal**: Unrepresented event types other than `D3D12XBOX_FRAME_EVENT_ORIGIN` (value 0) return `E_INVALIDARG` (`0x80070057`), leaving the output sentinel intact. - **Separated fault controls**: - `cpu_frame_events_provider_clobber` simulates refusal sentinel overwrite, caught specifically at step 2 (asserted exit `0xE03`). - `cpu_frame_events_provider_early` simulates premature release before tick, caught specifically at step 3 (asserted exit `0xE04`). ### Verification Tested under Windows 10 (MSVC 19.44 x64) at commit `2b977cd`: ```powershell cmake --build --preset dev --target cpu_frame_events_provider cpu_frame_events_provider_clobber cpu_frame_events_provider_early cpu_frame_events_caller ctest --preset dev --no-tests=error -R '^cpu_native_frame_events$' -V cmake --build --preset release --target cpu_frame_events_provider cpu_frame_events_provider_clobber cpu_frame_events_provider_early cpu_frame_events_caller ctest --preset release --no-tests=error -R '^cpu_native_frame_events$' -V .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py .\out\pe-env\Scripts\python.exe -B tests/hardware_reports_check.py ``` Outputs: - Dev preset: `cpu_native_frame_events` passed in 0.31s (exit `0x874`). - Release preset: `cpu_native_frame_events` passed in 0.31s (exit `0x874`). - Mutation 1 (sentinel clobber): caught at step 2 with exit `0xE03`. - Mutation 2 (early release): caught at step 3 with exit `0xE04`. - Withholding `d3d12_xs.dll` stopped `pe_map` at import resolution (`STATUS["unresolved"]`). - All 217 markdown links, bidirectional control checks, form coverage, and hardware reports passed. Refs #874. _AI-assisted (Antigravity)._
upstream-sync closed this pull request 2026-11-24 06:45:51 +00:00
R0Y00 commented 2026-11-24 06:49:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T21:25:45Z.


I reproduced cpu_native_frame_events on Windows Release at 1b8cfbb7: the native and mapped callers return 0x874, the withheld provider stops at WaitFrameEventX, and the combined faulty provider exits 0xe03. That last exit is the refusal-sentinel assertion at step 2, before the premature-release mutation can run.

Please separate the two mutations and assert their specific exit codes, so a loader failure cannot satisfy either control. Also separate scheduling from delivery: the Microsoft sample registers ORIGIN once, then waits each frame. A fixture control can inject two ticks after one registration, with a bounded wait and an explicit witness for the pending state. Currently calling Schedule again adds a tick directly and the two finite waits return immediately, so the fixture does not exercise a blocked waiter. If you keep the sequential version, describe it as polling an empty queue and narrow the timing claim.

The linked sample calls device methods and passes an actual DXGI output to SetFrameIntervalX. Please label the PE imports, null output, numeric values and seeded token as fixture choices, drop unused HANDLE signaling, and keep PresentX as a cited follow-up (this caller does not pass a token to it).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7114448682 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1014#issuecomment-7114448682). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T21:25:45Z. --- I reproduced `cpu_native_frame_events` on Windows Release at `1b8cfbb7`: the native and mapped callers return `0x874`, the withheld provider stops at `WaitFrameEventX`, and the combined faulty provider exits `0xe03`. That last exit is the refusal-sentinel assertion at step 2, before the premature-release mutation can run. Please separate the two mutations and assert their specific exit codes, so a loader failure cannot satisfy either control. Also separate scheduling from delivery: the Microsoft sample registers ORIGIN once, then waits each frame. A fixture control can inject two ticks after one registration, with a bounded wait and an explicit witness for the pending state. Currently calling Schedule again adds a tick directly and the two finite waits return immediately, so the fixture does not exercise a blocked waiter. If you keep the sequential version, describe it as polling an empty queue and narrow the timing claim. The linked sample calls device methods and passes an actual DXGI output to SetFrameIntervalX. Please label the PE imports, null output, numeric values and seeded token as fixture choices, drop unused HANDLE signaling, and keep PresentX as a cited follow-up (this caller does not pass a token to it).
Holastor commented 2026-11-24 06:49:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-23T21:33:17Z.


Updated in 2b977cd addressing each point:

  1. Separated mutations and exit codes:
    • Split into two independent provider targets: cpu_frame_events_provider_clobber (asserts exit 0xE03 specifically for refusal sentinel clobber at step 2) and cpu_frame_events_provider_early (asserts exit 0xE04 specifically for premature wait release at step 3). Both are checked independently in frame_events_check.py.
  2. Separated scheduling from delivery & blocked waiter:
    • The caller calls ScheduleFrameEventX(ORIGIN) once to register origin scheduling per the Microsoft sample.
    • An internal injector thread injects two scheduled ticks separated by a delay.
    • Both subsequent WaitFrameEventX calls block until their respective tick arrives, verified by the explicit witness get_frame_events_blocked_waits() == 2.
  3. Dropped unused HANDLE signaling:
    • Removed fake HANDLE signaling logic from both calls.
  4. Qualifications:
    • Labeled PE imports from d3d12_xs.dll, null output passed to SetFrameIntervalX, numeric constants, and seeded monotonic integer tokens as fixture choices.
    • Kept PresentX cited as a follow-up.

Both dev and release CTests pass in ~0.31s with zero wall-clock drift, and all Python lint checks pass.

AI-assisted (Antigravity).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7114614167 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1014#issuecomment-7114614167). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-23T21:33:17Z. --- Updated in `2b977cd` addressing each point: 1. **Separated mutations and exit codes**: - Split into two independent provider targets: `cpu_frame_events_provider_clobber` (asserts exit `0xE03` specifically for refusal sentinel clobber at step 2) and `cpu_frame_events_provider_early` (asserts exit `0xE04` specifically for premature wait release at step 3). Both are checked independently in `frame_events_check.py`. 2. **Separated scheduling from delivery & blocked waiter**: - The caller calls `ScheduleFrameEventX(ORIGIN)` once to register origin scheduling per the Microsoft sample. - An internal injector thread injects two scheduled ticks separated by a delay. - Both subsequent `WaitFrameEventX` calls block until their respective tick arrives, verified by the explicit witness `get_frame_events_blocked_waits() == 2`. 3. **Dropped unused HANDLE signaling**: - Removed fake HANDLE signaling logic from both calls. 4. **Qualifications**: - Labeled PE imports from `d3d12_xs.dll`, null output passed to `SetFrameIntervalX`, numeric constants, and seeded monotonic integer tokens as fixture choices. - Kept `PresentX` cited as a follow-up. Both `dev` and `release` CTests pass in ~0.31s with zero wall-clock drift, and all Python lint checks pass. _AI-assisted (Antigravity)._
R0Y00 commented 2026-11-24 06:49:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T21:39:50Z.


Thanks for separating the two mutants and pinning their exits. I pushed ea777873 to replace the two Sleep(15) guesses with a condition-variable handshake. The worker can deliver each tick only after the corresponding caller wait releases the shared lock, and the mapped check now reads the recorder counts. Windows Release ctest --preset release --no-tests=error -R '^cpu_native_frame_events$' --repeat until-fail:30 --output-on-failure passed all 30 runs, including the exact refusal-clobber and early-release exits. This is the source-built recorder for #874.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7114756432 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1014#issuecomment-7114756432). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T21:39:50Z. --- Thanks for separating the two mutants and pinning their exits. I pushed `ea777873` to replace the two `Sleep(15)` guesses with a condition-variable handshake. The worker can deliver each tick only after the corresponding caller wait releases the shared lock, and the mapped check now reads the recorder counts. Windows Release `ctest --preset release --no-tests=error -R '^cpu_native_frame_events$' --repeat until-fail:30 --output-on-failure` passed all 30 runs, including the exact refusal-clobber and early-release exits. This is the source-built recorder for #874.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1007
No description provided.