Skip to content

D3D12.X: coordinate view texture creation by cache key - #2812

Open
CryingLaughing wants to merge 2 commits into
xcl-dev:mainfrom
CryingLaughing:fix/coordinate-view-resource-creation
Open

CryingLaughing wants to merge 2 commits into
xcl-dev:mainfrom
CryingLaughing:fix/coordinate-view-resource-creation

Conversation

@CryingLaughing

@CryingLaughing CryingLaughing commented Nov 26, 2026 •

Copy link
Copy Markdown

Stacked on #2762. Part of #2743.

The view-resource cache now shares one pending placement per normalized address and description. Concurrent callers for that key receive the completed resource. Lookups for other keys can proceed during creation.

What is in it

  • Adds a pending entry for creation. Once the resource is published, the entry holds only the completed result. Zero remains a cached result, and the completed entry count still includes failures.
  • Checks shared pending creation, independent keys, cached zero and publication with a bounded CPU fixture.

Tested

  • Head ab169f5396bda3df5a48497e668f49a99192e892, based on D3D12.X: a view's padding does not make a second texture #2762 head 496ef5780a4549fc3f15bc65340deb1db4794d6b. RTX 4080 driver 621.01, i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC, DXC 1.8.2502.11.
  • The focused cache test passed 1/0/0. The separate native sequential resource identity check passed 1/0/0 with zero capability skips and reused the exact and padding-only requests.
  • cargo build --workspace --locked -j 4 and cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output passed 1,437 passed, 0 failed, 47 ignored across 37 harnesses, including 29 capability skips.

Regression run

Independent retail smoke by Anon64 compared release builds of main and this exact head on an RTX 3060 12 GB (driver 581.80), Core i9-14900KF, and Windows 11 build 26200. The 60-second runs used the same title. The head retained 103.0% of the baseline frames and used 104.6% of its peak commit, with zero crashes or device removals. The run did not establish whether the title reached the changed code.

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1461 (PresentX 1462)
presents per 2 s (last 3): 10 1 1
device removals: 0
crashes: 0
peak commit: 23855 MB

PR:

xcl-smoke v1
commit: ab169f5396bda3df5a48497e668f49a99192e892
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1505 (PresentX 1506)
presents per 2 s (last 3): 8 20 12
device removals: 0
crashes: 0
peak commit: 24952 MB

Not tested

  • Concurrent native allocations and the effect on title memory use.

