Repository navigation
feat(agc): sample non-sRGB textures through FORCE_DEGAMMA samplers as sRGB views - #4487
Conversation
… sRGB views A sampler with FORCE_DEGAMMA decodes the texels of a non-sRGB 8-bit texture as sRGB. Such a binding was refused; it now samples an sRGB view of the same image. Snapshot images whose format has an sRGB twin (R8, R8G8, RGBA8, BGRA8, ABGR8 packed, BC1/2/3/7 UNORM) are created with MUTABLE_FORMAT, and storage images are already mutable. The view is made on first use for the full, first-layer or base-level range, with sampled usage only and the descriptor's minimum LOD. A format without an sRGB twin is still refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Has this version been run on PPSA26344? The description says only an earlier one was. |
|
Another data point: High on Life (PPSA15388) stops on this error in its home base (a later save): With this PR cherry-picked onto my stack ( Tested and written by Claude (AI assistant) on a contributor's machine. |
|
Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on main
Not tested: no game run. The batch was built once, not per PR; nothing failed, so no bisect was needed. AI-assisted (Claude Code). |
… in the shader SrgbTwinFormat mapped R8_UNORM and R8G8_UNORM to R8_SRGB and R8G8_SRGB without asking the device. Where 8_SRGB or 8_8_SRGB is decoded in the shader (context.srgbDecodeFormats: the device cannot sample the sRGB format, or APS5_SRGB_SHADER_DECODE=1), the forced view would have been created with a format the device cannot sample. Those two formats now get no twin there, so a FORCE_DEGAMMA sampler on them keeps the refusal. The image is no longer created MUTABLE_FORMAT either. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@oneandonlydean thanks, you're right. On PPSA26344: no, this exact head hasn't run there. Our Yōtei runs (run85, about 66 minutes, intro and wolf scene, no stop on this error) used a local integration stack. It has the same forced-sRGB change plus the Tests
Tested and written by Claude (AI assistant) on a contributor's machine. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ireSame The test cherry-picked from boykopovar#4487 calls the five-argument RequireSame that main gained with boykopovar#3843 (ANISO_OVERRIDE), which this branch does not have. Fold the extra labels into the three-argument form and drop the ANISO_OVERRIDE case.
lean-x24 (fcfc98c + boykopovar#4487) passed the loading bursts but died at ~1344 s when an allocation in the overflow type itself failed: 82k spilled snapshots had been made by then (26 GB), a new set for every build that bound the same image tables, since spilled snapshots were never admitted and their one-off entries only reused them while a build still held them. 4.7 GB of them were alive with heap 1 (system memory) at 11.6 of its 15.5 GB budget; on an idle machine the RTX 3080 Laptop takes 12 GiB of type 0 past a full VRAM (agc_driver_texture_memory_placement full), so the limit is the system memory the driver moves those pages to. - Spilled snapshots stay alive in their one-off entries (same validity checks as cache hits), least recently used first out, unused ones only. - The overflow budget: the system heap's VK_EXT_memory_budget budget less its usage less a sixteenth (APS5_TEXTURE_OVERFLOW_MIB forces it). Before each lookup, kept snapshots go while the overflow type (or system memory) holds more; while still over, up to four of the oldest recorded batches are waited for (Recorder::RetireOldest) and the kept ones trimmed again. The out-of-memory reclaim drops kept ones too. - Overflow-type bytes count as the caches' own (not other usage) but are not taken from the sampled ceiling or the share. - [texture-cache] reports snapshots made vs distinct surfaces, spilled reuses, kept drops and waits per 10 s; [mem] adds tex_overflow_live, _budget, _kept, _dropped, _waits, tex_snapshots_made, tex_spilled_reuses. - burst_overflow test: 5 builds binding the same 8 mipmapped snapshots past the share make 5 (not 25+), reuse 20, and the burst's kept ones are dropped down to a 4 MiB budget.
What
A guest sampler with FORCE_DEGAMMA makes the hardware decode the texels of a non-sRGB 8-bit texture as sRGB.
mainrefuses that binding ("…which is not sRGB, is sampled through a sampler that forces sRGB decoding, which is not implemented"). With this change the binding samples an sRGB view of the same image:Texture::SrgbViewcreates the view on first use, for the range the binding needs (full, first layer or base level). The view hasVK_IMAGE_USAGE_SAMPLED_BITusage only and carries the descriptor's minimum LOD.SrgbTwinFormatmaps R8, R8G8, RGBA8, BGRA8, ABGR8 (packed) and BC1/2/3/7 UNORM to their sRGB formats.VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, so the view is valid. Textures viewed from storage images are already mutable.RequireDegammaFormatbecomesForcesDegammaOn, which tellsShaderResourcesto bind the sRGB view. A texture with no sRGB view (a format without an sRGB twin, or an image that isn't mutable) is still refused, and the message says so.Tested
Windows 11, RTX 4090.
agc_driver_image_sample_force_degamma. The case that expected a rejection for 8_8_8_8_UNORM now checks:On
mainthe new test fails with the old refusal.Validation layer (
VK_LAYER_KHRONOS_validation, SDK 1.4.363.0): the test passes with no errors or warnings. To check that the layer covers the change, I built it once withoutVK_IMAGE_CREATE_MUTABLE_FORMAT_BITon the image. The test still passed on this driver, but the layer reportedVUID-VkImageViewCreateInfo-image-12397(an R8G8B8A8_SRGB view of an R8G8B8A8_UNORM image).Full suite: 966/966 pass; 7 tests skip on this machine (
agc_driver_stencil_ref_export, fivevideo_out_flip_*,guest_video_out_wqhd_detection_no_vulkan).Ghost of Yōtei (PPSA26344): an earlier version of this change let its shader
0x80003fca00sample a BC1 texture through a FORCE_DEGAMMA sampler instead of stopping at the refusal. That version didn't create the image as mutable, which this one fixes.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (the remaining case is a refusal).mdfiles or images added to the repository🤖 Generated with Claude Code