Skip to content

recomp: f64 abs / neg modifiers on the sign bit - #72

Closed
gefydev wants to merge 2 commits into
xcl-dev:mainfrom
gefydev:recomp-f64-neg-sign-bit
Closed

gefydev wants to merge 2 commits into
xcl-dev:mainfrom
gefydev:recomp-f64-neg-sign-bit

Conversation

@gefydev

@gefydev gefydev commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

On top of #71, which is what runs this test on NVIDIA. Only the last commit is new.

The f64 source modifiers are emitted as -x (NEG) and abs(x) (ABS). DXIL (LLVM 3.7) has no fneg, so DXC compiles -x as fsub double -0.0, x, and IEEE 754 doesn't define the sign of a NaN result there. AMD happens to flip it. On a GTX 1650, v_frexp_mant_f64 with NEG on 0x7FF8000000000001 returns 0x7FF8000000000001 instead of 0xFFF8000000000001:

assertion `left == right` failed: lane 8 v_frexp_mant_f64 neg
  left: 9221120237041090561
 right: 18444492273895866369

On RDNA the modifiers only flip or clear the sign bit, NaN included. f64v now applies them that way, to the high dword: asdouble(lo, hi ^ 0x80000000u) and asdouble(lo, hi & 0x7FFFFFFFu). For anything but NaN the value is the same as before.

f32 operands (fsrc) still use -x / abs(). I haven't seen a failing case there, so I left them alone.

Validation

GTX 1650, Windows 11, NVIDIA driver 32.0.16.2114 (and before that the same GPU on Linux with vkd3d-proton). On Windows, cargo test --workspace has 0 failures and gpu_frexp_f64_exp_and_mant runs and passes. The failure output above is from vkd3d-proton; on Windows I only ran it with the fix.

  • gpu_frexp_f64_exp_and_mant now uses gpu_ready_wave32. It fails without this commit (above) and passes with it.
  • f64_class_compare_vopc_and_vop3, frexp_f64_instructions and rndne_f64_instructions check the generated HLSL, so they now expect the new form.
  • cargo test -p xcl --lib: 0 failed on the GTX 1650 (19 SKIPPED) and without a GPU.

@gefydev
gefydev force-pushed the recomp-f64-neg-sign-bit branch from 2803e43 to a7a2074 Compare November 23, 2026 00:29
@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.

No TDR, no device removal; mesh and e2e tests unaffected. Nothing from a game package was used.

AI-assisted.

On an adapter without 64-lane waves (NVIDIA) every kernel test that
needs wave64 was skipped: 41 of them, most of which check instruction
semantics that do not depend on the wave size (f64, atomics, images,
typed buffers, scalar moves).

Options::hw_wave = 32 now runs a wave64 kernel as two native wave32
halves, as console mesh programs do there: lane_id covers both halves,
each half ORs its SGPRs into the zeroed result, so a lane mask gets
both words and a uniform value stays the same. runner::run_code and
run_code_with use it on such an adapter, and refuse a program that
needs both halves at once (geometry_wave32_hazards). The 22 tests
whose programs pass that check switch to gpu_ready_wave32.
The f64 NEG source modifier was emitted as -x and ABS as abs(x). DXIL
has no fneg: DXC writes -x as fsub -0.0, x, and IEEE leaves the sign
of a NaN result open, so a negated NaN kept its sign on NVIDIA
(v_frexp_mant_f64 with NEG on 0x7FF8000000000001). The hardware
modifiers only flip or clear the sign bit; they are now that, on the
high dword.
@gefydev
gefydev force-pushed the recomp-f64-neg-sign-bit branch from a7a2074 to ec446ec Compare November 23, 2026 01:13
gefydev added a commit to gefydev/xcl that referenced this pull request Nov 23, 2026
…pute e2e through the PSO hook (not for merge)
DIMASIK1502 pushed a commit to DIMASIK1502/xcl that referenced this pull request Nov 23, 2026
KickoffX (xcl-dev#93), Wait32/64BitValueX (xcl-dev#71/xcl-dev#72), RSSetDepthBiasX (xcl-dev#94). Conflicts with main resolved (console slots and PC overrides united; ExecuteCommandLists keeps the per-queue title-memory refresh). KickoffX resets the PC list mid-recording: it now also restores what the Reset clears and console code had set (descriptor heaps, topology, viewports, scissors, blend factor, stencil ref, vertex buffers, render targets) - on the console a kickoff leaves the list's state as it was; without the heaps a translated draw after it would read garbage descriptors.
ivall pushed a commit that referenced this pull request Nov 23, 2026
The f64 NEG source modifier was emitted as -x and ABS as abs(x). DXIL
has no fneg: DXC writes -x as fsub -0.0, x, and IEEE leaves the sign
of a NaN result open, so a negated NaN kept its sign on NVIDIA
(v_frexp_mant_f64 with NEG on 0x7FF8000000000001). The hardware
modifiers only flip or clear the sign bit; they are now that, on the
high dword.

Cherry-picked from #72 (ec446ec) without #71, which #67 superseded; the
test gates on gpu_ready (#67: wave64 programs run split on 32-lane GPUs).
ivall added a commit that referenced this pull request Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Landed as c2887bb (cherry-picked, authorship kept), without #71 – #67 already runs these kernels on 32-lane GPUs, so the test now gates on gpu_ready instead of gpu_ready_wave32. Passes on an RX 9070 natively and with XCL_SPLIT_WAVE64=1 (the 32-lane split form forced on RDNA). Closing here since the commit is on main. Thanks!

@ivall ivall closed this Nov 23, 2026
ivall added a commit that referenced this pull request Nov 23, 2026
…st and fence methods

Placeholder VirtualAlloc, XMemMapPhysicalPagesScatter with 4 KiB page numbers, the
title's allocation hooks, pipeline streams translated as plain descs, fence #12,
GetResourceAllocationInfo2, 1D / 3D textures in xg (checked against the console's
library), the newer list layout from #72 on, and XCL_NETWORK=0.

Not playable yet: the title runs out of memory while compiling pipelines (HANDOFF).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
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