shader: draw the core pixel shader set on a Vulkan device #2289
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2297"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Ybucaille on 2026-11-25T10:43:57Z.
Refs #614. Follows the Vulkan host and the subnormal check (
tests/pixel_denorm_vulkan_check.py).Summary
Runs the
draw-coretranslated pixel shaders, with their negative controls, on a Vulkan 1.2 device.tests/pixel_aot_check.py draw-core-vulkan <dxc> <device> [--allow-denorm-mismatch]:check_renderrunsunchanged. The renderer is the Python interpreter and the backend is the new adapter.
compile_shaderemitsSPIR-V (
SPIRV_ARGS, b0 to b2 at 0 to 2, t0 and t1 at 16 and 17, s0 at 32) andspirv-valchecks it. Othermodes build exactly the DXIL command they built before.
tests/vk_offscreen.py: stands in foroffscreen_checkfor--check-pixel,--check-pixel-case,--check-pixel-batchand--check-pixel-quad-lod, with the same exit codes,pixel_mismatch x= y=words andcase=N status=lines. The comparison isdraw_verified's: every channel bit for bit, except the channels acase marks in its NaN-class mask. With no arguments (or
--self-test) it runs device-free controls: the caseparser, one-ulp mismatches reported first in scan order, a NaN-mask lane, the batch status lines through a fake
host, and the refusals. It is added to the Linux Python checks and to the list in
AGENTS.md.tests/vk_pixel_draw.c: a--drawform with options for target, constants, b1/b2, mip chain, viewport,indices, write mask and clear color. The original positional form is unchanged.
-denorm preserve. A device withoutshaderDenormPreserveFloat32is acapability skip (77).
--allow-denorm-mismatchdraws anyway and is a diagnostic run only.docs/non-windows-hosts.md(usage) anddocs/experiments.md(method and results).Like #473 and the subnormal check, this is optional and not registered in CMake or CI beyond the device-free
self-test.
Reproduce
Needs DXC,
spirv-val, a C compiler and the Vulkan loader headers.Results
Base
25317c63plus this change, DXC 1.10.2605.37, Mesa 26.2.7, Arch Linux.shaderDenormPreserveFloat32--allow-denorm-mismatch--allow-denorm-mismatchpixel_mismatch x=16 y=0NVIDIA (measured): the pixel at x=16 reads back
0x3e14a000in byte 37 where the reference has0x3e148000.The reference comes from
export16, which rounds a binary32 toward zero to binary16 throughf32tof16/f16tof32. A compute probe on the same device gave the binary160x30a5and a widened value0x3e149495. Hypothesis, not verified: the NVIDIA compiler foldsf16tof32(f32tof16(x))tox, so thatrounding does not happen. I do not know whether the NVIDIA D3D12 driver does the same. The run is a diagnostic
and says nothing about NVIDIA's subnormal handling.
Negative controls
On Intel every negative control of
check_renderis detected (wrong references and mutated shaders reportpixel_mismatch). The self-test adds its own: a one-ulp difference must fail with the first pixel in scan order,a non-NaN actual in a NaN-masked lane must fail, a mask on a non-NaN expectation must be refused, and a title
memory trailer, a bad viewport, unknown flag bits and a short NaN mask must be refused.
Not covered
offscreen_checkmodes and title-memory trailers.debug_layer=unavailable).draw(the full set) under Vulkan; onlydraw-core.Other checks:
git diff --checkclean;tests/docs_links_check.pyandtests/bidi_controls_check.pypassed;tests/pixel_denorm_vulkan_check.py(no arguments) passed. Not run: CMake, ctest and Windows CI.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:48:59Z.
Review: COMMENTED
Review of head
0671765ad96ff6aee4e9a9864b8021ba68425489.Summary: The adapter and the
draw-core-vulkanmode look correct. The comparison followsdraw_verified(bit-exact, NaN-class mask only where marked). The default SPIR-V path is gated bySPIRV_ARGS, which is reset infinally, so the other modes keep building the same DXIL command. One test gap (P2) below.Commands run locally (in a worktree at this head):
git diff --stat origin/main...HEAD: 7 files, +751/-41python3 tests/vk_offscreen.py->vk_offscreen self-test passedpython3 tests/docs_links_check.py-> Checked 18 Markdown files and 438 linkspython3 tests/bidi_controls_check.py-> no bidirectional controlsgit diff --check origin/main...HEAD-> cleangh pr checks: Linux Python checks, Windows build/test and gfx1013 fixtures all pass; /O2 and chart jobs skipped.tests/vk_offscreen.pycompare(), changedelif expected[c] != actual[c]:toelif c != 3 and expected[c] != actual[c]:(alpha ignored). The self-test still passed (exit 0), so the mutation survived. Reverted withgit checkout -- ..Findings
tests/vk_offscreen.pyself-test (the one-ulp control at ~line 378 only perturbs channel 2) does not exercise a mismatch in every channel. A regression that skips the compare for channel 3 (alpha) passes the self-test. Suggest one control per channel (or a loop over c in 0..3) asserting thepixel_mismatchreport and the channel index.draw-core-vulkan) needs a real device, so it was not run here. Linux CI covers only the device-free self-test.No Windows run was done: the PR touches only the Vulkan test harness, not gfx2hlsl or C++ paths used on Windows.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T10:54:36Z.
I tested the D3D12 side of the rounding question with the fixture at
0671765a. On a desktop RTX 4060 (Windows 11 build 26100.9711, driver 32.0.15.9579),python -B tests/pixel_aot_check.py draw-core <dxc> <offscreen_check> hardwareexited 0, including the existing negative controls. DXC was 1.9.2609.5. The renderer was built from59a05959; itspixel_aot_render.cppis identical to this head.I also compiled
translate(assembly(False))withcompile_shader(..., ieee=False)and used--check-pixel-case shader.dxil ramp.case pixels.rawon the RTX and on WARP 10.0.26100.9711. The case used the 64 expected colors fromvk_offscreen.ramp_input(False). At pixel (16, 0), input red byte 37, both devices returned[3e148000, 00000000, 3f008000, 3f800000]. The full 4,096 pixels matched on each device. Removing just the decrement inexport16also matched these fixtures on both.As a control, I replaced the four export calls with
widen16(narrow16(channel)), using the shader's integer nearest-even implementation. Both devices then failed first at (16, 0), redexpected_bits=3e148000 actual_bits=3e14a000, and the raw output contained the same actual word. This adjacent half is distinguishable on the D3D12 path. The unchanged DXIL shader on these particular devices produced the reference value. The Linux Vulkan compiler-folding hypothesis remains open.I also ran the same head on two Windows Vulkan drivers. I compiled the unchanged
tests/vk_pixel_draw.con Windows and used the PR's shader compiler arguments, SPIR-V validation,check_render(..., core_only=True)andvk_offscreen.pyreference. The Windows launcher supplied the host binary and vertex SPIR-V in place of the Linux host-build step.3e148000, all 4,096 pixels matched.3e14a000at (16, 0). The other three channels matched.The desktop RTX produced the reported adjacent half under the diagnostic Vulkan run on Windows as well. On that same GPU and driver the original DXIL ramp matched all pixels. These observations distinguish the two API paths on one device. They do not isolate which compiler step selected the rounding.
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T11:14:46Z.
Review: COMMENTED
Review of head
0671765ad96ff6aee4e9a9864b8021ba68425489on Windows 11 (26200.9974, MSVC19.44.35228.0, Windows SDK / DXC10.0.26100.0).Findings
tests/vk_offscreen.py:401-422, Windows portability):AGENTS.mdaddstests/vk_offscreen.pyto the Pure-Python checks list, butpython -B tests/vk_offscreen.pyfails on Windows inself_test():self_test()writes an extensionless shebang script (fake_host) and runs[host, "--draw", ...], which WindowsCreateProcessrejects (%1 is not a valid Win32 application), sorun_check_pixel_batchturns every case intostatus=error. Writingfake_host.pyand invoking[sys.executable, host, ...](or a.cmdwrapper onos.name == "nt") would let the self-test pass on Windows as well as Linux/macOS.Additional Windows D3D12 data point (AMD RDNA 3 + WARP)
Built
offscreen_check(devpreset) at0671765aand randraw-coreon AMD hardware (draw-core-vulkanwas not run because Vulkan SDK headers andspirv-valare not installed on this host):AMD Radeon RX 7900 XTX(vendor=1002,device=744c, driver32.0.32029.2010, D3D12 debug layer enabled): exit0(max_absolute_error=0,debug_errors=0 debug_warnings=0,multitap_sample (hardware): 2 taps on tex verified,trig_unreduced_mismatches=0/4).Microsoft Basic Render Driver(WARP 10.0.26100.9818, D3D12 debug layer enabled): exit0(max_absolute_error=0,debug_errors=0 debug_warnings=0,multitap_sample (warp): 2 taps on tex verified,trig_unreduced_mismatches=0/4).Other local checks on
0671765apython -B tests/pixel_denorm_vulkan_check.py-> passed (classification controls: 10 cases passed)python -B tests/docs_links_check.py-> passed (18 files, 438 links)python -B tests/bidi_controls_check.py-> passed (1585 tracked files)git diff --check upstream/main...HEAD-> cleanImported from R0Y00/Xbox2Windows. Originally posted by Ybucaille on 2026-11-25T12:00:48Z.
Thanks for the reviews and the runs. Both P2 findings are fixed in
e3c65e8f(onlyself_test()intests/vk_offscreen.pychanged; production code is untouched).@stan495 (Windows): the fake host is now
fake_host.py, started throughsys.executableby a one-line launcher, a.cmdfile on Windows and ashscript elsewhere, since the adapter takes a single host path. Nothing relies on a shebang any more. I could only run the Linux branch here, so apython -B tests/vk_offscreen.pyon Windows would confirm it. Thanks also for the RX 7900 XTX and WARPdraw-coreresults.@tedin7 (channel coverage): the one-ulp control now loops over the four channels. Each pass perturbs one channel at (9, 5) and checks every
channel=cline,actual_bitsone aboveexpected_bitson the perturbed channel and equal on the other three. Your mutation (elif c != 3 and expected[c] != actual[c]:) now fails the self-test, and the test passes again once it is reverted.On the draft question:
draw-core-vulkancannot run without a device, so CI only covers the device-free self-test. The device runs so far are Intel ANV (exit 0, negative controls caught) here and on Windows (@RavenCurseBurg's UHD 770, all 4,096 ramp pixels), and lavapipe and NVIDIA returning the expected capability skip (77). I am happy to switch the PR to draft if you would rather wait for an AMD run.@RavenCurseBurg: thanks, that comparison is useful. The same RTX 4060 gives
3e148000through DXIL/D3D12 and3e14a000through SPIR-V/Vulkan, so the adjacent half comes from the Vulkan path rather than the GPU.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:05:03Z.
Review: COMMENTED
Review of head
e3c65e8f563e6c64800a1766be756b8147eb80f0(previous review by @tedin7 was on0671765a, so this is a new head).Scope read:
tests/vk_offscreen.py(new adapter and self-test), thedraw-core-vulkanmode andSPIRV_ARGShook intests/pixel_aot_check.py, the workflow and AGENTS.md lines, and the docs. I did not read all oftests/vk_pixel_draw.cline by line, and I did not run any Vulkan device or DXC. I did not request a Win2025 run: the change is test-only, the adapter self-test needs no device, and the Windows job on this head is green.CI on this head: Linux Python checks pass, Windows build and test pass, gfx1013 fixtures pass. /O2 and chart jobs are skipped. The PR is mergeable, and the title is neutral.
Commands run locally in the PR worktree:
python3 -B tests/vk_offscreen.py->vk_offscreen self-test passedpython3 tests/docs_links_check.py-> self-test passed, 18 Markdown files and 438 links checkedpython3 tests/bidi_controls_check.py-> 1585 files, no bidirectional controlsgit diff --check origin/main...HEAD-> cleanMutations (reverted with
git checkout -- .):compare(), skip channel 3 in the exact-word comparison. The self-test fails with anAssertionError(pixel_mismatch x=1 y=20), so it is killed.is_nan_bits(), drop the mantissa test, so +/-Inf counts as NaN. The self-test still passes, so it survives.Findings:
tests/vk_offscreen.py:161,is_nan_bits): no self-test case has a NaN-masked channel where the actual word is an infinity, so mutation 2 survives. A case such as expected NaN bits with actual0x7F800000expectingpixel_mismatchwould pin it. Infinity is the likeliest wrong value from a denorm or divide path, so it is worth one case.SPIRV_ARGSis a module global that is set and reset incheck_render_vulkan. It is restored infinally, so it is correct. Passing it as a parameter would be tidier, but it is not needed for this PR.No blocking issues found in what I read.
AI-assisted; commands listed were executed locally.