Skip to content

recomp: run wave64 compute programs as two wave32 halves on 32-lane GPUs - #70

Closed
gefydev wants to merge 1 commit into
xcl-dev:mainfrom
gefydev:recomp-compute-wave32
Closed

gefydev wants to merge 1 commit into
xcl-dev:mainfrom
gefydev:recomp-compute-wave32

Conversation

@gefydev

@gefydev gefydev commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

On NVIDIA (32-lane waves only) every translated console compute shader fails. The compute path always emits [WaveSize(64)], since console compute programs are wave64, and the driver refuses that pipeline:

CreateComputePipelineState: E_INVALIDARG (0x80070057)

translated_compute_pso then records a translation error and the title's dispatches with that pipeline are skipped. The README mentions this ("console wave64 compute … programs are mostly refused there").

Mesh programs already have the fix for the same problem (#39): a logical wave64 runs as two native wave32 halves (xcl_half, xcl_logical_wave64), and geometry_wave32_hazards refuses programs that need both halves at once. This PR uses that for compute:

  • Options::compute_wave32 and translate_compute, the compute counterpart of translate_mesh: the same hazard check, with "compute program requires unsupported cross-half wave64 semantics" in the error.
  • With it the CS prologue is [WaveSize(32)], with xcl_half = (gi >> 5) & 1 and lane_id = WaveGetLaneIndex() + 32 * xcl_half, as in mesh mode. numthreads, thread ids, group ids, TG_SIZE and LDS are unchanged.
  • translated_compute_pso passes geometry_wave32_required(this), the same adapter check console mesh pipelines use. On adapters with wave64 (RDNA) it is false and the generated HLSL is unchanged.

This doesn't cover programs with cross-half semantics (DPP/swizzle reductions, whole-wave mask counts, …). Those are still refused, as for mesh. #33 is working on a groupshared rendezvous for those. This PR is the smaller step that lets everything else run.

Validation

GTX 1650 (Turing, wave32 only), Windows 11, NVIDIA driver 32.0.16.2114, MSVC debug build: cargo test --workspace has 0 failures, as on main on this machine, and the three new tests ran and passed. I first worked on it on the same GPU on Linux (Wine + vkd3d-proton 2.14.1), where the results are the same.

  • New gpu_compute_wave64_as_wave32_halves: the program from gpu_compute_mode_dispatch_abi (two wave64s per group, LDS + s_barrier between them) translated split. Same results as the wave64 test checks. gpu_compute_mode_dispatch_abi now shares its program and check with it.
  • New gpu_compute_wave32_halves_keep_their_exec_bits: v_cmpx keeps lanes 0..39, so the high half has 8 live lanes. With lane_id left at WaveGetLaneIndex() it fails (lane 32 gives 0 instead of 33).
  • New split_compute_refuses_cross_half_semantics (no GPU): s_bcnt1_i32_b64 on VCC is refused split and translates with wave64.
  • The same program unsplit on this GPU: CreateComputePipelineState: 0x80070057, i.e. what main does.
  • cargo test -p xcl --lib: 0 failed on the GTX 1650 (41 GPU tests skipped with "no wave64", as before) and without a GPU.

Not tested on RDNA: there the split tests run [WaveSize(32)], which RDNA supports, and nothing else changes.

Console compute programs are wave64, and the compute path always
emitted [WaveSize(64)]. On an adapter without 64-lane waves (NVIDIA)
the driver refuses that pipeline (E_INVALIDARG), so every translated
console compute shader failed there and its dispatches were skipped.

On such an adapter a wave64 compute program now runs as two native
wave32 halves, the same split mesh programs use (xcl_half,
xcl_logical_wave64); a program that needs both halves at once (whole-
wave masks, cross-lane exchange, …) is refused with the same hazard
check. Adapters with wave64 are unchanged.
@FZNull

FZNull commented Nov 23, 2026

Copy link
Copy Markdown

Validated on native Windows 11 (not Wine/vkd3d-proton): RTX 4060 (Ada, lane range 32..32), MSVC, DXC 1.8.2502.11 from SDK 10.0.26100.

  • base dd713e3 / PR head 1772f1e
  • cargo test --workspace --no-fail-fast: 375 passed, 0 failed, 34 ignored (main: 372), 42.4 s
  • SKIPPED ...: no wave64 stays at 41 on this adapter; the 3 new split-compute tests pass
  • cargo build --workspace: 11.3 s, no warnings from the changed crates

No TDR, no device removal. Nothing from a game package was used.

AI-assisted.

gefydev added a commit to gefydev/xcl that referenced this pull request Nov 23, 2026
…pute e2e through the PSO hook (not for merge)
@certified-retart

Copy link
Copy Markdown
Contributor

Verified 1772f1e end-to-end on native Windows 10 (D3D12 Agility SDK 1.620.2 / DXC 10.0.26100.0) on NVIDIA GeForce RTX 5070 (wave32, XCL_ADAPTER=0) combined with PR #78's gpu_compute_e2e test (console_wave64_compute_through_the_pso_hook_dispatch_and_read_back):

@Foniass

Foniass commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Heads-up for the reviewer and @gefydev: #67 solves the same problem (wave64 programs on 32-lane GPUs) another way, and it conflicts with this PR and with #71 / #72. The difference: #67 also runs programs whose halves must exchange values (through groupshared), which this PR still refuses.

I ran both on the same RTX 5070 Ti, merged onto current main; the table and details are in #67 (comment). Short version: both pass the whole suite and #78's end-to-end compute test. On NVIDIA, #70 + #72 still skip 18 GPU tests, #67 skips 2. #72's f64 fix applies on top of #67 as well (one line in its test), so it's worth keeping either way.

@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Thanks – closing this as superseded by #67 (merged), which runs wave64 compute (and mesh / ES+GS) as two wave32 halves that exchange masks and lane values through groupshared, so programs with cross-half semantics run too instead of being refused. Your lane_id = WaveGetLaneIndex() + 32 * xcl_half / exec-bit case is covered there by its split tests. Also verified on AMD with XCL_SPLIT_WAVE64=1.

@ivall ivall closed this Nov 23, 2026
ivall pushed a commit that referenced this pull request Nov 23, 2026
Since #117 translated shaders declare every cube T# as a TextureCubeArray,
but dev_create_srv_x forwarded a title's own SRV description unchanged: a
D3D12_SRV_DIMENSION_TEXTURECUBE view was bound to a shader that declares a
cube array, a dimension mismatch D3D12 leaves undefined (the risk noted on
#117). It now becomes TEXTURECUBEARRAY { First2DArrayFace 0, NumCubes 1 }
with the view's mips and LOD clamp; format, mapping and every other view
dimension are forwarded as before. Device #70 (views of memory) goes
through the same path.

Test srv_tests::a_cube_view_becomes_the_cube_array_of_one_cube.

Co-Authored-By: Claude Code <[email protected]>
heretic1321 added a commit to heretic1321/xcl that referenced this pull request Nov 23, 2026
…cl-dev#248)

Stacked on xcl-dev#269 (which moves 64 KiB-aligned kept-in-step title textures
onto shared 64 KiB pages in vram::Book).

What remains after xcl-dev#269:
- Overwritten placements stayed registered in title_textures forever,
  continuing to be scanned/uploaded and holding extra tiles / leftover
  pages in vram::Book even when a newer texture replaced their memory.
- real::resource_at (device xcl-dev#70/xcl-dev#71 by-address SRV/UAV creation) stored
  every created ID3D12Resource in MADE forever and never released
  superseded entries (including unaligned committed textures).
- Device / queue release did not clear MADE, title_textures state,
  upload queues, or vram::Pages::waited.
- XCL_ACTIVITY memory lines lacked title-texture active/covered/retired/
  released counters.

This commit adds O(log N + k) overlap retirement in title_textures,
detaches retired entries from vram::Book, cools and releases superseded
entries in real::resource_at (2 s cooling + MADE_MAX cap), cleans up on
device/queue release, and logs title-texture counters on XCL_ACTIVITY.

Assisted-by: Antigravity CLI (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]>
JR-Wiederkehr pushed a commit to JR-Wiederkehr/xcl that referenced this pull request Nov 25, 2026
A retail title gives the GPU only addresses in a GPU view of its memory
(PAGE_NOACCESS on the CPU; with the 16-window layout it lies in the view
windows). The device's views and placed buffers took such an address as
memory nobody has: a constant buffer view was left empty, a buffer placed
there became a committed resource of its own that stayed zero (so its GPU
address, the buffer views of it, indirect arguments, copies and vertex
buffers read zeros), and a view made by address carried the address but
never asked for the tiles behind it, so the shader read zeros there too.

Each now asks for the tiles of exactly the range it covers
(view_want::want): views by address (device xcl-dev#70 / xcl-dev#71, the range
buffer_words_at computes), constant buffer views, views of buffer
resources, the acceleration-structure view (from the root on; its size is
not known) and a Map read of a buffer in the view. A constant buffer view
and an acceleration-structure view in a view window carry the address. A
buffer placed in a GPU view goes over the view window's tiles through
sparse::place_buffer, as one in a sparse window does, and may run on into
the next view windows; when that is refused it is a resource of its own
as before, logged once. A Map read of such a buffer reads back what the
GPU wrote into its CPU view, and its release does not wait as one over
CPU pages does.

Without the 16-window layout no address is in a view window and nothing
changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
grahamster2 added a commit to grahamster2/xcl that referenced this pull request Nov 26, 2026
resource_at keys the resources it makes for views by address (device xcl-dev#70,
xcl-dev#71) by (address, 0x38-byte resource desc) and cleared only 0x34.. of it.
Bytes 0x04..0x08 are the padding between Dimension and Alignment (the
same for every dimension: the desc is one D3D12_RESOURCE_DESC); the title
leaves stack bytes there, so the same view at the same address made a
second resource whenever they differed. view_resource_key clears both.
On amd-dev's placed SRVs this was 31 % of the entries in a 200 s run.

Test: a_view_by_address_ignores_the_padding_of_its_desc.

Ported from amd-dev c093211 by Greem (the same fix there is in
format_alias.rs prepare_placed_srv_desc / prepare_placed_uav_desc).
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.

5 participants