GPU: implement SetPredication, SetMarker, BeginEvent, and EndEvent on command lists #859

Open
opened 2026-11-26 04:14:04 +00:00 by github-bot · 3 comments
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 12:48 UTC · original

Summary

Implements 4 missing standard ID3D12GraphicsCommandList vtable slots in crates/victory-gpu/src/list.rs across both LIST_FUNCTIONS and NEWER_LIST_FUNCTIONS:

  • Slot 31 (0xf8): SetPredication
  • Slot 56 (0x1c0): SetMarker
  • Slot 57 (0x1c8): BeginEvent
  • Slot 58 (0x1d0): EndEvent

Because external PR creation is currently restricted (collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:

  • Branch: geiyiliyabumo/VIctory@feat/list-predication-and-markers
  • Commit: geiyiliyabumo/VIctory@a74fe6b (based on main ffe310e)

Changes (crates/victory-gpu/src/list.rs)

  • set_predication (0xf8):
    • Null buffer cleanly disables predication (SetPredication(None, 0, D3D12_PREDICATION_OP_EQUAL_ZERO)).
    • Non-null buffer validates operation (0 = EQUAL_ZERO, 1 = NOT_EQUAL_ZERO), 8-byte offset alignment, and buffer_range(buffer, offset, 8).
    • For host-backed resources, ensures D3D12_RESOURCE_STATE_PREDICATION before forwarding; for CPU-backed guest buffers, stages the 8-byte predicate via a list-owned host.upload(device, 8) filled at submission (host.defer_fill) so deferred guest writes are observed.
  • set_marker (0x1c0), begin_event (0x1c8), end_event (0x1d0):
    • Normalizes null/zero-size payloads to (None, 0) before forwarding to host D3D12 and records diagnostics op notes.
  • Tests:
    • list::tests::predication_and_marker_slots_are_stable (verifies all 4 slots in both LIST_FUNCTIONS and NEWER_LIST_FUNCTIONS).
    • list::tests::set_predication_and_markers_execute_on_gpu (exercises markers/events + EQUAL_ZERO predication skipping on 0, executing on 1, and disabling with null, verifying exact GPU readback bytes and zero final refcounts).

Verification (Windows 11 x64 MSVC, AMD Radeon RX 9060 XT RDNA4 + WARP)

  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy --workspace --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-gpu --locked -- predication: 2/2 PASS (live RX 9060 XT GPU readback)
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- predication: 2/2 PASS
  • cargo test -p victory-gpu --locked: 52 passed, 0 failed, 1 ignored

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 12:48 UTC · [original](https://github.com/Marvisak/VIctory/issues/859) ### Summary Implements 4 missing standard `ID3D12GraphicsCommandList` vtable slots in `crates/victory-gpu/src/list.rs` across both `LIST_FUNCTIONS` and `NEWER_LIST_FUNCTIONS`: - **Slot `31` (`0xf8`)**: `SetPredication` - **Slot `56` (`0x1c0`)**: `SetMarker` - **Slot `57` (`0x1c8`)**: `BeginEvent` - **Slot `58` (`0x1d0`)**: `EndEvent` Because external PR creation is currently restricted (`collaborators_only`), the CI-green branch is ready on my fork for cherry-pick / review: - **Branch**: `geiyiliyabumo/VIctory@feat/list-predication-and-markers` - **Commit**: `geiyiliyabumo/VIctory@a74fe6b` (based on `main` `ffe310e`) ### Changes (`crates/victory-gpu/src/list.rs`) - **`set_predication` (`0xf8`)**: - Null buffer cleanly disables predication (`SetPredication(None, 0, D3D12_PREDICATION_OP_EQUAL_ZERO)`). - Non-null buffer validates `operation` (`0` = `EQUAL_ZERO`, `1` = `NOT_EQUAL_ZERO`), 8-byte `offset` alignment, and `buffer_range(buffer, offset, 8)`. - For host-backed resources, ensures `D3D12_RESOURCE_STATE_PREDICATION` before forwarding; for CPU-backed guest buffers, stages the 8-byte predicate via a list-owned `host.upload(device, 8)` filled at submission (`host.defer_fill`) so deferred guest writes are observed. - **`set_marker` (`0x1c0`), `begin_event` (`0x1c8`), `end_event` (`0x1d0`)**: - Normalizes null/zero-size payloads to `(None, 0)` before forwarding to host D3D12 and records `diagnostics` op notes. - **Tests**: - `list::tests::predication_and_marker_slots_are_stable` (verifies all 4 slots in both `LIST_FUNCTIONS` and `NEWER_LIST_FUNCTIONS`). - `list::tests::set_predication_and_markers_execute_on_gpu` (exercises markers/events + `EQUAL_ZERO` predication skipping on `0`, executing on `1`, and disabling with `null`, verifying exact GPU readback bytes and zero final refcounts). ### Verification (Windows 11 x64 MSVC, AMD Radeon RX 9060 XT RDNA4 + WARP) - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy --workspace --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-gpu --locked -- predication`: **2/2 PASS** (live RX 9060 XT GPU readback) - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- predication`: **2/2 PASS** - `cargo test -p victory-gpu --locked`: **52 passed, 0 failed, 1 ignored** *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:04 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 12:57 UTC · original · edited 2026-11-24 13:00 UTC

Daniel checked a predicate produced on the GPU earlier in the same command list at a74fe6b. A host copy wrote a nonzero predicate into the ordinary guest buffer’s GPU shadow, while the corresponding CPU bytes were still zero. Binding that shadow directly through D3D12 let the dispatch write 0x22; a zero predicate preserved the 0x11 sentinel. With the same nonzero GPU value, the guest SetPredication path preserved 0x11. For an ordinary buffer it stages the CPU bytes at submission, before the GPU executes the producing command.

A second synthetic comparison used a guest typed UAV clear as the producer, on a stack with #785’s written-shadow lookup. In order, the three cases were a GPU-written nonzero predicate, a CPU zero, and a CPU nonzero written after recording. The original binding produced [0x11, 0x11, 0x22]. Selecting the tracked GPU shadow for the covered eight bytes and transitioning it to PREDICATION produced [0x22, 0x11, 0x22]. The CPU cases still used deferred staging.

Daniel also isolated the transition in the direct host control on this Wine/vkd3d-proton backend. With #334’s BUFFER_READ (GENERIC_READ) transition, the nonzero case left all 16 sentinel bytes at 0x11. Changing only the transition to D3D12_RESOURCE_STATE_PREDICATION made that dispatch write 0x22 to all 16 bytes, and the zero case still skipped.

Measured on RTX 4090 with Wine/vkd3d-proton 3.2. The original predicated-copy fixture also failed on this backend, so the comparison above uses compute dispatches with independent zero/nonzero host controls. Your native AMD and WARP results cover the separate CPU-written copy case. Title use remains open.

The tested implementation is available on the combined #859/#785 branch. It uses an earlier tracked GPU write only when the same command list covers all eight predicate bytes and the resolved shadow offset is aligned. The fallback keeps deferred CPU staging. Query emulation and writes from another command list were outside this test.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 12:57 UTC · [original](https://github.com/Marvisak/VIctory/issues/859#issuecomment-7132145729) · edited 2026-11-24 13:00 UTC Daniel checked a predicate produced on the GPU earlier in the same command list at `a74fe6b`. A host copy wrote a nonzero predicate into the ordinary guest buffer’s GPU shadow, while the corresponding CPU bytes were still zero. Binding that shadow directly through D3D12 let the dispatch write 0x22; a zero predicate preserved the 0x11 sentinel. With the same nonzero GPU value, the guest SetPredication path preserved 0x11. For an ordinary buffer it stages the CPU bytes at submission, before the GPU executes the producing command. A second synthetic comparison used a guest typed UAV clear as the producer, on a stack with #785’s written-shadow lookup. In order, the three cases were a GPU-written nonzero predicate, a CPU zero, and a CPU nonzero written after recording. The original binding produced `[0x11, 0x11, 0x22]`. Selecting the tracked GPU shadow for the covered eight bytes and transitioning it to PREDICATION produced `[0x22, 0x11, 0x22]`. The CPU cases still used deferred staging. Daniel also isolated the transition in the direct host control on this Wine/vkd3d-proton backend. With #334’s BUFFER_READ (GENERIC_READ) transition, the nonzero case left all 16 sentinel bytes at 0x11. Changing only the transition to D3D12_RESOURCE_STATE_PREDICATION made that dispatch write 0x22 to all 16 bytes, and the zero case still skipped. Measured on RTX 4090 with Wine/vkd3d-proton 3.2. The original predicated-copy fixture also failed on this backend, so the comparison above uses compute dispatches with independent zero/nonzero host controls. Your native AMD and WARP results cover the separate CPU-written copy case. Title use remains open. The [tested implementation](https://github.com/MichaelSmithAI/VIctory/commit/e9186e18ce6656f6b2847d2c8964ccbb46455b39) is available on the combined #859/#785 branch. It uses an earlier tracked GPU write only when the same command list covers all eight predicate bytes and the resolved shadow offset is aligned. The fallback keeps deferred CPU staging. Query emulation and writes from another command list were outside this test.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-24 13:14 UTC · original

I ran a separate native Windows WARP check for the proposed e9186e1 fix. I extended the fork's predicated-copy test with a third predicate initialized to zero on the CPU and set to one by an earlier native copy into its GPU shadow on the same list.

At a74fe6b, the guest call left the destination at 0x11, even though the predicate copied back as 1 after execution. Binding that same shadow with native D3D12 in the control allowed the copy to write 0x22. With e9186e1, the guest call also wrote 0x22, using the list's buffer state tracker for the producer. The existing CPU-written zero, CPU-written one, and disable controls all passed.

The combined branch with the local regression fixture passed 59 diagnostics library tests, with one benchmark ignored. AI-assisted. Verified with synthetic buffers on native Windows WARP.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-24 13:14 UTC · [original](https://github.com/Marvisak/VIctory/issues/859#issuecomment-7132553246) I ran a separate native Windows WARP check for the proposed `e9186e1` fix. I extended the fork's predicated-copy test with a third predicate initialized to zero on the CPU and set to one by an earlier native copy into its GPU shadow on the same list. At `a74fe6b`, the guest call left the destination at `0x11`, even though the predicate copied back as `1` after execution. Binding that same shadow with native D3D12 in the control allowed the copy to write `0x22`. With `e9186e1`, the guest call also wrote `0x22`, using the list's buffer state tracker for the producer. The existing CPU-written zero, CPU-written one, and disable controls all passed. The combined branch with the local regression fixture passed 59 diagnostics library tests, with one benchmark ignored. AI-assisted. Verified with synthetic buffers on native Windows WARP.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:55 UTC · original

Automated triage for the maintainers.

main still lacks these four list slots (crates/victory-gpu/src/list.rs has no SetPredication, SetMarker, BeginEvent or EndEvent). The branch is open as PR #1168 ("Closes #859"), so review continues there. The follow-up in the comments, which reads a predicate written by the GPU earlier in the same list (commit e9186e1, checked on Wine and on native WARP), is not in #1168 yet. Please offer it on that PR.

Pull requests are open to everyone again, so new changes can go straight to a PR. Left for the maintainers.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:55 UTC · [original](https://github.com/Marvisak/VIctory/issues/859#issuecomment-7155303741) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T13:14:42Z at=2026-11-25T06:55:39Z --> Automated triage for the maintainers. `main` still lacks these four list slots (`crates/victory-gpu/src/list.rs` has no `SetPredication`, `SetMarker`, `BeginEvent` or `EndEvent`). The branch is open as PR #1168 ("Closes #859"), so review continues there. The follow-up in the comments, which reads a predicate written by the GPU earlier in the same list (commit `e9186e1`, checked on Wine and on native WARP), is not in #1168 yet. Please offer it on that PR. Pull requests are open to everyone again, so new changes can go straight to a PR. Left for the maintainers. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#859
No description provided.