d3d12: honor predication for buffer CopyResource (D3D-PREDICATED-COPY-RESOURCE) #1443

Closed
PyZikYG wants to merge 1 commit from upstream-pr/1443 into main
PyZikYG commented 2026-11-25 00:19:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PyZikYG on 2026-11-25T00:19:59Z.


Claimed as D3D-PREDICATED-COPY-RESOURCE.

Summary

Buffer-to-buffer CopyResource now honors SetPredication. Replay uses the byte-copy path shared with CopyBufferRegion and tracks its compute writes for readback visibility. The helper dispatch is left out of application pipeline statistics. This change covers buffer resources.

Verification

Checked the copy and skip paths against native D3D12/WARP, including a predicate with only its high word set. Checked readback staging, large offsets and pipeline-statistics accounting.

AI-assisted: yes.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5482660064 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1443). Originally posted by [PyZikYG](https://github.com/PyZikYG) on 2026-11-25T00:19:59Z. --- Claimed as [D3D-PREDICATED-COPY-RESOURCE](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7148306735). ### Summary Buffer-to-buffer `CopyResource` now honors `SetPredication`. Replay uses the byte-copy path shared with `CopyBufferRegion` and tracks its compute writes for readback visibility. The helper dispatch is left out of application pipeline statistics. This change covers buffer resources. ### Verification Checked the copy and skip paths against native D3D12/WARP, including a predicate with only its high word set. Checked readback staging, large offsets and pipeline-statistics accounting. AI-assisted: yes.
whoalin1 commented 2026-11-25 05:40:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T05:40:38Z.


Independent verification on both of our GPUs (native Windows 11, validation on):

  • NVIDIA RTX 4070 SUPER: 10/10 core + 6/6 descriptor/copy extras — vk_predicated_copy genuinely ran ("32 gated + 32 reused submissions … passed"), plus d3d12_predicated_copy, d3d12_predication_atomic_copy, d3d12_noop_copy, d3d12_subresource_copy, predicated_copy, replay_copy_offset, replay_khr_as_copy_postbuild, replay_write_immediate_predication, replay_query_predication, d3d12_copy_xfmt, d3d12_stencil_copy, d3d12_descriptor, d3d12_console_descriptor_heap, d3d12_set_descriptor_heaps, descriptor_table.
  • AMD Radeon iGPU (gfx1036, LEONIDA_PC_TAIL_UBO=1): identical 10/10 + 6/6, vk_predicated_copy confirmed on the AMD device, 0 VUIDs.
  • Clean origin/main c7e82e26e baseline: 27/27 on both GPUs — no pre-existing failures.

Code review agrees with the PR's claim: predication now covers buffer CopyResource; only texture copies remain unpredicated, matching the doc update.

AI-assisted verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7154028593 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1443#issuecomment-7154028593). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T05:40:38Z. --- Independent verification on both of our GPUs (native Windows 11, validation on): - **NVIDIA RTX 4070 SUPER**: 10/10 core + 6/6 descriptor/copy extras — `vk_predicated_copy` genuinely ran ("32 gated + 32 reused submissions … passed"), plus `d3d12_predicated_copy`, `d3d12_predication_atomic_copy`, `d3d12_noop_copy`, `d3d12_subresource_copy`, `predicated_copy`, `replay_copy_offset`, `replay_khr_as_copy_postbuild`, `replay_write_immediate_predication`, `replay_query_predication`, `d3d12_copy_xfmt`, `d3d12_stencil_copy`, `d3d12_descriptor`, `d3d12_console_descriptor_heap`, `d3d12_set_descriptor_heaps`, `descriptor_table`. - **AMD Radeon iGPU** (gfx1036, `LEONIDA_PC_TAIL_UBO=1`): identical 10/10 + 6/6, `vk_predicated_copy` confirmed on the AMD device, 0 VUIDs. - Clean `origin/main` `c7e82e26e` baseline: 27/27 on both GPUs — no pre-existing failures. Code review agrees with the PR's claim: predication now covers buffer `CopyResource`; only texture copies remain unpredicated, matching the doc update. AI-assisted verification.
zmasi commented 2026-11-29 02:00:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T02:00:25Z.


Verification Report (b21bfffbea merged into main 59e65849b0)

  • Environment: Windows 11, MSVC 19.44 (Ninja Release), NVIDIA GeForce RTX 3090 (Ampere, driver 610.88, subgroup 32..32) + Microsoft WARP, Vulkan SDK 1.4.363.1 (LEONIDA_VK_VALIDATION=1 with VK_LAYER_KHRONOS_validation). No game data used (check_no_game_data.py rc=0).
  • Diff & Merge Audit: Merged b21bfffbea cleanly into origin/main (59e65849b0, 0 conflicts; 4 files changed: docs/d3d12_vulkan.md, runtime/src/vulkan_replay.h, runtime/test/predicated_copy_test.cpp, runtime/test/d3d12_predicated_copy_test.cpp). Hoisting the predicated byte-copy dispatch conversion in leonida::prepare() after both CopyBuffer and buffer CopyResource populate p.buffer_copies routes whole-buffer CopyResource through the existing VK_EXT_conditional_rendering compute byte-copy helper, sets VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT for host-readable destinations (!p.predicated_copy.empty()), rejects active pipeline-statistics queries without helper isolation, and leaves texture copies counted in out.unpredicated_copies.

Red -> Green Results

Target Base main vulkan_replay.h + #1443 tests Merged main + #1443 (b21bfffbea)
predicated_copy_test (CPU replay) RED (rc=1: predicated buffer CopyResource left in buffer_copies with unpredicated_copies == 1) GREEN (rc=0)
d3d12_predicated_copy_test (RTX 3090 + WARP + LEONIDA_VK_VALIDATION=1) RED (rc=1: whole-buffer CopyResource executes unconditionally when predicate suppresses copy) GREEN (rc=0, 0 validation errors: query-to-predicated-copy: 16 exact cases, 4 recapture controls; GPU overwrite and predicate guards exact, predicated buffer copies: 220 exact cases (Vulkan + WARP + literal byte oracle))
test_docs_table_rows.py & test_docs_encoding.py — GREEN (rc=0)
  • Verdict: PASS (verified Red -> Green on physical RTX 3090 + WARP with Khronos validation enabled; also verified conflict-free composition in vulkan_replay.h alongside #539, #778, and #1179).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7249150519 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1443#issuecomment-7249150519). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T02:00:25Z. --- ### Verification Report (`b21bfffbea` merged into `main` `59e65849b0`) - **Environment**: Windows 11, MSVC 19.44 (Ninja Release), **NVIDIA GeForce RTX 3090** (Ampere, driver `610.88`, subgroup `32..32`) + Microsoft WARP, Vulkan SDK `1.4.363.1` (`LEONIDA_VK_VALIDATION=1` with `VK_LAYER_KHRONOS_validation`). No game data used (`check_no_game_data.py` `rc=0`). - **Diff & Merge Audit**: Merged `b21bfffbea` cleanly into `origin/main` (`59e65849b0`, 0 conflicts; 4 files changed: `docs/d3d12_vulkan.md`, `runtime/src/vulkan_replay.h`, `runtime/test/predicated_copy_test.cpp`, `runtime/test/d3d12_predicated_copy_test.cpp`). Hoisting the `predicated` byte-copy dispatch conversion in `leonida::prepare()` after both `CopyBuffer` and buffer `CopyResource` populate `p.buffer_copies` routes whole-buffer `CopyResource` through the existing `VK_EXT_conditional_rendering` compute byte-copy helper, sets `VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT` for host-readable destinations (`!p.predicated_copy.empty()`), rejects active pipeline-statistics queries without helper isolation, and leaves texture copies counted in `out.unpredicated_copies`. #### Red -> Green Results | Target | Base `main` `vulkan_replay.h` + `#1443` tests | Merged `main` + `#1443` (`b21bfffbea`) | |---|---|---| | `predicated_copy_test` (CPU replay) | **RED** (`rc=1`: predicated buffer `CopyResource` left in `buffer_copies` with `unpredicated_copies == 1`) | **GREEN** (`rc=0`) | | `d3d12_predicated_copy_test` (RTX 3090 + WARP + `LEONIDA_VK_VALIDATION=1`) | **RED** (`rc=1`: whole-buffer `CopyResource` executes unconditionally when predicate suppresses copy) | **GREEN** (`rc=0`, `0` validation errors: `query-to-predicated-copy: 16 exact cases, 4 recapture controls; GPU overwrite and predicate guards exact`, `predicated buffer copies: 220 exact cases (Vulkan + WARP + literal byte oracle)`) | | `test_docs_table_rows.py` & `test_docs_encoding.py` | — | **GREEN** (`rc=0`) | - **Verdict**: **PASS** (verified Red -> Green on physical RTX 3090 + WARP with Khronos validation enabled; also verified conflict-free composition in `vulkan_replay.h` alongside `#539`, `#778`, and `#1179`). AI-assisted.
enlight3d commented 2026-11-29 08:58:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T08:58:25Z.


Validation run of this pull request.

  • PR head: b21bfffbea. main: 54b2a81e95. Merged cleanly (git merge --no-edit --no-ff pr-1443, no conflicts); tested at the merge commit.
  • Commands:
    • cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ON
    • cmake --build runtime/build --target gta6rt predicated_copy_test d3d12_predicated_copy_test vk_predicated_copy_test vk_command_replay_test replay_copy_offset_test -j 8
    • ctest -R "^(predicated_copy|d3d12_predicated_copy|vk_predicated_copy|vk_command_replay|replay_copy_offset)$" --output-on-failure -j1
  • Green (merged): 5 of 5 passed, none skipped (the last three share vulkan_replay.h with the change).
  • Red (behavioural, no API change): the two changed tests kept, runtime/src/vulkan_replay.h and docs/d3d12_vulkan.md taken back from main. Tests build and run: d3d12_predicated_copy fails on the Vulkan comparison (copy 1/1 ... got 0b expected ad), predicated_copy fails its check at line 69 (the log shows replay: unsupported and replay: unresolved resource lines from vulkan_replay.h). vk_predicated_copy still passes, as its source is not part of the change.
  • Link: no new imports vs main (gta6rt.exe, 714 imports on both).
  • Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7253451501 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1443#issuecomment-7253451501). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T08:58:25Z. --- Validation run of this pull request. - PR head: b21bfffbea9337fa38afe696d8ae51d7149452cf. main: 54b2a81e95c470c953ddee6177fd6255cbaf041d. Merged cleanly (`git merge --no-edit --no-ff pr-1443`, no conflicts); tested at the merge commit. - Commands: - `cmake -S runtime -B runtime/build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_REQUIRE_VULKAN=ON` - `cmake --build runtime/build --target gta6rt predicated_copy_test d3d12_predicated_copy_test vk_predicated_copy_test vk_command_replay_test replay_copy_offset_test -j 8` - `ctest -R "^(predicated_copy|d3d12_predicated_copy|vk_predicated_copy|vk_command_replay|replay_copy_offset)$" --output-on-failure -j1` - Green (merged): 5 of 5 passed, none skipped (the last three share `vulkan_replay.h` with the change). - Red (behavioural, no API change): the two changed tests kept, `runtime/src/vulkan_replay.h` and `docs/d3d12_vulkan.md` taken back from main. Tests build and run: `d3d12_predicated_copy` fails on the Vulkan comparison (`copy 1/1 ... got 0b expected ad`), `predicated_copy` fails its check at line 69 (the log shows `replay: unsupported` and `replay: unresolved resource` lines from `vulkan_replay.h`). `vk_predicated_copy` still passes, as its source is not part of the change. - Link: no new imports vs main (gta6rt.exe, 714 imports on both). - Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44.
TheGeogeo commented 2026-11-29 14:18:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T14:18:32Z.


Ready for testing: merges cleanly with main 3535eb5c4. Not in main yet: git cherry finds 1 commit(s) not there, and 11 of the 44 lines it adds are already present. No duplicate found: it carries no claim ID, and no other open pull request has the same title.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257202104 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1443#issuecomment-7257202104). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T14:18:32Z. --- Ready for testing: merges cleanly with `main` `3535eb5c4`. Not in `main` yet: `git cherry` finds 1 commit(s) not there, and 11 of the 44 lines it adds are already present. No duplicate found: it carries no claim ID, and no other open pull request has the same title. AI-assisted (Claude Code).
aslan2142 commented 2026-12-01 16:35:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:35:34Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317861394 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1443#issuecomment-7317861394). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:35:34Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!1443
No description provided.