Skip to content

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

Open
Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:pr/resource-creation-fallbacks
Open

Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:pr/resource-creation-fallbacks

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

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 Runtime: CPU check at start, bounded reads in the exception logger, t… #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

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Dec 2, 2026
@Kalmarv Kalmarv closed this Dec 2, 2026
@Kalmarv Kalmarv reopened this Dec 2, 2026
@github-actions github-actions Bot added the needs-1st-check Passes gates; needs first independent merge-check (#3041) label Dec 2, 2026
@jsalzy

jsalzy commented Dec 3, 2026

Copy link
Copy Markdown

merge-check claim
head: e751b21

@jsalzy

jsalzy commented Dec 3, 2026

Copy link
Copy Markdown

merge-check
base: 078358a
head: e751b21
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.

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:title-run Runtime change: needs a merge-check with a real title run into the world (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) labels Dec 3, 2026

@vasanex vasanex 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.

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.

// 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 vasanex Dec 3, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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).

Comment thread crates/xcl/src/hle/d3d12x/real.rs Outdated
);
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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 (Runtime: CPU check at start, bounded reads in the exception logger, t… #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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread crates/xcl/src/hle/d3d12x/device_x.rs Outdated
// - 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Unifies console resource description, resource flag, initial state, optimized clear value, and heap property/flag sanitization across CreateCommittedResource(X), display target creation, CreatePlacedResource(X) and its fallbacks, and CreateReservedResource(1).

Consolidates and resolves all review findings from xcl-dev#3291, xcl-dev#3414, xcl-dev#3418, and xcl-dev#3376:
- pc_resource_desc enforces PC buffer/texture flag invariants (buffer strips DS/DENY_SRV/SIMULTANEOUS_ACCESS while keeping RT/UAV; texture RT|DS resolves by format family; depth strips UAV/SIMULTANEOUS_ACCESS; DENY_SHADER_RESOURCE requires DS or video reference flags; MSAA strips SIMULTANEOUS_ACCESS; textures strip ALLOW_CROSS_ADAPTER).
- pc_initial_state_for_desc derives initial state from sanitized PC flags and drops RENDER_TARGET, DEPTH_WRITE/READ, and UNORDERED_ACCESS when the matching PC flag is absent; placed console buffers created in UNORDERED_ACCESS or RAYTRACING_ACCELERATION_STRUCTURE promote ALLOW_UNORDERED_ACCESS before pc_initial_state_for_desc so place_at_title_address / sparse::place_buffer_in keep the UAV flag and state.
- pc_clear_for_resource_desc handles buffers/non-targets before reading the pointer, maps depth families (including typeless/partially-typeless formats) to their typed DSV clear format, resolves typeless/UNKNOWN clears on concrete RTs, and is used across every creation and fallback path.
- dev_create_committed_resource_x routes non-buffer ALLOW_DISPLAY resources through create_display_target (falling through to the existing path if it fails), retries sanitized heap properties (preserving CPU-visible console buffers as CUSTOM+L0) and heap flags only on failure, and logs both raw and tried values on failure.
- dev_create_reserved_resource(1) adds a console-only fallback (skipping own_work and PC-native invalid calls) that maps console layouts (0 or >3) to 64KB_UNDEFINED_SWIZZLE, refuses bytes-per-texel-changing format promotions, and propagates the actual PC state to lut3d/reserved_3d.

Assisted-by: Antigravity (Gemini 4 Neon)
Assisted-by: Claude Code (Claude Opus 5.5)
@Kalmarv
Kalmarv force-pushed the pr/resource-creation-fallbacks branch from e751b21 to 26eaea2 Compare December 3, 2026 02:41
@Kalmarv

Kalmarv commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

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).

@github-actions github-actions Bot removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:title-run Runtime change: needs a merge-check with a real title run into the world (#3041) labels Dec 3, 2026
@Kalmarv Kalmarv closed this Dec 3, 2026
@Kalmarv Kalmarv reopened this Dec 3, 2026
@Foniass

Foniass commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 078358a
head: 26eaea2
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 e751b21 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 e751b21: 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 e751b21. 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 D3D12.X: the console's acceleration-structure resource flag becomes UAV, not a video flag #3141, in code and in meaning. D3D12.X: the console's acceleration-structure resource flag becomes UAV, not a video flag #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 D3D12.X: the console's acceleration-structure resource flag becomes UAV, not a video flag #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 e751b21 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 (D3D12.X: sanitize reserved and placed resource descriptions and initial states #3291, D3D12.X: sanitize display target desc/clear/state and committed console heap flags #3376, D3D12.X: sanitize PC resource flag invariants in pc_resource_desc #3414, D3D12.X: sanitize optimized clear values against PC resource descriptors #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 395405e; the description's two smoke blocks are from main 5ad98ad and the head 26eaea2 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, GameInput: XCL_PRESS_BASE=frame counts scripted presses from the first 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.

@Kalmarv

Kalmarv commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Foniass for the thorough merge-check and 234 s title run! Leaving HEAD at 26eaea2 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 26eaea2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants