Skip to content

GPU tests: read back two color export targets (TEST-1083) - #4880

Open
timorjay wants to merge 2 commits into
ItsNotRexed:mainfrom
timorjay:test/two-color-export-readback
Open

timorjay wants to merge 2 commits into
ItsNotRexed:mainfrom
timorjay:test/two-color-export-readback

Conversation

@timorjay

@timorjay timorjay commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as TEST-1083. Claim in #4816

What and why

This adds two-color-target readback for the per-export mask question in #3988. The test harness previously saved only color attachment 0. Setting VKH_MRT1=1 writes both attachments to <out.raw> and <out.raw>.mrt1. A direct draw uses VKH_COLOR_FORMAT for both. In the default RGBA32F format, MRT0 clears to −1 and MRT1 to −2 in all four channels.

Three hand-written pixel shaders run under both GPU test entry points. The write and discard controls check every channel of both images. The mixed case exports MRT0 with full EXEC and vm, waits for that export, clears EXEC and exports MRT1 with done and no vm. It checks the defined MRT0 pixels and reports what MRT1 contained. Missing or short second images fail the test. The change is independent of Vonsek's translator patch and can land on main.

Hardware verification at 5d8091d4

Merged upstream main at 561b65a8 and rebuilt the Vulkan harness. I selected the RTX 5090 D v2 (617.42) and Ryzen 7 9800X3D Radeon iGPU (32.0.21036.18) by name and verified the device reported by each draw.

  • On both adapters, --filter ps_mrt_exports --require-pass passed 3/3 even with VKH_COLOR_FORMAT=9:1 in the caller's environment. The built-in fixtures explicitly use RGBA32F. Three separate 8×8 draws per case reproduced both write colors, both discard clears and the defined first target of the mixed case, bit for bit.
  • The mixed case's second target illustrates why its histogram is diagnostic. The Radeon returned 64 zero pixels in each of three draws. On NVIDIA, two draws returned 64 zero pixels each and the third returned 64 pixels in the “other” bucket. The original RDNA2 export still needs an independent native reference.
  • For a direct draw at the odd extent 3×5, both adapters captured distinct, byte-exact targets in R8_UNORM (15 bytes/file) and RGBA16F (120 bytes/file). A single-target R8 control produced exactly 15 bytes. The newly merged ps_persp_bary and the single-target ps_flat controls also passed on both devices.
  • The focused Python checker and runner suites passed 170 tests plus 417 subtests.

Earlier verification

Windows 11 Pro 26300.9974. Tested this branch at ba8b9aa6 (base 64b45d07) and applied the test patch separately to the exact #3988 head 55338a17. Selected the adapters by name and checked the device reported by the draw program. On both revisions, each row below was reproduced in three fresh draw processes per adapter. All counts are out of 64 pixels per image.

Case RTX 5090 D v2 (617.42) AMD Radeon integrated graphics (1002:13c0, Vulkan 25.10.36, Windows 32.0.21036.18)
Write both MRT0 64× (1,2,3,4), MRT1 64× (4,3,2,1) Same, bit-for-bit
Discard all MRT0 64× (−1,−1,−1,−1), MRT1 64× (−2,−2,−2,−2) Same, bit-for-bit
Full mask at MRT0, empty mask at MRT1 MRT0 64× (1,2,3,4), MRT1 64× (+0,+0,+0,+0) Same, bit-for-bit

On the AMD iGPU I also queried the driver's disassembly for the translated mixed shader via VK_AMD_shader_info. It loads zero into v1, exports mrt1 v1, v1, v1, v1 vm, and then exports MRT0 with done vm. That inspection draw returned the same bytes as the regular run. This explains the observed zeros on this driver. A reference draw executing the original RDNA2 export order and EXEC change is still needed to establish the native result. Other Vulkan drivers may produce different MRT1 bits.

  • python -I scripts/run_gpu_tests.py --build <build> --filter ps_mrt_exports --require-pass ran 3/3 cases on both GPUs and both revisions. All four fixture modules, including the vertex shader, passed spirv-val (LLVM 22.1.8, SPIRV-Tools 2026.4).
  • The existing single-target ps_flat test matched all 4,096 pixels on both GPUs. The stencil-backed ms_v5_workgroup test matched all 24 groups on both.
  • The four Python runner/checker test files passed (157 tests, 342 subtests). The existing rdna2spirv: a pixel lane off at the last color export is not written; without vm, EXEC at the color export decides (measured on RDNA2) #3988 export-mask semantic test file passed all 24 tests. With an older one-target harness the new check failed with missing MRT1 readback.

AI-assisted: yes, with OpenAI Codex. All inputs are synthetic.

