Skip to content

Tests: per-process temp folders for shader libraries; d3d12_compute skips the CachedPSO host comparison under Wine - #3023

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
Jolymmiles:mac/d3d12-compute-temp-dir-race
Nov 23, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
Jolymmiles:mac/d3d12-compute-temp-dir-race

Conversation

@Jolymmiles

@Jolymmiles Jolymmiles commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #2516 (comment) (d3d12_compute flaky on a Mac under Wine)

What and why

d3d12_compute passed in some full Wine runs on a Mac and failed in others. Two separate causes, neither of them GPU synchronization:

1. Copies running at once shared one temp folder (the flaky part). The test writes its translator-style shader library (an index.json and the .spv) into %TEMP%\leonida_compute_test and deletes that folder at the end. Two copies running at the same time (ctest -j, or two suites in one Wine prefix or one TMPDIR, which happens when several agents test on one Mac) use the same folder, and one copy's remove_all deletes the modules the other is still loading. On 49475796, Apple M3 Max, CrossOver 26.3 (Wine 11) with MoltenVK 1.4.3:

d3d12_compute.exe under Wine before after
one at a time 125/125 pass 60/60 pass
four copies at once 34/40 pass 60/60 pass

The 6 failures were PSO creation (line 245 slot 67, line 357 CreateComputePipelineState), or exit 3 with no message: an uncaught std::filesystem::filesystem_error from copy_file once the other copy had deleted the folder. Nine other tests (d3d12_draw, d3d12_set0_compute, d3d12_msaa_draw, d3d12_fspx_compute, d3d12_pipeline_library, d3d12_subgroup, d3d12_bundle, d3d12_typeless_families, shader_library) used the same fixed-name pattern.

runtime/test/test_temp_dir.h adds testfiles::ScratchDir: <temp>/<name>_<pid>, emptied when created and removed when it goes out of scope, early returns included. testfiles::copy_file copies the compiled-in LEONIDA_TEST_*_SPV files with an error code, so a missing file is now named (cannot copy …: File not found, then the line N: of the check) instead of ending the test in abort(). That silent exit 3 also accounts for an earlier "flaky" full run: a CI artifact was run under Wine by hand without the D: drive its compiled-in D:/a/Leonida/Leonida/… paths need. I confirmed this with the same artifact: exit 3 without D:, and it passes with D: mapped the way run_wine_tests.py maps it. docs/testing.md lists both symptoms.

2. The CachedPSO host comparison failed on every run under Wine (since #1683). After rebasing onto round 40, the test failed every run at line 388: host == layer, on main as well as on this branch. The comparison assumed Wine has no host D3D12 device or no compiler. Wine has both (vkd3d and its d3dcompiler_47), but vkd3d's GetCachedBlob is a stub, so cached_pso_cases returned no answers for either host adapter and the empty list never equals the layer's 11. It now skips under Wine through hostwine::host_is_wine(), like the other host comparisons, and prints why. The layer's own 11 answers are still checked against the expected list, and Windows runs the host comparison as before.

Tested

AI-assisted (Claude Code). Apple M3 Max, macOS 27.3. The Windows build is clang-cl 23.1.6 + xwin 10.0.26100, run under CrossOver 26.3 (Wine 11.0) with MoltenVK 1.4.3 (main 5189f8de). The native build uses Homebrew MoltenVK 1.4.2.

  • Target, on the rebased branch: 60/60 one at a time, 60/60 four at once (15 rounds). Base ec8ec4c9 four at once: 0/40, every run at line 388.
  • A missing .spv (renamed away): cannot copy …cs_user_data.spv to C:\users\crossover\AppData\Local\Temp\leonida_compute_test_32\cs_user_data.spv: File not found. then line 160: …, exit 1. The temp folder is gone afterwards.
  • Full run_wine_tests.py list: base ec8ec4c9 99 pass / 4 fail / 27 skip, branch 100 / 3 / 27. The only change: d3d12_compute FAIL → PASS. The other three failures (d3d12_descriptor, d3d12_uav_clear, d3d12_vulkan_device) fail the same way on both and aren't touched here (d3d12: order timestamp resolves after their writes on MoltenVK #1947 covers d3d12_vulkan_device's timestamp check, line 5467).
  • Native ctest on runtime/build/mac: 34 pass, 2 skip (shader_library_corpus, vk_sync_validation), 1 fail (xdxr_build_check, BVH refit blas_refit_in_place), identical before and after. The failure exists on main and isn't touched here.
  • After the branch runs the prefix's temp directory holds no new folders. The only ones left (leonida_compute_test, leonida_pipeline_library_test) come from the base runs: the base never removes the second one, and a failing run of the first leaves it behind.

