Skip to content

Fix D3D12 frame and texture handling - #69

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
Tems-py:fix/d3d12-frame-and-texture-handling
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
Tems-py:fix/d3d12-frame-and-texture-handling

Conversation

@Tems-py

@Tems-py Tems-py commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bind the selected private D3D12 view heap for local descriptor indices and retain the shared heap for shared indices.
  • Preserve placed texture identities in aliasing barriers and remove resource tracking on final release.
  • Queue the PresentX copy before reporting the flip, retain its source until the copy fence completes, and skip allocator reuse when the fence wait times out.
  • Serialize texture refreshes and preserve pending CPU writes when registering textures.

@Tems-py

Tems-py commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author
obraz fixes flicker on intel arc

@Foniass

Foniass commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

For the reviewer, since #84 touches the same problem: on NVIDIA the shared shader-visible heap holds 1 000 000 view descriptors. Minecraft's eight view heaps need 1 179 632, so the last two got no range in it, and their draws read other heaps' slots (blank frames). This PR's first item binds such a heap separately. #84 gives every view heap its place in the shared heap a page at a time instead, so no heap is left out, and draws that mix descriptors from several heaps keep working.

The two don't fight: with #84 every view heap is in the shared heap, so the pc_heaps change here never has a private heap to pick. They merge cleanly, and main + #84 + #86 + #68 + #67 + this PR passes the full test suite on an RTX 5070 Ti. The rest of this PR (aliasing barriers, PresentX ordering, texture refresh) is independent of #84.

Intel Arc: if its MaxViewDescriptorHeapSize is also 1 000 000, #84 alone should fix the flicker there too. Not tested, there's no Arc here.

@ivall
ivall merged commit 55fca5a into xcl-dev:main Nov 23, 2026
ivall added a commit that referenced this pull request Nov 23, 2026
…ible

Follow-up to #69: with #84 every view heap goes to the shared heap and is created CPU-only;
one that found no room there (or no UMA for its slots) is such a CPU-only heap, and binding
it would be invalid – the shared heap stays bound then, as before #69. A heap that kept a
shader-visible PC heap of its own (no shared heap) is bound for its local indices.
ivall added a commit that referenced this pull request Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged. Checked on an RX 9070 (RDNA4): cargo test --workspace with the retail samples (shader pack, console DLLs, texture archive) – natively, and with XCL_SPLIT_WAVE64=1 (new in ba905cf: forces the split wave64 form on RDNA, which runs both wave sizes, so the NVIDIA path can be checked on AMD). XDefiant (title screen correct, 6 299 translated pipelines, 0 translation errors), Minecraft and Unicorn Overlord run.

One change on top (593a237): with #84 every view heap goes into the shared heap and is created CPU-only, so a heap that found no room there is a non-shader-visible PC heap – binding it in pc_heaps would be invalid. A title's own view heap is now bound only when it is shader visible; otherwise the shared heap stays bound, as before.

Michael-Glaser added a commit to Michael-Glaser/xcl that referenced this pull request Nov 24, 2026
…cl-dev#104)

