WIP: feat(d3d12): a Direct3D 12 back end beside Vulkan, chosen with RX_D3D12=1 #2040
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2040
Loading…
Reference in a new issue
No description provided.
Delete branch "nyannoying/Longshot:feat/d3d12-renderer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Longshot draws with Vulkan only. This adds a second renderer,
longshot_d3d12.dll: a Direct3D 12 back end behind thesame seam as
longshot_vk.dll(MkwVkHostandMkwVkRendereringpu/vk/vk_api.h). Vulkan stays the default.RX_D3D12=1(orHOS_D3D12=1) starts the D3D12 one; Vulkan starts instead when its DLL is missing or doesn't start(
host/rx_backend.c). It is for Windows, Intel Arc first: there D3D12 is what the driver and Intel's tools are made for,and XeSS frame generation and XeLL exist only on D3D12.
Where it stands, on an Arc B580 (driver 32.0.101.9175), Castle Town's market at a 2560x1440 output:
Vulkan's.
RX_D3D12_PREPARE=1): all of the game's shaders translated ahead of play, about 15 minutes on20 threads, a 5.2 GB cache; play afterwards translates a handful.
How it works, in short (
docs/d3d12.mdhas the design and every measurement behind it):spirv_to_dxilto DXIL, on worker threads, kept in aprogram cache. Global loads read the guest page table where a draw's bindings allow (
RX_D3D12_GP_TABLE=4: eachprogram translated both ways, the draw choosing).
made on a second one (the recorder).
atomics write live in VRAM copies, compared back with a shadow.
earlier run made.
RX_D3D12_MESH_NATIVE=1), off:slower on the B580.
longshot_d3d12.dllbeside the Vulkan back end and places Mesa'sspirv_to_dxil.dlland its licenses with it. The DLL is in this PR,third_party/mesa-spirv-to-dxil/bin(10.4 MB, thebytes its
PROVENANCE.mdpins, checked bytests/test_d3d12_game_build.py), so no build tools change.python -I scripts/dev.py d3d12builds the back end alone.Read first:
docs/d3d12.md§1 and §10.1,host/rx_backend.c,gpu/d3d12/d3d_api.cpp, thengpu/d3d12/d3d_draw.cpp.Related: #1619 (an earlier build on an Intel Arc iGPU). #2362 put Mesa's DLL into the build tools' archive; this PR
carries the DLL itself instead, so #2362 is not needed. #2286 replaces the builder: this back end's build moves into it
once that lands (my comment there).
How to try it (testers)
You need Windows 10 or 11, a Direct3D 12 GPU with shader model 6.6, and current drivers. With a build of this branch:
userfolder) somewhere safe.longshot_d3d12.dllandspirv_to_dxil.dllbesidelongshot.exe.longshot_env.txtin the game folder with the lineRX_D3D12=1. Without the line, the game runs onVulkan as always.
logshas lines startingd3d12:.Optional, to skip the stutters of first visits: add the line
RX_D3D12_PREPARE=1. The shaders are translated while thegame runs, about 15 minutes on a 20-thread CPU (longer with fewer cores), the CPU busy all that time. The game folder's
cachegrows to about 5.2 GB, so have 6 GB free. The log saysd3d12: the preparation: doneat the end. Then delete theline; the cache stays.
What to expect, and what to report:
a minute (the game looks frozen: wait).
that looks wrong next to Vulkan at the same spot; how smooth it felt next to Vulkan.
Testing
Tested: Windows 11 (build 29704), Intel Arc B580, driver 32.0.101.9175,
RX_D3D12=1, a 2560x1440 output:f9fb7449changed only main's audio files), 2026-11-23: 6 runs of a save's first loadand Castle Town's market, 325 s each, no device removed, the market's picture as expected; 6 more for the search
loop's A/B, no device removed.
market, again and again; the Insert menu, XeSS, XeSS-FG (1 to 3 frames) and XeLL; V-Sync On, Off and Auto.
parentheses), the Intel XeLL row's docs line, and Mesa's DLL moved into the repository (the same bytes the runs used).
None changes what the game runs.
run_all.py --no-skip, spirv-val on the path) at6bf20189: 966 passed, 45 failed: 44 fail onmain too;
tests/test_coverage_run.pyfails here inscripts/coverage/cover.pyreadingtasklist'soutput (this PC's code page; the branch doesn't change that code). At the head, the checks that read the Mesa commit's
files (
run_all.py --changed): 117 passed, the 12 failures all main's.Still to test:
HOS_D3D12=1, from the title into the game, expecting the picture as onVulkan and no device removed (
@Beanstalk)Measurements
Verdict: D3D12 is 1.1 ms a frame behind Vulkan in the market on the B580 (13.69 against 12.62 ms). Vulkan on this
branch is not measured against main yet: before ready.
Setup: Windows 11 build 29704, Arc B580, driver 32.0.101.9175; the player's settings (output 2560x1440, the main pass at
1920x1080, HDR, no upscaler, no frame generation, uncapped); Castle Town's market, the frame time over 195 to 315 s of a
run, the caches warm.
RX_D3D12=1)Where D3D12's time goes (GPU timings,
RX_D3D12_GPU_TIMES): 11.5 ms of GPU work a frame against Vulkan's 9.1. The meshfallback costs 1.2 ms (native mesh shaders are slower still on this GPU), the atomics' copies back 1.2 ms.
Switches:
RX_D3D12ships off, so Vulkan stays the default. TheRX_D3D12_*rows ingpu/vk/switches.defgive eachone's kind and default: the diagnostics off, the kill switches leaving their part on, the attempts off
(
RX_D3D12_MESH_NATIVE,RX_D3D12_PREPARE,RX_D3D12_SSBO_LOOP: +1.5 % frame time in play), and the tuning ones at thedefaults
docs/d3d12.mdexplains, measured.Risks
RX_D3D12=1nothing changes for players: the host loadslongshot_vk.dllas before.gpu/vk/eden,gpu/vk/sirit) gains D3D12-only options, all off for Vulkan;the emitter fixtures check that Vulkan's SPIR-V is unchanged.
RX_D3D12=1: a heap corruption on a translation worker during a cold first load, seen once in more than 10 coldloads, cause not found; the first visits stutter without the preparation.
RX_D3D12_GP_TABLE=4(the default), the window glass in Castle Town's market draws white insteadof dark leaded glass (Vulkan is right). One graphics program reads a small buffer a compute dispatch wrote earlier in the
frame through the guest page table, while the written copy is still live in VRAM, so it reads the pool's older bytes.
RX_D3D12_GP_TABLE_DRAWS=1draws it right but costs +25 % frame time in the market, so it is not the default; the fixbelongs in the rule that picks table or search per draw, and comes in a later commit.
third_party/directx-headers(MIT),dxc-api(NCSA),mesa-spirv-to-dxil(MIT),spirv-cross(Apache-2.0 and MIT), upstream copies with theirPROVENANCE.md. Mesa'sspirv_to_dxil.dll(MIT,mesa-dist-win's 26.2.6 build) is the first DLL in the repository: 10.4 MB in its history,
.gitignoreletting this onefile in. It goes beside the game with its licenses. DXC's DLLs are only for the native mesh shaders, off, and never shipped.
nx2/build.pyandmake_game.py, where this back end's game build lives; that part moves intolongshot-buildafter it lands.RX_D3D12. A revert is enough.Checklist
Ready for review
main; the title is a Conventional Commit. (rebased onf9fb7449, 2026-11-23)mise run testpasses (any failure that also fails onmainis named). (the full suite as Testing says: nofailure main lacks but
tests/test_coverage_run.py, this PC's code page in code the branch doesn't change)main, or Measurements says why there is nothing to measure. (this branch's Vulkan against main's:before ready)
third_party/untouched; nothing GPL-incompatible.(four new parts, upstream copies with their notes, Mesa's DLL as its release built it; the existing parts untouched,
scripts/check_third_party.pypasses)When it applies
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.the host change being Windows-only)
mainand here, for a change that shows on screen. (none for now: the author'scall)
Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
The world's near geometry draws, and the lighting's froxel volumes are bound: the hedge scene is no longer black. - NOP_DRAW_MESH runs the mesh program as the Vulkan back end does on a GPU without mesh shaders (Eden's compute fallback, docs/d3d12.md section 7): the task stage (if any) and the mesh stage as compute dispatches that write their outputs to a 64 MB records buffer, a record a primitive corner, then a vertex stage made for the program draws them with an indirect draw, a vertex a record. The stages reach the records and the payloads through pointers in the push block (Mesa's: a heap index above a byte offset), to views at fixed heap slots. D3D12 reads no buffer as indirect arguments while a view of it is in use, so the header's counts are copied into the indirect ring before each ExecuteIndirect. Direct mesh draws and indirect ones ({count, first} where a GPU pass wrote them, in a pool opened in place) run; those with a draw count stay out, as Vulkan's fallback leaves them. RX_D3D12_NO_MESH=1 leaves mesh draws out, for A/B tests. - An indirect dispatch's pool is back in UNORDERED_ACCESS once its group counts are copied out (it stayed in COPY_SOURCE while the shader used its storage buffers). - Points: D3D12 draws a point as a pixel, with no sprite coordinate. Mesa's spirv_to_dxil made PointCoord a varying no vertex stage writes, and 3 pipelines did not link (E_INVALIDARG; the debug layer's vertex-pixel linkage error). Eden's profile gains has_no_point_coord (off for Vulkan): no PointCoord input, and its reads are the pixel's centre, (0.5, 0.5). - 3D storage images: a 3D texture a compute pass stores to is a 3D render target (UAV, RTV and SRV of its slices). The lighting's froxel volumes were not bound, and the scene came out black behind the fog. Measured at the save (hedge scene): 52 mesh draws a frame, all drawn; 55 mesh programs translated, none failed; no pipeline fails and the debug layer reports no error (RX_D3D12_DEBUG=1). Draws and dispatches left out in 5 s: 2,255 before, 413 after. 4.6 to 5.0 fps, as before: the replay waits on the GPU. With RX_D3D12_NO_MESH=1 the scene is as black as before and the trees' branches are gone. Still too dark: the 12288 x 12288 shadow map is a depth texture no draw makes, left out (next). Checks: python -I -B tests/run_all.py --changed main: 575 pass, 98 skipped. 46 of the 48 failures fail on the last commit too (tests/test_switch_table.py only for main's RX_VK_PGO_FILE row). Of the other two, tests/test_longshot_ctl.py passes alone, and tests/test_coverage_run.py fails in scripts/coverage/cover.py, which this does not touch. Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>At the save a frame was the replay's recording on the game's submitting thread, then the GPU's work, in turn: each submit's command list went to the GPU only at the submit's end, and the game submits most of a frame at once. The bounce ring (VRAM copies of the storage buffers a dispatch's atomics write) also made the replay wait for the GPU twice a frame: about 43 MB a frame went through 32 MB. - send_if_long (d3d_draw.cpp, after each op the replay records): the open list goes to the GPU once it holds RX_D3D12_SEND_EVERY (128) draws and dispatches, so the GPU runs a long submit's first part while the rest is recorded. 0: at each submit's end only, as before. - The bounce ring is 256 MB (was 32). - The replay's 5-second line ends with the rings: what each handed out, its waits for the GPU and the sends of the open list it forced, and the sampler heap's resets (how the bounce ring's waits were found). - docs/d3d12.md (sections 5, 6 and 10) and docs/d3d12-tools.md say so. Measured at the save (hedge scene, 1920x1080 in a 2560x1440 window, --mode timing, frames from 90 to 116 s; GPU from RX_D3D12_GPU_TIMES): fps replay, 5 s GPU a frame lists a frame before 11.3 3545 ms 46.1 ms 5.0 bounce ring 256 MB 11.8 2450 ms 45.5 ms 4.0 + every 128 (default) 16.4 3313 ms 46.3 ms 15.8 + every 32 16.3 3509 ms 46.4 ms 58.0 + every 256 16.0 3183 ms 45.8 ms 9.3 The ring's waits went from 112 in 5 s (1.1 s) to none. Every 32 is no faster than 128 and its longest replay run is 151 ms (128: 31 ms). RX_D3D12_SEND_EVERY=0 measures as the 256 MB ring alone (11.8 fps). The picture at the save is as before: mean luma 103 and 100 in two shots (Vulkan: 100), no black pixels. Next at the save: 46 ms of GPU work and 40 ms of replay a frame; the replay copies about 177 MB of vertex and index data a frame into the upload ring. Checks: python -I -B tests/run_all.py --changed main: the 46 failures of the commit before, and two more that fail on this PC's state and pass alone or on another run (test_longshot_ctl.py, a relaunch's timing; test_coverage_run.py, tasklist's German output with no game running). Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>A profile of the replay thread at the save (the host's HOS_SAMPLE_ALL, named through the DLL's symbol table) had a quarter of its time in one memcpy: the vertex streams copied into the upload ring. Each stream per vertex was copied from its start to the last vertex the draw reads, and the game draws from large buffers by their base vertex: 9.3 GB in 5 s copied for 1.2 GB the draws read. - stream_copy (d3d_draw.cpp): a stream per vertex from the first vertex the draw reads (its base plus its least index; read_indices finds it with the largest) to its last; one per instance from its start, as before. - draw_one moves the draw's base back by that first vertex (BaseVertexLocation, StartVertexLocation), so each index reads its element. The vertex stage's index does not move: it is SV_VertexID, which no base moves, plus the runtime data's first vertex, the draw's base as before. - ub_read takes no lock of its own: the uniform buffer updates it lays over memory are read and changed under replay_mu only. The lock had a tenth of the replay thread's samples, and 3 % of its time. Measured at the save (hedge scene, 1920x1080 in a 2560x1440 window, --mode timing, frames from 90 to 116 s): fps replay, 5 s upload ring, 5 s GPU a frame before 16.4 3313 ms 14.5 GB 46.3 ms from the first vertex 18.6 2653-2698 ms 7.2 GB 45.0 ms + no lock in ub_read 18.6 2570-2587 ms 6.6 GB 45.5 ms The picture is as before (mean luma 103 in the shot at 105 s, no black pixels; the geometry whole). The frame is the GPU's now: 45 ms of GPU work in a 54 ms frame, and the game's thread waits for the GPU about 15 ms a frame. Copying the storage a dispatch only reads into VRAM first (an experiment, not kept) changed no dispatch's time. tests/test_d3d12_vertex_copy.py: stream_copy, cut out of its source, on 20000 draws made up there (each index reads the same element in the copy as in the stream, inside it), the bound size, kMaxCopy, instanced streams and the edges; the wiring read from the sources. It fails on each of 7 mutations of stream_copy. docs: d3d12.md section 10's performance, d3d12-tools.md's CPU samples (and what a lock's samples overstate). Checks: python -I -B tests/run_all.py --changed main: the failures of the commit before (test_coverage_run.py fails on this PC's German tasklist output), and the new check passes. Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>Where the device has mesh shader tier 1 and DXC's dxcompiler.dll is beside the back end (RX_D3D12_DXC names another), a mesh program is translated twice: Eden's compute fallback, then its task and mesh stages as D3D12's amplification and mesh shaders. Eden's SPIR-V with Profile::hlsl_mesh goes to HLSL by SPIRV-Cross (shader model 6.5, third_party/spirv-cross, vulkan-sdk-1.4.363.0) and to DXIL by DXC (third_party/dxc-api's dxcapi.h, the DLL loaded at run time); the fragment stage stays Mesa's. hlsl_mesh: no descriptor arrays (a constant buffer is one uvec4 array), the payload a struct, OpIAddCarry written out, the mesh stage's generics at the locations the fragment stage reads them (RuntimeInfo::mesh_output_locations), and the guest's 32-lane warp as the workgroup (emit_spirv_warp.cpp: votes, ballots and shuffles through workgroup memory and a barrier, only where every thread reaches it). An indirect draw's {count, first} is copied to {first, count, 1, 1} for a command signature that sets the first task workgroup. The program cache keeps the native half, stamped with DXC's version. docs/d3d12.md section 7.1. With RX_D3D12_MESH_NATIVE=1 a draw takes the native route once it is made. On the walk route (B580, driver 32.0.101.9175, OS build 29704) 4 of 49 mesh programs translated natively, and the first native indirect draw in Kokiri Forest hung the GPU: DRED said the device hung, with no page fault, and RX_D3D12_MARKERS=2 named the draw. Of the 45 that fell back, 40 stop at an OpAccessChain with an undefined operand, 3 at a warp operation in divergent control flow, 2 at SPIRV-Cross's lack of variable pointers in HLSL. So the switch is off: every mesh program is drawn by the fallback, as before. Profile::hlsl_mesh is off for the Vulkan back end, whose SPIR-V these changes leave as it was (not checked with a Vulkan run); sirit's error for a null operand names the op. Bench: dxprobe meshlanes and dxbench meshrun measure the lanes the B580 runs amplification and mesh shaders with. Checks: tests/test_d3d12_program_cache.py stamps d3d_hlsl.cpp and .h, and RX_D3D12_DXC. scripts/check_third_party.py: 17 parts as their notes say. tests/run_all.py, with the next commit: 589 passed, 47 failed, 98 skipped; the same 47 fail on the commit before, none of them a Direct3D 12 check. Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>214b92a1 made Eden's SPIR-V emitter read the profile's hlsl_mesh in the DrawParameters block and keep cf_depth and cf_early_exit in the Unreachable case. nx2/test_draw_parameters.py and tests/test_mesh_unreachable_outputs.py cut those blocks into stand-in contexts that had neither, so both stopped building ("no member named 'profile' in 'Ctx'", "no member named 'cf_early_exit'"). They skip on Windows (they need spirv-val), which is why this PC's runs did not show it; a Linux run of the whole suite did. The stand-ins now have the members, off, as for the Vulkan back end's programs. Checks, with spirv-val (SPIRV-Tools v2026.4) and the SPIR-V and Vulkan headers on this PC: both fixtures pass; python -I -B tests/run_all.py --no-skip fails no check here that passes on the merge base544229a2(75 failed here, 76 there: the same names, and test_longshot_ctl.py there only). Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>tests/test_d3d12_dead_targets.py cuts gpu/d3d12/d3d_texture.cpp's frame out of the source (texture_stats up to textures_line: textures_frame, and the code that lets dead targets go when it is there), with target_rendered, target_sampled, same and target_slices, and runs it on stand-ins for target_for, the views' heaps, the GPU's timeline and the queues' bindings. Each target let go is checked against the check's own record of its uses and of every draw: let go only at a present's end, drawn over since its last use (from another start, over an eighth of it or more; from its own start, 60 presents unused), the GPU past the list of the frame that last used it, bound by no queue, of one level and layer, no dump asked for, its views back in their heaps. The cases: - OoT's scratch heap: 6 targets a frame at offsets that move each frame, each pass sampling the one before, 400 frames with the GPU a frame behind: 4 frames' worth held at most; the picture's own target and one used in 10 frames only, which nothing drew over, kept; - drawn over from its start a frame later: kept 59 presents unused, gone at the 60th; a shadow map drawn every 8 presents where another target is drawn each frame: made once, gone 60 presents after its last draw; drawn once and sampled 100 presents: kept 60 presents from its last sample; - drawn over in the frame that last used it: stays; from another start, less than an eighth of it: stays, an eighth: goes; a smaller target inside it: stays; - the GPU stalled before the frame that last used it: kept until it ran that frame; - drawn into after a present while still bound, with no new binding, or sampled in the frame another was drawn over it in: kept until the GPU ran that frame; - bound by a queue, an array's, a cube map's, a 3D or a mipmapped target, RX_D3D12_DUMP_TARGETS set: kept; an array of one layer, and one unused 100 presents then drawn over: go; - target_rendered stamps a draw as the target's use and write; the books (n_targets, target_bytes, the map, the views given out and back, a depth target's to the DSV heap) match the targets held; RX_D3D12_KEEP_TARGETS=1 keeps them all. d3d_replay.cpp's target_bound and the census line (targets_line) run on stand-in queues, and the wiring is read from the source: target_for stamps the target it finds or makes, and counts it and puts its address in the map only past its last return with nothing made; every write that marks a target drawn stamps it written; present sends the frame's list before textures_frame and records nothing between. At this commit it fails: all 2,400 of the scratch heap's targets are held after 400 frames, the targets that should go are kept, target_for puts an address in the map before it can still fail, and target_bound is not in the source yet. Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>dev.py ab measures a switch within one run (HOS_AB) when its reader asks for the A/B's value at each use. It finds those readers in the source by hos_ab_value("NAME", ...), the host's, so a renderer's reader, which asks through MkwVkHost.ab_value (interface 36: gpu/vk/vk_draw.cpp's RX_VK_MESH_CONV), is never found, and dev.py ab measures such a switch in separate runs. The check now expects RX_VK_MESH_CONV among the switches found, and a host->ab_value("NAME", ...) reader in a source of its own; hos_ab_value_at, the host's own function, is no reader. It fails here: {'HOS_OS_YIELD', 'HOS_COLLECT_WIDE', 'HOS_OOT_BARRIER_WAIT'}. (test_options_keys_in_source in the same file fails on main702a57a4as here.) Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>The source scan for HOS_AB's readers takes ab_value("NAME", ...), so it finds a renderer's reader, host->ab_value("NAME", ...) (MkwVkHost.ab_value, interface 36), as well as the host's hos_ab_value. dev.py ab then measures gpu/vk/vk_draw.cpp's RX_VK_MESH_CONV within one run, as its reader was written for, and the Direct3D 12 back end's switches once they read the A/B. developing.md says where a renderer's reader asks. tests/test_dev_ab.py's test_wired_from_source passes; with the old pattern it fails on {'HOS_COLLECT_WIDE', 'HOS_OS_YIELD', 'HOS_OOT_BARRIER_WAIT'}. test_doc_anchors passes. Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested in game: Windows 11 (build 29704), Intel Arc B580, driver 32.0.101.9175, RX_D3D12=1 at 2560x1440: from the title into the game; Kokiri Forest, Zora's River and the areas after it, and Castle Town's market; runs of 240 s with no device removed; the head's code at 44 fps standing in the market (2026-11-21).
Pushed six commits:
198dbfc8): the driver's blob of each pipeline is kept incache/longshot_d3d12_pipelines.bin, so no draw waits for a pipeline an earlier run made, even after Intel's own 512 MB cache has dropped it. On the B580 a graphics pipeline made from a blob draws slower (the scene pass 4.3 ms against 3.1), so each is made again from its shaders on an idle worker and swapped in at a present. Timing runs at the save: 42.7 fps with the store and without it.docs/d3d12.md§3.7.5570090d,RX_D3D12_MARK_KEY=1): the next frame's picture and its draws in the log, for a glitch seen while playing.2fe63d57,7ecb2376), and the ground fog drawn in dashes on Intel's GPUs (bf3082db,22055729).The description's Summary and Testing say so.
71e2d1be0695eeede988On the B580 (driver 32.0.101.9175) an ExecuteIndirect whose command signature sets a root constant before DISPATCH_MESH hangs the GPU once the mesh stage reads a constant buffer, as every translated stage does. The native mesh draws' signature set the push block's first task workgroup that way, and the first native indirect draw in Kokiri Forest hung the device. A standalone repro took the parts away one at a time: the same stages and arguments run by DispatchMesh with the word set from the CPU, or by a signature of DispatchMesh alone; a mesh stage that reads no constant buffer runs under the root constant's signature; the debug layer reports nothing. tests/test_d3d12_native_mesh_signature.py cuts mesh_native_ready, mesh_native_one and the indirect ring out of gpu/d3d12/d3d_draw.cpp and runs them on a model device and command list that execute what is recorded on the words of their buffers. The signature must hold DispatchMesh's counts alone; an indirect draw of a mesh stage alone dispatches {count, 1, 1} whatever its first workgroup; an indirect draw with a task stage is the fallback's; a direct draw dispatches its workgroups with its first workgroup in the push block, and one of more than DispatchMesh takes is the fallback's. Here it fails at the first check: the signature sets a root argument (a constant) before DispatchMesh. Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>The native mesh draws' indirect command signature now holds DispatchMesh's counts alone, and an indirect draw's {count, first} is copied to {count, 1, 1}. On the B580 the root constant it also set (the push block's first task workgroup) hung the GPU once the mesh stage read a constant buffer: DXGI_ERROR_DEVICE_HUNG after about 3.5 s, no page fault (docs/d3d12.md section 7.1). A mesh stage alone reads no first workgroup. A task stage reads it from the push block, and an indirect draw's is on the GPU, where only a root argument in the signature could take it from: such draws (about 7 of the 73 mesh draws a frame at the save spot) are the fallback's for now. Direct draws are as before, the word set from the CPU. The native draws have a row of their own in RX_D3D12_GPU_TIMES, "the native mesh shaders". In the game (B580, a five-minute walk through Kokiri Forest, Castle Town's market and Hyrule Field with RX_D3D12_MESH_NATIVE=1, the program cache off): no device lost, 40 mesh programs native and 15 not, 62 % of the mesh draws native. In Hyrule Field the native draws took 2.5 ms of GPU time a frame for 34, the fallback's 3.7 ms for 21. RX_D3D12_MESH_NATIVE stays off by default until it is measured against the fallback. tests/test_d3d12_native_mesh_signature.py passes (clang++ and g++), fails on the parent for the bug's reason, and fails on four broken versions: the root constant back in the signature, an indirect draw with a task stage drawn natively, the first workgroup copied where the count goes, a direct draw's first workgroup not pushed. The other checks that read the changed files pass, but those that fail on the parent too or for files this does not change (test_dev_ab, test_frame_overlap, test_crash_dialog, test_driver_env_choose, test_vk_occlusion_queries, test_target_reuse_memory, test_present_queue_default, test_linux_pressure). Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <[email protected]>fb742f17ce30e9f3d489f721a3c44e0984e394d9Brought up to date: rebased on main
f9fb7449, head0984e394.RX_D3D12_PREPARE=1), and 13.69 ms a frame in Castle Town's market against Vulkan's 12.62 on an Arc B580.spirv_to_dxil.dllis now in this PR (third_party/mesa-spirv-to-dxil/bin, its bytes pinned by itsPROVENANCE.mdand checked), so a build of this branch, the Test Farm's too, makes the D3D12 back end with no build tools change. #2362 is closed for it.@Beanstalk Windows on an NVIDIA GPU and an AMD GPU: start with HOS_D3D12=1, from the title into the game. Expect the picture as on Vulkan and no device removed.
@nyannoying only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.@beanstalk
Beanstalk test farm · an earlier run: commit
0984e39(the newer results are in a comment below)Commit
0984e39· approved by HumanBean (reviewed) · dashboard⚠️ Note: The title and gameplay are separate starts, not a continuous title-to-save transition. The generic D3D12 log prefix confirms that the backend logged, but may not by itself rule out a later fallback to Vulkan.
⚠️ Note: Headless pictures and timings do not test the swapchain, window presentation, V-Sync, XeSS frame generation or XeLL; the farm cannot take comparison pictures in its window scenarios.
⚠️ Note: The fixed 1920×1080 output and uncontrolled D3D12 caches cannot reproduce the author’s prepared-cache 2560×1440 Arc measurement or quantify preparation time and cache size.
Started at 16:23 UTC.
windows+nvidiawindows+amdwindows+intelWhy it failed
windows+nvidia:title · HOS_D3D12=1 (PR only)screenshot.max_diff:0.0 → 1.0; limit 0.2windows+nvidia:build times (lift)build_s.max_delta_pct:1,376 → 2,199 (+59.7%); limit 20.0windows+nvidia:build times (lift)build_lift_s.max_delta_pct:204.0 → 253.2 (+24.1%); limit 20.0windows+nvidia:gameplay · HOS_D3D12=1 (PR only)crash:1 PR run crashedwindows+nvidia:gameplay · HOS_D3D12=1 (PR only)screenshot.max_diff:0.5 → 1.0; limit 0.2windows+amd:title · HOS_D3D12=1 (PR only)crash:2 PR runs crashedwindows+amd:title · HOS_D3D12=1 (PR only)screenshot.max_diff:0.0 → 1.0; limit 0.2windows+amd:gameplay · HOS_D3D12=1 (PR only)crash:3 PR runs crashedCouldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.
windows+amd, report 1:the pr runtime failed (exit 1): return a.func(a) or 0What was tested
What will be tested · AI plan (
gpt-6.1-terra)On Windows NVIDIA, AMD and Intel GPUs, the plan compares the PR’s requested D3D12 backend with main’s Vulkan renderer at the title, Castle Town Market and Kokiri Forest. It takes two title starts and three gameplay starts per side, with 20-second warmed measurements at each gameplay location; the Windows Intel target will wait for a tester. Crashes, a missing D3D12 log line, device-removal messages, materially different pictures or frame-time regressions beyond 20% fail the PR. Timed lift builds also check for build-time regressions. No tester online now matches windows+intel: that target waits for one.
1(PR only).market-entrance, then teleport to Market, take the picture market to compare with main, measure market for 20 s (after 10 s warm-up), teleport to Kokiri Forest, take the picture forest to compare with main, measure forest for 20 s (after 10 s warm-up); 3 runs on each side.Measurements on `windows+nvidia`, for the PR description
Verdict: fail on windows+nvidia (2 reports):
title screenshot.max_diff;build times (lift) build_s.max_delta_pct (+59.7%);build times (lift) build_lift_s.max_delta_pct (+24.1%)failed.Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 5050 Laptop GPU, 621.24.0AMD Ryzen 5 220 w/ Radeon 740M Graphics, 16 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 3070, 621.35.0AMD Ryzen 5 5600X3D 6-Core Processor, 32 GB RAMScene: title, from the title screen; gameplay, from the repository's save market-entrance; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); title: 2 game starts a side; gameplay: 3 game starts a side, market 20 s after 10 s warm-up, forest 20 s after 10 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)f9fb7440984e39HOS_D3D12=1 (PR only)· forbidden log linesHOS_D3D12=1 (PR only)· expected log lines missingHOS_D3D12=1 (PR only)· longest load (s)HOS_D3D12=1 (PR only)· forest · frame time (p99) (ms)HOS_D3D12=1 (PR only)· market · frame time (p99) (ms)HOS_D3D12=1 (PR only)· forbidden log linesHOS_D3D12=1 (PR only)· expected log lines missingHOS_D3D12=1 (PR only)· forest · frame time (worst 1%) (ms)HOS_D3D12=1 (PR only)· market · frame time (worst 1%) (ms)Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
f9fb7440984e39Flags and settings
HOS_D3D121As Markdown for the PR description:
Measurements on `windows+amd`, for the PR description
Verdict: fail on windows+amd (2 reports):
title crash;title screenshot.max_diff;gameplay crashfailed.Hardware: 1: windows+amd+amd-proprietary+dgpu
AMD Radeon RX 7900 XT, 2.0.416AMD Ryzen 7 5700X 8-Core Processor, 16 GB RAM; 2: windows+amd+amd-proprietary+dgpuAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMScene: title, from the title screen; gameplay, from the repository's save market-entrance; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); title: 2 game starts a side; gameplay: 3 game starts a side, market 20 s after 10 s warm-up, forest 20 s after 10 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)f9fb7440984e39HOS_D3D12=1 (PR only)· forbidden log linesHOS_D3D12=1 (PR only)· expected log lines missingHOS_D3D12=1 (PR only)· longest load (s)HOS_D3D12=1 (PR only)· forest · frame time (p99) (ms)HOS_D3D12=1 (PR only)· market · frame time (p99) (ms)HOS_D3D12=1 (PR only)· forbidden log linesHOS_D3D12=1 (PR only)· expected log lines missingHOS_D3D12=1 (PR only)· forest · frame time (worst 1%) (ms)HOS_D3D12=1 (PR only)· market · frame time (worst 1%) (ms)Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
f9fb7440984e39Flags and settings
HOS_D3D121As Markdown for the PR description:
Measurements on `windows+intel`, for the PR description
Verdict: fail on windows+intel (1 report):
title crash;title screenshot.max_diff;gameplay crashfailed.Hardware: 1: windows+intel+intel-proprietary+dgpu
Intel(R) Arc(TM) B580 Graphics, 0.406.98313th Gen Intel(R) Core(TM) i5-13600K, 64 GB RAMScene: title, from the title screen; gameplay, from the repository's save market-entrance; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); title: 2 game starts a side; gameplay: 3 game starts a side, market 20 s after 10 s warm-up, forest 20 s after 10 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)f9fb7440984e39HOS_D3D12=1 (PR only)· forbidden log linesHOS_D3D12=1 (PR only)· expected log lines missingHOS_D3D12=1 (PR only)· longest load (s)HOS_D3D12=1 (PR only)· forest · frame time (p99) (ms)HOS_D3D12=1 (PR only)· market · frame time (p99) (ms)HOS_D3D12=1 (PR only)· forbidden log linesHOS_D3D12=1 (PR only)· expected log lines missingHOS_D3D12=1 (PR only)· forest · frame time (worst 1%) (ms)HOS_D3D12=1 (PR only)· market · frame time (worst 1%) (ms)Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
f9fb7440984e39Flags and settings
HOS_D3D121As Markdown for the PR description:
The testers' hardware
windows+nvidiaNVIDIA GeForce RTX 5050 Laptop GPU, 621.24.0AMD Ryzen 5 220 w/ Radeon 740M Graphics, 16 GB RAMwindows+nvidiaNVIDIA GeForce RTX 3070, 621.35.0AMD Ryzen 5 5600X3D 6-Core Processor, 32 GB RAMwindows+amdAMD Radeon RX 7900 XT, 2.0.416AMD Ryzen 7 5700X 8-Core Processor, 16 GB RAMwindows+amdAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMwindows+intelIntel(R) Arc(TM) B580 Graphics, 0.406.98313th Gen Intel(R) Core(TM) i5-13600K, 64 GB RAMBeanstalk test farm
Commit
e90a42c· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Pushed
e90a42c7(3 commits on0984e394):edd7f13efeat: a corner note with the shader preparation's progress over the game (RX_D3D12_PREPARE), then "Shaders prepared" for 8 s.0ff0f8d2test +e90a42c7fix: the crash at quit the farm found. Each start that quit through the control bridge ended with exit code 2170 (DXGI's exception 0x87a, on Intel and AMD). Longshot leaves throughExitProcess. The back end's globals still released their DXGI and D3D12 objects in static destructors during the DLL's detach. They now leave them to the process's end (DllMainnotes the detach, Windows' rule for it).tests/test_d3d12_exit_release.pyfails before the fix and passes after.Not fixed yet, being looked at:
@Beanstalk please run the same plan again on
e90a42c7: does the quit still end in a crash (exit code 2170), and does the market load still hang?🤖 Generated with Claude Code
@nyannoying only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.Tested
e90a42c7on an Intel Arc A750 (Alchemist, 8 GB): the device was lost after ~15 min, transparency broken, long hitchesSetup: Intel Arc A750 8 GB, driver 32.0.101.8974, Windows build 26300, Core i3-10105F (4 cores, 8 threads), 16 GB RAM,
1920x1080 at 60 Hz. Log line 1:
longshot v3.1.1-231-ge90a42c7. Built withdev.py update --branch refs/pull/2040/head,libxess_fg.dllandlibxell.dllbeside the game.RX_D3D12=1; the first run withRX_D3D12_PREPARE=1.What worked
During play after it only 27 DXIL conversions in ~15 minutes, so the program cache does its job.
Problems, worst first
Device lost after ~15 minutes of play (second run, Upscaler Intel XeSS, Frame generation 2x):
VRAM use ran ~2.6 GB over the budget, textures were let go and made again thousands of times, then E_OUTOFMEMORY at a
list's Close and a device reset. The B580 in the description has 12 GB; an 8 GB card looks like it needs the budget held.
Transparency broken in many places: text in the title menu and the settings drawn on solid boxes (light blue behind
"New Game", black behind "Options"), subtitles on a solid black box, a dark/noisy box behind the hearts, white patches in
the world. Looks like one blend/alpha problem rather than several.
Long hitches and flicker on the first visits: pipelines, not programs. The preparation covers DXIL but the driver's
pipelines on Alchemist are very slow to make, and draws are left out meanwhile (objects vanishing and coming back,
flicker, blue lines; at the end the screen went white and stayed so after the device was lost):
Over the run: 849991 draws left out while their program or pipeline was made; one replay run of 17.7 s; one compute
pipeline of 42.5 s. Also 174 lines with "stopped too long" waits. Making the pipelines in the preparation too (or a
pipeline list run first) would help Alchemist a lot.
The Intel XeLL row says "Off" while XeSS-FG keeps XeLL on. The row is locked and its hint reads "The game as without
it.", while the description says XeSS-FG keeps it on and the log has XeLL's reports throughout. The
row's text could show the state in force while
xell_locked()(for example "On (XeSS-FG)").Minor:
DXC 1.9 from dxcompiler.dll (no dxil.dll: the DXIL it makes is not validated).XeSS-FG itself couldn't be judged: the run was not playable before it came into it. Happy to test again on the A750 with
any build or switches you want (for example a lower texture budget).
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.