Skip to content

docs/testing: LEONIDA_SHADERS changes which tests pass, not just which run - #2806

Closed
fiestorra wants to merge 1 commit into
ProjectLeonida:mainfrom
fiestorra:docs-shaders-env-changes-two-tests
Closed

fiestorra wants to merge 1 commit into
ProjectLeonida:mainfrom
fiestorra:docs-shaders-env-changes-two-tests

Conversation

@fiestorra

Copy link
Copy Markdown
Contributor

LEONIDA_SHADERS changes which tests pass, not just which tests run. docs/testing.md warns that a passing ctest percentage does not establish that the tests ran; this adds the other half of that sentence, because it cost me two false regression reports in one evening.

What happened, on main cd9fe51a9, Release, serial, this machine:

with LEONIDA_SHADERS and LEONIDA_SHADER_DXBC exported (I had them set for shader_library_corpus):
  575 ran, 99% passed, 4 failed
    11:display_white_cache   329:d3d12_r9g9b9e5_uav   355:d3d12_descriptor   399:xbox_present

from a shell with neither set:
  575 ran, 99% passed, 1 failed
    399:xbox_present

And the two in the middle, re-run both ways:

d3d12_r9g9b9e5_uav   with the variable: FAILED 2.28 s     without: Passed 0.23 s
d3d12_descriptor     with the variable: FAILED 2.35 s     without: Passed 0.31 s

