Skip to content

startup: implement command-list slots 53-55 ClearUAV and Discard (Part of #870) - #1972

Merged
tedin7 merged 4 commits into
R0Y00:mainfrom
tedin7:x2w-frontier-slots53-55
Nov 25, 2026
Merged

tedin7 merged 4 commits into
R0Y00:mainfrom
tedin7:x2w-frontier-slots53-55

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Part of #870

What this unblocks: render targets and UAV buffers cleared (and discarded) on a list before the first world frame no longer hit the no-op trap at list slots 53/54/55.

Summary:

  • Slot 53/54 ClearUnorderedAccessViewUint/Float: the CPU handle is resolved through its shadow record (copied descriptors follow), the GPU handle must lie on a known CBV/SRV/UAV heap, the resource must allow unordered access; the target moves to UNORDERED_ACCESS around the clear. Anything else is refused, logged and counted.
  • Slot 55 DiscardResource: render, depth and UAV resources are moved to the matching state and discarded; other resources, unreadable regions and null resources are dropped (discard is a hint).
  • New test startup_clear_uav (ctest startup_clear_uav_warp / _hardware): uint clear, rect clear, float clear, refused clears (bad GPU handle, empty CPU handle, no values) leave the target untouched, discards with and without region; readback on the desktop device, no device removal, no debug-layer errors. Without the handlers the slots are no-ops and the readback assertions fail.

Verification:

  • git diff --check : clean
  • x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only tests/startup_clear_uav.cpp : no errors
  • x86_64-w64-mingw32-g++ -fsyntax-only on d3d12_xs_device.cpp : only the pre-existing MSVC __try/__except errors in local_log.h, none in the new code
  • Win2025 (NOT yet run): Release build, ctest -R startup_clear_uav on WARP and hardware

AI-assisted; commands listed were executed locally.

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Merge-order check: these four PRs cannot all land in any order — one pair conflicts, the other three compose

Four open PRs now add command-list behaviour to the same two files (CMakeLists.txt, src/startup_stubs/d3d12_xs_device.cpp):
#1975, #1974, #1972, #1944. I merged them against main 889cd3f4 in every pair, then all four together.

#1975 + #1974   clean
#1975 + #1972   clean
#1975 + #1944   clean
#1974 + #1972   clean
#1974 + #1944   clean
#1972 + #1944   conflict: CMakeLists.txt, src/startup_stubs/d3d12_xs_device.cpp

And the four-way merge conflicts on the same pair, at the shared CMakeLists.txt insertion point just after the
foreach(backend IN ITEMS warp hardware …) block that registers the list tests — the two PRs append their new
add_executable / add_test group at the same anchor, so git has no ordering hint to pick.

The three that do compose, compose for real

Merged #1975 + #1974 + #1972 onto main, configured, built and ran their tests:

git merge pr-1975 pr-1974 pr-1972          # 0 conflicts
cmake --preset dev                          # Generating done
cmake --build --preset dev --target startup_root_constant_store startup_list_dispatch_check startup_clear_uav
build exit 0

ctest --preset dev -R 'root_constant|list_dispatch|clear_uav'
1/6 startup_root_constant_store ............   Passed 0.15
2/6 startup_clear_uav_warp .................   Passed 0.62
3/6 startup_clear_uav_hardware .............   Passed 4.03   (physical GPU, not a skip)
4/6 startup_list_dispatch ..................   Passed 0.14
5/6 startup_list_dispatch_no-limit_control .   Passed 0.03
6/6 startup_list_dispatch_no-state_control .   Passed 0.02
100% tests passed, 0 tests failed out of 6

So the command-list slots those three add coexist in one build, including both negative controls that #1974 registers.

What this means for ordering

Nothing is semantically wrong with #1944 — it is a text conflict at a shared anchor. The practical consequence is that whichever of
#1972 / #1944 lands second has to rebase
, and a rebase that resolves the anchor by hand needs the same care as the original: the
ENVIRONMENT list (X2W_D3D12_PERMISSIVE, X2W_D3D12_LIST_NOOP, X2W_D3D12_RENDER, X2W_D3D12_DEBUG) and SKIP_RETURN_CODE 77
have to survive on both groups, or one PR's tests silently run without the permissive flags and fail in CI instead of here.

I did not resolve the conflict myself: the resolution depends on which PR the maintainer wants first, and inventing an ordering would
hide the decision.

Aside, same family

#1951 and #1947 (the two tools/ PRs in this batch) touch different files and do not conflict with any of the above.

Notes

  • AI-assisted, run on Windows 11 build 26300.9974 with MSVC 19.44.

@tedin7
tedin7 marked this pull request as ready for review November 24, 2026 22:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T22:45:42.071137Z 0d81de3 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d81de30e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/startup_stubs/d3d12_xs_device.cpp Resolved
Comment thread src/startup_stubs/d3d12_xs_device.cpp Resolved
Comment thread tests/startup_clear_uav.cpp Resolved
@Makto94

Makto94 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

WARP and hardware run at head 0d81de30 (Debug build, Windows 11 build 26300, NVIDIA GeForce RTX 3070 Ti driver 32.0.16.2101, debug layer enabled): 2/2 passed, 0 capability skips (exit code 77).

ctest --test-dir out/build/dev -j1 --no-tests=error -R '^startup_clear_uav_' -V

In both startup_clear_uav_warp and startup_clear_uav_hardware the debug layer emits three sev=1 messages (D3D12_MESSAGE_SEVERITY_ERROR), yet the last line of each test is debug layer errors: 0:

x2w-d3d12-debug [CommandQueue execute 35] sev=1 id=1314 ID3D12CommandList::ClearUnorderedAccessViewUint: The specified GPU decriptor handle needs to be from the descriptor heap currently set on the command list.
x2w-d3d12-debug [CommandQueue execute 35] sev=1 id=1314 ID3D12CommandList::ClearUnorderedAccessViewUint: The specified GPU decriptor handle needs to be from the descriptor heap currently set on the command list.
x2w-d3d12-debug [CommandQueue execute 35] sev=1 id=1314 ID3D12CommandList::ClearUnorderedAccessViewFloat: The specified GPU decriptor handle needs to be from the descriptor heap currently set on the command list.
...
device removed reason: 0x00000000, debug layer errors: 0

So the test passes and reports 0 errors although the layer reported errors, on both WARP and the physical GPU. Codex's inline P2 comment on tests/startup_clear_uav.cpp at this head concerns the same error counter.

…ource)

