Skip to content

Tests: check.py runs the four texture tests only run_gpu_tests.py ran, ps_texture_sample_d16 on every pixel - #826

Open
fearkov wants to merge 7 commits into
ItsNotRexed:mainfrom
fearkov:tests/check-py-texture-parity
Open

fearkov wants to merge 7 commits into
ItsNotRexed:mainfrom
fearkov:tests/check-py-texture-parity

Conversation

@fearkov

@fearkov fearkov commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in #374 as: #374 (comment)

What and why

CONTRIBUTING.md asks for a check in check.py for every GPU test, but four texture tests only ran in
scripts/run_gpu_tests.py: ps_sample_c_lz and ps_sample_c_lz_a16 (from #399 and #455: their check.py commits
came after those PRs' merge round, so they're here), ps_cube_sample and ps_texture_sample_d16, and a fifth,
ps_texture_sample, whose own check in vk_texture_test looked at one pixel's blue and alpha. Both runners also
drew ps_texture_sample_d16 with the wrong S# (@Vonsek's review).

Commits:

  1. TEXTURE_MODES in check.py: a shader run in one of vk_texture_test's own modes, from the directory with the
    shaders, as run_gpu_tests.py runs it (run gets a cwd). Starts with ps_sample_c_lz (dref). Unit tests in
    tests/test_shader_checks.py (PASSED is ok; FAILED or no PASSED fails; exit 77 skips).
  2. ps_cube_sample (cube) joins it
  3. check.py draws ps_texture_sample_d16 too. The full-frame check run_gpu_tests.py got in 445be4d
    (check_d16_texture) moves to check.py, unchanged, so both runners judge the frame with the same code.
  4. ps_sample_c_lz_a16 (dref_a16) joins TEXTURE_MODES
  5. vk_texture_test registers the four words after ptr_sgpr as sampler 1 in the descriptor table. Both runners
    passed zeros, but the shader builds the S# (0x92, 0xc00000, 0x14500000, 0) in s[16:19], so its lookup missed
    and the draw read fallback sampler 0, which only filters the same by chance. Both runners now pass the shader's
    words (D16_SAMPLER in check.py), the fixture's usage line too, and a unit test compares them with the s_movs
    in the .asm.
  6. vk_texture_test's default mode (ps_texture_sample, run by run_gpu_tests.py) checked the center pixel's blue
    and alpha only, so a sample of the wrong texel passed. Now every pixel must be the gradient texel its UV reads, all
    four channels.
  7. check.py runs ps_texture_sample too: TEXTURE_MODES maps it to None, the default mode, which takes no mode
    argument

Tested

NVIDIA GeForce RTX 2060 SUPER, Linux, driver 620.70.06, llvm-mc 23.1.5, rebased on 6a6704d.

Check this branch
runtime/test/shaders/build.py 185 translated, 185 pass spirv-val
runtime/test/shaders/check.py 127 of 162 pass, 35 skipped (the five above ok)
scripts/run_gpu_tests.py 133/173 passed, 40 skipped (ps_texture_sample: PASSED on all 4096 pixels)
python -m unittest discover -s tests/semantic OK
python -m pytest tests --ignore=tests/semantic 4243 passed, 98 skipped, 5 failed: test_cf_ref.py (2) and test_world_names.py (3), which fail the same way on main at 6a6704d

The skips are the wave64 tests (32-wide subgroups here) and, in check.py, the mesh fixtures build.py doesn't build.

  • With the translator from before the image_sample_c_lz d16 fix (d701d73 reverted), check.py reports
    ps_sample_c_lz as vk_texture_test dref: FAILED, 0 pixels wrong in the f32 result and 2048 in the d16 one.
  • Commit 5, with a vk_texture_test whose fallback sampler 0 is linear (a local build only, as @Vonsek did on an
    RTX 5080): zeros give 4032/4096 mismatches; at (4,0), the shader's words 4096/4096 RGBA pixels exact. With the
    normal build both are exact, which is why nothing noticed.
  • Commit 6, with U and V swapped in a copy of ps_texture_sample.asm (what a translator that mixed up the
    coordinates would give): the old check says PASSED (verified center pixel rgba=(0.502, 0.502, 0.502, 1.000) ...),
    the new one 3584 of 4096 pixels FAILED, first at (8,0). The real shader passes on all 4096 pixels.

The runs above are from my own machine.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.

@fearkov
fearkov force-pushed the tests/check-py-texture-parity branch from 734212e to d15b43a Compare November 22, 2026 03:50
@fearkov fearkov changed the title Tests: check.py runs ps_cube_sample and ps_texture_sample_d16, the d16 one on every pixel Tests: check.py runs the four texture tests only run_gpu_tests.py ran, ps_texture_sample_d16 on every pixel Nov 22, 2026
@fearkov
fearkov force-pushed the tests/check-py-texture-parity branch from d15b43a to c3f3403 Compare November 22, 2026 04:00
@UlteriorMotive00

Copy link
Copy Markdown
Contributor

