RT-STATE-AUDIT-FORMATS: quantize 16-bit packed UNORM and rgba4 fallback clears #2479
Closed
github-bot
wants to merge 4 commits from
github-bot/gh-2479 into main
AGit
pull from: github-bot/gh-2479
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2479
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2479"
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?
@lixonik on GitHub · 2026-11-27 16:18 UTC · original
lixonik:rt-state-audit-formats-packed-clear→main· +61 −12 · 4 files · 4 commits · closed without mergingPart of
RT-STATE-AUDIT-FORMATS(#2464; based on the format-state audit notes in #1608 by@kevincommitsand@Tauwni).Summary
VK_FORMAT_A1R5G5B5_UNORM_PACK16,VK_FORMAT_A4R4G4B4_UNORM_PACK16,VK_FORMAT_R4G4B4A4_UNORM_PACK16, andVK_FORMAT_A4B4G4R4_UNORM_PACK16todetail::render_target_clear_colorinruntime/src/vulkan_replay.hso 16-bit packed UNORM clears follow D3D12 round-to-nearest-even, clamp, andNaN -> 0rules across GPUs (VK_FORMAT_R5G6B5_UNORM_PACK16is intentionally left untouched to avoid overlapping #2268).std::nearbyint(std::clamp(channel, 0.0f, 1.0f) * 15.0f) / 15.0fin thergba4_render_fallbackclear path (runtime/src/vulkan_replay.h) withdetail::quantize_unorm(channel, 15.0)so 4-bit tie rounding andNaNhandling do not depend on the thread's active floating-point rounding mode.Tests
runtime/test/clear_color_test.cpp: added 16-bit packed UNORM clear quantization cases (A1R5G5B5,A4R4G4B4,R4G4B4A4,A4B4G4R4) andrgba4_render_fallbackreplay coverage underFE_DOWNWARD,FE_UPWARD, andFE_TOWARDZERO(full + rectangular clears, tie/clamp/NaN, includingVK_FORMAT_UNDEFINED).runtime/test/d3d12_b4g4r4a4_target_test.cpp: clear{0.5f, -1.0f, 2.0f, NaN}underFE_DOWNWARDand verify RGBA8 readback{0x88, 0x00, 0xFF, 0x00}(skips with 77 on GPUs with nativeA4R4G4B4color attachment support).runtime/test/d3d12_clear_formats_test.cpp: addedB5G5R5A1_UNORMandA4B4G4R4_UNORMdifferential WARP cases.Negative control & verification
main(ec91d695c):clear_color_testfailed onA1R5G5B5(got 0.5, expected 0.516129017).d3d12_b4g4r4a4_target_testfailed on RTX 5070 underFE_DOWNWARD(texel (8, 4) = 77 00 ff 00, want 88 00 ff 00).d3d12_clear_formats_testfailed on RTX 5070 vs WARP on 4B5G5R5A1_UNORMcases (layer 0f, WARP 10andlayer ef, WARP f0).ctest -R "^(clear_color|d3d12_b4g4r4a4_target|d3d12_b5g5r5a1_uav|d3d12_clear_formats)$": 4/4 passed.python scripts/check_no_game_data.py: clean.python -m unittest tests/test_ctest_registration.py: 6/6 OK.git diff --check: clean.GPUs tested: NVIDIA GeForce RTX 5070 (Windows 11, native Vulkan + WARP;
VK_LAYER_KHRONOS_validationnot installed locally).AI-assisted (Antigravity, Gemini).
Independent RTX 3080 Vulkan validation: all three focused CTests passed, including the RGBA8 fallback and the nonzero green outside the rect. Test report.
@djrolfes on GitHub · 2026-11-27 17:36 UTC · original
Independent Linux/Wine + NVIDIA RTX 3070 Ti review/test at
e7d11f0da(merged cleanly onorigin/mainc0201a806,wine-11.22, NVIDIA620.73.04). AI-assisted.render_target_clear_coloradds 16-bit packed UNORM quantization (A1R5G5B5,A4R4G4B4,R4G4B4A4,A4B4G4R4), andrgba4_render_fallbackswitches fromstd::nearbyinttodetail::quantize_unorm(channel, 15.0)so clears are independent of FP rounding mode.clear_color(native Linux build): PASSED (including all FP rounding modes andrgba4_render_fallback).d3d12_b4g4r4a4_target(Wine/Vulkan RTX 3070 Ti): PASSED (RGBA8 image, render-target clears 64x32 matched, SRV T# format 136, 0 validation errors, including theFE_DOWNWARDclear test).d3d12_clear_formatscompiled and ran on Wine/RTX 3070 Ti (0 failed, 0 in formats the layer does not expose); host WARP comparison differs under Wine because Wine's D3D12 is not Microsoft WARP.@MoonEyes on GitHub · 2026-11-27 18:40 UTC · original
Tested for #2464 as Aslanek asked: unit tests and a game run on my machine; CI ignored for now as asked.
Reading (marked):
Limits: one machine, one run for the PR, one run for each main witness.
AI-assisted (Claude Code, Claude Opus 5.5)
@MoonEyes on GitHub · 2026-11-27 19:49 UTC · original
Follow-up to my RUN above: the check on main is now done. Each of the three tests, built from this PR's test files on top of main ec91d695c's sources, fails on main and passes with the PR:
Same machine as above (RTX 4060 8 GB, NVIDIA 610.88, Windows 11). One correction to the RUN above: on main with this exact recipe the world entry was 195 and 200 s (two runs), not "about 165 to 200 s"; the 165-175 s runs had one setting changed. The rest of the RUN is unchanged.
AI-assisted (Claude Code, Claude Opus 5.5)
@Tauwni on GitHub · 2026-11-27 20:11 UTC · original
Tested on a Mac under Wine (Apple M3, macOS 26.5.1, Wine 11.0 with its MoltenVK 1.4.1), merged onto
main43a9d562d. Profile S, no game files. (MEASURED, 1 run each)maind3d12_b4g4r4a4_targetline 213: wrong == 0)clear_colorformat 8 rect 0 channel 0: got 0.5, expected 0.516129017)d3d12_clear_formatsd3d12_clear_formatsalso fails on plainmainhere: it needs WARP as its reference (WARP reference unavailable: differential test cannot run), which Wine lacks. Not this PR.This matters on Macs in particular: MoltenVK has no A4R4G4B4 colour attachment, so
rgba4_render_fallbackis the path every Mac takes.AI-assisted (Claude Code). Report only.
@timbot103 on GitHub · 2026-11-28 02:02 UTC · original
Reviewed at head
e7d11f0daon Windows 11 (MSVC 202219.44) with dual-GPU Vulkan validation (LEONIDA_VK_VALIDATION=1, Vulkan SDK1.4.363.0).Verification
clear_color_test,d3d12_b4g4r4a4_target_test, andd3d12_clear_formats_test.clear_color_test: 525 checks passed.d3d12_clear_formats_test(LEONIDA_VK_VALIDATION=1): passed with 0 validation errors on both NVIDIA GeForce RTX 5080 (616.64) and AMD Radeon(TM) Graphics (25.10.30.02).d3d12_b4g4r4a4_target_test(LEONIDA_VK_VALIDATION=1): passed on RTX 5080 (RGBA8 fallback exercised, 0 validation errors); skipped (77) on AMD Radeon (nativeA4R4G4B4attachment).Notes (non-blocking)
VkClearColorValue), NaN/Inf clamping, and directed-rounding quantization for the RGBA8 fallback (vulkan_replay.h:1550-1567,1637-1653,4862-4894) all look right.vulkan_replay.h:1637-1653):DXGI_FORMAT_B5G6R5_UNORM(VK_FORMAT_R5G6B5_UNORM_PACK16) is also an exposed 16-bit packed UNORM RTV (d3d12_vulkan_device.cpp:2335-2338) and still falls through to driver rounding; fine as a follow-up if covering all 16-bit packed UNORM RTVs.Approve.
AI-assisted review + local MSVC/dual-GPU verification.
@timbot103 on GitHub · 2026-11-28 14:36 UTC · original · reviewed
Static code audit against
e7d11f0da+ec740bcc3. The packed clear conversion and the shared color payload for full and rectangular clears look correct.Both regions now expect green
0x00, so a fallback that always writes zero to green passes (runtime/test/d3d12_b4g4r4a4_target_test.cpp:205). Could the outside clear use green10.0f / 15.0fand expect0xAAthere? That preserves a nonzero green readback alongside the new negative clamp, tie, and NaN checks.AI-assisted.
@lixonik on GitHub · 2026-11-28 15:44 UTC · original
@timbot103 Good catch.
8f45eda7duses10.0f / 15.0fgreen outside the rect and checks for0xAA. The inside still checks negative green clamping to zero, the red tie, blue clamping and NaN alpha.d3d12_b4g4r4a4_target,d3d12_clear_formatsandclear_colorall passed on Windows 11 with MSVC and RTX 5070 (610.88).AI-assisted.
@Maticcm on GitHub · 2026-11-28 20:55 UTC · original
Independent RTX 3080 verification at exact
8f45eda7dbbf091a63ff8732e18a8b191a82e1b8and parente7d11f0da41ea971af3627be077c998a9481c915. Native Windows 11 build 26340, NVIDIA driver 630.20, 10 GiB, MSVC 19.50.35717 RelWithDebInfo, Vulkan SDK 1.4.363.1 with Khronos validation.All three focused CTests passed on both revisions (
clear_color,d3d12_clear_formats,d3d12_b4g4r4a4_target) without skips. On the exact head, the 4444 render target used the RGBA8 fallback and all 64×32 pixels matched, including the new nonzero green0xAAoutside the clear rectangle. The format suite reported 261 WARP matches, zero differing or failed clears, and five checks for formats the layer does not expose. The fallback fixture reported zero Vulkan validation errors.Synthetic fixtures. AI-assisted (Codex).
@zmasi on GitHub · 2026-11-29 02:42 UTC · original
Windows 11 + RTX 3090 + WARP Verification (
8f45eda7dbmerged withmainc8bf0e7b65) — PASS10.0.26200), MSVC19.44.35207(/O2 /MD /EHsc /std:c++20 /W4 /permissive- /utf-8), NVIDIA GeForce RTX 3090 (610.88) + Microsoft WARP +VK_LAYER_KHRONOS_validation1.4.363.1(LEONIDA_VK_VALIDATION=1).git merge-treeontomain(c8bf0e7b65) (0conflicts);python -I scripts/check_no_game_data.pyrc=0;0new/W4warnings.clear_color_test.cppcompiled againstmainruntime/src/vulkan_replay.h): fails withrc=1(normalised clear: format 8 rect 0 channel 0: got 0.5, expected 0.516129017).d3d12_b4g4r4a4_target_test.cpplinked againstmainon NVIDIA GeForce RTX 3090 underFE_DOWNWARD): fails withrc=1(texel (11, 4) = 77 00 ff 00, want 88 00 ff 00becausestd::nearbyintrounded0.5 * 15downward to7instead of8).8f45eda7db+mainc8bf0e7b65):clear_color_test.exe:rc=0(525 full/rectangle integer, normalised and float replay checks passedacrossFE_DOWNWARD,FE_UPWARD,FE_TOWARDZERO, out-of-range, andNaNinputs).d3d12_b4g4r4a4_target_test.exeon NVIDIA GeForce RTX 3090:rc=0(OK (RGBA8 image, render-target clears 64x32 matched, SRV T# format 136, 0 validation errors)).d3d12_clear_formats_test.exeon NVIDIA GeForce RTX 3090 + WARP:rc=0(clears: 261 matched WARP, 0 differ, 0 failed,0VUID-validation errors).AI-assisted.
@OreoFR on GitHub · 2026-11-29 05:47 UTC · original
Verified by OreoFR — READY
c8bf0e7b6+ this PR (head8f45eda7d) merged with --no-ffclear_color: line 213,wrong == 0, because the PACK16 rows are not quantized.d3d12_clear_formats:got 0.5, expected 0.516129017on format 8, and 4 clears differ from WARP.d3d12_b4g4r4a4_targetfails as well.LEONIDA_CARGO=OFF,LEONIDA_XMA2_DECODER_LIBempty), main + this PR alone; imports unchanged vs main (25 DLLs, 655 functions, no WS2_32)AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.
1d3da5ebc7) and keep active_samples with quantized rgba4 clear aa1752225f@lixonik on GitHub · 2026-11-29 15:57 UTC · original
Merged
main(1d3da5ebc7) asaa1752225fto resolve theruntime/src/vulkan_replay.hconflict with #778 (d3d-sample-positions), keepingactive_samplesindetail::initialize(...)alongsidedetail::quantize_unorm(channel, 15.0).Local verification (Windows 11, MSVC 19.44, RTX 5070,
LEONIDA_VK_VALIDATION=1,VK_VALIDATE_SYNC=1):ctest --output-on-failure -R "^(clear_color|d3d12_clear_formats|d3d12_b4g4r4a4_target)$": 3/3 passed.python -I scripts/check_no_game_data.py: passed.AI-assisted (Antigravity, Gemini).
@OreoFR on GitHub · 2026-11-29 21:06 UTC · original
Verified by OreoFR (re-run at the new head after the main merge)
aa1752225merged with--no-ffonto main0e8737f2a; the PR's files are unchanged on main up to7bbc1d223, and the PR still merges cleanly thereLEONIDA_CARGO=OFFruntime/src/vulkan_replay.hrestored to main, so only the PR's tests are new): 3 of 3 failclear_color:format 8 rect 0 channel 0: got 0.5, expected 0.516129017d3d12_b4g4r4a4_target: line 213,wrong == 0(texels77where88is expected)d3d12_clear_formats: 599 clears match WARP, 4 differclear_color,d3d12_clear_formats,d3d12_b4g4r4a4_target)loaderandxbox_presentfail on main tood3d12_queue_wait_timeout(a 10 s timeout control) timed out twice while other builds were loading the machine, then passed 9 of 9 re-runs alone. The PR does not touch the queue wait path, so I count it as load-sensitive, not a regression.gta6rt.exeimports the same 25 DLLs as the main-side build, with no WS2_32. The only difference is one fewer CRT function:nearbyintfis no longer imported.cfd12b24f)8f45eda7dand with the author's run at this head.Ready to merge per the maintainers' plan.
This verification was AI-assisted (Claude Code, oreofr-agent).
@ammonium231 on GitHub · 2026-11-30 13:43 UTC · original
RTX 3090 / 621.40, validation on,
aa1752225merged onto mainf9f3ec4c6: clear_color_test 577 pass (main 567); d3d12_clear_formats_test 603 match WARP, 0 differ (main 598); b4g4r4a4 OK. No validation errors.@aslan2142 on GitHub · 2026-12-01 16:45 UTC · original
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.Pull request closed