Both binaries print OK and 0 validation errors when run directly, so it is not the test being flaky - it is the environment changing what it tests. display_white_cache is a different thing: its own assertion races the scheduler (about 1 in 1000 runs here, written up in #2713), and I mention it only because it landed in the same run and would otherwise look like a third environment effect.

The paragraph added, after the existing warning:

LEONIDA_SHADERS is one environment variable that changes which tests pass, not just which ones run. It is what shader_library_corpus reads, and d3d12_descriptor and d3d12_r9g9b9e5_uav also pick up whatever it names. Set the variable for the corpus test only, or pass it on that test's command line, so the rest of the suite runs in the environment it was written for.

Why a doc and not a code change: I do not know why those two tests read it - they may load the library deliberately, and making them ignore it could remove a check. The honest fix tonight is to say what happens, and if the coupling is unintended, that is a separate change its authors should make.

docs-only, +9/-0, one file, no code.

AI-assisted: yes - DeepSeek v4.1 (flash), which is also what ran the suite both ways.

Written with an AI assistant.

…h run

The suite section already warns that a passing percentage does not mean the tests ran. This adds
the other half: one variable changes the answers. Measured on main cd9fe51 with a translated
corpus exported for shader_library_corpus, 575 ran and four failed; from a shell without it, one
failed and the two in the middle passed in 0.23 s and 0.31 s on their own.
@OreoFR

OreoFR commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Read by OreoFR on macOS 27.2.1, Apple M5, head 97691daa2, main b7a1be296. This PR only changes the docs (docs/testing.md, +9).

READ IN CODE

  • LEONIDA_SHADERS is read on main in the runtime shims, among them runtime/shims/d3d12_xs_device.cpp, d3d12_vulkan_device.cpp, d3d12_precompile.h and runtime/src/shader_directory.h.
  • d3d12_descriptor and d3d12_r9g9b9e5_uav link gta6rt_d3d12_com (runtime/CMakeLists.txt:3337 for the latter), which contains those shims. So it is plausible that they pick the variable up, as the paragraph says.
  • shader_library_corpus is its own test (CMakeLists.txt:1742-1745, skip code 77, 1 h timeout).

ASSUMED

  • The four-failures-versus-one observation is from your machine (it is Windows-only: those tests are under the MSVC block). Not reproduced here. The advice (set the variable for the corpus test only) is sound either way.

AI-assisted: Claude Code

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mechanism checks out: a device created with an empty VulkanDeviceInfo::shader_dir loads whatever LEONIDA_SHADERS names (d3d12_vulkan_device.cpp:12263, with the count printed at :12267-12281), and both tests you cite leave it empty (d3d12_descriptor_test.cpp:330-347, d3d12_r9g9b9e5_uav_test.cpp:385-399). shader_library_corpus_test.cpp:121-124 is the registered-but-skipping one (SKIP_RETURN_CODE 77), so the variable changes pass/skip, not collection — the title is right.

But the enumeration is a big understatement, and that is the part that will rot: 95 of the 138 test files that call create_vulkan_device never set info.shader_dir, so on a shell with the variable exported they all load the corpus — d3d12_a8_copy, d3d12_clear_formats, d3d12_existing_heap, xbox_present_test and ninety-odd more. Please state the rule ("any test whose VulkanDeviceInfo leaves shader_dir empty") and give these two as examples.

Two smaller fixes:

  • display_white_cache is listed among the four failures, but your own description calls it an unrelated scheduler race (#2713). As written, a reader will blame the variable — drop it from the list or label it.
  • "Pass it on that test's command line" does not work: shader_library_corpus_test.cpp:120 is int main() and add_test passes no arguments — only the environment (or an env prefix) works. And the corpus test also reads LEONIDA_SHADER_DXBC and defaults to ../dxbc (:126-127), not just LEONIDA_SHADERS.

Otherwise the advice is worth having: run_gpu_tests.py never sets the variable, so a reader who exported it for the game gets exactly the false regression you describe. No test guards prose in this page (tests/test_docs_design_rows.py only checks table shape), which is another reason to state the rule rather than a list.

@aegish-zagi

Copy link
Copy Markdown
Contributor

Verification — VERIFY-2806

Verdict: PASS

  • PR: docs/testing: LEONIDA_SHADERS changes which tests pass, not just which run #2806 | head sha: 97691daa29270bec0f7cd41fd1bca9220a5ca521 | merge state vs main: clean merge with current main cd0c52fcf in a scratch worktree (docs/testing.md auto-merged, no conflicts)
  • Diff audited: docs-only — one paragraph in docs/testing.md stating LEONIDA_SHADERS changes which tests pass, not just which run, naming shader_library_corpus, d3d12_descriptor and d3d12_r9g9b9e5_uav, with the measured four-vs-one failure comparison and the advice to scope the variable to the corpus test.
  • Claim checked READ IN CODE: LEONIDA_SHADERS is genuinely read by the runtime/device code (runtime/shims/d3d12_vulkan_device.cpp, d3d12_xs_device.cpp, runtime/src/main.cpp) and shader_library_corpus is wired in runtime/CMakeLists.txt, so the mechanism the paragraph describes exists as written. The specific failure counts are the author's measurement on a GPU/Windows host — not reproducible on this no-GPU Linux host, stated as a limit.
  • Tests run (Linux, Python 3.12.3, python -I): on the merged PR, tests/test_docs_env_vars.py, tests/test_docs_repo_paths.py and tests/test_docs_links.py all OK — the new paragraph introduces no stale path, link or env-var documentation error. Docs-only change, so no red/green pair applies.

AI-assisted: yes (Muse Wonder, Muse by Meta)

@merzleckeier

Copy link
Copy Markdown
Contributor

I ran a synthetic A/B/C/D check of the two named GPU tests on cd0c52f with docs revision 97691da applied. The stock Win64 Release executables ran under Wine 11.22 on Radeon Raphael (RADV 26.3.1) and RTX 4070 SUPER (620.73.04). Both shader folders contained the same hand-written no-op compute SPIR-V, with the same digest. The only difference was the module’s descriptor_hash in index.json.

Environment d3d12_descriptor_test d3d12_r9g9b9e5_uav_test
LEONIDA_SHADERS unset Pass Pass
Synthetic library, fnv1a Pass Pass
Same library, fnv1a_fmix32 Fail Fail
Same fmix library, LEONIDA_DESCRIPTOR_HASH=fnv1a Pass Pass

Every row agreed on both physical GPUs. The fmix runs explicitly logged that the library was loaded and selected fnv1a_fmix32. The descriptor test hit count == texels. The R9 test read 0 where the bindless sample expected 1. This isolates an independent way to reproduce the two failures without a translated corpus. The doc env-var, repo-path and link checks also passed. MEASURED with a synthetic shader. AI-assisted (Codex).

@aslan2142

Copy link
Copy Markdown
Collaborator

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

@aslan2142 aslan2142 closed this Dec 1, 2026
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.

6 participants