joeypercia and others added 2 commits November 26, 2026 02:41
resource_at makes a placed texture for each new (address, description)
of a view the title writes without a resource object (device xcl-dev#70/xcl-dev#71)
and keeps it. Its key cleared the padding after the flags but not the
padding after Dimension (bytes 4..8). A retail title leaves that set,
so the same view made another texture whenever it differed: 24,844 of
80,953 textures in a 200 s run were such twins (GreemSC, xcl-dev#2743).

The key now leaves out both. The activity line counts the textures
kept.

Part of xcl-dev#2743, xcl-dev#2688.

Assisted-by: Claude Code (Claude Opus 5.5)
Publish one completed placed texture for each normalized view key. Keep allocation and waits outside the map lock so distinct keys can progress. Preserve completed failed entries and ownership of successful resources.
@CryingLaughing
CryingLaughing marked this pull request as ready for review November 26, 2026 14:17
@Anon64

Anon64 commented Nov 26, 2026

Copy link
Copy Markdown

Regression run of ab169f5 on a newer retail title: no device removal, no crash, frames and commit within the limits.

Setup: RTX 3060 12 GB (NVIDIA 581.80), i9-14900KF, Windows 11 26200, release builds of main b49be18 (this PR's base) and of this PR's exact head, scripts/smoke.ps1 -Game <title> for 60 s with XCL_NETWORK=0 and A pressed every 4 s from 20 s. Main ran before and after a batch of 11 PRs and peaked at 23,855 and 23,844 MB, so the baseline held steady over the batch.

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1461 (PresentX 1462)
presents per 2 s (last 3): 10 1 1
device removals: 0
crashes: 0
peak commit: 23855 MB

this PR:

xcl-smoke v1
commit: ab169f5396bda3df5a48497e668f49a99192e892
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1505 (PresentX 1506)
presents per 2 s (last 3): 8 20 12
device removals: 0
crashes: 0
peak commit: 24952 MB

103 % of main's frames, 104 % of its peak commit. One run each.

Not tested: the suite on this head; whether the title reaches the code this PR changes in its first 60 s; AMD.

AI use: Claude Code (Claude Opus 5.5) ran these runs on this machine and wrote this report.

@SzczepanGrela

Copy link
Copy Markdown

RX 9070 / Wine concurrent native resource_at check of ab169f5396bda3df5a48497e668f49a99192e892: eight same-key callers share one creation on head and on its current-main integration. Current main creates eight distinct resource objects under the same controlled overlap.

Tested

Compared exact head, current main 8b957bec6f82495aec940944c6bf47faa02db590, and current main with this PR's full diff applied. Head is stacked on #2762 commit 496ef5780a4549fc3f15bc65340deb1db4794d6b; the PR's upstream base is b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7. The integration applied without conflicts; additions/deletions and surrounding diff context matched independently. The padding result below includes the parent change; this was not a runtime comparison against the direct parent.

RX 9070 16 GB, PCI 1002:7550, RADV GFX1201 / Mesa 26.3.1-arch3.5 (mesa / vulkan-radeon packages 3:26.3.1-5), Ryzen 7 7700, CachyOS 7.3.0-5-cachyos, GE-Proton11-12 Wine 11.0 Staging with ntsync. Native d3d12/d3d12core/dxgi, vkd3d-proton 8293130ebe370b1+ with local assertions-disabled build, Rust 1.97.1, release x86_64-pc-windows-gnu.

Source copies received reversible cfg(test) observation immediately before/after the existing native creation call and a local fixture. The actual create_placed_resource_x call, arguments and cache decisions were retained; the factory was not substituted. Removing test additions reconstructs every original source hash. These were instrumented source copies, not clean Git checkouts.

cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run
wine <libtest.exe> hle::d3d12x::real::view_key_tests:: hle::d3d12x::real::srv_tests:: --nocapture --test-threads=N
wine <libtest.exe> hle::d3d12x::real::workflow_view_cache_probe::concurrent_native_views_share_creation --exact --nocapture --test-threads=1

XCL_NETWORK=0, XCL_ADAPTER="AMD Radeon RX 9070", XCL_REQUIRE_GPU=wave64, native DLL overrides, private enabled caches. Native probes ran with XCL_VRAM_ARENAS unset and with XCL_VRAM_ARENAS=1, three fresh processes per source/configuration, alternating source order.

  • Original cache/SRV selections at N=1 and N=4: exact head and integrated head each 4 passed / 0 failed / 0 ignored per invocation; current main 2/0/0. Main has no new view_key_tests module. The head module includes the cached-zero/independent-key CPU check.
  • Native fixture: exact head and integrated head each 1/0/0 per invocation. Main 0/1/0, failing one creation per normalized key after all native creation, identity and descriptor checks completed.

The native fixture uses small RGBA8 render targets, with a 192 KiB owned synthetic address range. It holds creation for the first address until all eight callers are observed: eight caller references to the pending entry on head, eight factory entrants on main. A different address completes while that first creation remains held. After release, every head caller receives the same pointer; main returns eight distinct pointers. An exact repeat uses a previously returned pointer on all three source variants.

Per-process outcomes were identical in every repetition and both placement configurations:

Observation current main exact head / integrated head
Native creator entries for the eight overlapping same-key requests 8 1
Distinct returned objects for those requests 8 1
Different-key completion before release yes yes
New creation for padding-only repeat 1 0
New creation for width 16 to 32 1 1
Total native creations, including the different address 11 3
Completed-entry counter at end unavailable 3

Across 24 harness invocations: 0 ignored, 0 capability skips. The 18 native probes created 102 real resources. Independently checked saved pointer sets, creation counts, joins and native descriptors; each resource's device matched the selected RX 9070 LUID. Default placement mapped one tile per resource; arena mode had no page mappings. Shared page/heap backing means these object counts do not establish VRAM savings. Creation references and synthetic address identities remain valid until process exit, matching the cache's lifetime.

Not tested

Texture drawing, shader dispatch or pixel readback, native driver failures during concurrent creation, other formats or multiple devices, long-running cache lifetime, whole workspace suite, native Windows, other adapters, retail data, scripts/smoke.ps1, FPS, allocation latency or measured RAM/VRAM reduction.

AI use

OpenAI Codex (GPT-6; exact serving variant not exposed) audited the diff, wrote local test-only observations/fixture, ran all source variants, independently verified raw logs/source/executable hashes, and drafted this report. Publication authorized by the account owner.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants