Skip to content

[OFFICIAL] Looking for PRs with shaders optimization #1269

Todo

Description

@ivall

We have to optimize shaders a lot. They are main problem right now. We are open for big PRs aiming to optimize shaders compilation time etc. It should be done by skipping EXEC emulation and compiling shaders directly into DXIL I believe. Post PRs here, thank you.

Activity

  1. added
    help wanted
    on Nov 24, 2026
  2. pinned this issue on Nov 24, 2026
  3. throny commented on Nov 24, 2026

    @throny
    Collaborator

    Plan from our side, to avoid duplicate work: measurements first, no code yet.

    On a retail shader pack (26 503 records, 2 689 compute programs) and an RTX 4080 (32-lane waves, so the split wave64 form), I will post here:

    1. Per compute program: instructions, HLSL size and translation time, for the split wave64 form and the native wave64 form side by side. That shows what the split form costs in source size on 32-lane GPUs.
    2. DXC time and DXIL size against HLSL size for a sample spread over the size range, both forms, and at -O1 / -O3 around the 1 MB switch.
    3. The programs that never finish: xcl shaders --precompile --only cs stops advancing after record 22 600 on three NVIDIA machines (Shaders: save offline compute pipelines to the runtime driver cache #744: one compile, over 33 minutes on one thread, memory growing past 14 GB). I will find which programs are still missing from the DXIL cache after those passes and what they have in common (size, loops, memory windows, cross-half exchanges).
    4. Driver compile time against DXIL size from the title's own runs and the xcl pipelines pass (Shaders: xcl pipelines compiles a run's queued pipelines outside the title #759), for the compute programs the world load uses.

    Counts and timings only, no shader names or code. If the numbers point at a specific construct that makes DXC or the driver slow, I will propose a small PR for that one here before writing it. Direct DXIL emission is more than I will start on without a design agreed with you.

    AI use: Claude Code (Claude Fable 5.2) will run the measurements and write the reports.

  4. throny commented on Nov 24, 2026

    @throny
    Collaborator

    First numbers (parts 1 and 3 of the plan above). main 47efa2e, a retail pack's 2 689 compute programs, translated as a 32-lane GPU gets them (split wave64, 4 memory windows) and as a 64-lane GPU does; DXIL cache as two days of title runs and three stalled --precompile --only cs passes left it. A temporary local test, not for a PR; counts only.

    Where the precompile pass stops: the -O0 fallback, not the split form

    programs instructions HLSL DXIL in the cache
    all compute programs 2 689 median 2 277, 735 over 10 000, max 88 863 3.83 GB in total 1 164 cached
    HLSL over 8 MB (compiled at -O0, dxc.rs) 6 44 430 – 88 863 9.9 – 31.0 MB each three cached: 14.1, 29.6 and 29.8 MB
    • The three cached ones are records 22 616 – 22 618 of the pack: exactly where --precompile --only cs --pipelines stops advancing on the RTX 4080, 4090 and 5080 (Shaders: save offline compute pipelines to the runtime driver cache #744). DXC finishes them; it is the driver that is then handed a 14 – 30 MB DXIL and does not come back (33 minutes on one thread and still growing past 14 GB when I stopped it).
    • At -O0 the DXIL is 0.92 – 0.96 of the HLSL size. For everything compiled with optimisation it is 0.27 – 0.28 (median, 1 161 programs). So these programs are about 3.4 times bigger than they would be optimised, on top of being the biggest sources.
    • The other 1 525 uncached programs are all after record 22 989: not reached, not failed. Their largest are 5.3 – 10.4 MB of HLSL (19 600 – 46 700 instructions).

    What the split wave64 form and the memory windows cost in source

    HLSL, all 2 689 programs ratio per program
    native wave64 form, 4 windows 3.82 GB –
    split wave64 form, 4 windows 3.83 GB 1.05 median, 1.10 at the 90th percentile, 1.12 max (the 1 208 wave64 programs)
    split form, 1 window 3.47 GB 4 windows cost 1.12 median, 1.27 at the 90th percentile, 1.36 max
    • The split form adds about 5 % of source; the memory-window switch adds 12 – 36 %. Neither is where the size comes from.
    • The size is per instruction: about 240 bytes of HLSL per RDNA2 instruction (median over programs of more than 2 000 instructions), plus a fixed ~45 KB per program (the 50 smallest programs: 14 instructions and 47 KB median).
    • Translation itself is not a cost: 84 s for all 2 689 programs on 8 threads, in either form.

    Read (inference): on 32-lane and 64-lane GPUs alike, what DXC and the driver are given is roughly 240 bytes of source and 65 bytes of DXIL per console instruction; a program of 20 000 instructions is 5 MB of HLSL and 1.2 MB of DXIL however EXEC is handled. The -O0 threshold then makes the six largest programs worse instead of safer for the driver.

    Next from me (trimmed so it does not repeat others' parts): DXC time with and without the comments and indentation, -O1 against -O3 under 8 MB, and the NVIDIA Windows driver's compile time against DXIL size from the title runs I already have. Not from me: -O0 / -O1 on the six largest and RADV driver times (@frozht), the direct backend (@gefydev), the synthetic benchmark (@BetterJdue).

    AI use: Claude Code (Claude Fable 5.2) wrote the measurement, ran it and wrote this.


    Update: where the HLSL bytes go (same 2 689 programs in the split form; the split by the emitter's // pc: mnemonic lines is @upipibi's idea from the comment below. I wrote my own script along those lines rather than run theirs, so any error in the numbers is mine.)

    part of the source MB share
    prelude, before main 111.5 2.9 % (41.5 KB per program)
    main before the first instruction (register loads) 11.1 0.3 %
    main, the instructions 3 703.5 96.8 % (238 bytes per instruction, 15 588 842 instructions)

    Inside main, counting the matched text itself:

    MB share of all HLSL
    leading indentation 1 175.0 30.7 %
    comment lines (one // pc: mnemonic operands per instruction) 958.0 25.0 %
    64-bit address and memory-window lines (…_ea = …, xcl_w = …) 324.8 8.5 % (2 502 663 lines)
    the exec select wrapper, both forms: select(lanebit(exec_lo, exec_hi), in wave64 programs and select((((exec_lo >> lane_id) & 1u) != 0u), in wave32 ones 398.2 10.4 % (9 211 332 uses: 712 377 + 8 498 955)
    pc dispatch lines 6.8 0.2 %
    cross-half exchange calls 1.4 0.04 % (95 375)

    By opcode group:

    group instructions MB share bytes per instruction
    VALU other than compares 9 447 630 1 764.2 46.1 % 187
    scalar other than loads and branches 3 925 320 928.8 24.3 % 237
    s_load_* 528 223 363.8 9.5 % 689
    buffer_* / global_* / flat_* 257 595 291.1 7.6 % 1 130
    v_cmp* 735 088 179.3 4.7 % 244
    image_* 149 724 106.6 2.8 % 712
    branches 528 028 64.8 1.7 % 123

    The single opcodes on top: v_mul_legacy_f32 431 MB (2.1 M uses, 204 bytes each), s_load_dwordx4 259 MB (635 each), v_fmac_f32 230 MB, v_fma_f32 184 MB, s_buffer_load_dword 158 MB (796 each), s_buffer_load_dwordx4 131 MB (951 each).

    What follows from this:

    • More than half of what DXC is handed is indentation and comments (55.7 %). That does not reach the DXIL, so what it costs is DXC's front end; I am timing the same programs with and without it now.
    • The -O1 and -O0 thresholds in dxc.rs are on the source length, comments and indentation included. A program at the 8 MB -O0 limit has about 3.5 MB of code. The six programs over it are 44 000 – 89 000 instructions. -O0 against -O1 for those six is @frozht's part 2 above, so I leave it to them and time only programs under 8 MB.
    • The exec select wrapper, the thing "skipping EXEC emulation" would remove from the source, is 10.4 % of it: 9.21 M selects for 9.45 M VALU instructions other than compares, i.e. practically every vector write. (Corrected: I first wrote 0.6 % and 712 377, because my pattern matched only the wave64 form of the guard; @ASThome00 pointed out below that wave32 programs spell it differently. What it costs after optimisation I still cannot tell from source size.)
  5. ofc0urse commented on Nov 24, 2026

    @ofc0urse
    Contributor

    A data point for the largest programs, from a 32-lane NVIDIA card with 8 GB (RTX 4060 Ti, driver 32.0.16.2124, i5-14400F, 32 GB RAM, retail 1.0.2.1).

    On this machine those programs do more than make the load slow: they end the run. In the world load, a few compute programs of about 1 MB of DXIL took 60 to 97 s each in the driver, and process commit went from about 31 GB to 84.7 GB until Windows ran out of commit (numbers in #560 (comment)).

    With a local patch that is not meant for upstream (compute programs of 768 KB of DXIL or more get the fallback CS instead of the driver's compile, XCL_SKIP_CS_KB=768), 11 programs are refused per run, commit stays flat at about 31 GB, and the title gets through the world load. Today, with #640 and #1252 on top, that is far enough to draw world geometry on this card. So for an 8 GB NVIDIA machine, what happens to those few programs decides whether the world loads at all.

    I have not measured which of them are among the six over 8 MB of HLSL in your table.

    AI use: Claude Code (Claude Opus 5.5) ran the runs and wrote this.

  6. frozht commented on Nov 24, 2026

    @frozht
    Contributor

    Plan from our side, to complement @throny's numbers on AMD rather than repeat them: measurements first, no code yet.

    Setup: RX 7900 XT (RDNA3, native 64-lane waves), RADV (Mesa 26.2.6), vkd3d-proton under Wine 11.22 Staging, Ryzen 9 5900X, main 47efa2e. On a retail title, the stall that ends our runs is compute pipelines built on the game's threads at a loading fade: about 240 compute PSOs, the large ones (150–533 KB DXIL) taking 3.8–12 s each in vkd3d-proton plus RADV, so this issue is our blocker too.

    What I will post here, from the xcl shaders CLI and the title's own pipeline cache (no game runs):

    1. Driver compile time against DXIL size on RADV for the compute programs the title builds at that fade, i.e. part 4 of the plan above on AMD. That includes host memory per compile, to see whether the ~1 MB DXIL programs that exhaust commit on @ofc0urse's 8 GB card cost the same on RADV.
    2. -O0 against -O1 for the programs whose HLSL is over 8 MB (the ones that compile at -O0 in dxc.rs): DXC time, DXIL size, and RADV's compile time on each result.
    3. -O1 against -O3 for a sample in the 1–8 MB range, judged by the driver's compile time as well as DXC's.

    Counts and timings only, no shader names or code. If (2) shows -O1 is better on both vendors, a small PR to drop the -O0 fallback would be the natural follow-up; I will propose it here before writing it.

    AI use: Claude Code (Claude Opus 5.5) wrote this plan and will run the measurements and write the reports.

  7. Mortaal339 commented on Nov 24, 2026

    @Mortaal339

    Hey! I’m not a dev or anything, but I’d really love to help out with XCL.

    Here’s my PC setup:
    • Ryzen 5 5600X
    • RTX 3060 OC 12GB
    • 16GB RAM
    • Windows 11

    I was wondering if you guys could use an extra pair of hands for testing, finding bugs or collecting performance data.

    I’m down to help out however I can, even though I don’t know how to code. Really appreciate the work you guys are putting into this project. Keep it up

  8. gefydev commented on Nov 24, 2026

    @gefydev
    Contributor

    The direct DXIL backend's progress report has moved to the bottom of the thread, where it is edited in place from now on: #1269 (comment)

  9. upipibi commented on Nov 24, 2026

    @upipibi
    Contributor

    @throny a tool for the next step of your plan, if it helps. You found about 240 bytes of HLSL per console instruction. This script splits that by opcode and by construct, using the // pc: mnemonic line the emitter writes before every instruction. Run it over a folder from xcl shaders <pack> --recomp with XCL_DUMP_HLSL=<dir> XCL_DUMP_EVERY=1. It prints counts and byte totals only, nothing of the programs. It uses only the standard library: python -I hlsl_bytes.py <dir> --top 30.

    It reports:

    • prelude vs main bytes, and bytes per instruction;
    • the share of the exec selects (select(lanebit(exec_lo, exec_hi), …), one per VALU write), comment lines (gone in DXIL, so DXC parse time only), cross-half exchanges, loop guards and memory-window switches;
    • the opcodes that cost the most HLSL in total, with count and bytes per instruction.

    On a hand-built 19-instruction program it gives 110–160 bytes per VALU or store. In this form an exec select costs about 30 bytes per write, and lanebit is recomputed at every write. Which opcodes reach the 240-byte average in real programs (my guess is buffer and image accesses with their bounds and window code) is what the top-30 table would show, and that is where a size cut would pay.

    hlsl_bytes.py
    """Where the HLSL of translated console programs goes: bytes per RDNA2 opcode and per
    construct, over a folder of `XCL_DUMP_HLSL` files (`xcl shaders <pack> --recomp` with
    `XCL_DUMP_HLSL=<dir> XCL_DUMP_EVERY=1`). Prints counts only, nothing of the programs.
    
        python -I hlsl_bytes.py <dump folder> [--top 30]
    """
    import collections
    import os
    import re
    import sys
    
    INST = re.compile(r"^\s*// ([0-9a-f]{4,}): (\S+)", re.M)
    CONSTRUCTS = {
        "exec select `select(lanebit(exec_lo, exec_hi), ...)`": re.compile(r"select\(lanebit\(exec_lo, exec_hi\), "),
        "exec test `lanebit(exec_lo, exec_hi)` (all uses)": re.compile(r"lanebit\(exec_lo, exec_hi\)"),
        "comment lines (all; gone in DXIL)": re.compile(r"^\s*//[^\n]*\n", re.M),
        "cross-half exchanges `xcl_x_*(`": re.compile(r"xcl_x_[a-z_]+\("),
        "loop guards": re.compile(r"if \(xcl_budget == 0u\) break; xcl_budget--;"),
        "memory-window switches `xcl_w`": re.compile(r"\bxcl_w\b[^;\n]*;"),
    }
    
    
    def main():
        args = sys.argv[1:]
        top = 30
        if "--top" in args:
            i = args.index("--top")
            top = int(args[i + 1])
            del args[i:i + 2]
        folder = args[0]
        per_op = collections.defaultdict(lambda: [0, 0])  # mnemonic -> [count, bytes]
        construct = collections.Counter()
        total = prelude = body = files = insts = 0
        for name in sorted(os.listdir(folder)):
            if not name.endswith(".hlsl"):
                continue
            text = open(os.path.join(folder, name), encoding="utf-8", errors="replace").read()
            files += 1
            total += len(text)
            marks = list(INST.finditer(text))
            if not marks:
                prelude += len(text)
                continue
            start = text.rfind("\n", 0, marks[0].start()) + 1
            main_at = text.rfind("void main", 0, start)
            prelude += main_at if main_at >= 0 else start
            body += len(text) - (main_at if main_at >= 0 else start)
            for k, m in enumerate(marks):
                end = marks[k + 1].start() if k + 1 < len(marks) else len(text)
                op = per_op[m.group(2)]
                op[0] += 1
                op[1] += end - m.start()
                insts += 1
            for label, rx in CONSTRUCTS.items():
                for hit in rx.finditer(text):
                    construct[label] += 1 if label.startswith("exec test") else len(hit.group(0))
        if not files:
            sys.exit("no .hlsl files in " + folder)
        print(f"{files} programs, {insts} instructions, {total / 1e6:.1f} MB of HLSL")
        print(f"before main (prelude, declarations): {prelude / 1e6:.1f} MB ({100 * prelude / total:.0f} %)")
        print(f"main: {body / 1e6:.1f} MB ({100 * body / total:.0f} %), {body / max(insts, 1):.0f} bytes per instruction")
        print()
        print("constructs (bytes of the construct's own text; the exec test is a count):")
        for label, v in construct.most_common():
            print(f"  {label}: {v:,}" + ("" if label.startswith("exec test") else f" bytes ({100 * v / total:.1f} %)"))
        print()
        print(f"top {top} opcodes by HLSL bytes (from their `// pc:` line to the next):")
        print(f"  {'opcode':<28} {'count':>10} {'bytes':>14} {'share':>7} {'per inst':>9}")
        for op, (n, b) in sorted(per_op.items(), key=lambda kv: -kv[1][1])[:top]:
            print(f"  {op:<28} {n:>10,} {b:>14,} {100 * b / total:>6.1f}% {b / n:>9.0f}")
    
    
    if __name__ == "__main__":
        main()

    AI-assisted (Claude Code); tried only on my own hand-built programs.

  10. brainhay5 commented on Nov 24, 2026

    @brainhay5

    A data point that may separate two failure modes. main 47efa2e, retail 1.0.2.1.

    Hardware: RTX 5070 Ti (Blackwell, 15,997 MiB VRAM), Ryzen 7 5800X3D, 64 GB RAM, Windows 11 22631, driver 32.0.16.1088, DXC 1.9.2602.17. 32-lane waves.

    Pack statistics (xcl shaders shaders.rpf --top 8, 4.5 s):

    RPF9 package 392.6 MB, 26,503 shader records
    stages: PS 12101, MS 9282, CS 2689, VS 2236, GS 195
    RDNA2 instructions: 44,422,713, undecoded dwords 0 (0.0000%)
    top: v_mul_legacy_f32 13.44%, v_fmac_f32 9.46%, s_waitcnt 5.58%,
         v_fma_f32 5.37%, v_mov_b32 4.77%
    

    The pool stalls without any memory pressure. During a world load, XCL's overlay at 95 s:

    0.0 FPS | compiling shaders: 0 running, 3 done, 57516 pipelines queued
    

    and the thread dump has xcl-pso-5 … xcl-pso-14 all in ntdll.dll+0xa49f4 (a wait), none in DXC. Process commit stays around 14 GB and flat — nothing like the 84.7 GB @ofc0urse measured on the 8 GB card.

    So on this machine the few large programs do not exhaust commit; the workers simply never come back. That fits their conclusion from the other side: the same programs, blocked, with enough RAM to hide the symptom. If that is right, a fix that keeps those compiles off the title's threads (or bounds them) would show up here as the queue starting to drain, not as a memory change — and that is easy to measure.

    Offering: I have the title and a 4-minute build/run loop on this card. Happy to run any of these if useful — driver compile time for the specific large programs, -O0 vs -O1 vs -O3 on them on a 16 GB Blackwell card, or a patch that caps/refuses the oversized ones to see whether the queue drains (0 running → anything) and whether the world load completes. Counts and timings only.

    AI use: OpenCode, DeepSeek V4.1 Flash 1017.

  11. Sr-0w commented on Nov 24, 2026

    @Sr-0w
    Contributor

    AMD on Windows (native 64-lane waves): where the world-load stall comes from, and one result that matters for the direct backend

    Setup: RX 7800 XT (RDNA3, native wave64), AMD driver on Windows 11, 64 GB RAM, DXC 1.9.2602.17. main b8b1f49 + #889 + #570 + #680 (XCL_HEAP_WINDOWS=1), retail 1.0.2.1. Counts and timings only.

    1. The stall is compile throughput, not something else. Runs hold ~30 fps to about 70 s into the world load, fall to 7–8 fps, and the title's watchdog fires at 145–166 s. With XCL_PSO_WAIT_MS=5000 it still fires (166 s; 89 dispatches skipped). Thread stacks at the watchdog: 5 of the title's threads, the render submission thread among them, wait in pso_async::resolve_within ← resolve_for_bind ← bind::set_pipeline_state / execute_indirect. 3 xcl-pso workers wait for DXC (dxc::compile) and 3 are inside amdxc64.dll. No title thread is anywhere else.

    2. DXC costs as much as the driver. One compute program of the size the world load builds (≈21 000 instructions, 5.7 MB HLSL, 4 heap windows, structured): DXC 23.6 s (-O1), 1 042 KB DXIL, then 30.2 s in the AMD driver. In two title runs the slowest driver builds were 850 KB DXIL in 64 s, 1 094 KB in 29.6 s, 975 KB in 26.2 s, 727 KB in 21.7 s. The driver blob cache across runs works (those come back in 2–9 ms the next run), but every run reaches programs it has not built yet.

    3. On this driver, removing the guards makes the driver slower. Same program, one variant of the emitted HLSL at a time, each a distinct program so the driver's disk cache does not answer:

    variant DXIL DXC AMD driver
    as emitted 1 042 KB 23.6 s 30.2 s
    window index without NonUniformResourceIndex 1 042 KB 23.4 s 48.4 s
    window buffer not globallycoherent 1 042 KB 23.6 s 28.4 s
    no xcl_w >= 4 guard 922 KB 19.8 s 32.1 s
    no exec select on vector writes 896 KB 19.0 s 45.0 s

    Read (inference): on AMD Windows the gain of a direct backend should come mostly from not running DXC at all (the 23.6 s, and the workers queued behind it), not from fewer guards; a program with fewer guards was not cheaper for this driver. @gefydev this may be worth measuring on the driver side before turning the new path on by default.

    What I can take on. I have what the direct backend's checklist cannot be tested on elsewhere so far: native 64-lane waves and the full title. Two offers, whichever helps, after you agree, so nothing is done twice:

    • the wave operations item for native wave64 (with GPU tests run through both paths on this card);
    • running your branch on the full title on AMD as soon as it is pushed, with DXC / driver times and the run's outcome.

    AI use: Claude Code (Claude Opus 5.5) ran the measurements and wrote this.

  12. ofc0urse commented on Nov 24, 2026

    @ofc0urse
    Contributor

    @brainhay5 the first mode shows up on the 8 GB card too, so I think your split holds. From a thread dump at 600 s in a world load last night (an older local build: main 508a0c7 plus #690 and local patches, so not today's main): a title thread was in pso_async::resolve_wait (via bind::graphics_bound) waiting for a graphics pipeline, while all 15 xcl-pso workers were idle and one xcl-dxc thread was inside dxcompiler on a ~25 MB DXIL compute program. That wait cleared by about 1000 s, so it was slow rather than stuck. On this card both modes happen in the same run: the idle workers, and the commit growth when the driver gets the largest programs.

    AI use: Claude Code (Claude Opus 5.5) read the old dump and wrote this.

  13. vitor127wt commented on Nov 24, 2026

    @vitor127wt

    Cold compute pipeline timings on Linux — RTX 5070 Ti

    I tested both memory-window modes of #680 at 95f34c1 with the synthetic nv680 split-wave64 compute probe. Each row is the median of three paired seeds. DXC used -O1, and each pipeline was created in a fresh Wine process with the vkd3d-proton and NVIDIA disk caches disabled. All 12 PSOs were created successfully.

    Rounds per shader DXC, switch → heap DXIL, switch → heap PSO creation, switch → heap
    250 0.60 → 0.50 s 147 → 98 KiB 3.38 → 2.98 s
    500 1.60 → 1.20 s 294 → 196 KiB 21.13 → 26.74 s

    At 500 rounds the heap form produced one-third less DXIL and spent 27% longer in CreateComputePipelineState on vkd3d-proton 3.1.0. For the direct-DXIL work, this is a concrete case for timing cold PSO creation separately and comparing more than one shader size. The comparison here uses the current HLSL-to-DXIL path and synthetic shaders. Full test report and commands

    Follow-up with the same DXIL

    On the same RTX 5070 Ti and driver, changing vkd3d-proton reversed the result for the larger sample. These are 500-round medians across two paired seeds, with cold caches. The DXIL files were identical across builds. Upstream build

    vkd3d-proton D3D12 PSO creation, switch → heap Vulkan pipeline feedback, switch → heap
    3.1.0 (4522cc1) 21.2 → 24.9 s 7.6 → 8.9 s
    ec207194 (dxil-spirv 7c04863) 17.1 → 1.8 s 15.5 → 1.5 s

    For the direct-DXIL work, record the exact vkd3d-proton revision on Wine and keep DXIL generation, total D3D12 PSO latency, and Vulkan pipeline feedback as separate measurements. Full follow-up, method and CPU samples

    Environment — RTX 5070 Ti (16,303 MiB), NVIDIA Linux driver 620.73.04, Ryzen 7 9700X, 30 GiB RAM visible to Linux, CachyOS kernel 7.3.5-2-cachyos, Wine 11.22, DXVK v2.7.1-498-ga6764047e587178, vkd3d-proton 3.1.0 (4522cc1a8b1347f), DXC 1.9.2609.5, Rust 1.100.0 (Windows MSVC debug cross-build).

    Read-select windows on the RTX 5070 Ti

    I reproduced the read-select idea locally from pr1sm-dev's description. The four root UAVs stay bound. Each read uses its actual offset in the selected window and offset zero in the other three, then selects the value. An invalid window returns zero. Stores and atomics retain the switch. Original experiment

    For compilation, I reused the synthetic split-wave64 HLSL from the #680 95f34c1 benchmark above, with two seeds per size. I compared switch, #680 heap, and a local HLSL transformation; the four-window inputs otherwise match. Native DXC 1.9.2609.5 used -E main -T cs_6_6 -HV 2021 -O1. Each nv680 create <shader.dxil> ran in a fresh Wine process on vkd3d-proton ec20719452e916b (dxil-spirv 7c04863), with VKD3D_SHADER_CACHE_PATH=0, __GL_SHADER_DISK_CACHE=0 and VKD3D_CONFIG=pipeline_library_log. All 12 PSOs were created successfully and Vulkan feedback reported no cache reuse.

    Rounds Form DXC wall DXIL bytes D3D12 PSO Vulkan feedback
    250 Switch 0.53–0.54 s 150,920 3.42–3.44 s 3.07–3.09 s
    250 Heap 0.39 s 101,120–101,124 0.63–0.67 s 0.56–0.59 s
    250 Read-select 0.53–0.58 s 161,516 1.71 s 1.49–1.50 s
    500 Switch 1.38–1.39 s 301,100–301,104 17.30–20.31 s 15.79–18.75 s
    500 Heap 0.97–0.98 s 201,208–201,212 1.85–1.89 s 1.54–1.57 s
    500 Read-select 1.39 s 322,956–322,960 5.72–5.78 s 4.77–4.83 s

    For execution I used a separate SM 6.6 wave32 shader, with four non-overlapping buffer regions and a dependent scalar read in each iteration. Each dispatch used 64 groups of 128 threads and 512 reads per lane. The CPU reference matched all 8,192 output words in all three modes with wave-uniform and wave-divergent window selection, and in a separate 17-iteration check that includes out-of-range IDs. Memory outside the output region was unchanged.

    Form Uniform window, ms/dispatch Divergent window, ms/dispatch
    Switch 0.123 0.164
    Heap 0.112 0.104
    Read-select 0.114 0.276

    These are medians of three 64-dispatch batches per mode and pattern, with rotated order. I timed submission to fence completion and divided by 64. That interval includes the GPU buffer copies, UAV barriers, and queue/fence overhead. I discarded the D3D12 timestamps because their intervals did not scale reliably with the batch size on this stack. In this divergent workload, read-select cost about 69% more per dispatch than the switch, even though its cold PSOs built sooner. This dispatch test covers scalar loads on synthetic data.

    Same Ryzen 7 9700X, RTX 5070 Ti and driver 620.73.04, Wine 11.22 and CachyOS kernel 7.3.5-2-cachyos. The dispatch helper was a Windows MSVC release cross-build based on #680 95f34c1d1a24f644d0c4895810a7c36910b123e8 with local changes to bind the four regions and wait on the fence.

    AI use — Codex (GPT-6, exact variant unavailable) ran the cross-build, measurements and profiling and drafted the report. Codex also reproduced the read-select accessor and ran the timed dispatch checks.

  14. GreemSC commented on Nov 24, 2026

    @GreemSC

    Numbers from AMD on Linux (RADV), on today's main and with 16 GB of RAM. @frozht is on the same GPU and driver with main 47efa2e and is doing the per-program RADV driver times (their part 1), so I leave that to them. What follows is what changed between 384f7f7 and 930e8b4, which their runs and @Sr-0w's (b8b1f49) do not cover. Counts and timings only.

    Setup: RX 7900 XT (RDNA3, wave64), Mesa RADV 26.2.5, i7-12700K, 16 GB RAM, CachyOS, Proton-CachyOS Wine, vkd3d-proton 0bb64c5 rebuilt with dxil-spirv 53aac41 (the #611 fix that #775 carries). Retail title, same scripted run each time (A every 4 s from 22 s, 240 s), XCL_PSO_PRELOAD=0.
    XCL main 930e8b4 against main 384f7f7, both with the same local patches: #871, #684 and the sparse.rs part of #203. 2 runs on 384f7f7, 3 on 930e8b4 (1 with a cold cache, because b8b1f49 translates the shaders again, and 2 warm).

    1. On a 16 GB machine, 9a272d4 + 25c6f7e remove a DXC stall that comes before the driver one.

    • On 384f7f7, world loading stopped with the title waiting for 5 xcl-dxc threads: one was compiling and the others were in the wait_for_memory queue. With 16 GB, less than 6 GB of commit is free at that point.
    • On 930e8b4, the DXC queue is empty when the run stops (1–2 of 19 DXC workers busy, at most 2 PSO workers busy). The title also reaches more of the load: 244–260 compute pipelines in the warm runs, against 142–185 before.

    2. Behind it is the stall @frozht describes: the title's own thread builds big compute pipelines in RADV.

    • In each 930e8b4 run, one or more of the title's threads are inside build_compute → finish_pso → RADV when the run stops.
    • Example, one title thread back to back: 522 KB of DXIL in 11.2 s, 262 KB in 5.8 s, 234 KB in 4.8 s, then a next one still building at the stop. No frame is presented during these builds.
    • The title's hang watchdog (+0x23cf683) fires about 28–30 s after the last frame. With 930e8b4 the title gets to that stall sooner: at 158 s (cold run), 136 s and 134 s, against 185 s and 188 s on 384f7f7.
    • Peak RAM + swap of the game: ~12 GB.

    3. b8b1f49 shows no visible change in RADV's time per KB. These are from the compute PSO … (N B DXIL, T ms) lines; builds that reused a driver blob are left out.

    DXIL size 384f7f7: n, median, max 930e8b4 warm: n, median, max
    128–256 KB 17, 1.1 s, 4.3 s 7, 1.0 s, 5.8 s
    256–512 KB 3, 3.1 s, 3.8 s 5, 2.8 s, 11.2 s
    ≥ 512 KB — 1, 7.1 s, 7.1 s
    • That is about 7–10 ms per KB above 128 KB, on both commits. b8b1f49 reports 95 s → 6 s for a Windows AMD driver; I do not see a change of that kind on RADV.
    • These are not the same programs on both sides, though: this is not a per-program comparison.
    • On 384f7f7, the time logged for a big build also includes its wait for the big-build slot (fixed in 25c6f7e). Those builds are few (3 at 256–512 KB).
    • The longest RADV build I saw was 11.2 s. These runs did not reach the ~1 MB programs.

    Not tested: Windows, other AMD generations, a per-program before/after comparison (same DXIL hash on both commits), and xcl shaders --precompile --pipelines under Wine.

    AI use: Claude Code (Claude Opus 5.5) ran the measurements and wrote this report. I checked it before posting.

  15. itsd-effex commented on Nov 24, 2026

    @itsd-effex

    Linux / NVIDIA (vkd3d-proton) numbers for this issue: where a compute pipeline's compile time goes, what b8b1f49 did to xcl pipelines, and the three screen-probe programs under Wine. Measurements only, no code.

    Setup: RTX 3080 Ti 12 GB, NVIDIA 620.73.04 (Linux), i7-11700KF (8 cores / 16 threads), 32 GB RAM + 36 GB swap, CachyOS. Proton Experimental's Wine. vkd3d-proton master ec207194 (dxil-spirv 7c04863, which has dxil-spirv #371) with #257's patch. DXC 1.9.2609.5. Release, x86_64-pc-windows-msvc. Retail 1.0.2.1's journal (pipelines.bin, 58 745 pipelines: 56 011 graphics, 2 734 compute) and xcl pipelines (#759) under Wine, in a cgroup capped at 25 GB RAM + 32 GB swap.

    1. Where the CPU time goes. perf record -F 199 on the xcl pipelines process for 30 s, 12 driver compiles and the DXC workers busy, about 83 500 samples. Tree: main 930e8b4 + #688 + #759 + #684. This was ordinary 0.1–1 MB compute programs, none of the three below.

    module all samples of the driver-compile (xcl-warm-*) threads
    NVIDIA's compiler back end (libnvidia-gpucomp.so) 56.5 % ~88 %
    NVIDIA's SPIR-V front end (libnvidia-glvkspirv.so) 3.2 % ~5 %
    libc (allocator) 2.9 % ~4.5 %
    vkd3d-proton incl. dxil-spirv (d3d12core.dll) 1.3 % ~2 %
    DXC (dxcompiler.dll, on the xcl-dxc-* threads; Wine maps it anonymously, so perf shows [JIT]) 35.9 % –

    So on Linux, with dxil-spirv #371, translating DXIL to SPIR-V is a small share. As on Windows, the time is in NVIDIA's compiler back end, so a smaller or simpler DXIL should help Linux about as much as Windows. DXC was the other third here, because b8b1f49 changed many programs and their DXIL was compiled again.

    2. b8b1f49 on this machine, measured as xcl pipelines throughput on the same journal's compute part. Not a controlled A/B: the settings were tuned between runs, and the set of programs left differs a little.

    3. The three screen-probe programs under Wine. These are the ones @throny and @bstillbstill found at records 22 616–22 618: console CS 56c0cd3b82a00c6e (ActivateProbes, 29.75 MB DXIL), 958400d2caf07244 (ActivateProbesTarget, 29.6 MB) and 95cc13288a27a96e (ActivateRays, 14.1 MB), on 930e8b4. In this journal exactly one pipeline uses each.

    • When xcl pipelines reached them, the process went from 25 GB RAM + 5.8 GB swap to 25 GB + 26.5 GB in about a minute. I stopped it there.
    • With only ActivateProbes skipped (marked done) and the other two still in the batch, it passed 17 GB of swap within 40 s of the restart.
    • With all three marked done, the same run continued at 11.9 GB and no swap.

    I didn't isolate a single one of them, so this is the three together, plus 9–11 ordinary compiles beside them. But on this stack they grow memory far faster than the 4.6 GB in 14 min @bstillbstill measured for ActivateRays with the Windows driver. On a 32 GB Linux machine they end a precompile pass within a minute or two, and the same would happen in a title run that starts one. I haven't profiled which module grows: NVIDIA's compiler or dxil-spirv (whose thread allocator frees nothing until a conversion ends, #611).

    Not tested: Windows on this card. The three programs one at a time. #1278 / #1279. A title run on 930e8b4 (next, with and without #1288 + #1278).

    AI use: Claude Code (Claude Opus 5.5) ran the builds, xcl pipelines, perf and the memory measurements, and wrote this comment. The runs are mine, on the hardware above.

  16. 849 remaining items

  17. upipibi commented on Nov 25, 2026

    @upipibi
    Contributor

    @throny On your question of whether XCL keeps pages for textures the title is done with: yes, as long as the texture object is alive. This is from the code, with one synthetic measurement. It could account for part of the 5.1 → 9.9 GB target pages growth in your table if the title keeps the texture objects (not checked; edited, I first wrote that it explains part of it), and not for the removal, which your 11:15 run already rules out as the cause on its own.

    From the code (main 426a5a74):

    • A placed title texture's video-memory pages are freed only when the texture resource's last Release runs (hle/d3d12x/real.rs:1691). A title freeing or decommitting the memory under a texture it still holds (kernelx VirtualFree, kernelx.rs:471) never reaches the texture-page code.
    • Sparse-window tiles do follow the title's decommits.
    • Freeing part of a physical-page block keeps every page of the block until its last page is freed (kernelx.rs:1312).
    • XCL reads QueryVideoMemoryInfo only to log it. Nothing evicts, offers or changes residency when the budget is exceeded.

    Measured (synthetic test, RTX 3070 8 GB, not pushed): 16 placed RGBA8 4096×4096 textures (1 GiB) over title memory, local CurrentUsage:

    step local in use
    before 15 MB
    textures created and backed 1046 MB
    title memory under them decommitted (VirtualFree), objects kept, 6 s of refresh ticks 1046 MB
    texture objects released 86 MB (one 64 MiB pool kept)

    So a title that frees the memory but keeps (or leaks) the texture objects keeps the video memory too. Whether the title does that during the world load, I can't tell without it. The test is a ~110-line #[ignore] patch to title_textures.rs if you want to run it.

    AI-assisted (Claude Code). Synthetic tests only.

  18. claudetools-gh commented on Nov 25, 2026

    @claudetools-gh

    @throny a third 16 GB NVIDIA data point for the budget question, agreeing with your correction: here the device stayed up for two minutes at up to 4.3 GB over the budget, so the removal is not the crossing itself.

    Setup: RTX 5070 Ti 16 GB, Ryzen 7 9700X, 62 GB RAM, Windows 11 Pro 26300, release. #2057 4df1e6e + treybertram06's upload wait + #2092 / #541 / #1803 / #1887 + a 2 s QueryVideoMemoryInfo log. XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=0 XCL_WATCH_HOT=0 XCL_NETWORK=0, warm caches (no driver compile without a blob in the run), one run.

    time local in use local budget
    29–59 s 6.2 GB 15.2 GB
    89 s 7.3 GB 15.2 GB
    115 s 15.2 GB → over 15.0 GB
    147 s 18.5 GB 15.0 GB
    177–237 s 19.2–19.3 GB 14.8–15.0 GB
    240.4 s device removed (0x887a0005)
    • Non-local stayed at 4.1–5.0 GB of 46 GB throughout.
    • The only warnings in the last seconds are the sparse windows' no video memory for more tiles, and they already carry 0x887a0005 as the reason, so they follow the removal rather than cause it.
    • No would close a GPU cycle line in this run (0 cycle breaks).
    • The removal point moves with how fast the title gets through the load, not with time: on the same machine and tree it came at 131 s with XCL_PSO_WAIT_MS=50 XCL_HUGE_PSO_CONCURRENCY=4 (fewer stalls on pipeline builds) and at 285–418 s with the title waiting on its builds.

    Not tested: more than one run with the log; XCL_TEXTURE_PAGES_SYSTEM_MEMORY (#1702 is not on this tree); AMD.

    AI-assisted.

  19. throny commented on Nov 25, 2026

    @throny
    Collaborator

    NVIDIA, D3D12 debug layer on the world load (split off + #2163, RTX 4080, removed at 92.1 s as usual). Also: no nvlddmkm Xid and no TDR event in the System log for any of today's removals, so this doesn't look like a GPU fault or a timeout. The runtime or driver removes the device.

    With #2163 the resubmit error (553) is gone. Three errors remain. I logged each id's 1st–8th message and then each power of two, so the times show the rate:

    id count reached at
    1047 UpdateTileMappings: the buffer is still written in flight on another queue (#262) 8 at 8.9 s, 128 at 9.9 s, 256 at 58.6 s, 512 at 60.9 s, 1024 at 81.5 s, 2048 at 82.0 s, 4096 at 83.1 s, 8192 at 84.7 s, 16384 at 85.9 s
    1422 RT/DS on a CREATE_NOT_ZEROED heap used before a Clear/Discard/Copy 3 before 21 s, then 4→8 at 81.0 s, 16 at 82.0 s, 32 at 82.0 s
    538 ClearRenderTargetView on a resource in UNORDERED_ACCESS state 17 lines, the last at 56 s; none near the stop

    So in the ~10 s before every stop, the sparse windows remap tiles of a buffer that another queue is still writing, about 3 000 times a second: from ~500 in the first minute to 16 000+ by 86 s. That's the same 1047 as #262, but in the world load it goes from rare to constant right where the device goes. The uninitialised render targets (1422) start in the same second.

    That would also fit @claudetools-gh's "the removal moves with the load, not with time", and the run that ran over budget for two minutes: the remaps come with what the load streams in, not with how full video memory is.

    I haven't tried a fix yet. The cheap test is a sparse-window mapping queue that waits for the title queues' last signals before UpdateTileMappings (#262 says that alone deadlocks), or mapping on the title queue itself.

    AI use: Claude Code (Claude Opus 5.5) ran this and wrote it.

  20. throny commented on Nov 25, 2026

    @throny
    Collaborator

    Follow-up on the 1047s: they're mostly fresh mappings, not remaps, so the lead is weaker than I wrote.

    I ran an experiment switch that never unmaps or reuses a decommitted sparse tile, so UpdateTileMappings only ever maps new tiles. One NVIDIA run, split on, #2163 + #929:

    • The device was still removed, at 98.6 s.
    • The sparse pools grew as in every other run (1.0 GB at 58 s → 2.3 GB at 90 s, nearly all of it mapped).

    So in the world load, the windows mostly add tiles while a title queue writes elsewhere in the same 4 GiB buffer. The debug layer flags that per resource, but it's hardly a hazard on the hardware. On its own it doesn't explain the removal. The 1047 rate is still a good marker of where the load is, but not a cause I can show. (I'll say the same on #262.)

    Still ruled out on NVIDIA, each on its own:

    Next I'll compare with what #2057 changes that gets a 16 GB card to 240 s.

    AI use: Claude Code (Claude Opus 5.5).

  21. clemthohere commented on Nov 25, 2026

    @clemthohere

    NVIDIA cold CreateComputePipelineState, synthetic f32 mul/add chains: most of the direct DXIL form's extra driver time comes from the missing fast flag, and fast changes results (RTX 5080 Laptop)

    This follows up @zhouzhidong3-hash's RTX 5070 numbers (comment). There, direct DXIL's runner wall time was 57.7 ms against 23.0 ms for HLSL at 1024 instructions, and they suggested profiling PSO construction separately. I timed the driver call on its own.

    Setup

    • Hardware: RTX 5080 Laptop GPU 16 GB, driver 621.35, Ryzen 9 8940HX, 16 GB RAM, Windows 11 26300.
    • Build: main 568e7db plus a local test patch (not pushed): ignored tests and a runner::time_create helper. Release build, DXC 1.9.2602.17, no XCL_* variables set.
    • Programs: wave32 kernels in the test runner's kernel mode, with one memory window. Counts and timings only; the programs are synthetic, so no game files, shader names or code are involved. Two families:
      • mul: zhouzhidong's V_MUL_F32-with-literal chains, with the same literals except the first, which is the salt below.
      • muladd: V_MUL_F32 and V_ADD_F32 alternating.
    • Cold builds: the first literal of every build is a salt that was never used before, so each container is new to the driver. Creating the same container a second time takes 0.3–1.3 ms (the warm control), against 39–801 ms cold at the sizes in the table.
    • What is timed: CreateComputePipelineState alone, on the runner's device and root signature. The variants are interleaved in rotating order, with 3 seeds × 4 rounds; the table gives medians of those 12 builds.
    • Repeatability: three separate processes gave mul HLSL and direct medians within about 3 % of each other.
    cold Create ms, median mul 1024 mul 4096 muladd 1024 muladd 4096
    HLSL path (DXC's default: fast on every float op here) 39.5 291 45.5 314
    HLSL path with -Gis (no fast-math) 83.2 747 66.2 446
    direct, #1426 per-instruction form (no flags) 88.7 776 73.2 477
    control: direct disassembled, values named, reassembled by DXC (no other edit) 94.1 795 78.5 497
    control + fast on fmul/fadd 48.9 334 55.5 365
    control + nnan, ninf, nsz or arcp alone 93–94 797–801 77–79 499–501
    • The extra time is the driver build, not GPU work. A warm run (dispatch and readback) takes 3.5–4.7 ms in both forms, from n = 32 to 4096. So on this machine the whole HLSL/direct gap is PSO creation. That fits the wall-time gap zhouzhidong saw, though I didn't check it on their card or driver.
    • Most of the extra time comes from the fast flag; the code shape accounts for the rest.
      • In mul, HLSL with -Gis has the same DXIL instruction count as default HLSL, but it builds 1.4–2.6× slower, within 4–11 % of the direct form.
      • Adding fast cuts 26–58 % off the control, which leaves it 14–24 % above HLSL.
      • By either measure, fast accounts for about 83–94 % of the HLSL/direct gap in mul and 70–81 % in muladd.
      • No other fast-math flag on its own (nnan, ninf, nsz or arcp) helps. In LLVM 3.7, fast is UnsafeAlgebra, which implies those four; I didn't test the four together without it.
      • Folding the direct form's constant bitcast i32 … to float removes 20 % of its instructions (mul), and the time stays within about 2 % (91.4 / 792 ms against its control's 93.5 / 800 ms, in a separate run of 15 builds).
    • fast changes results. In muladd at 1024, lane 0 differs from the flagless form in 11 of 12 programs, by 5 to 28 ULP; the 12th is identical. In mul at 1024 no variant changes lane 0.
      • Default HLSL and control + fast give the same bits as each other, and HLSL with -Gis and plain direct agree bit for bit, 12 of 12. That fits the driver fusing the mul/add pairs once the ops are not precise.
      • At 4096 every variant overflows to inf, so that column says nothing about results.
      • This is the NVIDIA side of what Diskuss (comment, AMD, signed zero), Recompiler: the HLSL backend's fast-math loses -0 in f16 results and changes v_sin/v_cos on AMD #2168 and vakaobr (comment, D3DMetal, reassociated constant multiplies) found with DXC's default fast.
      • The direct form leaves fast-math out on purpose: Lw::fbin passes no flags, and mad_nf relies on that for V_MAD_F32's two roundings. So this is a trade-off between precision and compile time, not a free fix.
    • What this means for comparisons. For f32 mul/add code like this, HLSL with -Gis is the closer baseline for the direct form. Here it changes only the flags: same instructions, and the same bits as direct. It isn't a match in general: -Gis also marks float dx.op calls !dx.precise, and Recompiler: preserve zero sign in HLSL f16 multiplies #2183 reports FMA-family differences with it. The same rows put a price on compiling the HLSL path with -Gis everywhere, as considered for Recompiler: the HLSL backend's fast-math loses -0 in f16 results and changes v_sin/v_cos on AMD #2168: 1.4–2.6× the driver time on these programs.

    Not claimed.

    • Retail programs: they are dominated by memory access, window switches and control flow. On retail programs, the direct form already builds at least as fast as HLSL in the NVIDIA driver: about half the driver time per big pipeline on an RTX 5080 (IvyNotFound, comment), the same on an RTX 2070 SUPER (Ryongen, comment), and 5–35 % faster on an RTX 4090 (Pipodi, comment). These synthetic numbers don't contradict that. They only isolate one factor, and how much of a retail program's driver time it accounts for is unknown.
    • Measuring the ceiling: someone with the pack could do it with a local change, passing super::module::fmf::FAST instead of 0 in Lw::fbin (gpu/dxil/lower.rs:555). That puts fast on every float add, sub, mul and div the direct form emits, including mad_nf, fneg, f16 and f64, which is more than the HLSL path does. It will change results, so it is for measurement only, not something to ship.

    Not tested

    • Retail programs.
    • Compute mode, which is the runtime's ABI, as opposed to the test runner's kernel mode.
    • XCL_PER_LANE, AMD and Intel, and other NVIDIA drivers.
    • The four non-fast flags together, and float ops other than f32 mul/add (f16, f64, fma/mad, dx.op math).
    • The driver's background second compile (D3D12.X: XCL_BACKGROUND_COMPILES=0 stops the driver's second compiles #1552). I left 150–250 ms between builds and rotated the order of the variants.
    • Cross-process repeats of muladd, which ran in one process.
    How the variants were made
    • runner::time_create(dxil) times only ID3D12Device::CreateComputePipelineState with the runner's root signature, then releases the PSO.
    • Direct variants: the gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 container goes through gpu::dxil::validate::disassemble. Unnamed values %N are renamed %vN, so that lines can be dropped, and comments are stripped. The text is then edited (fast-math keywords on fmul/fadd/fsub, or constant bitcasts replaced by float literals). Finally it is reassembled and signed with gpu::recomp::dxil::assemble::assemble, which is DXC's assembler and validator. The unedited reassembly is the control. It is 2–7 % slower than the original container and about twice its size, because of the value names. So compare the flag rows with the control.
    • HLSL variants: translate + dxc::compile(…, "cs_6_6", &[]), or with &["-Gis"].
    • Commands: cargo test --release -p xcl --lib -- <test> --ignored --nocapture --test-threads=1, one process each:
      • local_pso_create_probe: HLSL against direct, warm runs.
      • local_pso_variant_probe: bitcast folding.
      • local_pso_flag_probe: the table.

    AI use: Claude Code (Claude Opus 5.5) wrote the probe, ran the measurements and wrote this comment. Claude Code subagents mapped the thread and checked the draft against the logs.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    goal:world-loadhelp wanted

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions