RT-STATE-AUDIT-FORMATS: quantize 16-bit packed UNORM and rgba4 fallback clears #2479
Closed
leonida/mandy
lixonik wants to merge 0 commits from
rt-state-audit-formats-packed-clear into main
pull from: rt-state-audit-formats-packed-clear
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
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
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!2479
Loading…
Reference in a new issue
No description provided.
Delete branch "rt-state-audit-formats-packed-clear"
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?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Part 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.
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.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)
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)
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.
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 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.
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).
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.
Verified by OreoFR — READY
clear_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.
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).
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).
RTX 3090 / 621.40, validation on, aa1752225 merged onto main f9f3ec4c6: clear_color_test 577 pass (main 567); d3d12_clear_formats_test 603 match WARP, 0 differ (main 598); b4g4r4a4 OK. No validation errors.
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.