Skip to content

D3D12.X: null and default view descriptions the PC accepts - #3731

Open
Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:pr/null-and-default-views
Open

Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:pr/null-and-default-views

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Consolidates #3319 and #3280 into one change on crates/xcl/src/hle/d3d12x/real.rs so PC D3D12 accepts console null-resource view descriptions (pResource == NULL) and default/DXGI_FORMAT_UNKNOWN view descriptions on typeless depth buffers.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs:
    • typeless_depth_format, pc_dsv, and default_dsv: resolve DXGI_FORMAT_UNKNOWN on typeless depth DSVs, sanitize null-resource DSV formats, support 1D/1DArray default DSVs, and reuse GetDesc() once in dev_create_dsv_x.
    • is_typeless_format, concrete_view_format, pc_format_support1, sanitize_null_image_srv, sanitize_null_image_uav, and sanitize_null_rtv: cached per-adapter format support check and null-resource view sanitization wired into dev_create_srv_inner, dev_create_uav_x, and dev_create_rtv.
    • pc_srv: 1D and 1DArray default SRV construction for typeless depth textures.
    • null_and_default_view_tests: unit tests for 1D/typeless DSV and SRV construction plus a child-isolated WARP D3D12 debug-layer test verifying null SRV/UAV/RTV/DSV and default 1D/2D view creation with zero debug-layer errors.

Regression run

main (5ad98adbc360225ac8a57ad9661e16fe8df9d8dd):

xcl-smoke v1
commit: 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1555 (PresentX 1555)
presents per 2 s (last 3): 80 169 71
device removals: 0
crashes: 0
peak commit: 16102 MB

PR (cb4b133553997f9061796a2cf5c6537e0521d424):

xcl-smoke v1
commit: cb4b133553997f9061796a2cf5c6537e0521d424
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1663 (PresentX 1663)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16837 MB

Tested

Hardware: AMD Ryzen 9 9950X, Windows 11 10.0.26200.0, NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), rustc 1.99.0, DXC 1.9.2609.5.

  • cargo build --release -p xcl: ok (39 warnings, unchanged from 39 on main 5ad98adbc).
  • cargo test -p xcl --lib -- null_and_default_view_tests --nocapture: 2 passed, 0 failed, 0 ignored, 0 SKIPPED (D3D12 debug layer ran on WARP with 0 errors).
  • .\scripts\test.ps1: 3007 passed, 0 failed, 52 ignored, 24 SKIPPED (22 no wave64 on RTX 5070 Ti, 2 no heap windows).

Not tested

  • AMD/Intel/wave64 GPUs and XCL_HEAP_WINDOWS=1.
  • Retail title paths exercising 1D depth buffers or MSAA default DSVs (the 1D/null-view paths are covered by unit tests and the WARP D3D12 debug-layer test).

AI use

Antigravity (Gemini 4 Neon) consolidated #3319 and #3280, fixed the review findings, wrote the unit and WARP debug-layer tests, ran the test suite and paired smoke runs, and drafted this PR description.

Consolidates xcl-dev#3319 and xcl-dev#3280 (excluding the MSAA default-DSV overlap
with xcl-dev#1087) and addresses all review findings from both PRs:

- Null-resource SRV/UAV/RTV/DSV sanitization: reject unmapped console
  formats when CheckFeatureSupport fails, map all 22 *_TYPELESS formats
  to concrete same-family view formats, reject depth formats on null
  RTVs, set PlaneSlice = 1 only for 2D/2DArray stencil SRVs and clear
  PlaneSlice to 0 on all non-stencil null SRVs, null image UAVs, and
  null RTVs.
- Default and DXGI_FORMAT_UNKNOWN views on typeless depth buffers:
  resolve DXGI_FORMAT_UNKNOWN on typeless depth DSVs, build 1D/1DArray
  default DSVs and default SRVs (`pc_srv`), and preserve D16_UNORM DSV
  formats on R24G8_TYPELESS resources so DSVs remain aligned with PSO
  DSVFormat.
