feat(agc): sample texture format 43 through a lossless B10G11R11 copy #7271
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7271"
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 gjonn on 2026-10-17T21:00:30Z.
What
Sampling a texture of format 43 (10_11_11 float) is refused on main ("samples or gathers a converted float image, or queries its LOD, which is not implemented"). This PR makes it sample natively, including at any LOD and from cube faces.
Format 43 holds unsigned floats of 10 bits (R, bit 0), 11 bits (G, bit 10) and 11 bits (B, bit 21).
VK_FORMAT_B10G11R11_UFLOAT_PACK32holds R11 at bit 0, G11 at bit 11 and B10 at bit 22. So if the guest R field goes into the Vulkan B field and the guest B field into the Vulkan R field, every texel moves without changing a bit of any component. A sampled format-43 texture is now uploaded that way: a repack pass runs over the detiled words (TextureRepack.comp), and the view swaps R and B back (TextureComponentChannel). The hardware sampler then filters it like any other float texture: point and bilinear, every mip level and LOD, and cube faces.If a storage image still holds the texture's results, the texture is copied from that image (
vkCmdCopyImageToBuffer, the repack pass,vkCmdCopyBufferToImage) and copied again whenever the image changes, as the depth and block copies are. The recompiler treats a sampled format-43 image as a float image with no conversion. Storage reads and writes keep the packedR32_UINTpath. A 3D texture whose results are still in a storage image is flushed and uploaded instead.Stops at: format 43 only. The other converted formats (11_11_10 unorm and the like) are unchanged.
Relation to open #5958 (converts converted unorm and float images in the shader): the two PRs complement each other. After this PR, format 43 no longer needs #5958's in-shader conversion, and #5958 is still needed for the other converted formats. They do interact in one test. If both merge, the #5958 test that expects its 8-bit-grid bilinear result for format 43 (1.693848) would need to drop that expectation, because native filtering gives 1.694336. Native hardware filtering is what the console's TMU does, so the native value is the exact one.
Tests:
ImageRepackedFloat(new GPU test):image_sample_lof a mipmapped format-43 texture at each LOD, plusimage_loadof mip 0. Cube-face samples are compared with a native B10G11R11 cube that holds the same texels, plusimage_loadof cube face 0.TextureFormat(CPU): format 43 is sampled asB10G11R11_UFLOATand stored asR32_UINT. Every R, G and B field value read through the repacked word and the swapped channel gives back the same bits and the same float, including Inf, NaN and denormals.ImageConvertedUnorm: pointimage_sample_lzofR10_G11_B11_FLOATwas expected to be refused and now returns the texel values. The test also samples it while the results are still on the GPU (from the storage image).Tested
Windows 11, NVIDIA GeForce RTX 5090 Laptop GPU, driver 616.92. Ninja/MinGW Release with
BUILD_TESTING=ON, on current main (bd56fa6fd).The test was failing before the change: I built main without the change, adding only this PR's test files. Two of those files call helpers this PR adds (
IsRepackedTextureFormat,RepackTextureWord), so on main they do not compile:To get runtime failures, I swapped in local copies of the two helpers (the bit swap only) for the main run:
With the change:
tools/check_conventions.py --base origin/mainandtools/check_test_registration.pyare clean.PPSA01317 on main: boot used to abort on its format-43 sampling, a mipmapped format-43 texture sampled at a LOD other than 0 and a format-43 cube map. With this PR it gets past both and runs to about 49 s into boot.
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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T21:19:42Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/shader/recompiler/Optimization/src/ResourceMaterializer.cppL227-228, L246core/libs/prx/libSceAgcDriver/CMakeLists.txtL236core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hppL85core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cppL7, L117Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/execution/ImageConvertedUnorm.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/include/TextureFormat.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureFormat.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cppcore/libs/prx/libSceAgcDriver/tests/TextureFormat.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-18T04:15:21Z.
RTX 4090 data point on PPSA01317, on top of my #7254 / #7256 runs (same stack, same box), where the title stopped on
samples a converted float image that is not a 2D or 2D array viewwhile sampling the 10_11_11 float cube map it had just rendered. Short version: with this PR that sample goes through on this GPU too, 3 of 3 runs, and the next stop is a limit of #5958 itself (sampling of a converted image is implemented only with wrap or clamp-to-edge addressing), which no open PR covers.Setup. Gran Turismo 7 PPSA01317 01.000.001 (base package), Windows 11 (26200), RTX 4090 (NVIDIA 616.92), AMD Ryzen 7 5800X, MinGW-w64 GCC 15.2.0 r7 (UCRT), Release
libstarget only (no tests built).app.exeis the relink frommain31cbb55d7(--windows --registry --module-dir .); onlylibs/is swapped between runs. Tree: the #7256 stack (main5f8d2a252+ #71372aa6bfca6+ #7207 ec28b6be8 + #7175 555b7e824 + #5958 87a9b8d28 + #7243da158d61f+ #72384aaf27699+ #72407c19c66de+ #7254ebe289bdc+ #7256558975214, b81f69024) merged with this PR's head571fecadd(7bc6cf432). One conflict, intests/execution/ImageConvertedUnorm.cpp, the #5958 test this PR edits; the PR's version was taken, and the file is not compiled here. ThelibSceSsl.prxis the one from #7319 (1f267559e). No controller, no input, nobody at the keyboard; one-shot interactive task per run, 600 s cap, box otherwise idle.Result. Run 1 recompiled the shader cache (the recompiler source changed), runs 2 and 3 were warm. All three get past the cube sample: splash, the black loading screen with the GT spinner (title-bar counter 30 FPS, 1,150 frames at the last capture of run 3), save data mounted, three
sceNetResolverStartNtoa -> host DNS lookup failed, 392 further shaders registered, one new warning (texture 0x123fe90000 (format 22) has mixed DCC keys at 0x1240610000; its texels are read as stored), and then, identically every time:That is #5958's
ResourceMaterializer.cppthrow for a converted image (one of the formats this PR leaves to #5958) sampled with clamp-to-border or mirror addressing, so on this box the open-PR chain for the title ends here until #5958 takes those address modes. No format-43 refusal of any wording, noImageRepackor copy failure, no device loss.shader 0x1258d31800 stage 5: samples a converted float image that is not a 2D or 2D array viewcompute shader 0x1258d69600: sampling of a converted image is implemented only with wrap or clamp-to-edge addressingThe chain on this box tonight, all on a
libsbuilt from the stack above: #6350 crash (#7137) ->sceSslConnect(#7319) -> 11_11_10 blend (#7243) -> dynamic-mip storage image (#7238) -> unnormalized sampler (#7240) -> layered colour view (#7254) -> layered depth view (#7256) -> converted float cube sample (this PR) -> #5958's addressing limit.stderr of run 3 (warm, box idle) from the second 10 s summary to the abort, the 392 per-shader
ShaderRegistrylines removedAI-assisted: yes (Claude Code)