Repository navigation
Conversation
|
Independently checked head Local build & dual-GPU verification (
Code review notes:
AI-assisted. |
|
Vice-Tay #370 isolates the transfer-function portion: an sRGB view reading a midpoint returned about 0.21582 rather than the raw 0.50196. That provides a simple full-alpha control for the sRGB path here. Then run the exact RGB/alpha pair at half alpha against the premultiplied path and retain a linear-format control. This would distinguish a transfer-function fix from applying the alpha correction twice. |
|
@timbot103 Thanks for the dual-GPU + validation verification! @akimfomin Good check --
AI-assisted (Antigravity, Gemini). |
timbot103
left a comment
There was a problem hiding this comment.
Static code audit against ef5620bf6 and ec740bcc3. The embedded SPIR-V matches an in-memory glslang compile byte for byte and passes Vulkan 1.1, 1.2, and 1.3 validation. The new uniform overlay expectations agree with the hand calculations.
runtime/src/present_compose.comp:153— Please preserve additive HDR light separately through bilinear filtering and SDR tone mapping. With 203-nit white and a 1000-nit peak, the 100-nit zero-alpha grey from C4 gives byte 186 over black. Mixing in just 2.5% opaque black gives about byte 45 because the shader divides the additive light by the filtered alpha before tone mapping. Weighting the additive contribution gives about byte 184. A mixed-texel C4 case would catch the resulting dark seam.runtime/src/present_compose.comp:100— C2b's UNORM red code 188 over grey 64 gives red byte 196 at alpha code 0 and clips to 255 at alpha code 1. Please handle the encoded additive excess independently of coverage and test those adjacent alpha codes.
AI-assisted.
|
@timbot103 Thanks for pointing out both edge cases. The previous shader failed at alpha code 1 with the new fixture. With the updated shader both new cases passed on Windows 11 with RTX 5070 (610.88). The standalone run still hit the existing swapchain resize failure later in the test. With #2507 applied locally, the complete AI-assisted. |
Summary
Fixes two alpha-decoding bugs in the PresentX composition shader (
runtime/src/present_compose.comp+ regeneratedruntime/src/present_compose.inc) for premultiplied plane 1 overlays:Premultiplied
*_UNORM_SRGBplane 1 overlays (flag_srgb_source != 0,flag_straight_alpha == 0,!opaque):An
*_UNORM_SRGBrender target blends in linear light and sRGB-encodes the premultiplied RGB on write, sotexelFetchalready returns linear premultiplied RGB. Previouslyfetch_texelre-encodedc.rgbwithsrgb_encode, divided the encoded value by linear alpha (srgb_encode(0.5) / 0.5 = 1.471), decoded it back (2.426), and multiplied by alpha (1.213), clipping translucent 50% and 25% white UI overlays to solid white (255instead of188and137).pc.sdr_eotf == 0u),fetch_texelnow returnsmax(c.rgb, 0.0)directly without re-encoding or dividing by alpha.pc.sdr_eotf == 1u),fetch_texelsplits continuously into the[0, a]unassociated sRGB component (preserving stored-byte identity for opaque pixels and avoiding 8-bit sRGB quantization jumps atlin ~= a) plus any additive excessmax(lin - a, 0.0).*_UNORM_SRGBoverlays (flag_straight_alpha != 0) and opaque*_UNORM_SRGBplane 0 are unchanged.Additive premultiplied pixels (
rgb > 0, a == 0) on plane 1:Previously
fetch_texelreturnedvec4(0.0)whenevera == 0.0(andto_workingreturnedvec3(0.0)whenplane_hdr && !out_hdr && a <= 0.0), discarding additive premultiplied glow/UI pixels even thoughpresent_compose.compexplicitly notes additive premultiplied colour support.*_UNORM_SRGBplanes now decodee/ preservelinwhena == 0.0, while transparent black(0, 0, 0, 0)and straight-alphaa == 0pixels still contribute zero light.to_workingnow tone-maps HDR10 additive emission whena <= 0.0instead of zeroing it.Updated
docs/d3d12_vulkan.mdsection 4.5 to document both rules.SPIR-V generator note (
runtime/src/present_compose.inc)main'spresent_compose.incwas compiled withglslc --target-env=vulkan1.1 -O -mfmt=c(shaderc generator word0x000d000b, ID bound0xbb3). Becauseglslcis not installed locally,present_compose.incin this PR was regenerated frompresent_compose.compusingglslang -V --target-env vulkan1.1(glslang generator word0x0008000b, ID bound0x35f, SPIR-V 1.3, 5041 words), which accounts for the full-file.incdiff.Verification
main39f52f39c):xbox_present_testfailed immediately at C2b withpixel 0,0 is 255,255,255, expected 188,188,188on a 50% premultipliedR8G8B8A8_UNORM_SRGBoverlay over black.xbox_present_testpass on RTX 5070: premultiplied and straight*_UNORM_SRGBoverlays under piecewise sRGB and gamma 2.2 (50% -> 188/186, 25% -> 137, opaque gamma 2.2 byte-20 identity), additive premultiplieda == 0for sRGB, UNORM, and HDR10 (PQ and SDR tone-map), plus transparent-black and straight-alphaa == 0invariants.main(39f52f39c) has a pre-existing resize-readback failure later inxbox_presentcase F (9f98dcc61regression, fixed separately in vulkan_present: keep continuous readback valid on OUT_OF_DATE present #2507). With vulkan_present: keep continuous readback valid on OUT_OF_DATE present #2507 applied alongside this PR,ctest --output-on-failure -R ^xbox_present$passes 1/1 (2.78 s).python -I scripts/check_no_game_data.pyon all 4 changed files: pass.python -I tests/test_ctest_registration.py -v: pass (6/6).git diff --check: clean;git merge-treeclean against open PRs Preserve sRGB midtones on the SDR UNORM swapchain fallback #2001, Treat BGRX overlays as opaque in PresentX composition #2014, and vulkan_present: keep continuous readback valid on OUT_OF_DATE present #2507.Claimed in #1608 (comment) (
RT-PICTURE-2D-LAYERS). No game files used.GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341;
VK_LAYER_KHRONOS_validationandspirv-valnot installed locally).AI-assisted (Antigravity, Gemini).