On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (xcl-dev#59, xcl-dev#60, xcl-dev#68, xcl-dev#69, xcl-dev#78, xcl-dev#81, xcl-dev#84, xcl-dev#88, xcl-dev#89, xcl-dev#93, xcl-dev#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method.

Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at xcl-dev#59 and the original base-table stub for slots >= scanned). Slot xcl-dev#10 (Reset) stays Reset on both layouts and is not orphaned.

Assisted-by: Antigravity (Gemini 4 Neon)
vincentes added a commit to vincentes/xcl-wasm that referenced this pull request Nov 24, 2026
The null device becomes `win::d3d12x`, a device that does the memory side
of D3D12.X for real and still renders nothing:

- Unified memory, as on the console: a resource's GPU address is its
  address in the title's address space. Committed resources and heaps get
  graphics memory, placed resources lie in their heap, and
  CreatePlacedResourceX (xcl-dev#44) puts one on memory the title allocated; Map
  returns that address. Read-back buffers up to 64 MiB come from the
  fourth 4 GiB of the region, where XCL's Windows runtime keeps them.
- Command lists record; a queue runs what it is given, in order, at every
  turn of the scheduler (`pump`): buffer copies, the console's memory
  commands (CopyMemoryToMemoryX xcl-dev#60, FillMemoryWith32BitValueX xcl-dev#61,
  Write32 / 64BitValue…X xcl-dev#69 / xcl-dev#70 / xcl-dev#89 with the GPU timestamp) and
  Wait32 / 64BitValueX (xcl-dev#71 / xcl-dev#72), which hold the queue until another
  thread writes the value. KickoffX (xcl-dev#93) starts a list before it is
  closed. A fence moves, and its events are signalled, when the queue
  gets to its Signal.
- The console's layouts: device extensions from slot 44
  (CreateCommandQueueX, CreateCommandListX with the DMA engine's own list
  interface, page pools, pipeline-state creation as objects, …), the
  graphics command list's console slots, AllocateUploadMemory (xcl-dev#148).
- CheckFeatureSupport zeroes the whole structure; a raytracing
  acceleration structure view writes the console's descriptor words.

Draws, pipelines, other views, PresentX and the frame clock do nothing
or are missing. Dev builds optimise `xcl-emu` (the title test: 37 s →
3.3 s).

Measured on macOS (aarch64): the test title passes 40 of its checks (9 of
D3D12.X's 16); the 6 that fail before it aborts in its XG texture check
need HLSL compilation and rendering, the frame clock, or DirectStorage.
`cargo test -p xcl-guest`: 38 passed, 0 failed (the title test now checks
every check by name; the staged tree was built and tested apart from
the working tree). Inside the wasm64 module (1.2 MB, Node 24) the same
run takes 4.4 s: 115 M instructions, most of them the 80 MiB upload check.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Michael-Glaser added a commit to Michael-Glaser/xcl that referenced this pull request Nov 24, 2026
…vall#104)

On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (ivall#59, ivall#60, ivall#68, ivall#69, ivall#78, ivall#81, ivall#84, ivall#88, ivall#89, ivall#93, ivall#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method.

Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at ivall#59 and the original base-table stub for slots >= scanned). Slot ivall#10 (Reset) stays Reset on both layouts and is not orphaned.

Assisted-by: Antigravity (Gemini 4 Neon)
theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 25, 2026
…pelineX) are UAV barriers

FlushGpuCacheRangeX and FlushShaderCacheRangeX of the newer list layout were answered with nothing.
They are how a title orders a pass behind the one that wrote what it reads: a retail title calls them
thousands of times a minute, and its compute passes (the ones that write indirect arguments and the
ones that read them) had no order there. FlushPipelineX (xcl-dev#67, newer layout xcl-dev#69) as well; at xcl-dev#69 a
newer-layout title's call ran Write32BitValueBottomOfPipeX with the flags as the address.

The PC has no ranges of caches: a UAV barrier for all resources, on direct and compute lists.

Test: cache_flushes_are_uav_barriers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
The null device's plain lists ran the console memory slots (xcl-dev#60/xcl-dev#61/
xcl-dev#69-xcl-dev#72/xcl-dev#89/xcl-dev#93) as logging stubs, so the title's console_list_methods
check read back 0x0 on the null backend while the identical immediate
host writes already passed on Vulkan lists. The vtable now wires the
same VulList_* functions into Kind::CommandList; GetDevice (xcl-dev#7),
the UAV barrier (xcl-dev#146) and AllocateUploadMemory (xcl-dev#148) stay
Vulkan-only with their slices (barrier/upload ride with raytracing,
which still fails on null at the OPTIONS5 tail-zero assert).

Failing-first: the new null_list_shares_the_console_memory_methods
test fails pre-route (slot 69 stub writes nothing) and passes now
(write32/fill/copy/timestamp land, pre-satisfied wait returns,
kickoff is a silent no-op), mirroring the title's asserts.
Gates: check -p xcl --tests EXIT 0; check --workspace EXIT 0; lib 797
passed/0 failed/1 ignored (--test-threads=4). Title e2e, fresh roots:
null 12->11 FAILs (Write32 fixed, byte-identical remainder), Vulkan 9
unchanged with the real present (640x360 token 0x1 on Intel Arc).
Retail HOLDS (SIGSEGV exe+0x2237320, exit 139, called_stubs 20,
0 d3d12).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants