mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:45:53 +01:00
[PR #1179] vulkan_replay: sRGB render-target clears are encoded in the layer, as WARP encodes them (D3D-CLEAR-SRGB-ENCODE) #1212
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1212
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1179
Author: @MalexAson
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/srgb-rtv-clear-encode📝 Commits (1)
e2c13dbvulkan_replay: sRGB render-target clears are encoded in the layer, as WARP encodes them (D3D-CLEAR-SRGB-ENCODE)📊 Changes
6 files changed (+231 additions, -16 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+41 -2)📝
runtime/src/vulkan_replay.h(+43 -3)📝
runtime/test/clear_color_test.cpp(+98 -4)📝
runtime/test/d3d12_clear_formats_test.cpp(+29 -2)📝
runtime/test/d3d12_clear_test.cpp(+6 -5)📝
runtime/test/d3d12_state_sweep_test.cpp(+14 -0)📄 Description
Claimed in the coordination issue as: D3D-CLEAR-SRGB-ENCODE
What and why
ClearRenderTargetViewonR8G8B8A8_UNORM_SRGBandB8G8R8A8_UNORM_SRGBhanded the linear float tovkCmdClearColorImageorvkCmdClearAttachmentsand the GPU encoded it, so the stored byte depended on the GPU. Against WARP,d3d12_clear_formatsdiffered in 10 clears andd3d12_srgb_uavin 2 on an Intel Iris Xe (0.5 isbbthere andbcon WARP).What I measured (the new "sRGB RTV clears" item in
docs/d3d12_vulkan.mdhas the details):mainonly because the five test colours miss those values.x * 4095in single precision, rounded half up) and then takes the nearest code of the sRGB curve. All 255 floats at which its byte changes are the ones this rule gives, and 84 582 further values agree.The change:
render_target_clear_colorencodes the colour channels itself by WARP's rule (srgb8_from_linear) and hands Vulkan the linear value of that code (srgb8_linear). Alpha is unchanged. This is whatquantize_unormdoes for UNORM ties.One thing for a maintainer to decide. A GPU's own D3D12 driver encodes as its Vulkan driver does, so the layer used to equal that driver and differ from WARP; now it equals WARP on every GPU and differs from that driver where the driver differs from WARP. I followed what the layer does for UNORM ties and D24: the layer converts, WARP is the reference, and a host that does otherwise is a host quirk. If you would rather keep the GPU's encoding, the alternative is to leave the layer alone and compare the sRGB colour channels with WARP within one code in the two tests. Say so and I will redo it that way.
d3d12_state_sweep_testcompares with the same adapter's D3D12 driver and cleared its sRGB targets to 0.2, 0.4 and 0.6, of which Intel's driver stores the first two as 123 and 169 where WARP has 124 and 170. With the layer change it differed in 4 of 482 cases on the Iris Xe, so its sRGB targets now start from the values of codes 124, 170 and 203, which every implementation measured stores alike. The sweep is about blending.Not changed: a draw into an sRGB target is still encoded by the GPU, and
d3d12_clear_teststill compares castable sRGB views within 1.Tested
On
main6293c1c4fwith MSVC 14.50 (Build Tools 2026), RelWithDebInfo, WARP 10.0.26100.5074, each on both GPUs throughLEONIDA_VK_DEVICE:d3d12_clear_formats: before, 241 matched WARP and 10 differ on the Iris Xe (251 and 0 on the RTX 4060). With the extended sRGB colours on the unfixed layer, 178 of the 352 sRGB cases differ on the Iris Xe and 170 on the RTX 4060. After: 593 matched and 0 differ on both.d3d12_srgb_uav: before, 2 of 4 clears differ on the Iris Xe; after, 0 failures on both.clear_color(no GPU): 567 checks pass.ctestfor the 23 tests that clear or present sRGB targets or use the changed code (d3d12_clear,d3d12_clear_restricted_depth,d3d12_clear_formats,d3d12_srgb_uav,d3d12_uav_clear,d3d12_short_uav_clear,d3d12_typeless_rtv,d3d12_typeless_families,d3d12_typeless_depth,d3d12_state_sweep,d3d12_draw,d3d12_present,d3d12_close_parity,d3d12_vulkan_device,dxgi_swapchain,xbox_present,xs_proxy_mock,vk_presenter_sync,typeless_rtv,clear_color,replay_clear_gate,replay_uav_clear_offset,d3d12_rgb9e5_rtv): on both GPUs 21 pass,d3d12_rgb9e5_rtvskips andd3d12_vulkan_devicefails. It fails the same way without this change (three resource-flag cases ofcompare_invalid_argumentsagainst the host runtime), which has nothing to do with clears.ctest(only these targets were built),LEONIDA_VK_VALIDATION=1(no validation layer on this PC), an AMD GPU, Linux.GPUs tested: Intel Iris Xe (Raptor Lake-P, 8086:a7a0), Intel 32.0.101.7092, Windows 11 build 26100; NVIDIA GeForce RTX 4060 Laptop GPU, NVIDIA 616.92, Windows 11 build 26100
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (not applicable: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.