Tested c3f3403 on Windows with an AMD RDNA2 iGPU and an RTX 5070: pass (first Windows and AMD runs; the PR was tested on an RTX 2060 SUPER under Linux).

Windows 11 Home 10.0.26300, MSVC 14.44.35207, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8, Python 3.14.7, VK_LOADER_LAYERS_DISABLE=~implicit~. One PC, two GPUs, picked with VK_LOADER_DRIVERS_SELECT: AMD Radeon iGPU of a Ryzen 7 9800X3D (RDNA2, AMD 2026.04.17, subgroup 32..64) and NVIDIA GeForce RTX 5070 (Blackwell, 617.42, subgroup 32).

Check AMD iGPU RTX 5070
build.py 95 translated, 95 pass spirv-val (same build)
check.py 92 of 95 pass, 3 skipped 67 of 95 pass, 28 skipped (wave64)
run_gpu_tests.py 100/100 passed 73/100 passed, 27 skipped (wave64)

ps_sample_c_lz, ps_sample_c_lz_a16, ps_cube_sample and ps_texture_sample_d16 are ok in check.py and PASS in run_gpu_tests.py on both GPUs. The d16 one reports 4096 RGBA pixels exact (the texel narrowed to f16) on both. tests/test_shader_checks.py: OK.

ctest with LEONIDA_VK_VALIDATION=1: RTX 5070 32/32; AMD iGPU 31/32. The AMD failure is the base's OPTIONS19.SupportedSampleCountsWithNoOutputs mismatch (since fixed on main), not this PR. The branch is 356 commits behind main.

AI-assisted (Claude Code). No game files.

@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Your full-frame D16 checker covers the same improvement I opened in #1226; I missed this older claim and am closing the duplicate. One distinct issue still applies to your texture_sample_d16_test: the shader literal sampler key is (0x92, 0xc00000, 0x14500000, 0) but the helper passes four zeros after ptr_sgpr. Both sampler slots currently have identical filtering. On RTX 5080 I made only fallback slot 0 linear: binding the four zeros gave 4032/4096 wrong pixels, while binding the encoded key returned all 4096 exactly. Please use the encoded words in that call (and in the fixture usage comment). Swapping only R/G in the shader export also confirms the oracle should reject the predicted 3584 pixels. Details: #1226 (comment) . AI-assisted.

@quackottu

Copy link
Copy Markdown
Contributor

Tested c3f3403 on RTX 5070, driver 621.24, Windows 11: pass. run_gpu_tests.py native 73/100 (27 skipped, the usual ones for this GPU), with wave64 emulation 100/100; semantic suite 1016 tests OK; no FAIL lines.

@fearkov

fearkov commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@Vonsek thanks, you're right: vk_texture_test puts the words it's given into the descriptor table as sampler 1, so with zeros the shader's S# missed and the draw fell back to sampler 0. Both runners pass the shader's words now (5b27d8c), and so does the fixture's usage line. A unit test compares them with the shader's s_movs. I reproduced your numbers on an RTX 2060 SUPER, with sampler 0 made linear in a local build: zeros give 4032/4096 wrong pixels and the encoded words give 4096 exact. Your full-frame check from 445be4d is now the one both runners use. I moved it to check.py without changes, so check.py judges the same way.

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 5b27d8c3e7e9e4c681c6b1e657939760a298af13 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

Independent Vulkan pass on Linux 7.0.0-43-generic with a GeForce RTX 5090, NVIDIA driver 595.99.02, LLVM 21.1.8, and SPIRV-Tools 2026.1.

Both runners passed the four stock texture fixtures. ps_texture_sample_d16 matched all 4,096 RGBA pixels, and all 64 shader-check tests passed. The translated modules validated.

I repeated the sampler-selection control with only fallback sampler 0 changed to linear filtering in a local harness build. The declared sampler key still matched all 4,096 pixels. Passing zeros instead produced 4,032 mismatches, confirming that the corrected key selects the intended point sampler.

AI-assisted verification.

@fearkov
fearkov force-pushed the tests/check-py-texture-parity branch 2 times, most recently from ff3c75d to 0121b00 Compare November 22, 2026 22:06
@zneel

zneel commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Tested 0121b00f on AMD Radeon RX 9070 XT (RDNA4, subgroup 32..64), AMD 26.11.2, Windows 11 Pro 10.0.26300, AMD Ryzen 7 9800X3D CPU (64 GB RAM), Python 3.12.10: pass.

Runtime and test programs built from this head (MSVC 14.51, Ninja, RelWithDebInfo), native Windows llvm-mc 21.1.8, Vulkan SDK 1.4.363.0. No game files.

run result
run_gpu_tests.py (whole suite, native wave64) 196/210, 14 skipped, 0 failed
same with LEONIDA_W64_EMULATE=1 196/210, 14 skipped, 0 failed
check.py on build.py output of ps_texture_sample, ps_cube_sample, ps_sample_c_lz, ps_sample_c_lz_a16, ps_texture_sample_d16 (+ vs_ids), native and LEONIDA_W64_EMULATE=1 all five ok in both
ctest 154/154
pytest tests/test_shader_checks.py tests/test_run_gpu_tests.py 127 passed, 276 subtests passed

