fix(agc): swizzle opaque black borders like the T# DST_SEL #24793
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24793"
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?
Imported from boykopovar/AnyPS5. Originally posted by GiannisG1 on 2026-11-21T02:59:18Z.
What
#23059 recorded that RDNA2 (gfx1036, hardware oracle) applies a T#'s DST_SEL to an opaque black border the same way it does to a texel. For example, an 8_8_8_8 texture with DST_SEL W,Z,Y,X returns (1, 0, 0, 0) through
CLAMP_BORDERwithBORDER_COLOR_TYPE1. The entry adds that NVIDIA returns (0, 0, 0, 1) instead, because AnyPS5 does not use VK_EXT_border_color_swizzle. This PR uses it.The DST_SEL becomes the image view's component mapping (
ViewComponents). Vulkan-Docschapters/textures.adoc, "Instruction/Sampler/Image View Validation" makes the texel poison when an opaque black border meets a non-identity view swizzle, unless one of two things holds:borderColorSwizzleFromImageis enabled, in which case the device swizzles the border from the view;VkSamplerBorderColorComponentMappingCreateInfoEXT. Itscomponentsmust then equal the view's swizzle, and itssrgbmust equal the view's sRGB encoding, or the result is poison again.borderColorSwizzleborderColorSwizzleFromImageChanges:
VulkanDeviceenables the extension (with VK_EXT_custom_border_color, which it requires) and both features wherever they are offered.borderColorSwizzleFromImage,resolveImageBindingrecords, for each S# that reads an opaque black border, the real view swizzle and sRGB encoding of every texture paired with it. "Real" meansTexture::ViewComponents(): depth-compare and depth-copy views use identity.applySamplerVariantsthen callsOpaqueBlackBorderMapping:CheckOpaqueBlackPairing).borderColorSwizzleFromImagetakes no new path apart from enabling the feature.The debt entry from #23059 is still a pending fragment, so it is cut to what stays open in place, as
a1aad4c914did. The remaining items are the fallbacks above, formats other than 8_8_8_8 (unmeasured), and the 5_6_5 / 1_5_5_5 / 4_4_4_4 host channel orders on devices that swizzle from the image.Tests:
agc_driver_image_sample_border_colorgets new cases for an opaque black border under DST_SEL W,Z,Y,X (UNORM and UINT, expecting (1, 0, 0, 0)) and X,X,X,X (expecting (0, 0, 0, 0)). Z,Y,X,W keeps (0, 0, 0, 1). It also covers a transparent black border under W,Z,Y,X and an opaque white border under X,X,X,X. Those three keep the border and run on every device. On a device withoutborderColorSwizzle, the moved cases still run (on today's sampler), but their values are not checked, because Vulkan leaves that border undefined there; the test then reports a skip with a device-limitation reason.VulkanDevice::BorderColorSwizzle()reports the feature.agc_driver_graphics(GuestSamplerResource.cpp):OpaqueBlackBorderMappingoutcome, including an identity component compared with its explicit channel;vkCreateSamplerwith its components andsrgb;CheckOpaqueBlackPairingfor table pairings.Tested
Setup: Linux Mint 22.3, kernel 7.0.0-38, GCC 13.3.0, Release build, run under Xvfb. The head is on
main3bf7091b75and merges cleanly with7ed059fc42. lavapipe is Mesa 26.0.8, built from the release tarball and selected withVK_DRIVER_FILES.borderColorSwizzleFromImagemain+ the new cases, 3 runs8_8_8_8_UNORM opaque black border under DST_SEL W,Z,Y,X: thread 0 component 0 is 0x00000000, expected 0x3f800000CI's llvmpipe already swizzles the border from the image, so only a device like the GTX shows the bug.
agc_driver_graphicsfails against a mutation of this PR in whichOpaqueBlackBorderMappingnever returns a mapping. It stops atan identity component and its explicit channel were taken for different swizzles, and the border test fails on the GTX.agc_driver_image_sample_border_color,_image_sample_shared_sampler,_image_sample_vcc_sampler,_image_table,_image_table_variants,_image_table_cache,_many_direct_samplers,_graphicsandagc_shader_sampler_limits.check_skips.pyaccepts every skip.VK_LOADER_DEBUG=layer, on the same nine tests on all four devices.VUID-vkCreateDevice-ppEnabledExtensionNames-01387: VK_EXT_border_color_swizzle requires VK_EXT_custom_border_color. That extension is now enabled with it, and only on devices that offer both. Its features stay off.VUID-,SYNC-HAZARD-orUNASSIGNED-message. The same tests onmain's sampler code give none either.borderColorSwizzlewas masked with the Khronos profiles layer on the GTX 1050 Ti, the HD 630 and llvmpipe 25.2.8.1d24b3936dstops witha texture whose swizzle moves the opaque black border of its sampler needs VK_EXT_border_color_swizzle, as on the RX Vega 56.43e35e76d7runs the moved cases, logs the fallback once, and reports the skip (exit 77) on all three, 3 of 3 runs;check_skips.pyaccepts the reason.43e35e76d7(tools/suite.py -j2: every test once, and the GPU tests on the GTX 1050 Ti, the HD 630 and llvmpipe). I compared it with our run of3bf7091b75+ #23809's libc change. The skips are the same, and so are the failures:main;main's run also had the intermittentagc_driver_frame_replay_rewind_copy(#22028).agc_driver_image_gather_lod(#24100),agc_driver_image_table_packed_guards(#21255) andagc_driver_scattered_runs(#21649), as onmain.check_conventions.py,check_test_registration.py,check_main_sync.py,check_compile.py,debt_fold.py --checkandgit diff --checkare all clean.pr_overlap.py --branch: #16935 extends the sameSamplerCache::Getsignature and the same key word. It uses bit 3 there; this PR's mapping starts at bit 4, so both fit, and whichever merges second resolves the signature. #7085 (theTexture.cppview lines) and #12904 (the test'sSamplerCapture) merge cleanly with this branch (git merge-tree).Sampler.hpp,Sampler.cpp,ShaderResources.hpp,ShaderResources.cppandtests/GuestSamplerResource.cpp. Both PRs extendSamplerCache::GetafterintegerBorder, word 4 of the cache key (its bit 3 and colour words, this PR's bits 4 and up) and the sampler construction (its custom-border eviction, this PR's mapping). Whichever lands second combines them. Custom border colours fall under the same Vulkan rule, so its table colours read through a T# with a non-identity DST_SEL need the same pairing once both have landed.Sampler.hpporTexture.cpp.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T03:18:12Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed hunks show no concrete blocking defect, but the full review is incomplete because no checks were run and some changed files were only read around their affected code.
What I ran
Reviewed head
1d24b3936d61b2358c80213d270af52693ff2304using the prepared diff and the pinnedrepo_read.pyreader. No build or tests were run.Results
Findings
Blocking
None identified in the code inspected.
Non-blocking
None.
Sources
Reviewed the prepared description, commit summary, manifest, and diff. Read the changed files
Context.hpp,Sampler.hpp,ShaderResources.hpp,Texture.hpp,TextureFormat.hpp,Sampler.cpp,TextureFormat.cpp,GuestSamplerResource.cpp,ImageSampleBorderColor.cpp, anddocs/dev/debt/changes/docs-nvidia-border-dst-sel.md. Also read the affected ranges ofVulkanDevice.cpp,ShaderResources.cpp, andTexture.cppthroughrepo_read.py.Not verified
No build, unit tests, execution tests, validation layer, or hardware behavior was independently verified. The full text of
VulkanDevice.cpp,ShaderResources.cpp, andTexture.cppwas not read; only relevant ranges were inspected. No other repository files were read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:22:54Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
43e35e76d785bb105fbbb4996eb8581a56a3eacethroughrepo_read.pytools. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
VulkanDevice.cpp,ShaderResources.cpp, andTexture.cppwas not read; only touched ranges and relevant callers were inspected. The review bundle excludes no changed files, but these three full texts were too large for inclusion. No build, tests, validation layer, hardware, or console behavior was independently verified.To get this to a good state
Nothing is required.