- Add unit tests and a child-isolated WARP D3D12 debug-layer test
  covering null and default view creation (skipping cleanly when the
  D3D12 debug layer or WARP is unavailable).

Assisted-by: Antigravity (Gemini 4 Neon)
@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) needs-1st-check Passes gates; needs first independent merge-check (#3041) labels Dec 2, 2026
@jsalzy

jsalzy commented Dec 3, 2026

Copy link
Copy Markdown

merge-check claim
head: cb4b133

@jsalzy

jsalzy commented Dec 3, 2026

Copy link
Copy Markdown

merge-check
base: 078358a
head: cb4b133
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3008 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. Both tests the PR adds ran and passed; null_and_default_views_pass_d3d12_debug_layer_on_warp ran its child with the D3D12 debug layer (not skipped). git diff --check clean; 39 compiler warnings, the same as main.
title run: not run
review: (1) On by default for every title: null-resource SRV/UAV/RTV formats now go through a format-support check, with fallbacks to R32_FLOAT (SRV/UAV) and R8G8B8A8_UNORM (RTV). A null-resource DSV without a depth format becomes D32_FLOAT. UNKNOWN DSVs on typeless depth buffers get the typed depth format, and 1D depth buffers get 1D default views. No AMD run here (the PR is gpu:both). (2) A multisampled typeless depth buffer's default DSV is still TEXTURE2D, by design (the PR leaves it to #1087). Open #1087 and open #3618 both make default_dsv pick the MS dimensions, and each conflicts with this PR in real.rs (git merge-tree), so whichever lands second has to adapt. Checked and fine: pc_format_support1 asks the device once per adapter and format and caches the answer, a failed query included, which counts as unsupported. The call goes through XCL's CheckFeatureSupport hook, which passes PC formats through unchanged. concrete_view_format maps all 22 *_TYPELESS formats to a readable format of the same family (depth families to R32_FLOAT, R24_UNORM_X8_TYPELESS, R32_FLOAT_X8X24_TYPELESS or R16_UNORM). The stencil formats (X32_TYPELESS_G8X24_UINT, X24_TYPELESS_G8_UINT) get PlaneSlice 1 only on 2D and 2D-array SRVs; all other null image SRVs, and all null UAVs and RTVs, get PlaneSlice 0. Null RTVs refuse depth formats. Only null-resource views take the new sanitizers; views of real resources keep main's format mapping (pc_view_format / pc_shader_view_format). The debug-layer test reports 0 validation errors and no device removal on WARP for these views. Duplicates: I searched open and merged PRs for null-resource view, null SRV, default_dsv, typeless depth view, null RTV, PlaneSlice and DXGI_FORMAT_UNKNOWN DSV, and checked #1607's groups (none lists 3731, 1087, 2511 or 3618). No open PR makes the same change: it consolidates the author's closed #3319 and #3280. #1087 and #3618 change default_dsv for MSAA as in (2). #2511 changes the null-UAV fallback in dev_create_uav_checked_x and the UAV companion SRV, and merges with this PR without a text conflict.
performance: none worth measuring (reasoned): one CheckFeatureSupport call per adapter and format, cached, and only for null-resource views.
verdict: safe to merge: no blocking finding, and the suite passes, the debug-layer WARP test included. It conflicts with open #1087 and #3618 in default_dsv (review (2)).
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 cb4b1335 (code reading and the tests named below, not a merge-check) · no findings

In short: views of a real resource with a valid description take the same code as on main; the only change there is a DSV with format UNKNOWN on a typeless depth buffer, which now gets the typed depth format. Null-resource image SRVs, UAVs and RTVs go through the new sanitizers, null DSVs get a depth format, and 1D typeless depth buffers get 1D default views. The typeless and depth format tables are right, the support cache is a leaf lock that is not held across CheckFeatureSupport, and the rewritten descriptions outlive the forwarded call.

Result: no blockers found. From the code, nothing stands in the way of a merge. This is a review, not a merge-check: the suite and a title run are not covered here.

Measured (RTX 3080, merge of this head onto main 078358a0, debug; the debug-layer test ran its child on WARP, not skipped)

  • cargo test -p xcl --lib -- null_and_default_view_tests: 2 passed, 0 failed.
  • The debug-layer test covers each sanitizer: with sanitize_null_image_srv, sanitize_null_image_uav or sanitize_null_rtv put back to what main does (one at a time), it fails at the first case of that kind ("null SRV fmt=118", "null UAV fmt=29", "null RTV fmt=0").
  • The stencil cases do reach the PlaneSlice = 1 branch on WARP: with a temporary print in sanitize_null_image_srv, formats 47 on Texture2D and 22 on Texture2DArray are kept with plane 1 and the debug layer accepts them; on TextureCube and Texture2DMS they fall back to R32_FLOAT.

Notes, none blocking

  1. The test's child sets XCL_COHERENT_MB=64 but not XCL_UMA_MB; the two other child tests in this file set both to 64. Here unified memory comes up with its default size, and the child then asserts uma::get().is_some(): on a machine short of address space or commit that is a failure, not a skip.
  2. The debug-layer test asserts "no error", not which format a case ends up with, so a sanitizer that always fell back to R32_FLOAT would pass it too. The measurement above shows that is not what happens today; an assertion on two or three of the resulting formats (the stencil plane, one typeless mapping) would keep it that way.

Not checked: the whole suite and a title run on this head (see the merge check), AMD and Intel (the support bits differ per driver; only WARP and the RTX 3080's build were run here), whether a title on this machine creates null views of the kinds changed.

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.

@Foniass

Foniass commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 078358a
head: cb4b133
merge: clean
build: ok
tests: 3008 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 3 medium (below)
performance: 60 s smoke run: 1669 → 1670 frames (100 % of main), peak commit 17577 → 17659 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 242 s there, 0 device removals, 0 crashes, 3 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: Turns null-resource SRV, image UAV, RTV and DSV descriptions into formats and PlaneSlices the PC accepts, resolves DXGI_FORMAT_UNKNOWN on typeless depth DSVs, and adds 1D/1DArray default DSV and SRV views. Reading the code found no bug, and only null views and calls that were invalid on main behave differently. Nothing blocks it; it is over the size target and conflicts with the open #1087.

Medium

  1. Over the size target with no reason given. 636 changed lines in real.rs (about 250 runtime, 380 test), combining two earlier PRs (D3D12.X: sanitize null-resource SRV, image UAV, and RTV formats #3319 null views, D3D12.X: fix default_dsv MSAA/1D dimensions and DXGI_FORMAT_UNKNOWN on typeless depth buffers #3280 default and UNKNOWN depth views). That is under 800, but the description should say why this is one PR, or split it.
  2. Conflicts with open D3D12.X: match default depth views to MSAA textures #1087. A trial merge (git merge-tree) of this head with D3D12.X: match default depth views to MSAA textures #1087 conflicts in real.rs, because both rewrite default_dsv. The description leaves out D3D12.X: match default depth views to MSAA textures #1087's MSAA default-DSV case on purpose, so one of the two has to be rebased on the other.
  3. Second format-support cache duplicates pc_typed_uav_supported. pc_format_support1 (real.rs ~3260) copies device_x::pc_typed_uav_supported (device_x.rs ~974) with its own cache, and gives the opposite answer when CheckFeatureSupport fails. Use one cached Support1 lookup for both, or comment why they differ. Every null image SRV, UAV and RTV now takes a mutex and calls GetAdapterLuid; that is cheap but not measured on a descriptor-heavy frame.
Checked and fine
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.

@github-actions github-actions Bot removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:title-run Runtime change: needs a merge-check with a real title run into the world (#3041) labels Dec 3, 2026
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) needs:amd-test Needs a test report or merge-check on an AMD GPU

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants