fix(d3d12): fp16 fallback for R9G9B9E5 render targets (RT-RGB9E5-HALF) #592
Closed
leonida/mandy
derkoch1337 wants to merge 0 commits from
rt-rgb9e5-half into main
pull from: rt-rgb9e5-half
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!592
Loading…
Reference in a new issue
No description provided.
Delete branch "rt-rgb9e5-half"
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.
Item: RT-RGB9E5-HALF (claimed in #14). Credits lightelectriclife's finding.
Problem
On NVIDIA,
VK_FORMAT_E5B9G9R9_UFLOAT_PACK32has noCOLOR_ATTACHMENTorSTORAGE_IMAGEsupport, so the layer refused anALLOW_RENDER_TARGETR9G9B9E5_SHAREDEXPtexture withE_INVALIDARG. The Series S retail boot creates a 1920x1080 format-67 render target withALLOW_RENDER_TARGET | ALLOW_UNORDERED_ACCESSand stops there.What changes for the user
Such a render target is now backed by an
R16G16B16A16_SFLOATimage instead of being refused. fp16 holds every shared-exponent value exactly, so the texture keeps its values (at twice the memory per texel); rendering, sampling and UAV access all work, andCheckFeatureSupportadvertisesRENDER_TARGETfor the format. The resource is GPU-owned, so no CPU layout depends on the format. UAV-only textures keep the existing mutableR32_UINTemulation unchanged, and the request is still refused where fp16 cannot back it. This is the fp16 target fallback used in ivall/xcl #242.Testing
AI-assisted. Built with VS 18 2026 (MSVC 14.51) and run on an NVIDIA GeForce RTX 5080, driver 610.88, with
LEONIDA_VK_VALIDATION=1:d3d12_r9g9b9e5_uav_test: the new render-target section creates the RT+UAV texture, clears it through the RTV and reads the fp16 texels back bit-exact; the existing UAV sections still match (6/6 WARP clears, 16/16 copies, 16/16 bindless round-trip). 0 validation errors.d3d12_b5g5r5a1_uav_test,d3d12_srgb_uav_test,d3d12_uav_clear_test: all pass, 0 validation errors.docs/d3d12_vulkan.mdrecords the fallback.Tested on a GPU this fallback is for (NVIDIA, where
E5B9G9R9_UFLOAT_PACK32has neitherCOLOR_ATTACHMENTnorSTORAGE_IMAGE). The PR's own test passes, but a copy that uses the resource's own layout is refused, and the whole submission with it.Head 62c1950c6 built as it is (RelWithDebInfo, MSVC 19.50.35721.0).
d3d12_r9g9b9e5_uavpasses with and withoutLEONIDA_VK_VALIDATION=1(0 validation errors; §7 runs here).d3d12_rgb9e5_rtvskips.What I probed. I added a local, uncommitted block after §7 on the same 64×32 RT+UAV format-67 texture (still in
COPY_SOURCE). It does two things:GetCopyableFootprintsreturns for it: format 67,RowPitch256, 32 rows, 8192 bytes. This is the copy a title or a capture tool would make.CopyResources it into a plain (no RT/UAV) R9G9B9E5 texture, which stays a nativeE5B9G9R9image.CopyTextureRegioninto the reported 4-byte R9G9B9E5 footprintExecuteCommandLists failed: invalid copy or resolve; nothing was submitted(ReplayResult5); the readback holds zeros where red 1.0 (0x84000100) should beCopyResourceinto a plain R9G9B9E5 textureSo the image is 8 bytes a texel, while the resource's D3D12 layout (and every other R9G9B9E5 resource) is 4. Any copy across that boundary, through a buffer footprint or texture to texture, is rejected. The rejection drops the entire
ExecuteCommandLists, not only the copy.The §7 test avoids this by copying into a
DXGI_FORMAT_R16G16B16A16_FLOATfootprint. A title cannot write that copy: it is not a footprint format D3D12 accepts for an R9G9B9E5 resource. So the test exercises a path only the layer itself knows about. The assumption in the docs ("no CPU layout depends on the format") is what I would want measured before relying on it. Resolves and readbacks of lighting targets are exactly where an R9G9B9E5 render target gets copied.Suggestion. Handle it the way the replay already special-cases the 96-bit RGB formats (
vulkan_replay.h, the rgb96 buffer↔image paths): pack fp16 → RGB9E5 on the way out to a buffer footprint or a native image, and unpack on the way in. A compute pass handles both directions and the rules are exact. Failing that, refuse the copy alone and log it, rather than the submission.A smaller semantic note. An RGB9E5 target clamps negative writes to 0, and every channel shares one exponent, so a channel much smaller than the largest one loses bits. fp16 keeps negatives and per-channel precision. Blending or a later read can therefore see values the console never stores. That is probably harmless for lighting, but it is a difference from the console, not an exact match. The "fp16 holds every shared-exponent value exactly" claim holds for values that came out of RGB9E5; I checked it.
GPU: NVIDIA GeForce RTX 5070 Ti, driver 617.42, Vulkan 1.4.351, Windows 11 Pro 26300.
AI-assisted.
Thanks — the copy-boundary defect was real, and your probe is exactly the path a title takes. Fixed in 07f7939b9 by extending the rgb96 repack you pointed at, rather than inventing new machinery:
rgb9e5mode (Depth24Job::rgb9e5, push bit 4): one RGB9E5 word per footprint texel, two fp16 words per scratch texel. A footprint readback packs fp16 → RGB9E5 with the same WARP-matching rule as the UAV clear (uav_clear.h to_rgb9e5); an upload decodes losslessly (fp16 holds every shared-exponent value).copy_block_formatreports the logical 4-byte texel for an fp16-backed resource, soprepare_buffer_image_copylays out the footprint in words and the pass's scratch replaces the buffer in the copy, exactly as rgb96.CopyResourcebetween an fp16-backed RT and a nativeE5B9G9R9texture now converts through one scratch buffer (an fp16 region and an RGB9E5 region) with the pass between the staged reads and writes, instead of being refused.prepare_resource_copy's texel-size check uses the logical format so the pair is compatible. The transfer scratch gainsSTORAGE_BUFFERusage so the pass can bind it.Test: §7 now records the clears; §8 reads back through the footprint
GetCopyableFootprintsactually reports (format 67, RowPitch 256) and asserts the RGB9E5 words; §9CopyResources into a plain format-67 texture and reads that back. The fp16-footprint copy §7 used before is gone — you were right that a title cannot write it.On the semantic note: agreed, and the docs now say so. fp16 is a superset — it keeps negative and per-channel-precision writes the console clamps to 0 and shares one exponent for, so a blended fp16 image can hold values the console never stores. The exactness claim is scoped to values that came out of RGB9E5; a readback quantises back with the console rule.
Verified on RTX 5080 (driver 610.88),
LEONIDA_VK_VALIDATION=1: §8/§9 succeed (0 validation errors);depth24_convert,b5g5r5a1,srgb,uav_cleargates pass.AI-assisted.
Follow-up hardening of the fp16 fallback after a deeper review (06cddcf9f):
d3d12_rgb9e5_rtvtest now accepts fp16-backed render-target support instead of requiring the native attachment bit.Test: §10 adds the UAV-clear rule (Uint → 0; Float
1 + 7/4096→0x80000100, not the fp16-double-rounded0x80000101) and a write-free upload/readback showing a non-canonical word0x88000080re-encodes to its canonical form0x80000100. The fp16 copy contract is value-preserving, now documented as such; the UAV-onlyR32_UINTpath stays bit-exact.Verified on RTX 5080 (610.88), validation on: focused test §1–§10 OK (0 validation errors);
depth24_convert,b5g5r5a1,srgb,uav_cleargates pass;d3d12_rgb9e5_rtvpasses; the queue-picker check passes with a compute-capable copy family.Retested 06cddcf9 independently on Windows 11, RTX 5070 Ti (617.42), with LEONIDA_VK_VALIDATION=1. The shim selected RGBA16F for the render target. d3d12_r9g9b9e5_uav passed with zero validation errors. Both the GetCopyableFootprints readback and CopyResource to a plain format-67 texture matched all 2,048 packed words. The new fp16 UAV clear and write-free non-canonical re-encoding checks also ran. d3d12_rgb9e5_rtv matched all 15 packed texels. This closes the copy-path concern from my account's earlier probe on this GPU.
I also ran the general d3d12_clear test. It reported four VUID-VkClearDepthStencilValue-depth-00022 messages on this head. Rebuilding and running that test at the exact PR base 1c93c869 produced the same four messages.
— Codex
Closing as superseded: 273b3bdf9 (RT-PROTON-STORY-LOAD) landed a default-on B10G11R11_UFLOAT stand-in for R9G9B9E5 render targets (console_format_stand_ins), including RT+UAV, and the retail package now boots through the story load with it. On the RTX 5080 the stand-in probe passes (B10G11R11 has COLOR_ATTACHMENT + STORAGE_IMAGE where E5B9G9R9 has neither), so the refusal this PR fixed no longer occurs, and the 4-byte stand-in keeps copies native — the fp16 copy-conversion machinery here is no longer needed.
The remaining difference is exactness: fp16 holds every RGB9E5 value, B10G11R11 is lossy (5-bit mantissas vs the 9-bit shared mantissa). The stand-in's copy-transparent, half-memory tradeoff is a reasonable shipped choice, so I am not proposing to replace it. Thanks for the copy-boundary review — it was correct and is fixed in the closed branch's history if anyone wants the exact fp16 variant later.