Add two-target write and discard controls and report the mixed-mask MRT1 observation separately. Compare defined pixels bit for bit without assuming a native RDNA2 value for the second target.
@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested ba8b9aa on Windows 11 with an NVIDIA GeForce RTX 4090 (driver 32.0.16.2101) and AMD Radeon(TM) Graphics (driver 32.0.21043.5001). The two-target readback checks pass on both adapters.

  • The write fixture gives the expected RGBA values at all 64 pixels of each target. The discard fixture keeps each target's clear value at all 64 pixels.
  • The masked fixture gives the expected color at all 64 pixels of MRT0. MRT1 has no reference value. In one run, all 64 AMD pixels contain zero. All 64 NVIDIA pixels fall outside the clear, zero, and export-color groups.
  • A separate 3 × 5 draw gives 240 bytes per target on both adapters. Every pixel contains (1, 2, 3, 4) on MRT0 and (4, 3, 2, 1) on MRT1. The harness device line confirms each adapter.
  • The same write fixture and head checker with the harness from merge base 64b45d0 give missing MRT1 readback.

I built the head and base with cmake --build <build> --config RelWithDebInfo --target vk_harness --parallel 8. I used the four checked-in assembly fixtures as tab-indented listings with the repository translator and SPIR-V assembler. I ran the head's mrt_exports_test for each fragment fixture. This checks the Vulkan draw and readback. The llvm-mc fixture build and the full GPU suite remain untested. py -3.14 -I tests/test_shader_checks.py passes all 82 tests.

AI-assisted.

@PingasMech

Copy link
Copy Markdown

On Windows 11, Intel UHD 770 driver 32.0.101.7088, the unwritten MRT1 in ps_mrt_exports_masked retained its clear color at all 64 pixels. I changed only MRT1's clear value from −2 to −7 and got −7 in all four channels at every pixel. MRT0 stayed (1, 2, 3, 4) throughout. Each result repeated in three fresh draw processes, both on ba8b9aa6 and with #3988 (55338a17) merged locally. The normal run_gpu_tests.py --filter ps_mrt_exports --require-pass run passed 3/3 on this head. The different values now reported across drivers support keeping masked MRT1 observational.

The new readback also makes a regression test for #3988 possible. In a hand-written 8×8 draw using vs_ids, I exported MRT0 on the left half, restored EXEC, then exported MRT1 on the right half. Neither export had vm. I waited with s_waitcnt expcnt(0) after each export and cleared EXEC before ending the shader. I checked the written target on each side. A second version left the middle two columns out of both exports and checked that both clears survived there.

Check, three fresh draws per row This head With #3988
Left four columns have MRT0's export color 0/32 32/32
Right four columns have MRT1's export color 0/32 32/32
Leave a two-column gap: left MRT0 / untouched middle / right MRT1 0/24 · 16/16 · 0/24 24/24 · 16/16 · 24/24

As a negative control I changed the combined translator to keep only the last target's lane mask. The split draw then lost all 32 left-side writes while all 32 right-side writes still matched. I'd put this case with #3988's regression tests once the two-target harness lands. These results cover translated Vulkan draws; the original two-target RDNA2 behavior still needs a native measurement. AI-assisted, synthetic fixtures only.

@l-CatDemon-l

Copy link
Copy Markdown

Tested ba8b9aa6468ed4c226ecef649c310cc206d2555f on Windows, RTX 4070 Ti, NVIDIA 616.56, subgroup 32..32; native Python 3.13.1, MSVC 19.44, LLVM MC 23.1.6, SPIRV-Tools v2026.4. Built vk_harness from this head.

  • run_gpu_tests.py --filter ps_mrt_exports --require-pass: 3/3 pass; all four fixture modules translate and pass spirv-val.
  • Separate build.py build of the four fixtures, followed by focused check.pixel_test calls: 3/3 pass; all four modules validate for Vulkan 1.2.
  • Write/discard controls match every channel of all 64 pixels in both images. Masked MRT0 matches all 64; masked MRT1 contains zero in every channel on this driver, recorded as an observation only.
  • Existing ps_flat: 4096/4096 pixels; stencil-backed ms_v5_workgroup: 24/24 groups.
  • Four runner/checker CPU files: 143 tests pass. test_export_valid_mask.py: 19 tests pass.

Negative controls: the old one-target harness gives missing MRT1 readback. In a separate valid synthetic SPIR-V copy I changed only MRT1's store value to MRT0's color: MRT0 still matches all 64 pixels, MRT1 differs at all 64, and the checker reports MRT1 (0,0). The modified module passes spirv-val and executes successfully, so this exercises comparison of the second image.

No blocking issue found in the reviewed changes. These checks cover translated Vulkan draws and the test harness; no native RDNA2 reference, game files, full runtime run or full GPU suite.

@tupacfan04

Copy link
Copy Markdown
Contributor

VERIFIED GOOD, with one gap. At head (local RTX 5070, VS18/MSVC): VKH_MRT1=1 gives MRT0 all (1,2,3,4) and out.raw.mrt1 all (4,3,2,1); kill gives -1/-2 clears; MRT0-only leaves MRT1 at -2; single-target output is byte-identical to main, and no .mrt1 is written without the env var. check.mrt_exports_test reports "64 RGBA pixels each exact", masked reports "64 clear, 0 zero, 0 export color" (observational, as documented). Negative control: main harness with the same check says "missing MRT1 readback" in all three. 167 Python tests, compileall and merge-tree clean.