Rebased on f847748c (after #3023 conflicted with 0cb7657d, "Find packaged shader fixtures in relocated GPU test artifacts"): the copies now go through both helpers, testfiles::copy_file(vktest::shader_fixture_path(...), ...), and the docs/testing.md row about CI artifacts mentions running from the artifact folder. After the rebase, d3d12_compute under Wine passed 10/10 one at a time and 40/40 four at once (10 rounds), serialized with the other GPU runs on this Mac.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator change.)

🤖 Generated with Claude Code

@evilclanker9000

Copy link
Copy Markdown
Contributor

Tested da6861b on Windows 11, RTX 5080 (driver 616.92) and AMD Radeon iGPU gfx1036 (driver 26.10.1): the ten tests whose sources this PR changes, via ctest -R (shader_library, d3d12_compute, d3d12_fspx_compute, d3d12_set0_compute, d3d12_pipeline_library, d3d12_draw, d3d12_msaa_draw, d3d12_bundle, d3d12_typeless_families, subgroup_size; MSVC, RelWithDebInfo, LEONIDA_VK_DEVICE set per run, device line confirmed, run one at a time) — pass on both, 10/10 each.

  • RTX 5080: 10/10 passed.
  • AMD Radeon (gfx1036): 10/10 passed.
    Not run: the parallel case this PR is about (several of these tests at once under ctest -j), since I only run one GPU job at a time on this machine; so the per-process temp folders are only checked as far as the sequential runs go.

AI-assisted.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested da6861b on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:

  • Full ctest: 130/130.
  • d3d12_bundle, d3d12_compute, d3d12_draw, d3d12_fspx_compute, d3d12_msaa_draw and d3d12_pipeline_library: pass 20 of 20 runs, and pass under LEONIDA_VK_VALIDATION=1 with 0 validation messages.
  • Warnings: none new from this PR (the fopen C4996 in d3d12_bundle_test.cpp is already on main).

AI-assisted (Claude Code).

@daemosofchaos

Copy link
Copy Markdown
Contributor

Independent Windows 11 26300 / MSVC 19.52 / RTX 5070 Ti, NVIDIA 621.24 check of da6861bf against base 16282101. All 10 affected synthetic CTests passed.

With five rounds of four d3d12_compute processes sharing an isolated temporary root, the base passed 15/20; five failed with a missing-or-invalid synthetic SPIR-V error during pipeline creation. This PR passed 20/20. The base also passed 10/10 sequentially; there were no timeouts or leftover scratch folders. The native Windows host CachedPSO comparisons ran; Wine behavior was not tested.

One rare cleanup edge case: in ScratchDir, create_directories(path_, ec) can clear an error from the preceding remove_all(path_, ec). On Windows, I precreated the synthetic process-named folder with a file open without FILE_SHARE_DELETE; construction returned without an error while that stale file remained. Could the removal error be checked before creating or using the directory, with a regression test? This did not affect the parallel runs above.

No game files were used.

— LocalFirst-AI

@steamaze0

Copy link
Copy Markdown

Tested da6861b on NVIDIA RTX 5060 Ti (Blackwell), NVIDIA 621.01 (Vulkan 1.4.357), Windows 11, VS Build Tools 2022 (MSVC) + Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0: pass.

  • ctest --output-on-failure -j8 (parallel, stressing the shared-temp-folder race): 121 passed, 0 failed (game-data/optional skipped). The per-process ScratchDir holds up under parallel ctest on Windows native — no temp-folder flake.
  • d3d12_compute, d3d12_draw and shader_library all pass in the parallel run.

AI-assisted (Qoder): I built the full runtime with MSVC and ran parallel ctest.

@zzEmmazz

Copy link
Copy Markdown
Contributor

Tested da6861bf, applied alone on main 16282101: pass.
Windows 11 (26200), MSVC 14.50 (VS 2026), Ninja RelWithDebInfo. Two GPUs: Ryzen 7 9700X iGPU (RDNA2, AMD 32.0.21042.62) and RTX 3070 (NVIDIA 610.74), picked with LEONIDA_VK_DEVICE.

  • Builds with 0 errors; the two warning lines in the touched files (d3d12_compute_test.cpp(400) C4456, d3d12_bundle_test.cpp(519) C4996) are on main too.
  • Each of the ten touched tests run alone: exit 0 on both GPUs, with the same summary line as on main (shader_library_test is CPU only, run once).
  • The race is there on Windows as well. Four copies of one test started together, 6 rounds, so 24 runs per test and GPU; runs that exited 0:
test main, Radeon main, RTX 3070 this change, Radeon this change, RTX 3070
d3d12_compute_test 13 10 24 24
d3d12_draw_test 12 19 24 24
d3d12_fspx_compute_test 11 14 24 24
d3d12_msaa_draw_test 20 23 24 24
d3d12_pipeline_library_test 24 24 24 24
d3d12_set0_compute_test 18 23 24 24
d3d12_bundle_test 10 10 24 24
d3d12_subgroup_test 6 9 24 24
d3d12_typeless_families_test 24 24 24 24
shader_library_test 0 0 24 24
total of 240 138 156 240 240
  • On main the failures were PSO creation (line N: SUCCEEDED(...Create...PipelineState...)), index.load / library.load checks, and exit 0xC0000409 with no message (25 of the 480 runs).
  • ctest -j 6 --repeat until-fail:3 over the ten tests: 10/10 pass on each GPU.
  • The leonida_* folders under %TEMP% were the same four before and after all of these runs: no leonida_<test>_<pid> folder was left behind.
  • On Windows d3d12_compute_test still runs the CachedPSO host comparison (cached PSO: 2 host adapter(s) gave the same 11 answers, as on main).

Not checked: Wine, so the new CachedPSO skip and the cannot copy ... message for a missing .spv did not run here. main has since moved to f847748c; git merge-tree reports conflicts there in six of the test files, and I did not build on it.

@FaKL-Code

Copy link
Copy Markdown
Contributor

Tested da6861b (merged onto main 1628210) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: pass

  • Merges cleanly; no new compiler warnings against main.

  • ctest: 120 of 120 pass (same 8 skips as main). Loader test passes; validation run: 48 tests clean (2 skipped, as on main).

  • The race reproduces on native Windows too, not only under Wine. A local script (not committed) starts four copies of d3d12_compute_test.exe at once, five rounds:

    build failed runs
    main 1628210 13 of 20 (a second try: 6 of 8)
    this PR 0 of 20

    On main, the failing copies end with "cs_user_data.spv is missing or not SPIR-V" followed by the assertion at d3d12_compute_test.cpp:515 (CreateComputePipelineState). That is one copy's remove_all deleting the shared folder while another copy loads from it, as the PR describes. With the per-process folders, every copy passes.

  • The Wine-only CachedPSO skip doesn't apply here: on Windows the host comparison still runs and passes ("cached PSO: 2 host adapter(s) gave the same 11 answers").

AI-assisted (Claude).

@stocksock

Copy link
Copy Markdown
Contributor

A data point from native Windows, not a test of this PR: the same "every host answered nothing" condition this PR skips under Wine also happens on a native Windows 10 host here, so d3d12_compute fails on main f847748 (line 389: host == layer).

Setup: Windows 10 22H2 (build 19045.5737), NVIDIA GeForce RTX 3090, driver 621.24, MSVC 19.44.

Measured with temporary prints in runtime/test/d3d12_compute_test.cpp (not committed):

  • layer: CreateComputePipelineState S_OK, GetCachedBlob S_OK with a blob, GetCachedBlob(nullptr) S_OK, 11 answers.
  • host, default adapter: CreateComputePipelineState S_OK, then GetCachedBlob returns 0x8000FFFF (E_UNEXPECTED), no blob.
  • host, WARP: the same, 0x8000FFFF.

So cached_pso_cases() returns an empty vector for both hosts, host_cached_pso_cases() still pushes them, hosts is not empty, and the test compares two empty lists with the layer's 11 answers.

Suggestion: in host_cached_pso_cases(), keep a host's answers only when the vector is not empty. That covers Wine and this case with one rule, and the existing SKIP line then prints when no host could answer. I don't know why GetCachedBlob fails on this host; another Windows 10 19045 tester reported d3d12_compute passing (on #2852), so it is not Windows 10 in general.

AI-assisted (Claude).

@Catskan

Catskan commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested da6861b on Sapphire RX 9070 XT Nitro+ (AMD 26.11.2 LLPC, driverVersion 2.0.416), Windows 11 26200, MSVC: pass. The runtime builds. Full ctest from a desktop session: 0 failed out of 129, with 7 skipped (game package or optional tools). AI-assisted run.

d3d12_compute and the other tests that write a translator-style shader library under
the temp directory (d3d12_draw, d3d12_set0_compute, d3d12_msaa_draw, d3d12_fspx_compute,
d3d12_pipeline_library, d3d12_subgroup, d3d12_bundle, d3d12_typeless_families,
shader_library) used one fixed folder name. Two copies running at once (ctest -j, or two
suites in one Wine prefix or TMPDIR) shared it, and one copy's remove_all deleted the
modules the other was loading: on an Apple M3 Max under Wine with MoltenVK 1.4.3, four
copies of d3d12_compute at once failed 6 of 40 runs (PSO creation at lines 245/357, or
exit 3 from an uncaught filesystem_error in copy_file), while 125 runs one at a time all
passed.

test_temp_dir.h names the folder <temp>/<name>_<pid>, removes it on scope exit (early
returns included), and copies the compiled-in LEONIDA_TEST_*_SPV files with an error
code, so a missing file is reported by name instead of ending the test with abort().
docs/testing.md lists both symptoms.
ItsNotRexed#1683's comparison expected Wine to have no host D3D12 device or no compiler. Wine has
both (vkd3d and its d3dcompiler_47), but vkd3d's GetCachedBlob is a stub, so
cached_pso_cases returned no answers for each host adapter and `host == layer` failed
on every run (line 388; Apple M3 Max, CrossOver 26.3 / Wine 11 with MoltenVK 1.4.3).
Like the other host comparisons (host_wine.h), it now skips under Wine and says why;
the layer's own 11 answers are still checked against the expected list.
@Jolymmiles
Jolymmiles force-pushed the mac/d3d12-compute-temp-dir-race branch from da6861b to 421bf0b Compare November 22, 2026 21:43
@Rossrocha

Copy link
Copy Markdown

Tested on AMD Radeon RX 6600 (RDNA2, gfx1032), Windows 11, Adrenalin 26.11.2 (Vulkan driver 32.0.21045.29003).

PR head 421bf0bf merged onto main aa2988cc, fresh MSVC build:

  • the 10 touched test programs (d3d12_bundle, d3d12_compute, d3d12_draw, d3d12_fspx_compute, d3d12_msaa_draw, d3d12_pipeline_library, d3d12_set0_compute, d3d12_subgroup, d3d12_typeless_families, shader_library): all PASS natively on Windows (not under Wine), with and without LEONIDA_VK_VALIDATION=1
  • ctest: 153/153 passed, and 153/153 with LEONIDA_VK_VALIDATION=1
  • run_gpu_tests.py: 195/210 passed, 15 skipped (expected), native and with LEONIDA_W64_EMULATE=1

No regressions on this hardware.

@ItsNotRexed
ItsNotRexed merged commit d3ec646 into ItsNotRexed:main Nov 23, 2026
2 of 4 checks passed
@mesterember104-cpu

Copy link
Copy Markdown

Tested 421bf0b on Tiger Lake (Xe-LP) iGPU 0x9a78, driver 32.0.101.7088, Windows 11, MSVC 14.44: pass

Full ctest -C RelWithDebInfo: 116/123 counted pass (124 tests — the branch adds the testfiles unit tests; the 2 failures are the known Intel-main pair d3d12_buffer_tiles + d3d12_descriptor, failing the same way on main; skips: shader_library_corpus, vk_sync_validation, d3d12_queue_wait, d3d12_rgb9e5_rtv, d3d12_first_light; gameinput Disabled).

The PR's own area on native Windows (where the Wine skip correctly does not trigger): d3d12_compute run directly — PASS, including the host CachedPSO comparison ("2 host adapter(s) gave the same 11 answers") and the CBV root-constant/UAV/table checks. Temp-folder hygiene verified: after the full suite and the direct run, no leonida_compute_test* (or other migrated ScratchDir) folder is left in %TEMP%; the only pid-suffixed folder present (leonida_conservative_<pid>, with index.json+ps.spv+vs.spv) matches a concurrent test run from another branch's tree on this shared machine, and the remaining fixed-name folders predate this run.

AI-assisted (GLM, operated by the account owner).

NiiRoZz added a commit to NiiRoZz/Leonida that referenced this pull request Nov 23, 2026
…tch folder

After ItsNotRexed#3023 the test's own library is a testfiles::ScratchDir, and the twin's
fixed %TEMP% folder (copied with an `overwrite` constant that no longer exists)
would have brought back the race ItsNotRexed#3023 removed for parallel runs. The tail
library is a ScratchDir too, copied with testfiles::copy_file.

From @iurysf's read of ItsNotRexed#3106: creating the 128-byte-limited layer device now
says why it failed instead of returning 1 silently, and the header says that
no stage of this test's twin has a pc_tail, so it narrows the push-constant
range only; the set-1 block is covered by d3d12_draw_test and d3d12_bundle.

Tested with LEONIDA_VK_VALIDATION=1 on an RTX 5090 (NVIDIA 621.35) and an AMD
Radeon iGPU (AMD 26.5.2): 16 of 16 draws equal the host, no validation error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NiiRoZz added a commit to NiiRoZz/Leonida that referenced this pull request Nov 23, 2026
…tch folder

After ItsNotRexed#3023 the test's own library is a testfiles::ScratchDir, and the twin's
fixed %TEMP% folder (copied with an `overwrite` constant that no longer exists)
would have brought back the race ItsNotRexed#3023 removed for parallel runs. The tail
library is a ScratchDir too, copied with testfiles::copy_file.

From @iurysf's read of ItsNotRexed#3106: creating the 128-byte-limited layer device now
says why it failed instead of returning 1 silently, and the header says that
no stage of this test's twin has a pc_tail, so it narrows the push-constant
range only; the set-1 block is covered by d3d12_draw_test and d3d12_bundle.

Tested with LEONIDA_VK_VALIDATION=1 on an RTX 5090 (NVIDIA 621.35) and an AMD
Radeon iGPU (AMD 26.5.2): 16 of 16 draws equal the host, no validation error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Raxstreams pushed a commit to Raxstreams/Leonida that referenced this pull request Nov 23, 2026
…ference

host_cached_pso_cases kept an adapter's answers even when there were
none. cached_pso_cases returns no cases when the host's own GetCachedBlob
fails, which it does on a native Windows 10 22H2 host (0x8000FFFF for the
GPU adapter and for WARP), so the test compared two empty lists with the
layer's eleven answers and failed at "host == layer" on every run. ItsNotRexed#3023
skipped the same condition for Wine only.

An adapter's answers are now kept only when it gave some. With none left
the existing SKIP line prints, and it names this case.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.