Part of R0Y00#870. Slots 53 and 54 clear a UAV through its shadow record (CPU
handle) with the GPU handle checked against known heaps; slot 55 discards
render, depth and UAV resources and drops other resources. Refusals are
logged and counted. Adds startup_clear_uav (WARP + hardware readback).
@tedin7
tedin7 force-pushed the x2w-frontier-slots53-55 branch from 99cc35a to 3792cc2 Compare November 25, 2026 08:27
@Makto94

Makto94 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Head 3792cc25: startup_clear_uav_warp and startup_clear_uav_hardware both pass, and both end with device removed reason: 0x00000000, debug layer errors: 0.

.\tools\dev.ps1; ctest --preset dev --no-tests=error -j1 -R '^startup_clear_uav_warp$' -V
.\tools\dev.ps1; ctest --preset dev --no-tests=error -j1 -R '^startup_clear_uav_hardware$' -V

Environment: NVIDIA GeForce RTX 3070 Ti (driver 32.0.16.2101) and WARP; Windows 11 build 26300.9974; Debug build; D3D12 debug layer enabled (x2w-d3d12 debug layer: 0x00000000 enabled). 0 capability skips (77). The hardware run was serial on an idle machine.

Compared with my earlier run at 0d81de30:

  • The three x2w-d3d12-debug ... sev=1 id=1314 lines (GPU descriptor handle not from the bound heap) no longer appear in either log (0 matches).
  • The log now has three refused clears: x2w-d3d12 ClearUnorderedAccessViewUint skipped: GPU handle is on no known descriptor heap, ... skipped: view holds no known resource and ... skipped: no clear values. Checks 4 to 6 of the test read refused +1 (expected +1).
  • The test counts errors with a message callback now (RegisterMessageCallback). The log has no no debug layer message callback line, so the callback registered on both adapters.