In run_gpu_tests.py, ps_texture_sample_d16 gives 4096/4096 RGBA pixels exact (native and emulated) with the corrected S#, and ps_texture_sample passes (ok). So both runners agree on all five texture tests on this driver.

AI-assisted (Claude Code); I checked the results.

CONTRIBUTING.md asks for a check in check.py for every GPU test; this one was only in run_gpu_tests.py. TEXTURE_MODES runs a shader in one of vk_texture_test's own modes, from the directory with the shaders, as run_gpu_tests.py does.
Only run_gpu_tests.py ran vk_texture_test cube; CONTRIBUTING.md asks for a check in check.py too.
Only run_gpu_tests.py drew it. Its full-frame check (445be4d) moves to check.py so both runners judge the frame the same way.
Both runners passed zeros as the S#, so the shader's (0x92, 0xc00000, 0x14500000, 0) wasn't in the descriptor table and the draw read fallback sampler 0, which only filters the same by chance. With sampler 0 made linear, zeros give 4032 wrong pixels and the shader's words none.
It looked at the center pixel's blue and alpha only, so a sample of the wrong texel passed: with U and V swapped in ps_texture_sample, 3584 of 4096 pixels are wrong and it still said PASSED. Now each pixel must be the gradient texel its UV reads.
vk_texture_test's default mode, which takes no mode argument.
@fearkov
fearkov force-pushed the tests/check-py-texture-parity branch from 0121b00 to 7fe6ab7 Compare November 23, 2026 04:25
@fearkov

fearkov commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on main 0db7fed (7fe6ab7). main's run_readback now removes a stale raw before each draw, so ps_texture_sample_d16 dropped its own unlink and kept the S# arguments. RTX 2060 SUPER, driver 620.70.06, Linux: check.py 158 of 193 pass, 35 skipped (all five texture shaders ok). run_gpu_tests.py 170/217 passed, 47 skipped, 0 failed (ps_texture_sample_d16: 4096/4096 RGBA pixels exact). tests/test_shader_checks.py and tests/test_run_gpu_*.py: 152 passed.

@junaydirfan

Copy link
Copy Markdown

Tested 7fe6ab7f merged into main 98fa503f on Linux (CachyOS, kernel 7.3.5), llvm-mc 23.1.5, LEONIDA_W64_EMULATE=1, test programs built from the merge: pass.

GPU driver run_gpu_tests.py main
Intel Raptor Lake-S iGPU (Xe-LP), subgroup 8..32 Mesa ANV 26.3.1 186/217 passed, 31 skipped, 0 failed 186/217
RTX 4080 Laptop GPU (Ada), subgroup 32 NVIDIA 620.73.04 201/217 passed, 16 skipped, 0 failed 201/217

Every other test has the same result as on main on both GPUs.

This PR is about check.py, so I also ran it (build.py and then check.py, test programs from each tree):

GPU main this PR
Intel 175 of 188 pass, 13 skipped 180 of 193 pass, 13 skipped
RTX 4080 184 of 188 pass, 4 skipped 189 of 193 pass, 4 skipped

The five tests it adds to check.py (ps_texture_sample, ps_cube_sample, ps_sample_c_lz, ps_sample_c_lz_a16, ps_texture_sample_d16) are ok on both GPUs. Everything else is unchanged.

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown

Tested 7fe6ab7 (merge base 98fa503) on NVIDIA GeForce RTX 5080, Linux 580.65.06: pass

Tested the PR head merged with current main 98fa503f (clean merge, not pushed). Runtime harnesses rebuilt from the merged tree (it changes C++: runtime/test/vk_texture_test.cpp); the main column uses harnesses built from main 98fa503f. llvm-mc 21, Python 3.13, Vulkan SDK 1.4.363, Linux native.

Check main 98fa503f this PR
run_gpu_tests.py native 170/217 passed, 47 skipped 170/217 passed, 47 skipped
run_gpu_tests.py with LEONIDA_W64_EMULATE=1 201/217 passed, 16 skipped 201/217 passed, 16 skipped
failed (native / emulated) 0 / 0 0 / 0
tests/semantic/regen_fixtures.py --check ok ok
pytest tests/test_shader_checks.py tests/test_run_gpu_tests.py tests/test_cf_diff.py 162 passed, 315 subtests passed in 3.70s (3 shared files) 170 passed, 315 subtests passed in 3.80s

Line-by-line against my main run (results that differ from main):

  • native:
    • none
  • emulated:
    • none

Not run: the full unittest discover -s tests/semantic (about 6 minutes, and main alone has failures there); only the test files this PR touches plus the shared checker tests ran. No other GPU vendor, no Windows. No game files.

AI-assisted (Claude Code).

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.

8 participants