Unverified here: the three .asm fixtures through llvm-mc -> rdna2spirv, so the end-to-end run_gpu_tests.py --filter ps_mrt_exports and the translated masked-MRT1 bits on NVIDIA are not exercised. The arrays sized 3 for the 2-color+stencil --mesh-group-readback path look right but are unrun.

Approve. AI-assisted review, no game files.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested ba8b9aa on Intel UHD Graphics 630 (CFL GT2), Mesa 25.2.8 ANV, Ubuntu 24.04, device selected with LEONIDA_VK_DEVICE=Intel: pass.

scripts/run_gpu_tests.py --filter ps_mrt_exports --require-pass: 3/3 passed, 4 shaders translated, 4 pass spirv-val.

  • ps_mrt_exports_write: MRT0 and MRT1: 64 RGBA pixels each exact
  • ps_mrt_exports_discard: MRT0 and MRT1: 64 RGBA pixels each exact
  • ps_mrt_exports_masked: MRT0: 64 pixels exact; MRT1 observed (no reference): 0 clear, 0 zero, 64 export color, 0 other

So on ANV the masked MRT1 export lands at all 64 pixels, unlike the UHD 770 Windows driver result above, where MRT1 kept its clear color. tests/test_shader_checks.py: 82 tests OK.

AI-assisted.

@memorypressure

Copy link
Copy Markdown

Verified on current main (3faac55, merges cleanly): python -I tests/test_shader_checks.py gives 82 tests OK (re-run); the new cases cover the second-image requirement, truncated-readback detection, and the mixed-mask bucket report through a mocked harness, so the CPU-side logic is exercised without a GPU. The three new fixtures are hand-written listings, the .mrt1 sidecar name matches vk_harness, and the masked MRT1 value is explicitly reported as an observation without a hardware reference — the honest choice given #3988. The GPU readbacks themselves are hardware claims and unverified here; CI reports no checks for this branch. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@whattheflop

Copy link
Copy Markdown
Contributor

Native Windows Radeon integration verification of ba8b9aa6 with #5022 a1bb3449 on 3faac557. The two runner changes merged cleanly to tree 7105bfe0. Stock Release vk_harness, Ryzen 7 9800X3D Radeon iGPU (1002:13c0, AMD 25.10.30.02 / Windows 32.0.21030.2001), MSVC 19.38, Vulkan SDK and Khronos validation 1.4.363 enabled. AI-assisted, synthetic inputs only.

  • Both-target write and discard controls each matched all 64 pixels per target.
  • In the mixed case MRT0 matched all 64 expected exports. MRT1 had 0 clear, 64 all-positive-zero, 0 export-color, 0 other. That is an observation of the translated draw for a value without a defined reference.
  • GPU tests: verify the complete base-ID and UV readback (TEST-1129) #5022's vs_base_ids with firstVertex 16 and firstInstance 7 matched both IDs at all 4,096 pixels. All UVs were finite, with zero observed error in U and V.

The runner suite passed all four cases. Separate stock harness draws confirmed Khronos loaded at instance and device, with no validation warnings or errors. WSL LLVM 21.1.8 was used for CPU assembly only. Six modules passed Vulkan 1.2 validation and 176 focused Python tests passed.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested ba8b9aa on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_shader_checks.py -> OK

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

Keep the perspective fixture registered and exercise RGBA32F controls independently of an external format override. Copy the two targets to aligned offsets and write each image without padding.
@tylerstraub

Copy link
Copy Markdown
Contributor

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

I ran the three 8×8 RGBA32F fixtures five times in separate runner processes. The write and discard controls matched all 64 pixels on both attachments in every run. For the masked export, MRT0 matched all 64 expected pixels each time.

On MRT1 the masked draw placed all 64 pixels in the histogram’s “other” category on each of the five runs. None matched the clear value, zero, or the explicit export color. Together with the Windows result in the PR description, this supports keeping the masked MRT1 histogram diagnostic. The defined outputs passed in all 15 fixture runs.

AI-assisted verification.

@bunbeans2-arch

Copy link
Copy Markdown

Tested the current head 5d8091d on an AMD Radeon RX 9070 XT (RDNA4, subgroup 32..64) with AMD's Windows driver, Windows 11 23H2 (the AMD Windows runs here so far are at ba8b9aa). The run builds the PR's own vk_harness.cpp. scripts/run_gpu_tests.py --require-pass gives 219/235 passed, 16 skipped. All three fixtures pass:

  • ps_mrt_exports_discard and ps_mrt_exports_write: "MRT0 and MRT1: 64 RGBA pixels each exact"
  • ps_mrt_exports_masked: "MRT0: 64 pixels exact; MRT1 observed (no reference): 64 clear, 0 zero, 0 export color, 0 other"

tests/test_shader_checks.py gives 90 passed, 284 subtests passed.

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

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.