I did not run a negative control that makes the callback fire in this run, so "0 errors" shows that no error message arrived, not that the callback is proven to catch one.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Thank you @Makto94 for the re-run at 3792cc2 on WARP and hardware, and for noting that the callback is not yet proven by a negative control.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Stage-2 verification at 3792cc25 (Win2025, WARP, default 3-slot pool):

  • Dev preset: build OK, ctest -R '^(...startup_clear_uav_warp...)$' (23 direct downstream tests): 23/23 passed.
  • Release /O2 preset: build OK (106.64s), same 23 tests: 23/23 passed (startup_clear_uav_warp 0.14s).
  • Hardware variants are not runnable on the VM (WARP only); the hardware run is the one posted by @Makto94 above.
  • GitHub CI on this head: Windows build and test, Linux Python checks and gfx1013 fixtures all pass. Mergeable, clean against main.
  • Diff, title, body and commit messages checked: no attribution trailers, no tool or model names.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Win2025 WARP receipt for head 1c4a9ac after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 1c4a9ac63d705af36a0af7d7b9f2d08780f92f0f:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target cpu_exe_io cpu_shim_draw cpu_shim_startup cpu_shim_startup_guest cpu_shim_startup_lifted d3d12_xs_device_obj d3d12_xs_shim d3d12x_compute_list_check d3d12x_descriptor_check d3d12x_device_check d3d12x_device_struct_return_control d3d12x_graphics_list_check pe_map startup_clear_uav startup_stub_acphal startup_stub_chad startup_stub_consumer startup_stub_gameinput startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs xgameruntime_preflight_exe xgameruntime_shim xmem_shim -- -j 2): 30.55s (configure 2.00s)
    • Test (ctest --preset dev -R '^(cpu_native_shim_startup|cpu_shim_chain_warp|cpu_shim_compute_warp|cpu_shim_draw_warp|cpu_shim_shadow_warp|cpu_shim_texture_reuse_warp|cpu_shim_upload_texture_warp|d3d12x_compute_list_warp|d3d12x_descriptor_heap_warp|d3d12x_descriptor_negative_warp|d3d12x_descriptor_table_warp|d3d12x_device_create_warp|d3d12x_device_negative_warp|d3d12x_device_struct_return_neither_control_warp|d3d12x_device_struct_return_warp|d3d12x_graphics_list_warp|d3d12x_pso_reject_warp|d3d12x_pso_static_sampler_warp|startup_build_rev_dll|startup_clear_uav_warp|startup_sampler_heap_wrapped_warp|startup_stubs|xgameruntime_preflight_stub_refused)$' --parallel 2 --no-tests=error --output-on-failure): 23/23 passed (9.56s: cpu_shim_upload_texture_warp 3.22s, cpu_shim_shadow_warp 4.20s, cpu_shim_chain_warp 2.25s, cpu_shim_draw_warp 2.72s, cpu_shim_compute_warp 2.09s, cpu_native_shim_startup 1.28s, cpu_shim_texture_reuse_warp 1.26s, startup_stubs 0.72s, startup_sampler_heap_wrapped_warp 0.14s, d3d12x_descriptor_heap_warp 0.04s, startup_build_rev_dll 0.11s, startup_clear_uav_warp 0.06s, xgameruntime_preflight_stub_refused 0.28s, d3d12x_descriptor_table_warp 0.05s, d3d12x_compute_list_warp 0.05s, d3d12x_graphics_list_warp 0.06s, d3d12x_device_create_warp 0.04s, d3d12x_descriptor_negative_warp 0.05s, d3d12x_pso_reject_warp 0.04s, d3d12x_pso_static_sampler_warp 0.04s, d3d12x_device_struct_return_neither_control_warp 0.05s, d3d12x_device_struct_return_warp 0.04s, d3d12x_device_negative_warp 0.03s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target cpu_exe_io cpu_shim_draw cpu_shim_startup cpu_shim_startup_guest cpu_shim_startup_lifted d3d12_xs_device_obj d3d12_xs_shim d3d12x_compute_list_check d3d12x_descriptor_check d3d12x_device_check d3d12x_device_struct_return_control d3d12x_graphics_list_check pe_map startup_clear_uav startup_stub_acphal startup_stub_chad startup_stub_consumer startup_stub_gameinput startup_stub_xapu startup_stub_xcrdapi startup_stub_xg_xs xgameruntime_preflight_exe xgameruntime_shim xmem_shim -- -j 2): 59.18s (configure 1.97s)
    • Test (ctest --preset release -R '^(cpu_native_shim_startup|cpu_shim_chain_warp|cpu_shim_compute_warp|cpu_shim_draw_warp|cpu_shim_shadow_warp|cpu_shim_texture_reuse_warp|cpu_shim_upload_texture_warp|d3d12x_compute_list_warp|d3d12x_descriptor_heap_warp|d3d12x_descriptor_negative_warp|d3d12x_descriptor_table_warp|d3d12x_device_create_warp|d3d12x_device_negative_warp|d3d12x_device_struct_return_neither_control_warp|d3d12x_device_struct_return_warp|d3d12x_graphics_list_warp|d3d12x_pso_reject_warp|d3d12x_pso_static_sampler_warp|startup_build_rev_dll|startup_clear_uav_warp|startup_sampler_heap_wrapped_warp|startup_stubs|xgameruntime_preflight_stub_refused)$' --parallel 2 --no-tests=error --output-on-failure): 23/23 passed (9.34s: cpu_shim_upload_texture_warp 3.04s, cpu_shim_shadow_warp 3.99s, cpu_shim_chain_warp 2.20s, cpu_shim_draw_warp 3.08s, cpu_shim_compute_warp 1.93s, cpu_native_shim_startup 1.31s, cpu_shim_texture_reuse_warp 1.21s, startup_sampler_heap_wrapped_warp 0.14s, xgameruntime_preflight_stub_refused 0.23s, startup_build_rev_dll 0.08s, d3d12x_compute_list_warp 0.05s, d3d12x_graphics_list_warp 0.05s, startup_clear_uav_warp 0.06s, d3d12x_descriptor_table_warp 0.04s, startup_stubs 0.68s, d3d12x_descriptor_heap_warp 0.04s, d3d12x_descriptor_negative_warp 0.05s, d3d12x_device_struct_return_neither_control_warp 0.04s, d3d12x_device_create_warp 0.04s, d3d12x_pso_static_sampler_warp 0.04s, d3d12x_device_struct_return_warp 0.04s, d3d12x_pso_reject_warp 0.04s, d3d12x_device_negative_warp 0.02s)
  • sccache: 4/14 hits; wall 121.4s

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 merged commit 2d275db into R0Y00:main Nov 25, 2026
5 checks passed
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.

3 participants