D3D12.X: resource-creation fallbacks accept console descriptions (desc, flags, clear values, heap props) #3729

Open
Kalmarv wants to merge 1 commit from upstream-pr/3729 into main
Kalmarv commented 2026-12-02 20:48:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T20:48:45Z.


Unifies console resource description, resource flag, initial state, optimized clear value, and heap property/flag sanitization across D3D12.X resource-creation and fallback paths.

Consolidates and replaces #3291, #3414, #3418, and #3376 into a single consistent change (417 changed runtime lines across device_x.rs and real.rs), addressing every open review finding from those four PRs and follow-up review feedback on this PR.

What is in it

  • Resource flag invariants (device_x::pc_resource_desc): strips buffer-illegal flags (ALLOW_DEPTH_STENCIL, DENY_SHADER_RESOURCE, ALLOW_SIMULTANEOUS_ACCESS) while keeping ALLOW_RENDER_TARGET (valid on PC buffers for D3D12_RTV_DIMENSION_BUFFER, without an optimized clear value) and ALLOW_UNORDERED_ACCESS; resolves texture RT | DS conflicts by format family (depth families keep DS, color formats keep RT); strips ALLOW_SIMULTANEOUS_ACCESS on depth and MSAA textures; keeps DENY_SHADER_RESOURCE only when ALLOW_DEPTH_STENCIL or video reference flags (0x40 | 0x80) are set; strips ALLOW_CROSS_ADAPTER on textures forced to TEXTURE_LAYOUT_UNKNOWN.
  • Initial state sanitization (device_x::pc_initial_state_for_desc, promote_placed_buffer_uav): derives initial state from the sanitized pc_flags instead of raw console flags and drops RENDER_TARGET (0x04), DEPTH_WRITE | DEPTH_READ (0x10 | 0x20), and UNORDERED_ACCESS (0x08) whenever the matching PC resource flag is absent; placed console buffers created in UNORDERED_ACCESS (0x08) or RAYTRACING_ACCELERATION_STRUCTURE (0x40_0000) promote ALLOW_UNORDERED_ACCESS (0x04) before pc_initial_state_for_desc in create_placed_resource_x and placed_in_heap_x so place_at_title_address / sparse::place_buffer_in keep the UAV flag and state.
  • Clear-value sanitization (device_x::pc_clear_for_resource_desc): checks buffer/non-target flags before reading the pointer (returning null even for unreadable pointers), adds 21 | 22 | 46 | 47 to is_typeless_format, maps ALLOW_DEPTH_STENCIL clears unconditionally via depth_clear_format, resolves UNKNOWN/typeless clears on concrete render targets, drops the unused clear argument from place_console_buffer and place_at_title_address, and wires pc_clear_for_resource_desc through every creation and fallback path (create_placed_resource_x, dev_create_committed_resource_x, create_display_target, placed_in_heap_x, own_memory_if_larger_on_the_pc, create_reserved_with_fallback).
  • Committed heap props, heap flags, and ALLOW_DISPLAY routing (real.rs): routes non-buffer ALLOW_DISPLAY textures in dev_create_committed_resource_x through create_display_target (which now sanitizes desc, heap props, clear value, and initial state), intentionally matching slot #127's committed display-target path (allocating console memory via kernelx::runtime_alloc(D3D_DISPLAY_TARGET) as a plain committed resource rather than place_console_texture) and falling through to the existing path if create_display_target fails; retries sanitized heap properties (pc_heap_properties, preserving CPU-visible console buffers via CUSTOM + L0 with the same CPUPageProperty) and committed heap flags (pc_committed_heap_flags, stripping console bits, ALLOW_DISPLAY, tier-1 DENY_*, HARDWARE_PROTECTED, ALLOW_WRITE_WATCH on non-CUSTOM, and ALLOW_SHADER_ATOMICS without SHARED) only on hr < 0, logging both raw and tried values on failure.
  • Reserved resource fallback and state propagation (real.rs): adds create_reserved_with_fallback for CreateReservedResource and CreateReservedResource1 (skipping XCL's own_work and purely PC-native invalid calls), maps console texture layouts (0 or > 3) to 64KB_UNDEFINED_SWIZZLE while keeping ROW_MAJOR rejected, refuses bytes-per-texel-changing format promotions (85/86/115, 116/117, 118..=120) so UpdateTileMappings tile counts cannot diverge, masks reserved_3d state with PC_RESOURCE_STATES, and propagates the actual created PC state from placed_in_heap_x / own_memory_if_larger_on_the_pc to lut3d::created.
  • Tests: merged unit and WARP D3D12 tests in device_x::tests and real::resource_creation_fallback_tests covering all invariants, placed-buffer UAV promotion, ALLOW_RENDER_TARGET buffers on WARP, ALLOW_DISPLAY buffer bypass, and prior review regressions.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 5070 Ti (driver 610.74), AMD Ryzen 9 9950X, Windows 11 x64, rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9.2609, debug + release.
  • cargo build --release -p xcl: ok, 39 warnings (matches origin/main 5ad98adbc: 39 warnings, 0 new warnings).
  • .\scripts\test.ps1 (with DXC 1.9.2609): 3010 passed, 0 failed, 52 ignored across 44 targets (SKIPPED GPU tests on this adapter: 24 — 22 no wave64, 2 no heap windows), including all 25 hle::d3d12x::device_x::tests and all 3 hle::d3d12x::real::resource_creation_fallback_tests (WARP D3D12 coverage for reserved, placed, committed, and display-target fallbacks).

Regression run

xcl-smoke v1
commit: 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1240 (PresentX 1240)
presents per 2 s (last 3): 75 108 75
device removals: 0
crashes: 0
peak commit: 16798 MB
xcl-smoke v1
commit: 26eaea260b2e311726cdae61546f992d1e6c60ac
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1693 (PresentX 1693)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 17408 MB

Not tested

  • AMD or Intel GPUs (only NVIDIA GeForce RTX 5070 Ti and Microsoft WARP were exercised; 22 wave64-only GPU tests and 2 opt-in heap-window GPU tests were skipped on this adapter).
  • Sample-data tests requiring XCL_SAMPLE_* environment variables (52 ignored).
  • Unified-memory place_at_title_address end-to-end execution of a placed buffer created in UNORDERED_ACCESS without ALLOW_UNORDERED_ACCESS (verified by promote_placed_buffer_uav + pc_initial_state_for_desc unit tests and code inspection of sparse::place_buffer_in, not an end-to-end UMA unit test).
  • Additional retail titles exercising CreateReservedResource1, CUSTOM+L0 CPU-visible console buffers, or ALLOW_DISPLAY committed targets beyond the WARP integration tests and the ea3b5e4d smoke run.

AI use

  • Antigravity, Gemini 4 Neon: consolidated #3291, #3414, #3418, and #3376, resolved all review findings, merged unit and WARP tests, and ran release build, full test suite, and paired smokes.
  • Claude Code, Claude Opus 5.5: authored the earlier individual PRs (#3291, #3414, #3418, #3376) that this PR consolidates and replaces.
<!-- greyfinch-sync:ivall/xcl:issue:5614453691 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T20:48:45Z. --- Unifies console resource description, resource flag, initial state, optimized clear value, and heap property/flag sanitization across D3D12.X resource-creation and fallback paths. Consolidates and replaces #3291, #3414, #3418, and #3376 into a single consistent change (417 changed runtime lines across `device_x.rs` and `real.rs`), addressing every open review finding from those four PRs and follow-up review feedback on this PR. **What is in it** - **Resource flag invariants (`device_x::pc_resource_desc`)**: strips buffer-illegal flags (`ALLOW_DEPTH_STENCIL`, `DENY_SHADER_RESOURCE`, `ALLOW_SIMULTANEOUS_ACCESS`) while keeping `ALLOW_RENDER_TARGET` (valid on PC buffers for `D3D12_RTV_DIMENSION_BUFFER`, without an optimized clear value) and `ALLOW_UNORDERED_ACCESS`; resolves texture `RT | DS` conflicts by format family (depth families keep `DS`, color formats keep `RT`); strips `ALLOW_SIMULTANEOUS_ACCESS` on depth and MSAA textures; keeps `DENY_SHADER_RESOURCE` only when `ALLOW_DEPTH_STENCIL` or video reference flags (`0x40 | 0x80`) are set; strips `ALLOW_CROSS_ADAPTER` on textures forced to `TEXTURE_LAYOUT_UNKNOWN`. - **Initial state sanitization (`device_x::pc_initial_state_for_desc`, `promote_placed_buffer_uav`)**: derives initial state from the sanitized `pc_flags` instead of raw console flags and drops `RENDER_TARGET` (`0x04`), `DEPTH_WRITE | DEPTH_READ` (`0x10 | 0x20`), and `UNORDERED_ACCESS` (`0x08`) whenever the matching PC resource flag is absent; placed console buffers created in `UNORDERED_ACCESS` (`0x08`) or `RAYTRACING_ACCELERATION_STRUCTURE` (`0x40_0000`) promote `ALLOW_UNORDERED_ACCESS` (`0x04`) before `pc_initial_state_for_desc` in `create_placed_resource_x` and `placed_in_heap_x` so `place_at_title_address` / `sparse::place_buffer_in` keep the UAV flag and state. - **Clear-value sanitization (`device_x::pc_clear_for_resource_desc`)**: checks buffer/non-target flags before reading the pointer (returning null even for unreadable pointers), adds `21 | 22 | 46 | 47` to `is_typeless_format`, maps `ALLOW_DEPTH_STENCIL` clears unconditionally via `depth_clear_format`, resolves `UNKNOWN`/typeless clears on concrete render targets, drops the unused `clear` argument from `place_console_buffer` and `place_at_title_address`, and wires `pc_clear_for_resource_desc` through every creation and fallback path (`create_placed_resource_x`, `dev_create_committed_resource_x`, `create_display_target`, `placed_in_heap_x`, `own_memory_if_larger_on_the_pc`, `create_reserved_with_fallback`). - **Committed heap props, heap flags, and `ALLOW_DISPLAY` routing (`real.rs`)**: routes non-buffer `ALLOW_DISPLAY` textures in `dev_create_committed_resource_x` through `create_display_target` (which now sanitizes desc, heap props, clear value, and initial state), intentionally matching slot #127's committed display-target path (allocating console memory via `kernelx::runtime_alloc(D3D_DISPLAY_TARGET)` as a plain committed resource rather than `place_console_texture`) and falling through to the existing path if `create_display_target` fails; retries sanitized heap properties (`pc_heap_properties`, preserving CPU-visible console buffers via `CUSTOM + L0` with the same `CPUPageProperty`) and committed heap flags (`pc_committed_heap_flags`, stripping console bits, `ALLOW_DISPLAY`, tier-1 `DENY_*`, `HARDWARE_PROTECTED`, `ALLOW_WRITE_WATCH` on non-`CUSTOM`, and `ALLOW_SHADER_ATOMICS` without `SHARED`) only on `hr < 0`, logging both raw and tried values on failure. - **Reserved resource fallback and state propagation (`real.rs`)**: adds `create_reserved_with_fallback` for `CreateReservedResource` and `CreateReservedResource1` (skipping XCL's `own_work` and purely PC-native invalid calls), maps console texture layouts (`0` or `> 3`) to `64KB_UNDEFINED_SWIZZLE` while keeping `ROW_MAJOR` rejected, refuses bytes-per-texel-changing format promotions (`85/86/115`, `116/117`, `118..=120`) so `UpdateTileMappings` tile counts cannot diverge, masks `reserved_3d` state with `PC_RESOURCE_STATES`, and propagates the actual created PC state from `placed_in_heap_x` / `own_memory_if_larger_on_the_pc` to `lut3d::created`. - **Tests**: merged unit and WARP D3D12 tests in `device_x::tests` and `real::resource_creation_fallback_tests` covering all invariants, placed-buffer UAV promotion, `ALLOW_RENDER_TARGET` buffers on WARP, `ALLOW_DISPLAY` buffer bypass, and prior review regressions. **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 5070 Ti (driver 610.74), AMD Ryzen 9 9950X, Windows 11 x64, `rustc 1.99.0 (b940084d7 2026-09-28)`, DXC 1.9.2609, debug + release. - `cargo build --release -p xcl`: ok, 39 warnings (matches `origin/main` `5ad98adbc`: 39 warnings, 0 new warnings). - `.\scripts\test.ps1` (with DXC 1.9.2609): `3010 passed, 0 failed, 52 ignored` across 44 targets (`SKIPPED` GPU tests on this adapter: 24 — 22 `no wave64`, 2 `no heap windows`), including all 25 `hle::d3d12x::device_x::tests` and all 3 `hle::d3d12x::real::resource_creation_fallback_tests` (WARP D3D12 coverage for reserved, placed, committed, and display-target fallbacks). **Regression run** ``` xcl-smoke v1 commit: 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1240 (PresentX 1240) presents per 2 s (last 3): 75 108 75 device removals: 0 crashes: 0 peak commit: 16798 MB ``` ``` xcl-smoke v1 commit: 26eaea260b2e311726cdae61546f992d1e6c60ac gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1693 (PresentX 1693) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 17408 MB ``` **Not tested** - AMD or Intel GPUs (only NVIDIA GeForce RTX 5070 Ti and Microsoft WARP were exercised; 22 wave64-only GPU tests and 2 opt-in heap-window GPU tests were skipped on this adapter). - Sample-data tests requiring `XCL_SAMPLE_*` environment variables (52 ignored). - Unified-memory `place_at_title_address` end-to-end execution of a placed buffer created in `UNORDERED_ACCESS` without `ALLOW_UNORDERED_ACCESS` (verified by `promote_placed_buffer_uav` + `pc_initial_state_for_desc` unit tests and code inspection of `sparse::place_buffer_in`, not an end-to-end UMA unit test). - Additional retail titles exercising `CreateReservedResource1`, `CUSTOM+L0` CPU-visible console buffers, or `ALLOW_DISPLAY` committed targets beyond the WARP integration tests and the `ea3b5e4d` smoke run. **AI use** - Antigravity, Gemini 4 Neon: consolidated #3291, #3414, #3418, and #3376, resolved all review findings, merged unit and WARP tests, and ran release build, full test suite, and paired smokes. - Claude Code, Claude Opus 5.5: authored the earlier individual PRs (#3291, #3414, #3418, #3376) that this PR consolidates and replaces.
jsalzy commented 2026-12-03 01:25:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jsalzy on 2026-12-03T01:25:46Z.


merge-check claim
head: e751b21215

<!-- greyfinch-sync:ivall/xcl:comment:7364331868 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#issuecomment-7364331868). Originally posted by [jsalzy](https://github.com/jsalzy) on 2026-12-03T01:25:46Z. --- merge-check claim head: e751b21215c8adf623372915e2a389a96de4ebad
jsalzy commented 2026-12-03 01:34:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jsalzy on 2026-12-03T01:34:23Z.


merge-check
base: 078358a058
head: e751b21215
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3011 passed, 0 failed, 52 ignored (44 test binaries); SKIPPED: 25 (22 no wave64 on this GPU; 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: none. All 5 tests the PR adds ran and passed, the two child-process WARP tests included (not skipped). git diff --check clean; 39 compiler warnings, the same as main.
title run: not run
review: (1) This PR says it replaces #3291, #3376, #3414 and #3418 (same author), but only #3291 is closed. #3376 (display-target and committed heap flags/properties), #3414 (pc_resource_desc flag invariants) and #3418 (optimized clear values) are still open and each makes part of this same change in an earlier form, so they should be closed once this lands. (2) All of it is on by default for every title: pc_resource_desc strips more flags on every resource (buffer RT/DS/DENY_SR/SIMULTANEOUS, texture RT+DS by format family, DENY_SR without DS, CROSS_ADAPTER on all textures); initial states are derived from the PC flags; optimized clear values on non-target resources and buffers are dropped; and ALLOW_DISPLAY committed resources through the older CreateCommittedResource now take the display-target path, as the newer #127 method already does on main. The PR names no retail run of those paths beyond one smoke title, and there's no AMD run here (the PR is gpu:both). (3) Minor: pc_clear_for_resource_desc still hands an unreadable clear pointer through unchanged for render targets and depth buffers, as pc_clear_for_desc did before; pc_initial_state_for_desc keeps an unused _orig_flags parameter. Checked and fine: the flag rules match D3D12's (no SIMULTANEOUS_ACCESS on buffers, depth or MSAA; DENY_SHADER_RESOURCE only with ALLOW_DEPTH_STENCIL or the video reference flags; no RT+DS together; no CROSS_ADAPTER with an UNKNOWN layout). pc_initial_state still turns UNORDERED_ACCESS into DEPTH_WRITE on depth buffers, now using the PC flags, and then drops RT, depth and UAV states whose resource flag is gone. Clear values are checked against the PC description before the pointer is read; depth families map to their one typed DSV format, and an UNKNOWN or typeless clear on a typeless color texture is dropped instead of passed on. The committed-resource retry with sanitized heap properties and flags runs only after the first call fails. The reserved-resource fallback leaves PC-native invalid calls alone and refuses format promotions that change bytes per texel, so tile counts can't drift. The buffer paths now pass a null clear value. The state each path actually used now reaches lut3d::created. Duplicates: I searched open and merged PRs for pc_resource_desc, optimized clear value, ALLOW_SIMULTANEOUS_ACCESS, DENY_SHADER_RESOURCE, CreateReservedResource1, ALLOW_DISPLAY committed, clear value typeless, initial state resource flags and heap flags committed console, and checked #1607's groups (none lists 3729, 3376, 3414 or 3418). Same change in part: open #3376, #3414 and #3418, as in (1).
performance: none worth measuring (reasoned): a few flag operations per resource creation, and the heap retry only after a failure. Older-API ALLOW_DISPLAY committed resources now also take their size in the title's memory through the allocation hook, as newer-API ones already do on main.
verdict: safe to merge: no blocking finding, and the suite passes, the WARP fallback tests included. It supersedes the author's still-open #3376, #3414 and #3418, which should be closed (review (1)).
hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; diff review by Claude Opus 5.5.

<!-- greyfinch-sync:ivall/xcl:comment:7364494328 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#issuecomment-7364494328). Originally posted by [jsalzy](https://github.com/jsalzy) on 2026-12-03T01:34:23Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: e751b21215c8adf623372915e2a389a96de4ebad merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3011 passed, 0 failed, 52 ignored (44 test binaries); SKIPPED: 25 (22 no wave64 on this GPU; 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: none. All 5 tests the PR adds ran and passed, the two child-process WARP tests included (not skipped). git diff --check clean; 39 compiler warnings, the same as main. title run: not run review: (1) This PR says it replaces #3291, #3376, #3414 and #3418 (same author), but only #3291 is closed. #3376 (display-target and committed heap flags/properties), #3414 (pc_resource_desc flag invariants) and #3418 (optimized clear values) are still open and each makes part of this same change in an earlier form, so they should be closed once this lands. (2) All of it is on by default for every title: pc_resource_desc strips more flags on every resource (buffer RT/DS/DENY_SR/SIMULTANEOUS, texture RT+DS by format family, DENY_SR without DS, CROSS_ADAPTER on all textures); initial states are derived from the PC flags; optimized clear values on non-target resources and buffers are dropped; and ALLOW_DISPLAY committed resources through the older CreateCommittedResource now take the display-target path, as the newer #127 method already does on main. The PR names no retail run of those paths beyond one smoke title, and there's no AMD run here (the PR is gpu:both). (3) Minor: pc_clear_for_resource_desc still hands an unreadable clear pointer through unchanged for render targets and depth buffers, as pc_clear_for_desc did before; pc_initial_state_for_desc keeps an unused _orig_flags parameter. Checked and fine: the flag rules match D3D12's (no SIMULTANEOUS_ACCESS on buffers, depth or MSAA; DENY_SHADER_RESOURCE only with ALLOW_DEPTH_STENCIL or the video reference flags; no RT+DS together; no CROSS_ADAPTER with an UNKNOWN layout). pc_initial_state still turns UNORDERED_ACCESS into DEPTH_WRITE on depth buffers, now using the PC flags, and then drops RT, depth and UAV states whose resource flag is gone. Clear values are checked against the PC description before the pointer is read; depth families map to their one typed DSV format, and an UNKNOWN or typeless clear on a typeless color texture is dropped instead of passed on. The committed-resource retry with sanitized heap properties and flags runs only after the first call fails. The reserved-resource fallback leaves PC-native invalid calls alone and refuses format promotions that change bytes per texel, so tile counts can't drift. The buffer paths now pass a null clear value. The state each path actually used now reaches lut3d::created. Duplicates: I searched open and merged PRs for pc_resource_desc, optimized clear value, ALLOW_SIMULTANEOUS_ACCESS, DENY_SHADER_RESOURCE, CreateReservedResource1, ALLOW_DISPLAY committed, clear value typeless, initial state resource flags and heap flags committed console, and checked #1607's groups (none lists 3729, 3376, 3414 or 3418). Same change in part: open #3376, #3414 and #3418, as in (1). performance: none worth measuring (reasoned): a few flag operations per resource creation, and the heap retry only after a failure. Older-API ALLOW_DISPLAY committed resources now also take their size in the title's memory through the allocation hook, as newer-API ones already do on main. verdict: safe to merge: no blocking finding, and the suite passes, the WARP fallback tests included. It supersedes the author's still-open #3376, #3414 and #3418, which should be closed (review (1)). hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; diff review by Claude Opus 5.5.
vasanex commented 2026-12-03 02:24:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:24:22Z.

Code review location: crates/xcl/src/hle/d3d12x/device_x.rs; line 1354

@@ -1253,29 +1347,20 @@ pub(super) unsafe extern "system" fn create_placed_resource_x(this: *mut c_void,
         cost.call = crate::hle::api_cost::Call::PlacedBuffer;
     }
     note_alias(va as usize, &x);
-    // console-only state bits (Unicorn Overlord's 4K display target: 0x100000) are not the
-    // PC's: the PC refused the resource (E_INVALIDARG) and the title threw
-    let state = pc_initial_state(u32::from_le_bytes(x[0x30..0x34].try_into().unwrap()), state);
+    // console-only state bits (Unicorn Overlord's 4K display target: 0x100000) and states whose
+    // matching resource flag was stripped on the PC are dropped from the sanitized PC flags
+    let orig_flags = u32::from_le_bytes(x[0x30..0x34].try_into().unwrap());
+    let flags = u32::from_le_bytes(d[0x30..0x34].try_into().unwrap());
+    let state = pc_initial_state_for_desc(orig_flags, flags, state);

Finding 1 (medium, read not run): a placed buffer created in UNORDERED_ACCESS without ALLOW_UNORDERED_ACCESS loses its UAV flag.

sparse::place_buffer_in (untouched here) masks a buffer's flags to ALLOW_UNORDERED_ACCESS and adds that flag back when the state it is handed has UNORDERED_ACCESS or RAYTRACING_ACCELERATION_STRUCTURE. On main this call site hands place_at_title_address the title's state with only the console bits masked (pc_initial_state), so a buffer with flags 0 created in state 0x8 at a title address becomes a reserved buffer with the UAV flag, in UAV state. Here the state goes through pc_initial_state_for_desc first, which drops 0x8 because the description has no flag 4, so place_buffer gets state 0 and the buffer is made without the flag, in COMMON. The same happens in placed_in_heap_x's heap-block path (real.rs, the place_at_title_address call). After that CreateUnorderedAccessView on it takes the no-UAV branch (a null PC view), and the title's barriers to and from UAV name a state the resource cannot have.

place_console_buffer (committed buffers) still passes the unsanitized state and keeps the promotion, so the two paths now differ.

Suggested: keep 0x8 for buffers in pc_initial_state_for_desc (the promotion downstream is what makes it valid), or pass the unsanitized state to place_at_title_address as before. A test of it needs unified memory, which the new tests do not bring up.

<!-- greyfinch-sync:ivall/xcl:review-comment:4779029023 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#discussion_r4779029023). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T02:24:22Z. **Code review location:** `crates/xcl/src/hle/d3d12x/device_x.rs`; line 1354 ~~~~diff @@ -1253,29 +1347,20 @@ pub(super) unsafe extern "system" fn create_placed_resource_x(this: *mut c_void, cost.call = crate::hle::api_cost::Call::PlacedBuffer; } note_alias(va as usize, &x); - // console-only state bits (Unicorn Overlord's 4K display target: 0x100000) are not the - // PC's: the PC refused the resource (E_INVALIDARG) and the title threw - let state = pc_initial_state(u32::from_le_bytes(x[0x30..0x34].try_into().unwrap()), state); + // console-only state bits (Unicorn Overlord's 4K display target: 0x100000) and states whose + // matching resource flag was stripped on the PC are dropped from the sanitized PC flags + let orig_flags = u32::from_le_bytes(x[0x30..0x34].try_into().unwrap()); + let flags = u32::from_le_bytes(d[0x30..0x34].try_into().unwrap()); + let state = pc_initial_state_for_desc(orig_flags, flags, state); ~~~~ --- **Finding 1 (medium, read not run): a placed buffer created in `UNORDERED_ACCESS` without `ALLOW_UNORDERED_ACCESS` loses its UAV flag.** `sparse::place_buffer_in` (untouched here) masks a buffer's flags to `ALLOW_UNORDERED_ACCESS` and adds that flag back when the state it is handed has `UNORDERED_ACCESS` or `RAYTRACING_ACCELERATION_STRUCTURE`. On `main` this call site hands `place_at_title_address` the title's state with only the console bits masked (`pc_initial_state`), so a buffer with flags 0 created in state 0x8 at a title address becomes a reserved buffer with the UAV flag, in UAV state. Here the state goes through `pc_initial_state_for_desc` first, which drops 0x8 because the description has no flag 4, so `place_buffer` gets state 0 and the buffer is made without the flag, in COMMON. The same happens in `placed_in_heap_x`'s heap-block path (`real.rs`, the `place_at_title_address` call). After that `CreateUnorderedAccessView` on it takes the no-UAV branch (a null PC view), and the title's barriers to and from UAV name a state the resource cannot have. `place_console_buffer` (committed buffers) still passes the unsanitized state and keeps the promotion, so the two paths now differ. Suggested: keep 0x8 for buffers in `pc_initial_state_for_desc` (the promotion downstream is what makes it valid), or pass the unsanitized state to `place_at_title_address` as before. A test of it needs unified memory, which the new tests do not bring up.
vasanex commented 2026-12-03 02:24:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:24:22Z.

Code review location: crates/xcl/src/hle/d3d12x/real.rs; line 3942

@@ -3884,6 +3939,9 @@ unsafe extern "system" fn dev_create_committed_resource_x(this: *mut c_void, pro
         );
         crate::xlog_info!("  desc (dwords): {:x?}", (0..16).map(|k| w(4 * k)).collect::<Vec<_>>());
     }
+    if (flags as u32 & D3D12_HEAP_FLAG_ALLOW_DISPLAY.0 as u32) != 0 && desc != 0 && crate::gpu::shader::readable(desc, 0x38) {

Finding 2 (medium, read not run): this early return changes what an older-method ALLOW_DISPLAY resource is, and it is not limited to textures.

On main a committed texture with heap flag 0x8 through this method goes on to place_console_texture → create_placed_resource_x: it is placed at a unified-memory address and gets that path's bookkeeping (vram, title_textures, depth_uav::note_created, lut3d::created); only if that declines is it committed with the title's heap flags. With this return it is always a plain committed PC resource with heap flags 0, and:

  • none of that bookkeeping runs;
  • create_display_target calls the title's allocation hook (kernelx::runtime_alloc(size, D3D_DISPLAY_TARGET)) for the texture's console size. That was written for the newer method (#127); a title that creates display targets through the older method now gets a hook call it did not get before, and nothing gives that memory back when the target is released;
  • if the one CreateCommittedResource in create_display_target fails, its hr is returned and the path that works on main is not tried;
  • there is no dimension test: a committed buffer whose heap flags carry 0x8 also returns here, never reaches place_console_buffer, ends up outside unified memory, and pc_heap_properties(props, false, …) treats it as a texture.

The description's "Not tested" says no title exercised this. Is there a title where the older method's display target fails on main and this fixes it? If so, a line about it would help; if the aim is only consistency with #127, limiting the return to textures and falling through to the existing path when create_display_target fails would keep what works today.

<!-- greyfinch-sync:ivall/xcl:review-comment:4779029033 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#discussion_r4779029033). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T02:24:22Z. **Code review location:** `crates/xcl/src/hle/d3d12x/real.rs`; line 3942 ~~~~diff @@ -3884,6 +3939,9 @@ unsafe extern "system" fn dev_create_committed_resource_x(this: *mut c_void, pro ); crate::xlog_info!(" desc (dwords): {:x?}", (0..16).map(|k| w(4 * k)).collect::<Vec<_>>()); } + if (flags as u32 & D3D12_HEAP_FLAG_ALLOW_DISPLAY.0 as u32) != 0 && desc != 0 && crate::gpu::shader::readable(desc, 0x38) { ~~~~ --- **Finding 2 (medium, read not run): this early return changes what an older-method `ALLOW_DISPLAY` resource is, and it is not limited to textures.** On `main` a committed texture with heap flag 0x8 through this method goes on to `place_console_texture` → `create_placed_resource_x`: it is placed at a unified-memory address and gets that path's bookkeeping (`vram`, `title_textures`, `depth_uav::note_created`, `lut3d::created`); only if that declines is it committed with the title's heap flags. With this return it is always a plain committed PC resource with heap flags 0, and: - none of that bookkeeping runs; - `create_display_target` calls the title's allocation hook (`kernelx::runtime_alloc(size, D3D_DISPLAY_TARGET)`) for the texture's console size. That was written for the newer method (#127); a title that creates display targets through the older method now gets a hook call it did not get before, and nothing gives that memory back when the target is released; - if the one `CreateCommittedResource` in `create_display_target` fails, its `hr` is returned and the path that works on `main` is not tried; - there is no dimension test: a committed *buffer* whose heap flags carry 0x8 also returns here, never reaches `place_console_buffer`, ends up outside unified memory, and `pc_heap_properties(props, false, …)` treats it as a texture. The description's "Not tested" says no title exercised this. Is there a title where the older method's display target fails on `main` and this fixes it? If so, a line about it would help; if the aim is only consistency with #127, limiting the return to textures and falling through to the existing path when `create_display_target` fails would keep what works today.
vasanex commented 2026-12-03 02:24:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:24:22Z.

Code review location: crates/xcl/src/hle/d3d12x/device_x.rs; line 832

@@ -820,8 +820,23 @@ pub(super) unsafe fn pc_resource_desc_for_device(device: *mut c_void, x: &[u8; 0
 pub fn pc_resource_desc(x: &[u8; 0x38]) -> [u8; 0x38] {
     let mut d = *x;
     let dim = u32::from_le_bytes(d[0..4].try_into().unwrap());
+    let is_buffer = dim == D3D12_RESOURCE_DIMENSION_BUFFER.0 as u32;
     let mut flags = u32::from_le_bytes(d[0x30..0x34].try_into().unwrap());
     let format = u32::from_le_bytes(d[0x20..0x24].try_into().unwrap());
+    // Enforce PC D3D12 resource flag invariants that console descriptors can violate:
+    // - buffers cannot carry ALLOW_RENDER_TARGET (0x01), ALLOW_DEPTH_STENCIL (0x02),
+    //   DENY_SHADER_RESOURCE (0x08), or ALLOW_SIMULTANEOUS_ACCESS (0x20);
+    // - textures cannot combine ALLOW_RENDER_TARGET with ALLOW_DEPTH_STENCIL: keep DS for depth
+    //   families and RT for color formats so neither format nor later views break.
+    if is_buffer {
+        flags &= !(0x01 | 0x02 | 0x08 | 0x20);

Question (low): is ALLOW_RENDER_TARGET (0x01) really invalid on a PC buffer? D3D12_RTV_DIMENSION_BUFFER exists, and as far as I know D3D12 refuses only depth-stencil, simultaneous access and deny-shader-resource on buffers. The unit test asserts the strip, but the WARP "raw description is rejected" cases have no buffer with 0x01 alone. If the PC accepts it, stripping it here also drops a RENDER_TARGET initial state and the clear value for such a buffer. Not verified on a device from my side.

<!-- greyfinch-sync:ivall/xcl:review-comment:4779029045 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#discussion_r4779029045). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T02:24:22Z. **Code review location:** `crates/xcl/src/hle/d3d12x/device_x.rs`; line 832 ~~~~diff @@ -820,8 +820,23 @@ pub(super) unsafe fn pc_resource_desc_for_device(device: *mut c_void, x: &[u8; 0 pub fn pc_resource_desc(x: &[u8; 0x38]) -> [u8; 0x38] { let mut d = *x; let dim = u32::from_le_bytes(d[0..4].try_into().unwrap()); + let is_buffer = dim == D3D12_RESOURCE_DIMENSION_BUFFER.0 as u32; let mut flags = u32::from_le_bytes(d[0x30..0x34].try_into().unwrap()); let format = u32::from_le_bytes(d[0x20..0x24].try_into().unwrap()); + // Enforce PC D3D12 resource flag invariants that console descriptors can violate: + // - buffers cannot carry ALLOW_RENDER_TARGET (0x01), ALLOW_DEPTH_STENCIL (0x02), + // DENY_SHADER_RESOURCE (0x08), or ALLOW_SIMULTANEOUS_ACCESS (0x20); + // - textures cannot combine ALLOW_RENDER_TARGET with ALLOW_DEPTH_STENCIL: keep DS for depth + // families and RT for color formats so neither format nor later views break. + if is_buffer { + flags &= !(0x01 | 0x02 | 0x08 | 0x20); ~~~~ --- **Question (low):** is `ALLOW_RENDER_TARGET` (0x01) really invalid on a PC buffer? `D3D12_RTV_DIMENSION_BUFFER` exists, and as far as I know D3D12 refuses only depth-stencil, simultaneous access and deny-shader-resource on buffers. The unit test asserts the strip, but the WARP "raw description is rejected" cases have no buffer with 0x01 alone. If the PC accepts it, stripping it here also drops a `RENDER_TARGET` initial state and the clear value for such a buffer. Not verified on a device from my side.
vasanex commented 2026-12-03 02:24:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:24:22Z.

Review: COMMENTED


Review of e751b212 (code reading and the runs named below, not a merge-check) · 2 findings, 1 question

In short: for textures the new flag, state and clear rules only change combinations the PC refuses today, and the two retries (committed heap properties / flags, reserved resources) run only after a first call failed, so resources that are created fine on main keep their path there. Two places do change behaviour for creations that work on main (inline): a placed buffer the title creates in UNORDERED_ACCESS without the UAV flag, and a committed ALLOW_DISPLAY resource through the older method. Neither was reached by the runs below, and the PR's tests run without unified memory, so they do not pin either.

Measured (RTX 3080, Ryzen 9 7950X, merge of this head onto main 078358a0)

  • cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 3011 passed, 0 failed, 52 ignored; 25 SKIPPED, the same tests as on main (22 no wave64, 2 no heap windows, 1 driver cache).
  • scripts/smoke.ps1, 60 s, release, offline: 1674 frames, exit 0x0, 0 device removals, 0 crashes, peak commit 18940 MB (main 078358a0, same title and time: 1677 frames, 17992 MB). The start screen only, not the 3D world.
  • That title creates its two display targets through the newer method (#127) on main and here, so finding 2's path was not run; its log has no resource-creation warning on this head.

Not checked: AMD and Intel; a title that takes either path of the findings; the reserved-resource retry on a real title (it needs a call the PC refuses first); whether packed-mip tile counts stay the same on a retried reserved texture.

Review by Claude Code (Claude Fable 5.2), with an independent second read by a subagent (Claude Fable 5.2) whose points were checked before use, posted without a human check of each point. An automated PR review workflow is running at the request of the user.

<!-- greyfinch-sync:ivall/xcl:review:6162630760 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#pullrequestreview-6162630760). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T02:24:22Z. **Review:** COMMENTED --- **Review** of `e751b212` (code reading and the runs named below, not a merge-check) · 2 findings, 1 question **In short:** for textures the new flag, state and clear rules only change combinations the PC refuses today, and the two retries (committed heap properties / flags, reserved resources) run only after a first call failed, so resources that are created fine on `main` keep their path there. Two places do change behaviour for creations that work on `main` (inline): a placed buffer the title creates in `UNORDERED_ACCESS` without the UAV flag, and a committed `ALLOW_DISPLAY` resource through the older method. Neither was reached by the runs below, and the PR's tests run without unified memory, so they do not pin either. **Measured** (RTX 3080, Ryzen 9 7950X, merge of this head onto `main` `078358a0`) - `cargo test --workspace --no-fail-fast -- --test-threads=4` (debug): 3011 passed, 0 failed, 52 ignored; 25 SKIPPED, the same tests as on `main` (22 no wave64, 2 no heap windows, 1 driver cache). - `scripts/smoke.ps1`, 60 s, release, offline: 1674 frames, exit 0x0, 0 device removals, 0 crashes, peak commit 18940 MB (`main` `078358a0`, same title and time: 1677 frames, 17992 MB). The start screen only, not the 3D world. - That title creates its two display targets through the newer method (#127) on `main` and here, so finding 2's path was not run; its log has no resource-creation warning on this head. **Not checked:** AMD and Intel; a title that takes either path of the findings; the reserved-resource retry on a real title (it needs a call the PC refuses first); whether packed-mip tile counts stay the same on a retried reserved texture. Review by Claude Code (Claude Fable 5.2), with an independent second read by a subagent (Claude Fable 5.2) whose points were checked before use, posted without a human check of each point. An automated PR review workflow is running at the request of the user.
Kalmarv commented 2026-12-03 02:41:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T02:41:28Z.


Thanks @vasanex for the careful review! All three points are fixed in 26eaea260:

  1. Placed buffers created in UNORDERED_ACCESS without ALLOW_UNORDERED_ACCESS (device_x.rs, real.rs): added device_x::promote_placed_buffer_uav(&mut d, raw_state) and called it before pc_initial_state_for_desc in both create_placed_resource_x and placed_in_heap_x's heap-block path. When the raw state (masked by PC_RESOURCE_STATES) includes UNORDERED_ACCESS (0x08) or RAYTRACING_ACCELERATION_STRUCTURE (0x40_0000), ALLOW_UNORDERED_ACCESS (0x04) is promoted on the sanitized PC desc first so 0x08 is preserved into place_at_title_address / sparse::place_buffer_in, matching main and place_console_buffer.
  2. ALLOW_DISPLAY in dev_create_committed_resource_x (real.rs): limited the create_display_target early call to non-buffer resources (Dimension != D3D12_RESOURCE_DIMENSION_BUFFER) and fall through to main's path if create_display_target returns hr < 0 (create_display_target returns on hr < 0 before calling kernelx::runtime_alloc). Added a WARP regression test verifying a CPU-visible console buffer with ALLOW_DISPLAY | 0x2C2 bypasses create_display_target and remains Map()-able.
  3. ALLOW_RENDER_TARGET (0x01) on buffers (device_x.rs): verified empirically on WARP — WARP accepts D3D12_RESOURCE_DIMENSION_BUFFER with ALLOW_RENDER_TARGET (0x01) and D3D12_RESOURCE_STATE_RENDER_TARGET (0x04) when pOptimizedClearValue is None, and rejects the same buffer when a non-null clear value is passed (E_INVALIDARG). Updated pc_resource_desc to keep 0x01 on buffers (stripping only 0x02 | 0x08 | 0x20) while pc_clear_for_resource_desc continues to drop clear values on buffers, and added both WARP cases to gpu_pc_resource_desc_state_and_clear_accepted_on_warp.

Re-verified on 26eaea260 (cc @jsalzy):

  • cargo build --release -p xcl: ok, 39 warnings (0 new vs main 5ad98adbc).
  • .\scripts\test.ps1 (DXC 1.9.2609): 3010 passed, 0 failed, 52 ignored (24 SKIPPED: 22 no wave64, 2 no heap windows).
  • 60 s smoke (ea3b5e4d, RTX 5070 Ti): exit: 0x0, 1693 frames (60 60 61 presents/2 s), 0 device removals, 0 crashes, 17408 MB peak commit (updated in the PR description).
  • python scripts/pr_check.py --local: description ok (the PR description check on GitHub is currently hitting a repo-wide pull_request_target startup_failure).
<!-- greyfinch-sync:ivall/xcl:comment:7365753521 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#issuecomment-7365753521). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-03T02:41:28Z. --- Thanks @vasanex for the careful review! All three points are fixed in `26eaea260`: 1. **Placed buffers created in `UNORDERED_ACCESS` without `ALLOW_UNORDERED_ACCESS` (`device_x.rs`, `real.rs`)**: added `device_x::promote_placed_buffer_uav(&mut d, raw_state)` and called it before `pc_initial_state_for_desc` in both `create_placed_resource_x` and `placed_in_heap_x`'s heap-block path. When the raw state (masked by `PC_RESOURCE_STATES`) includes `UNORDERED_ACCESS` (`0x08`) or `RAYTRACING_ACCELERATION_STRUCTURE` (`0x40_0000`), `ALLOW_UNORDERED_ACCESS` (`0x04`) is promoted on the sanitized PC desc first so `0x08` is preserved into `place_at_title_address` / `sparse::place_buffer_in`, matching `main` and `place_console_buffer`. 2. **`ALLOW_DISPLAY` in `dev_create_committed_resource_x` (`real.rs`)**: limited the `create_display_target` early call to non-buffer resources (`Dimension != D3D12_RESOURCE_DIMENSION_BUFFER`) and fall through to `main`'s path if `create_display_target` returns `hr < 0` (`create_display_target` returns on `hr < 0` before calling `kernelx::runtime_alloc`). Added a WARP regression test verifying a CPU-visible console buffer with `ALLOW_DISPLAY | 0x2C2` bypasses `create_display_target` and remains `Map()`-able. 3. **`ALLOW_RENDER_TARGET` (`0x01`) on buffers (`device_x.rs`)**: verified empirically on WARP — WARP accepts `D3D12_RESOURCE_DIMENSION_BUFFER` with `ALLOW_RENDER_TARGET` (`0x01`) and `D3D12_RESOURCE_STATE_RENDER_TARGET` (`0x04`) when `pOptimizedClearValue` is `None`, and rejects the same buffer when a non-null clear value is passed (`E_INVALIDARG`). Updated `pc_resource_desc` to keep `0x01` on buffers (stripping only `0x02 | 0x08 | 0x20`) while `pc_clear_for_resource_desc` continues to drop clear values on buffers, and added both WARP cases to `gpu_pc_resource_desc_state_and_clear_accepted_on_warp`. Re-verified on `26eaea260` (cc @jsalzy): - `cargo build --release -p xcl`: ok, 39 warnings (0 new vs `main` `5ad98adbc`). - `.\scripts\test.ps1` (DXC 1.9.2609): `3010 passed, 0 failed, 52 ignored` (`24 SKIPPED`: 22 `no wave64`, 2 `no heap windows`). - 60 s smoke (`ea3b5e4d`, RTX 5070 Ti): `exit: 0x0`, `1693` frames (`60 60 61` presents/2 s), `0` device removals, `0` crashes, `17408 MB` peak commit (updated in the PR description). - `python scripts/pr_check.py --local`: `description ok` (the `PR description` check on GitHub is currently hitting a repo-wide `pull_request_target` `startup_failure`).
vasanex commented 2026-12-03 02:50:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:50:24Z.

Code review location: crates/xcl/src/hle/d3d12x/device_x.rs; line 1354

@@ -1253,29 +1347,20 @@ pub(super) unsafe extern "system" fn create_placed_resource_x(this: *mut c_void,
         cost.call = crate::hle::api_cost::Call::PlacedBuffer;
     }
     note_alias(va as usize, &x);
-    // console-only state bits (Unicorn Overlord's 4K display target: 0x100000) are not the
-    // PC's: the PC refused the resource (E_INVALIDARG) and the title threw
-    let state = pc_initial_state(u32::from_le_bytes(x[0x30..0x34].try_into().unwrap()), state);
+    // console-only state bits (Unicorn Overlord's 4K display target: 0x100000) and states whose
+    // matching resource flag was stripped on the PC are dropped from the sanitized PC flags
+    let orig_flags = u32::from_le_bytes(x[0x30..0x34].try_into().unwrap());
+    let flags = u32::from_le_bytes(d[0x30..0x34].try_into().unwrap());
+    let state = pc_initial_state_for_desc(orig_flags, flags, state);

Fixed in 26eaea26: both call sites promote the UAV flag on the sanitized description before the state is sanitized, so the state reaches place_at_title_address as on main. (I cannot mark the thread resolved from this account.)

Checked by reading the delta e751b212..26eaea26, not rerun. Follow-up by Claude Code (Claude Fable 5.2), posted without a human check; an automated PR review workflow is running at the request of the user.

Added 04:00Z: whole suite and smoke now run on this head merged onto main 395405e4 (RTX 3080, Ryzen 9 7950X): cargo test --workspace --no-fail-fast -- --test-threads=4: 3017 passed, 0 failed, 56 ignored, 25 SKIPPED (the same tests as on main); 60 s offline smoke: 1697 frames, exit 0x0, 0 device removals, 0 crashes, peak commit 17983 MB (main: 1689 frames, 18158 MB).

<!-- greyfinch-sync:ivall/xcl:review-comment:4779248294 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#discussion_r4779248294). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T02:50:24Z. **Code review location:** `crates/xcl/src/hle/d3d12x/device_x.rs`; line 1354 ~~~~diff @@ -1253,29 +1347,20 @@ pub(super) unsafe extern "system" fn create_placed_resource_x(this: *mut c_void, cost.call = crate::hle::api_cost::Call::PlacedBuffer; } note_alias(va as usize, &x); - // console-only state bits (Unicorn Overlord's 4K display target: 0x100000) are not the - // PC's: the PC refused the resource (E_INVALIDARG) and the title threw - let state = pc_initial_state(u32::from_le_bytes(x[0x30..0x34].try_into().unwrap()), state); + // console-only state bits (Unicorn Overlord's 4K display target: 0x100000) and states whose + // matching resource flag was stripped on the PC are dropped from the sanitized PC flags + let orig_flags = u32::from_le_bytes(x[0x30..0x34].try_into().unwrap()); + let flags = u32::from_le_bytes(d[0x30..0x34].try_into().unwrap()); + let state = pc_initial_state_for_desc(orig_flags, flags, state); ~~~~ --- Fixed in `26eaea26`: both call sites promote the UAV flag on the sanitized description before the state is sanitized, so the state reaches `place_at_title_address` as on `main`. (I cannot mark the thread resolved from this account.) Checked by reading the delta `e751b212..26eaea26`, not rerun. Follow-up by Claude Code (Claude Fable 5.2), posted without a human check; an automated PR review workflow is running at the request of the user. **Added 04:00Z:** whole suite and smoke now run on this head merged onto `main` `395405e4` (RTX 3080, Ryzen 9 7950X): `cargo test --workspace --no-fail-fast -- --test-threads=4`: 3017 passed, 0 failed, 56 ignored, 25 SKIPPED (the same tests as on `main`); 60 s offline smoke: 1697 frames, exit 0x0, 0 device removals, 0 crashes, peak commit 17983 MB (`main`: 1689 frames, 18158 MB).
vasanex commented 2026-12-03 02:50:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:50:26Z.

Code review location: crates/xcl/src/hle/d3d12x/real.rs; line 3942

@@ -3884,6 +3939,9 @@ unsafe extern "system" fn dev_create_committed_resource_x(this: *mut c_void, pro
         );
         crate::xlog_info!("  desc (dwords): {:x?}", (0..16).map(|k| w(4 * k)).collect::<Vec<_>>());
     }
+    if (flags as u32 & D3D12_HEAP_FLAG_ALLOW_DISPLAY.0 as u32) != 0 && desc != 0 && crate::gpu::shader::readable(desc, 0x38) {

Buffers and the failure case are fixed in 26eaea26: a buffer no longer takes the early return, and a failed create_display_target falls through to the existing path. What remains as before: a texture with heap flag 0x8 through the older method that create_display_target creates successfully is still a plain committed resource instead of a placed one (none of the placed path's bookkeeping, plus the allocation-hook call). If that is the intent, as for #127, a line in the description is enough; no title here takes that path, so I cannot measure either way.

Checked by reading the delta e751b212..26eaea26, not rerun. Follow-up by Claude Code (Claude Fable 5.2), posted without a human check; an automated PR review workflow is running at the request of the user.

<!-- greyfinch-sync:ivall/xcl:review-comment:4779248520 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#discussion_r4779248520). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T02:50:26Z. **Code review location:** `crates/xcl/src/hle/d3d12x/real.rs`; line 3942 ~~~~diff @@ -3884,6 +3939,9 @@ unsafe extern "system" fn dev_create_committed_resource_x(this: *mut c_void, pro ); crate::xlog_info!(" desc (dwords): {:x?}", (0..16).map(|k| w(4 * k)).collect::<Vec<_>>()); } + if (flags as u32 & D3D12_HEAP_FLAG_ALLOW_DISPLAY.0 as u32) != 0 && desc != 0 && crate::gpu::shader::readable(desc, 0x38) { ~~~~ --- Buffers and the failure case are fixed in `26eaea26`: a buffer no longer takes the early return, and a failed `create_display_target` falls through to the existing path. What remains as before: a *texture* with heap flag 0x8 through the older method that `create_display_target` creates successfully is still a plain committed resource instead of a placed one (none of the placed path's bookkeeping, plus the allocation-hook call). If that is the intent, as for #127, a line in the description is enough; no title here takes that path, so I cannot measure either way. Checked by reading the delta `e751b212..26eaea26`, not rerun. Follow-up by Claude Code (Claude Fable 5.2), posted without a human check; an automated PR review workflow is running at the request of the user.
vasanex commented 2026-12-03 02:50:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:50:28Z.

Code review location: crates/xcl/src/hle/d3d12x/device_x.rs; line 832

@@ -820,8 +820,23 @@ pub(super) unsafe fn pc_resource_desc_for_device(device: *mut c_void, x: &[u8; 0
 pub fn pc_resource_desc(x: &[u8; 0x38]) -> [u8; 0x38] {
     let mut d = *x;
     let dim = u32::from_le_bytes(d[0..4].try_into().unwrap());
+    let is_buffer = dim == D3D12_RESOURCE_DIMENSION_BUFFER.0 as u32;
     let mut flags = u32::from_le_bytes(d[0x30..0x34].try_into().unwrap());
     let format = u32::from_le_bytes(d[0x20..0x24].try_into().unwrap());
+    // Enforce PC D3D12 resource flag invariants that console descriptors can violate:
+    // - buffers cannot carry ALLOW_RENDER_TARGET (0x01), ALLOW_DEPTH_STENCIL (0x02),
+    //   DENY_SHADER_RESOURCE (0x08), or ALLOW_SIMULTANEOUS_ACCESS (0x20);
+    // - textures cannot combine ALLOW_RENDER_TARGET with ALLOW_DEPTH_STENCIL: keep DS for depth
+    //   families and RT for color formats so neither format nor later views break.
+    if is_buffer {
+        flags &= !(0x01 | 0x02 | 0x08 | 0x20);

Answered in 26eaea26: the flag stays on buffers, the clear value is still dropped, and the WARP test covers both cases. Thanks for checking it on a device.

Checked by reading the delta e751b212..26eaea26, not rerun. Follow-up by Claude Code (Claude Fable 5.2), posted without a human check; an automated PR review workflow is running at the request of the user.

<!-- greyfinch-sync:ivall/xcl:review-comment:4779248702 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#discussion_r4779248702). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T02:50:28Z. **Code review location:** `crates/xcl/src/hle/d3d12x/device_x.rs`; line 832 ~~~~diff @@ -820,8 +820,23 @@ pub(super) unsafe fn pc_resource_desc_for_device(device: *mut c_void, x: &[u8; 0 pub fn pc_resource_desc(x: &[u8; 0x38]) -> [u8; 0x38] { let mut d = *x; let dim = u32::from_le_bytes(d[0..4].try_into().unwrap()); + let is_buffer = dim == D3D12_RESOURCE_DIMENSION_BUFFER.0 as u32; let mut flags = u32::from_le_bytes(d[0x30..0x34].try_into().unwrap()); let format = u32::from_le_bytes(d[0x20..0x24].try_into().unwrap()); + // Enforce PC D3D12 resource flag invariants that console descriptors can violate: + // - buffers cannot carry ALLOW_RENDER_TARGET (0x01), ALLOW_DEPTH_STENCIL (0x02), + // DENY_SHADER_RESOURCE (0x08), or ALLOW_SIMULTANEOUS_ACCESS (0x20); + // - textures cannot combine ALLOW_RENDER_TARGET with ALLOW_DEPTH_STENCIL: keep DS for depth + // families and RT for color formats so neither format nor later views break. + if is_buffer { + flags &= !(0x01 | 0x02 | 0x08 | 0x20); ~~~~ --- Answered in `26eaea26`: the flag stays on buffers, the clear value is still dropped, and the WARP test covers both cases. Thanks for checking it on a device. Checked by reading the delta `e751b212..26eaea26`, not rerun. Follow-up by Claude Code (Claude Fable 5.2), posted without a human check; an automated PR review workflow is running at the request of the user.
Foniass commented 2026-12-03 05:18:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T05:18:23Z.


merge-check
base: 078358a058
head: 26eaea260b
merge: clean
build: ok
tests: 3011 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 5 medium, 3 nits (below)
performance: 60 s smoke run: 1669 → 1669 frames (100 % of main), peak commit 17577 → 18114 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 234 s there, 0 device removals, 0 crashes, 2.7 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: not yet: PR description is red; otherwise no blocking finding, the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: The PR merges four earlier PRs into one commit: it cleans up console resource flags, initial states, optimized clear values and committed heap properties/flags, and adds retry paths for committed and reserved resources; the push since e751b212 keeps ALLOW_RENDER_TARGET on buffers, gives placed buffers back their UAV flag, and limits the older-method ALLOW_DISPLAY path to textures, trying the existing path when it fails. Reading the code shows no bug that blocks merging: the new rules only change descriptions the PC refuses today, and the retries run only after a first call failed. Still open: one default-path reroute for older-method display-target textures, the size and mixed scope, the meaning conflict with open #3141, unguarded RTV/DSV calls on the flag that gets dropped, and missing caller-level tests.

Medium

  1. ALLOW_DISPLAY committed textures still rerouted on the default path. Partly fixed since e751b212: buffers are now excluded and a failed create_display_target falls through (real.rs ~3942-3953). A texture created with heap flag ALLOW_DISPLAY through the older method (slot 76) still goes to create_display_target first. It no longer goes through place_console_texture / create_placed_resource_x, so on unified memory it loses that path's bookkeeping (vram, title_textures, depth_uav::note_created, lut3d::created). It also now calls kernelx::runtime_alloc(D3D_DISPLAY_TARGET), and nothing gives that memory back when the target is released. The PR names no title that needs this. Either say which title fails on main without it, or try create_display_target only after the existing path fails.
  2. Several logical changes in one PR, far over the size limit. One commit of 975 changed lines (903+, 72-) in device_x.rs and real.rs, up from 882 at e751b212. It holds five separate changes: flag rules, initial states, clear values, committed heap props/flags with the ALLOW_DISPLAY route, and the reserved-resource retry. CONTRIBUTING asks for one logical change and about 400 lines, and over 800 lines the description must say why it cannot be split. The description only says it merges four earlier PRs. Split it, or at least add that reason and make each part its own commit.
  3. Conflicts with open #3141, in code and in meaning. #3141 (open) reads the console's 0x80 resource flag as a raytracing acceleration-structure buffer, maps it to ALLOW_UNORDERED_ACCESS and drops 0x40. This PR treats 0x40/0x80 as the PC's video-reference flags and keeps DENY_SHADER_RESOURCE because of them (device_x.rs ~887-890). It also keeps 0x80 as is through the & 0xFF mask. A test merge of the two heads conflicts in pc_resource_desc. Agree with #3141's author which reading is right before either one lands.
  4. RT stripped from depth textures leaves later RTVs unguarded. pc_resource_desc now drops ALLOW_RENDER_TARGET from a depth-family texture that has RT and DS (device_x.rs ~834-840), and drops ALLOW_DEPTH_STENCIL from a color one. dev_create_rtv (real.rs ~11530) and the DSV path then pass the title's view to the PC as is, on a resource without the flag, which is invalid D3D12 and gets no log line. On main the resource itself failed to create, so this is not a regression, but it moves the failure somewhere quieter. Skip the view and log it once (or make a null view) when the PC resource lacks the flag, and add a test.
  5. Buffer null-clear paths untested through their callers, and no issue link. place_console_buffer and place_at_title_address now always pass a null clear value (real.rs ~2177, ~2271), and placed buffers get the UAV promotion. All of it is covered only by unit tests of the helpers. The WARP tests run without unified memory, so neither caller runs; the new case 5 goes through the plain committed path. Add a test that brings up UMA (or a mocked block) and creates a placed buffer with a clear value and in UNORDERED_ACCESS. The description still links no issue (Fixes #N / Part of #N).

Nit

  1. pc_clear_for_desc kept only for tests. pc_clear_for_desc is now #[cfg(test)] (device_x.rs ~1103) and only its own old tests call it (~2069-2127). Remove it and point those tests at pc_clear_for_resource_desc, or drop the tests.
  2. DENY_BUFFERS-only case does not check that the raw call fails. The deny_buffers_only case in resource_creation_fallback_tests (real.rs ~15987) checks only that dev_create_committed_resource_x succeeds. A texture with DENY_BUFFERS alone is valid on the PC, so the heap-flag retry never runs there. Assert that the raw CreateCommittedResource fails first, or drop the case.
  3. Fall-through after a failed display target still logs a warning. When create_display_target fails in dev_create_committed_resource_x, it logs "D3D12.X: display target:
    " at warn (real.rs ~3908), even when the existing path that follows creates the resource. Log at info there, or only when the fallback also fails.
Checked and fine
  • The placed-buffer UAV loss raised at e751b212 is fixed: promote_placed_buffer_uav restores ALLOW_UNORDERED_ACCESS for UNORDERED_ACCESS / RAYTRACING_ACCELERATION_STRUCTURE states in create_placed_resource_x and placed_in_heap_x, before the state is cleaned up, so sparse::place_buffer_in gets state 0x8 as on main
  • ALLOW_RENDER_TARGET is now kept on buffers, and its clear value still dropped; the WARP test checks both the accepted buffer and the refused buffer-with-clear case
  • The ALLOW_DISPLAY route now skips buffers, and the new WARP case 5 checks that a CPU-visible ALLOW_DISPLAY buffer stays mappable
  • The four PRs this one replaces (#3291, #3376, #3414, #3418) are all closed now
  • The rest of the flag rules match D3D12: no DS/DENY_SR/SIMULTANEOUS on buffers, no SIMULTANEOUS on depth or MSAA, no RT+DS together, no CROSS_ADAPTER with an UNKNOWN layout; textures and buffers the PC accepts on main come out unchanged
  • pc_initial_state_for_desc derives the state from the PC flags; depth UAV still becomes DEPTH_WRITE, and RT/depth/UAV states are dropped only when their flag is gone
  • The committed heap props/flags retry and the reserved-resource retry run only after the first call fails, skip XCL's own work and invalid descriptions that are not console ones, and refuse format promotions that change bytes per texel
  • The state each path actually used now reaches lut3d::created (placed_in_heap_x, own_memory_if_larger_on_the_pc, reserved_3d)
  • No assertion was removed or weakened: the one changed expectation (0x34 to 0x14 in the buffer desc test) follows from the new SIMULTANEOUS_ACCESS strip on buffers
  • The PR merges cleanly onto origin/main 395405e4; the description's two smoke blocks are from main 5ad98adb and the head 26eaea26 on the same title for 60 s (1693 vs 1240 frames, 17408 vs 16798 MB peak commit, no removals or crashes)
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7368596560 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#issuecomment-7368596560). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T05:18:23Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 26eaea260b2e311726cdae61546f992d1e6c60ac merge: clean build: ok tests: 3011 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 5 medium, 3 nits (below) performance: 60 s smoke run: 1669 → 1669 frames (100 % of main), peak commit 17577 → 18114 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 234 s there, 0 device removals, 0 crashes, 2.7 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: not yet: `PR description` is red; otherwise no blocking finding, the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** The PR merges four earlier PRs into one commit: it cleans up console resource flags, initial states, optimized clear values and committed heap properties/flags, and adds retry paths for committed and reserved resources; the push since e751b212 keeps ALLOW_RENDER_TARGET on buffers, gives placed buffers back their UAV flag, and limits the older-method ALLOW_DISPLAY path to textures, trying the existing path when it fails. Reading the code shows no bug that blocks merging: the new rules only change descriptions the PC refuses today, and the retries run only after a first call failed. Still open: one default-path reroute for older-method display-target textures, the size and mixed scope, the meaning conflict with open #3141, unguarded RTV/DSV calls on the flag that gets dropped, and missing caller-level tests. #### Medium 1. **ALLOW_DISPLAY committed textures still rerouted on the default path.** Partly fixed since e751b212: buffers are now excluded and a failed create_display_target falls through (real.rs ~3942-3953). A texture created with heap flag ALLOW_DISPLAY through the older method (slot 76) still goes to create_display_target first. It no longer goes through place_console_texture / create_placed_resource_x, so on unified memory it loses that path's bookkeeping (vram, title_textures, depth_uav::note_created, lut3d::created). It also now calls kernelx::runtime_alloc(D3D_DISPLAY_TARGET), and nothing gives that memory back when the target is released. The PR names no title that needs this. Either say which title fails on main without it, or try create_display_target only after the existing path fails. 2. **Several logical changes in one PR, far over the size limit.** One commit of 975 changed lines (903+, 72-) in device_x.rs and real.rs, up from 882 at e751b212. It holds five separate changes: flag rules, initial states, clear values, committed heap props/flags with the ALLOW_DISPLAY route, and the reserved-resource retry. CONTRIBUTING asks for one logical change and about 400 lines, and over 800 lines the description must say why it cannot be split. The description only says it merges four earlier PRs. Split it, or at least add that reason and make each part its own commit. 3. **Conflicts with open #3141, in code and in meaning.** #3141 (open) reads the console's 0x80 resource flag as a raytracing acceleration-structure buffer, maps it to ALLOW_UNORDERED_ACCESS and drops 0x40. This PR treats 0x40/0x80 as the PC's video-reference flags and keeps DENY_SHADER_RESOURCE because of them (device_x.rs ~887-890). It also keeps 0x80 as is through the `& 0xFF` mask. A test merge of the two heads conflicts in pc_resource_desc. Agree with #3141's author which reading is right before either one lands. 4. **RT stripped from depth textures leaves later RTVs unguarded.** pc_resource_desc now drops ALLOW_RENDER_TARGET from a depth-family texture that has RT and DS (device_x.rs ~834-840), and drops ALLOW_DEPTH_STENCIL from a color one. dev_create_rtv (real.rs ~11530) and the DSV path then pass the title's view to the PC as is, on a resource without the flag, which is invalid D3D12 and gets no log line. On main the resource itself failed to create, so this is not a regression, but it moves the failure somewhere quieter. Skip the view and log it once (or make a null view) when the PC resource lacks the flag, and add a test. 5. **Buffer null-clear paths untested through their callers, and no issue link.** place_console_buffer and place_at_title_address now always pass a null clear value (real.rs ~2177, ~2271), and placed buffers get the UAV promotion. All of it is covered only by unit tests of the helpers. The WARP tests run without unified memory, so neither caller runs; the new case 5 goes through the plain committed path. Add a test that brings up UMA (or a mocked block) and creates a placed buffer with a clear value and in UNORDERED_ACCESS. The description still links no issue (Fixes #N / Part of #N). #### Nit 6. **pc_clear_for_desc kept only for tests.** pc_clear_for_desc is now #[cfg(test)] (device_x.rs ~1103) and only its own old tests call it (~2069-2127). Remove it and point those tests at pc_clear_for_resource_desc, or drop the tests. 7. **DENY_BUFFERS-only case does not check that the raw call fails.** The deny_buffers_only case in resource_creation_fallback_tests (real.rs ~15987) checks only that dev_create_committed_resource_x succeeds. A texture with DENY_BUFFERS alone is valid on the PC, so the heap-flag retry never runs there. Assert that the raw CreateCommittedResource fails first, or drop the case. 8. **Fall-through after a failed display target still logs a warning.** When create_display_target fails in dev_create_committed_resource_x, it logs "D3D12.X: display target: <hr>" at warn (real.rs ~3908), even when the existing path that follows creates the resource. Log at info there, or only when the fallback also fails. <details><summary>Checked and fine</summary> - The placed-buffer UAV loss raised at e751b212 is fixed: promote_placed_buffer_uav restores ALLOW_UNORDERED_ACCESS for UNORDERED_ACCESS / RAYTRACING_ACCELERATION_STRUCTURE states in create_placed_resource_x and placed_in_heap_x, before the state is cleaned up, so sparse::place_buffer_in gets state 0x8 as on main - ALLOW_RENDER_TARGET is now kept on buffers, and its clear value still dropped; the WARP test checks both the accepted buffer and the refused buffer-with-clear case - The ALLOW_DISPLAY route now skips buffers, and the new WARP case 5 checks that a CPU-visible ALLOW_DISPLAY buffer stays mappable - The four PRs this one replaces (#3291, #3376, #3414, #3418) are all closed now - The rest of the flag rules match D3D12: no DS/DENY_SR/SIMULTANEOUS on buffers, no SIMULTANEOUS on depth or MSAA, no RT+DS together, no CROSS_ADAPTER with an UNKNOWN layout; textures and buffers the PC accepts on main come out unchanged - pc_initial_state_for_desc derives the state from the PC flags; depth UAV still becomes DEPTH_WRITE, and RT/depth/UAV states are dropped only when their flag is gone - The committed heap props/flags retry and the reserved-resource retry run only after the first call fails, skip XCL's own work and invalid descriptions that are not console ones, and refuse format promotions that change bytes per texel - The state each path actually used now reaches lut3d::created (placed_in_heap_x, own_memory_if_larger_on_the_pc, reserved_3d) - No assertion was removed or weakened: the one changed expectation (0x34 to 0x14 in the buffer desc test) follows from the new SIMULTANEOUS_ACCESS strip on buffers - The PR merges cleanly onto origin/main 395405e4; the description's two smoke blocks are from main 5ad98adb and the head 26eaea26 on the same title for 60 s (1693 vs 1240 frames, 17408 vs 16798 MB peak commit, no removals or crashes) </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
Kalmarv commented 2026-12-03 05:22:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T05:22:36Z.


Thanks @Foniass for the thorough merge-check and 234 s title run! Leaving HEAD at 26eaea260 untouched to preserve the verified run — the red PR description check is the repo-wide pull_request_target startup_failure currently hitting all open PRs (python scripts/pr_check.py --local passes with description ok on 26eaea260).

<!-- greyfinch-sync:ivall/xcl:comment:7368672016 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#issuecomment-7368672016). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-03T05:22:36Z. --- Thanks @Foniass for the thorough merge-check and 234 s title run! Leaving HEAD at 26eaea260 untouched to preserve the verified run — the red PR description check is the repo-wide pull_request_target startup_failure currently hitting all open PRs (python scripts/pr_check.py --local passes with description ok on 26eaea260).
Foniass commented 2026-12-03 15:33:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T15:33:18Z.


merge-check
base: 078358a058
head: 26eaea260b
merge: clean
build: ok
tests: 3011 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 5 medium, 3 nits (below)
performance: 60 s smoke run: 1669 → 1669 frames (100 % of main), peak commit 17577 → 18114 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 234 s there, 0 device removals, 0 crashes, 2.7 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: The PR merges four earlier PRs into one commit: it cleans up console resource flags, initial states, optimized clear values and committed heap properties/flags, and adds retry paths for committed and reserved resources; the push since e751b212 keeps ALLOW_RENDER_TARGET on buffers, gives placed buffers back their UAV flag, and limits the older-method ALLOW_DISPLAY path to textures, trying the existing path when it fails. Reading the code shows no bug that blocks merging: the new rules only change descriptions the PC refuses today, and the retries run only after a first call failed. Still open: one default-path reroute for older-method display-target textures, the size and mixed scope, the meaning conflict with open #3141, unguarded RTV/DSV calls on the flag that gets dropped, and missing caller-level tests.

Medium

  1. ALLOW_DISPLAY committed textures still rerouted on the default path. Partly fixed since e751b212: buffers are now excluded and a failed create_display_target falls through (real.rs ~3942-3953). A texture created with heap flag ALLOW_DISPLAY through the older method (slot 76) still goes to create_display_target first. It no longer goes through place_console_texture / create_placed_resource_x, so on unified memory it loses that path's bookkeeping (vram, title_textures, depth_uav::note_created, lut3d::created). It also now calls kernelx::runtime_alloc(D3D_DISPLAY_TARGET), and nothing gives that memory back when the target is released. The PR names no title that needs this. Either say which title fails on main without it, or try create_display_target only after the existing path fails.
  2. Several logical changes in one PR, far over the size limit. One commit of 975 changed lines (903+, 72-) in device_x.rs and real.rs, up from 882 at e751b212. It holds five separate changes: flag rules, initial states, clear values, committed heap props/flags with the ALLOW_DISPLAY route, and the reserved-resource retry. CONTRIBUTING asks for one logical change and about 400 lines, and over 800 lines the description must say why it cannot be split. The description only says it merges four earlier PRs. Split it, or at least add that reason and make each part its own commit.
  3. Conflicts with open #3141, in code and in meaning. #3141 (open) reads the console's 0x80 resource flag as a raytracing acceleration-structure buffer, maps it to ALLOW_UNORDERED_ACCESS and drops 0x40. This PR treats 0x40/0x80 as the PC's video-reference flags and keeps DENY_SHADER_RESOURCE because of them (device_x.rs ~887-890). It also keeps 0x80 as is through the & 0xFF mask. A test merge of the two heads conflicts in pc_resource_desc. Agree with #3141's author which reading is right before either one lands.
  4. RT stripped from depth textures leaves later RTVs unguarded. pc_resource_desc now drops ALLOW_RENDER_TARGET from a depth-family texture that has RT and DS (device_x.rs ~834-840), and drops ALLOW_DEPTH_STENCIL from a color one. dev_create_rtv (real.rs ~11530) and the DSV path then pass the title's view to the PC as is, on a resource without the flag, which is invalid D3D12 and gets no log line. On main the resource itself failed to create, so this is not a regression, but it moves the failure somewhere quieter. Skip the view and log it once (or make a null view) when the PC resource lacks the flag, and add a test.
  5. Buffer null-clear paths untested through their callers, and no issue link. place_console_buffer and place_at_title_address now always pass a null clear value (real.rs ~2177, ~2271), and placed buffers get the UAV promotion. All of it is covered only by unit tests of the helpers. The WARP tests run without unified memory, so neither caller runs; the new case 5 goes through the plain committed path. Add a test that brings up UMA (or a mocked block) and creates a placed buffer with a clear value and in UNORDERED_ACCESS. The description still links no issue (Fixes #N / Part of #N).

Nit

  1. pc_clear_for_desc kept only for tests. pc_clear_for_desc is now #[cfg(test)] (device_x.rs ~1103) and only its own old tests call it (~2069-2127). Remove it and point those tests at pc_clear_for_resource_desc, or drop the tests.
  2. DENY_BUFFERS-only case does not check that the raw call fails. The deny_buffers_only case in resource_creation_fallback_tests (real.rs ~15987) checks only that dev_create_committed_resource_x succeeds. A texture with DENY_BUFFERS alone is valid on the PC, so the heap-flag retry never runs there. Assert that the raw CreateCommittedResource fails first, or drop the case.
  3. Fall-through after a failed display target still logs a warning. When create_display_target fails in dev_create_committed_resource_x, it logs "D3D12.X: display target:
    " at warn (real.rs ~3908), even when the existing path that follows creates the resource. Log at info there, or only when the fallback also fails.
Checked and fine
  • The placed-buffer UAV loss raised at e751b212 is fixed: promote_placed_buffer_uav restores ALLOW_UNORDERED_ACCESS for UNORDERED_ACCESS / RAYTRACING_ACCELERATION_STRUCTURE states in create_placed_resource_x and placed_in_heap_x, before the state is cleaned up, so sparse::place_buffer_in gets state 0x8 as on main
  • ALLOW_RENDER_TARGET is now kept on buffers, and its clear value still dropped; the WARP test checks both the accepted buffer and the refused buffer-with-clear case
  • The ALLOW_DISPLAY route now skips buffers, and the new WARP case 5 checks that a CPU-visible ALLOW_DISPLAY buffer stays mappable
  • The four PRs this one replaces (#3291, #3376, #3414, #3418) are all closed now
  • The rest of the flag rules match D3D12: no DS/DENY_SR/SIMULTANEOUS on buffers, no SIMULTANEOUS on depth or MSAA, no RT+DS together, no CROSS_ADAPTER with an UNKNOWN layout; textures and buffers the PC accepts on main come out unchanged
  • pc_initial_state_for_desc derives the state from the PC flags; depth UAV still becomes DEPTH_WRITE, and RT/depth/UAV states are dropped only when their flag is gone
  • The committed heap props/flags retry and the reserved-resource retry run only after the first call fails, skip XCL's own work and invalid descriptions that are not console ones, and refuse format promotions that change bytes per texel
  • The state each path actually used now reaches lut3d::created (placed_in_heap_x, own_memory_if_larger_on_the_pc, reserved_3d)
  • No assertion was removed or weakened: the one changed expectation (0x34 to 0x14 in the buffer desc test) follows from the new SIMULTANEOUS_ACCESS strip on buffers
  • The PR merges cleanly onto origin/main 395405e4; the description's two smoke blocks are from main 5ad98adb and the head 26eaea26 on the same title for 60 s (1693 vs 1240 frames, 17408 vs 16798 MB peak commit, no removals or crashes)
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7383341349 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3729#issuecomment-7383341349). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T15:33:18Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 26eaea260b2e311726cdae61546f992d1e6c60ac merge: clean build: ok tests: 3011 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 5 medium, 3 nits (below) performance: 60 s smoke run: 1669 → 1669 frames (100 % of main), peak commit 17577 → 18114 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 234 s there, 0 device removals, 0 crashes, 2.7 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** The PR merges four earlier PRs into one commit: it cleans up console resource flags, initial states, optimized clear values and committed heap properties/flags, and adds retry paths for committed and reserved resources; the push since e751b212 keeps ALLOW_RENDER_TARGET on buffers, gives placed buffers back their UAV flag, and limits the older-method ALLOW_DISPLAY path to textures, trying the existing path when it fails. Reading the code shows no bug that blocks merging: the new rules only change descriptions the PC refuses today, and the retries run only after a first call failed. Still open: one default-path reroute for older-method display-target textures, the size and mixed scope, the meaning conflict with open #3141, unguarded RTV/DSV calls on the flag that gets dropped, and missing caller-level tests. #### Medium 1. **ALLOW_DISPLAY committed textures still rerouted on the default path.** Partly fixed since e751b212: buffers are now excluded and a failed create_display_target falls through (real.rs ~3942-3953). A texture created with heap flag ALLOW_DISPLAY through the older method (slot 76) still goes to create_display_target first. It no longer goes through place_console_texture / create_placed_resource_x, so on unified memory it loses that path's bookkeeping (vram, title_textures, depth_uav::note_created, lut3d::created). It also now calls kernelx::runtime_alloc(D3D_DISPLAY_TARGET), and nothing gives that memory back when the target is released. The PR names no title that needs this. Either say which title fails on main without it, or try create_display_target only after the existing path fails. 2. **Several logical changes in one PR, far over the size limit.** One commit of 975 changed lines (903+, 72-) in device_x.rs and real.rs, up from 882 at e751b212. It holds five separate changes: flag rules, initial states, clear values, committed heap props/flags with the ALLOW_DISPLAY route, and the reserved-resource retry. CONTRIBUTING asks for one logical change and about 400 lines, and over 800 lines the description must say why it cannot be split. The description only says it merges four earlier PRs. Split it, or at least add that reason and make each part its own commit. 3. **Conflicts with open #3141, in code and in meaning.** #3141 (open) reads the console's 0x80 resource flag as a raytracing acceleration-structure buffer, maps it to ALLOW_UNORDERED_ACCESS and drops 0x40. This PR treats 0x40/0x80 as the PC's video-reference flags and keeps DENY_SHADER_RESOURCE because of them (device_x.rs ~887-890). It also keeps 0x80 as is through the `& 0xFF` mask. A test merge of the two heads conflicts in pc_resource_desc. Agree with #3141's author which reading is right before either one lands. 4. **RT stripped from depth textures leaves later RTVs unguarded.** pc_resource_desc now drops ALLOW_RENDER_TARGET from a depth-family texture that has RT and DS (device_x.rs ~834-840), and drops ALLOW_DEPTH_STENCIL from a color one. dev_create_rtv (real.rs ~11530) and the DSV path then pass the title's view to the PC as is, on a resource without the flag, which is invalid D3D12 and gets no log line. On main the resource itself failed to create, so this is not a regression, but it moves the failure somewhere quieter. Skip the view and log it once (or make a null view) when the PC resource lacks the flag, and add a test. 5. **Buffer null-clear paths untested through their callers, and no issue link.** place_console_buffer and place_at_title_address now always pass a null clear value (real.rs ~2177, ~2271), and placed buffers get the UAV promotion. All of it is covered only by unit tests of the helpers. The WARP tests run without unified memory, so neither caller runs; the new case 5 goes through the plain committed path. Add a test that brings up UMA (or a mocked block) and creates a placed buffer with a clear value and in UNORDERED_ACCESS. The description still links no issue (Fixes #N / Part of #N). #### Nit 6. **pc_clear_for_desc kept only for tests.** pc_clear_for_desc is now #[cfg(test)] (device_x.rs ~1103) and only its own old tests call it (~2069-2127). Remove it and point those tests at pc_clear_for_resource_desc, or drop the tests. 7. **DENY_BUFFERS-only case does not check that the raw call fails.** The deny_buffers_only case in resource_creation_fallback_tests (real.rs ~15987) checks only that dev_create_committed_resource_x succeeds. A texture with DENY_BUFFERS alone is valid on the PC, so the heap-flag retry never runs there. Assert that the raw CreateCommittedResource fails first, or drop the case. 8. **Fall-through after a failed display target still logs a warning.** When create_display_target fails in dev_create_committed_resource_x, it logs "D3D12.X: display target: <hr>" at warn (real.rs ~3908), even when the existing path that follows creates the resource. Log at info there, or only when the fallback also fails. <details><summary>Checked and fine</summary> - The placed-buffer UAV loss raised at e751b212 is fixed: promote_placed_buffer_uav restores ALLOW_UNORDERED_ACCESS for UNORDERED_ACCESS / RAYTRACING_ACCELERATION_STRUCTURE states in create_placed_resource_x and placed_in_heap_x, before the state is cleaned up, so sparse::place_buffer_in gets state 0x8 as on main - ALLOW_RENDER_TARGET is now kept on buffers, and its clear value still dropped; the WARP test checks both the accepted buffer and the refused buffer-with-clear case - The ALLOW_DISPLAY route now skips buffers, and the new WARP case 5 checks that a CPU-visible ALLOW_DISPLAY buffer stays mappable - The four PRs this one replaces (#3291, #3376, #3414, #3418) are all closed now - The rest of the flag rules match D3D12: no DS/DENY_SR/SIMULTANEOUS on buffers, no SIMULTANEOUS on depth or MSAA, no RT+DS together, no CROSS_ADAPTER with an UNKNOWN layout; textures and buffers the PC accepts on main come out unchanged - pc_initial_state_for_desc derives the state from the PC flags; depth UAV still becomes DEPTH_WRITE, and RT/depth/UAV states are dropped only when their flag is gone - The committed heap props/flags retry and the reserved-resource retry run only after the first call fails, skip XCL's own work and invalid descriptions that are not console ones, and refuse format promotions that change bytes per texel - The state each path actually used now reaches lut3d::created (placed_in_heap_x, own_memory_if_larger_on_the_pc, reserved_3d) - No assertion was removed or weakened: the one changed expectation (0x34 to 0x14 in the buffer desc test) follows from the new SIMULTANEOUS_ACCESS strip on buffers - The PR merges cleanly onto origin/main 395405e4; the description's two smoke blocks are from main 5ad98adb and the head 26eaea26 on the same title for 60 s (1693 vs 1240 frames, 17408 vs 16798 MB peak commit, no removals or crashes) </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3729:upstream-pr/3729'
git switch 'upstream-pr/3729'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3729'
git switch 'upstream-pr/3729'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3729'
git switch 'upstream-pr/3729'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3729'
git switch 'main'
git merge --squash 'upstream-pr/3729'
git switch 'main'
git merge --ff-only 'upstream-pr/3729'
git switch 'main'
git merge 'upstream-pr/3729'
git push origin 'main'
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
xcl-dev/xcl!3729
No description provided.