Skip to content

fix(agc): sample 1_5_5_5 textures through A1R5G5B5 - #23360

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
GiannisG1:fix/agc-sample-135-through-a1r5g5b5
Nov 28, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
GiannisG1:fix/agc-sample-135-through-a1r5g5b5

Conversation

@GiannisG1

@GiannisG1 GiannisG1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Guest format 135 (Format1_5_5_5UNorm: X/Y/Z/W at bits 0/1/6/11, widths 1/5/5/5, #14628) is sampled and stored through VK_FORMAT_R5G5B5A1_UNORM_PACK16. Vulkan requires no feature for that format (Mandatory Format Support: Sub-Byte Components lists it, like B5G5R5A1, with no mandatory feature), and some devices have none:

Device (optimal tiling) R5G5B5A1_UNORM_PACK16 A1R5G5B5_UNORM_PACK16
NVIDIA GTX 1050 Ti (580.178.04) sampled, filtered, transfer src/dst sampled, filtered, transfer src/dst
Intel HD Graphics 630 (Mesa 25.2.8 ANV) not listed sampled, filtered, transfer src/dst
llvmpipe (Mesa 25.2.8) sampled, filtered, transfer src/dst sampled, filtered, transfer src/dst
lavapipe (Mesa 26.0.8, as on the anyps5-3 CI runners) sampled, filtered, transfer src/dst sampled, filtered, transfer src/dst

On the HD 630, textures and storage images of 135 are still created, uploaded, copied and filtered in R5G5B5A1. agc_driver_image_packed16_load and agc_driver_image_packed16_storage_135 pass only by luck there; the validation layer reports VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251, VUID-VkImageViewCreateInfo-None-02273, VUID-vkCmdCopyBufferToImage-dstImage-01997, VUID-vkCmdCopyImageToBuffer-srcImage-01998 and VUID-vkCmdDispatch-magFilter-04553.

  • Sampled textures now use A1R5G5B5_UNORM_PACK16, which every Vulkan device must sample, filter and copy (same table). Rotating each 16-bit texel right by one bit moves X/Y/Z/W from bits 0/1/6/11 to 15/0/5/10, which are A/B/G/R of A1R5G5B5, so the existing A/B/G/R selectors of 135 stay. The rotation runs on the paths format 43 already uses for its B10G11R11 repack: after the detile on upload, and in the copy from a storage image (CanRepackCopyFrom, RefreshDepthCopy). TextureRepack.comp gets a third mode next to 10_11_11 and depth-to-float, selected by TextureRepackFor. It runs on every device, so lavapipe on CI exercises the same path as the HD 630.
  • 16-bit ranges: a 135 region need not be whole 32-bit words, for example a storage image copy of odd width (its levels are packed tightly) or an odd linear pitch. For the rotation, DispatchRepack takes 2-byte-aligned ranges. A word the range shares with its neighbour is rewritten only in the range's own half, after a barrier that orders it after earlier repacks. The linear buffers are rounded up to whole words.
  • Storage images keep their R16_UINT views. The image itself is now created as R16_UINT where the device cannot sample and copy R5G5B5A1 (StorageFormatOrUndefined), and stays R5G5B5A1 elsewhere. Sampled 135 textures never view the storage image directly; they take the repacked copy.
  • ResolveTextureFormat and the DCC clear texels keep 135's guest layout (R5G5B5A1). A fast-cleared 135 texture is filled on the CPU and uploaded through the rotation, as format 43 already is.
  • The format-135 debt entry is updated (fragment fix-agc-sample-135-through-a1r5g5b5.md).

Tested

All runs below are mine, on one machine: Linux Mint 22.3, GCC 13.3.0, Release, head on main 866864a5bc.

  • tests/TextureFormat.cpp (agc_driver_graphics): 135 is repacked with the rotation and sampled as A1R5G5B5 (43 keeps its 10_11_11 repack); ResolveTextureFormat and DccClearTextureFormat keep R5G5B5A1. All 65536 texel values, each paired with a neighbour in one word, rotate so that the A/B/G/R selectors read X/Y/Z/W. A mock device without R5G5B5A1 features keeps 1_5_5_5 storage images as R16_UINT; one with them keeps R5G5B5A1.
  • tests/Recorder.cpp, new agc_recorder_rotated_repack: the repack shader rotates all 65536 texel values exactly as RotateTextureWord does. A range of texels 3 to 7 rotates only those, with both of its boundary words shared. A 5x3 1_5_5_5 storage image with two levels (30 and 4 bytes, the second starting in the middle of a word) is served through the repacked copy and reads every component correctly at both levels. Since 65d0793 (asked for by u-instinct11), 64 pairs of repacks in one command buffer whose ranges meet inside one destination word must leave every texel rotated or untouched, which needs the compute-to-compute barrier DispatchRepack records before a partial-word read-modify-write.
  • Without the fix: with 135 not repacked and DispatchRepack taking only whole words, agc_driver_graphics fails with texture format 135 must be sampled through a rotated copy and agc_recorder_rotated_repack with a texel repack needs whole aligned words. Without the R16_UINT storage fallback, agc_driver_graphics fails with a device that cannot copy R5G5B5A1_UNORM must keep 1_5_5_5 storage images in their R16_UINT form. Each failed in 3 of 3 runs on the GTX. With only that barrier removed, the adjacent-halves case fails 5 of 5 runs on the GTX (left texel 4 as 50245, expected 57890) and 5 of 5 on the HD 630 (texel 4 or 5). llvmpipe runs the dispatches one after another and passes 5 of 5. With the barrier, it passes 3 of 3 on each, with no validation-layer (SDK 1.4.363.1) messages.
  • Focused, 3 runs on each of the GTX, the HD 630, llvmpipe and lavapipe, all 16 pass, and check_skips.py is clean: agc_driver_graphics, agc_recorder_rotated_repack, agc_recorder_cube, the five agc_driver_image_packed16_*, agc_driver_image_repacked_float, agc_driver_own_refresh_repack_alias, agc_driver_recover_repack_allocation, agc_driver_image_depth24, agc_driver_image_depth24_float (the depth-to-float repack mode), agc_driver_image_load_packed, agc_driver_image_store_packed, agc_driver_image_packed_horizontal_gather.
  • Validation layer (Khronos 1.4.363.1 from the LunarG SDK): VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1, ctest -V -j1 on the same tests (15 on main, which lacks the new one), main 866864a5bc and this PR, on all four devices. Everything passes on both sides. The loader inserts the layer in every test that opens a device (all but agc_driver_graphics, which uses mock devices) and never reports it as not found. On main, the GTX, llvmpipe and lavapipe report nothing; the HD 630 reports 82 messages, all five VUIDs above, in agc_driver_image_packed16_load (36) and agc_driver_image_packed16_storage_135 (46). With this PR, all four devices report nothing.
  • Split suite (tools/suite.py: every test once, GPU tests on all three devices) on this PR, compared with main 866864a5bc's own run on the same machine. Nothing fails with the PR that does not fail on main. GTX: 6164 run, 2 failed, guest_libressl3_aes and guest_libressl3_aes_wrap (fix(libSceLibreSsl3): reject oversized lengths in AES_wrap_key and AES_unwrap_key #23208's length bound against the older tests; test(libSceLibreSsl3): probe unreadable key-wrap input at an accepted length #23337 and fix(libSceLibreSsl3): drop the INT_MAX length bound from AES_wrap_key and AES_unwrap_key #23334 are open). HD 630: 1687 run, 10 failed, all failing on main too (main also had agc_driver_pm4_order_signal). llvmpipe: 1687 run, the same 8 failed as on main. agc_driver_recorder, whose full run now includes the new test, stops on HD 630 and llvmpipe on both sides at an unchanged draw input was copied again (test(agc): skip the draw input mirror cases on devices whose memory is all device-local #20831), before reaching it; on the GTX it passes.
  • check_conventions.py, check_test_registration.py, check_main_sync.py (merges cleanly), check_compile.py and git diff --check are clean.
  • Overlap: pr_overlap.py --branch names feat(libSceAgcDriver): sample guest X24_8_32_FLOAT images through D32_SFLOAT_S8_UINT #16427, which also turns TextureRepack.comp's depthToFloat push constant into a mode and uses 2 for its X24_8_32 extract, and fix(agc): refuse 10_10_10_2 signed and 4_4 textures the device cannot sample #22717, which changes the two SampledTextureFormat lines next to the ones changed here. Whichever lands second renumbers its mode or takes the other's lines; I'll rebase this one if it is second. Of the 39 PRs it could not compare (they conflict with main), none changes the lines changed here. feat(agc): look up table images at run time through a device image table on the GPU heap (APS5_GPU_PATH) #7642, feat(agc): GPU descriptor heap on VK_EXT_descriptor_heap (APS5_GPU_HEAP) #9508, feat(agc): serve lane-keyed, pointer and runtime image-table columns #10193, feat(agc): resolve table samplers through device image keys #13928 and feat(agc): resolve runtime sampler addresses through device image keys #13929 add an addressed variant of the same shader's push block, and feat(agc): read frame capture deltas with the title's work in flight #15136 edits the same Windows set_tests_properties line.

Update 2026-11-26 (head e4cb9ddab3): rebased onto main e09d1349b5, after #22717. The one conflict was in SampledTextureFormat(): #22717's OptionalSampledBit check is kept, followed by this PR's explicit 10_11_11/11_11_10 → B10G11R11 and 1_5_5_5 → A1R5G5B5 lines. The old IsRepackedTextureFormat form is dropped, because with this PR it would also cover format 135.

On this head:

  • The focused set passes 3/3 on the GTX 1050 Ti, the HD 630, llvmpipe and lavapipe.
  • With the validation layer (Vulkan SDK 1.4.363.1), main logs 82 messages in that set on the HD 630, all from format 135: VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251, VUID-VkImageViewCreateInfo-None-02273, VUID-vkCmdCopyBufferToImage-dstImage-01997, VUID-vkCmdCopyImageToBuffer-srcImage-01998 and VUID-vkCmdDispatch-magFilter-04553. This branch logs none. The other devices log none on either side.
  • The split suite matches our main d237f5d065 run, except for two tests added to main since then. They fail the same way on unmodified main e09d1349b5 (3 runs):
    • agc_driver_float64_transcendental_denormals on the HD 630 (v_rsq_f64 of 0x…01);
    • agc_driver_image_filter_mode_three on llvmpipe (format 37 through a min/max reduction sampler).
  • The checkers are clean.

Merge order with #16427: if it lands first, both PRs extend DispatchRepack (this PR's TextureRepack enum, its mode 0/1/2), so the rebase has to fold its modes into the enum.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce GTX 1050 Ti (580.178.04), Intel HD Graphics 630 (Mesa 25.2.8), llvmpipe (Mesa 25.2.8), lavapipe (Mesa 26.0.8, built locally), Linux Mint 22.3
  • AI-assisted: yes

🤖 Generated with Claude Code

@GiannisG1

Copy link
Copy Markdown
Contributor Author

The red windows check fails only guest_libressl3_aes and guest_libressl3_aes_wrap, the two tests #23208 broke on main (reverted in #23365 after this run started). This PR doesn't touch libSceLibreSsl3; both tests fail on main 866864a5bc here too, with and without this PR.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 16427 core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp L56
core/libs/prx/libSceAgcDriver/Graphics/shaders/TextureRepack.comp L13, L20-21
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L796, L802
core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp L393, L395, L414, L433

Some 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.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6186 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6209 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6280 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/shaders/TextureRepack.comp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp
PR 9289 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/shaders/TextureRepack.comp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 9712 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 9852 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/shaders/TextureRepack.comp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 10442 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10743 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 11825 core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp
PR 12746 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 12792 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 13251 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 13796 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 13809 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 13928 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/shaders/TextureRepack.comp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 13929 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/shaders/TextureRepack.comp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 14262 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 15136 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 15456 core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 15529 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 15570 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 15621 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 16260 core/libs/prx/libSceAgcDriver/Graphics/src/TextureFormat.cpp
core/libs/prx/libSceAgcDriver/tests/TextureFormat.cpp
PR 16831 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 16953 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 17943 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 18082 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 18173 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 18185 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp
PR 20183 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 20580 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 20786 core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp
PR 21923 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 22190 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 22434 core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 22531 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 22647 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 23096 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 23157 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 24444 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 25610 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 26036 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 26613 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 26706 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 27133 core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake

@Colewiz7

Copy link
Copy Markdown
Contributor

Head 224fb9d833 merged onto main d89f26516c as 2ad7b5c262, no conflict. Linux 7.3.4, GCC 16.2.1 Release, Mesa 26.2.6 RADV, RX 7900 XT (gfx1100) and 7800X3D iGPU (gfx1036).

No new failures and no new validation messages on either GPU.

RX 7900 XT iGPU
tests run (6172 on the 7900 XT, the 2008 GPU ones on the iGPU), new failures vs main none none
-R '^agc' (1941 tests) with the layer, new failures vs main none none
VUID- / SYNC-HAZARD lines 0 / 0 0 / 0

Layer runs used VK_LAYER_KHRONOS_validation 1.4.363.1 with VK_LOADER_DEBUG=layer and ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1; the loader inserted the layer in every run, and the validation message set matches main.

AI-assisted: yes

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — comments

Changes are required before merge: clarify that validation and device test results are author-reported; this review did not run them.

What I ran

Reviewed head 224fb9d8335f48c7a6cccb616bafc8d089513767. Read the prepared description, commits, manifest, diff, and the included changed files; used repo_read.py to inspect the excluded Texture.cpp and related source callers. No commands or tests were run.

Results

Check Result Note
Source review passed Relevant code and callers inspected
Tests and validation not run Results in the description are author-reported

Findings

Blocking

None.

Non-blocking

  • description.md presents extensive multi-device test and validation-layer results under Tested without clearly labeling them as author-reported. Since those runs were not performed in this review, identify them as author-reported results to distinguish them from reviewer checks.

Not verified

No tests, builds, or validation-layer runs were performed. Texture.cpp and Recorder.cpp were excluded from the prepared full-text files and were read only in targeted ranges through repo_read.py; the remaining changed files listed in the manifest as included were read. Hardware behavior and the author-reported results were not independently verified.

To get this to a good state

Nothing is required. The labeling suggestion above is optional.

@GiannisG1

Copy link
Copy Markdown
Contributor Author

Thanks. The Tested section now says these are my own runs on one machine; the GPU checks posted on this PR by others are theirs.

@artor410

Copy link
Copy Markdown
Contributor

Windows + NVIDIA run of head 224fb9d833, merged onto main e67ac34998 with --no-ff (clean merge). The description covers Linux devices only.

Setup: Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 3070 Ti (Ampere), driver 610.88 (Vulkan 1.4.341), WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, Khronos validation layer 1.4.363 (LunarG SDK 1.4.363.0). The baseline is a Release build of main e67ac34998 in the same tree.

Format support on this device (optimal tiling, vulkaninfo), for the table in the description:

Device R5G5B5A1_UNORM_PACK16 A1R5G5B5_UNORM_PACK16
NVIDIA RTX 3070 Ti (Windows, 610.88) sampled, filtered, transfer src/dst sampled, filtered, transfer src/dst, color attachment

So the R16_UINT storage fallback is not taken here. The rotated A1R5G5B5 sampling path is, as on every device.

Focused tests: the 16 tests listed in the description (15 on main, which lacks agc_recorder_rotated_repack), run with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 and ctest -V -j1.

  • main: 15 of 15 pass. This PR: 16 of 16 pass.
  • The loader inserts VK_LAYER_KHRONOS_validation in every test that opens a device, which is all of them except agc_driver_graphics (mock devices). No log contains was not found but was requested by env var VK_INSTANCE_LAYERS.
  • No VUID- messages on either side.
  • The PR was run twice more without the layer: 16 of 16 each time, so 3 of 3 runs passed.
  • agc_driver_graphics prints 53 host import ... failed at vkAllocateMemory notes, the same count on main and on this PR, so they do not come from this change.

Not covered: the whole suite, and no title was run.

AI-assisted: yes (Claude Code). I ran the tests; this summary was written from their logs.

@artor410

Copy link
Copy Markdown
Contributor

The failing windows check comes from main, not from this PR. Its only failures are guest_libressl3_aes_wrap and guest_libressl3_aes (exit 0xc0000409, 5203 of 5205 passed).

Nothing in this PR needs to change. A collaborator only needs to start the Windows build again.

AI-assisted: yes (Claude Code).

@u-instinct11

Copy link
Copy Markdown
Contributor

I tested the pre-dispatch barrier on Windows 11 with an RTX 5090 Laptop (621.01) and Intel Graphics (101.8860). The production shader and dispatch at head 224fb9d, applied to 34bd032, matched an independent bit-field check in 18/18 runs across the two GPUs. The probe included every 16-bit input and adjacent in-place ranges sharing a word.

Removing only the barrier made the boundary probe fail in 18/18 runs. The existing rotated-repack test still passed 6/6 with the barrier removed, and six synchronization-validation runs on that control logged no SYNC-HAZARD. Could the recorder test include consecutive dispatches that update adjacent halves of one destination word in the same command buffer? That would cover the dependency the patch fixes.

I ran the focused test commands directly. The full recorder passed on NVIDIA on both revisions; on Intel both stopped at the existing unchanged-draw-input assertion before reaching this test. No title was run.

AI-assisted: yes.

@GiannisG1

Copy link
Copy Markdown
Contributor Author

@u-instinct11 thanks for the Windows runs and for isolating the barrier, you were right that nothing covered it. 65d0793 adds the case you describe to agc_recorder_rotated_repack. One command buffer records 64 pairs of repacks, each pair meeting inside one destination word (texels 0-4 and 5-9 of every 16), and the test then checks every texel.

  • Barrier removed: it fails 5 of 5 runs on the GTX 1050 Ti (left texel 4 as 50245, expected 57890) and 5 of 5 on the HD 630 (texel 4 or 5). llvmpipe runs the dispatches one after another and passes 5 of 5, so CI's lavapipe will not catch a missing barrier.
  • Barrier in place: it passes 3 of 3 on each device.

The description's Tested section has the same numbers.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

Nothing in the inspected changed code shows a verified blocking defect; the author reports passing targeted and broader checks, which I did not run.

What I ran

  • Read the prepared diff and commit description for head 65d079335b15e4c8dc10a5d8df9058a7452b57c9.
  • Read changed source ranges in Texture.hpp, TextureDetiler.hpp, TextureFormat.hpp, TextureRepack.comp, Texture.cpp, TextureDetiler.cpp, and TextureFormat.cpp; read changed test ranges in Recorder.cpp and TextureFormat.cpp, the recorder CMake registration, and the new debt note.
  • No build, test, or validation command was run.

Results

Check Result Note
Diff and targeted source review passed No verified blocking defect found
Build and tests not run Results in the PR description are author reported
Full changed-file review not run Two changed files were excluded from the prepared full-text bundle

Findings

Blocking

None.

Non-blocking

None.

Not verified

  • I did not run the reported test suite or Vulkan validation checks.
  • I did not read all of Texture.cpp or Recorder.cpp; only the changed hunks and relevant caller ranges were inspected. The prepared manifest marks these files as excluded because they are too large for the review folder.
  • I did not verify device behavior, the author’s test environment, or claims in the PR description against external sources.
  • Other changed files listed in the manifest were inspected at their changed ranges; the prepared review/files directory contained no files.

To get this to a good state

Nothing is required. The points above are limitations of this review, not requested changes.

@u-instinct11

Copy link
Copy Markdown
Contributor

Thanks for adding the adjacent-range case, @GiannisG1. I reran the updated recorder test on the two Windows GPUs from my earlier report. With the barrier present it passed 3/3 on Intel Graphics (101.8860) and 3/3 on the RTX 5090 Laptop (621.01). Removing just the barrier failed 3/3 on each: Intel left texel 4 as 50245 (expected 57890), and NVIDIA left texel 5 as 54614 (expected 27307).

I applied the test diff from 65d0793 to the same 34bd032 + PR build used for the earlier comparison, rebuilt the recorder executable, and ran it directly with --rotated-repack-only. Both driver binaries matched the hashes from that comparison. The Khronos validation layer loaded in all 12 runs with no VUID messages. The new test catches the missing barrier on both adapters here.

AI-assisted: yes.

@Helldiverr

Copy link
Copy Markdown
Contributor

Verdict: on an AMD R9700 under Windows, the five focused GPU tests and the CPU format test pass on main and 3 of 3 times on the merge, with 0 VUID-. Dropping the rotation's carry bit fails the three format-135 tests 3 of 3. Removing the new barrier fails agc_recorder_rotated_repack 20 of 20.

Code. I read the diff at 65d079335b.

  • Sampled format. Format 135 is now sampled as A1R5G5B5_UNORM_PACK16 (core/libs/prx/libSceAgcDriver/Graphics/src/TextureFormat.cpp:205). It goes through the repack paths that format 43 already uses, with TextureRepackFor (line 291) choosing the mode at core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:758 and 971.
  • Rotation. TextureRepack.comp mode 2 rotates each 16-bit half right by one bit (core/libs/prx/libSceAgcDriver/Graphics/shaders/TextureRepack.comp:25). It keeps the neighbour's half of a shared first or last word (lines 26 to 27). RotateTextureWord (TextureFormat.cpp:300) is the same expression on the CPU.
  • Half-word ranges. DispatchRepack accepts 2-byte-aligned ranges only for this mode (core/libs/prx/libSceAgcDriver/Graphics/src/TextureDetiler.cpp:298 to 300). It records a compute-to-compute barrier before a range that shares a word (line 324).
  • Storage image fallback. The image is created as R16_UINT only where R5G5B5A1 cannot be sampled and copied (Texture.cpp:1644, with the R16_UINT view from PackedStorageViewFormat at line 1596). On this device both formats have sampled, filtered, transfer and storage features in optimal tiling (vulkaninfo --show-formats), so storage images of 135 stay R5G5B5A1 here. Only the rotation path is exercised.
  • Debt and conventions. The debt change goes through docs/dev/debt/changes/fix-agc-sample-135-through-a1r5g5b5.md. I found no code comments in the diff, no made-up success and no title-specific values.
  • Checks. On the merge, tools/check_conventions.py --base 434792a795 passes and tools/debt_fold.py --check exits 0.

Overlap with #24218. Both PRs edit TextureRepack.comp: this one renames depthToFloat to mode, and #24218 changes the depth expression. I merged #24218 and then this PR onto 434792a795 (as 6a8db3a024) with no conflict. The result keeps #24218's depth rounding in the else branch. On that tree, agc_driver_image_depth24, agc_driver_image_depth24_float, agc_driver_image_packed16_load, agc_driver_image_packed16_storage_135 and agc_recorder_rotated_repack all passed once, with 5 layer inserts and 0 VUID-.

Existing runs.

  • The author: Linux.
  • Colewiz7: RX 7900 XT and gfx1036 on Linux (RADV).
  • artor410: RTX 3070 Ti on Windows.
  • u-instinct11: RTX 5090 Laptop and Intel Graphics on Windows, including the barrier removal.

None used AMD's Windows driver.

Negative control. On the merge I removed | ((word & 0x00010001u) << 15u) from TextureRepack.comp:25, rebuilt, and ran the five GPU tests 3 times:

  • Three tests failed 3 of 3:
    • agc_driver_image_packed16_load: packed bit walk/sample format 135 pass 0 texel 0 component 0 actual 0.000000 expected 1.000000.
    • agc_driver_image_packed16_storage_135: packed image_load has the wrong channel for format 135.
    • agc_recorder_rotated_repack: the rotating repack differs from RotateTextureWord at texel 0.
  • agc_driver_image_repacked_float and agc_driver_image_depth24 passed every run.
  • Each log has 0 VUID- lines.

I then reverted the change.

Probe. On the merge I removed the barrier at TextureDetiler.cpp:324, rebuilt, and ran agc_recorder_rotated_repack 20 times. It failed 20 of 20:

  • 8 runs with two rotating repacks in one command buffer that meet inside a word left texel 4 as 50245, expected 57890;
  • 12 runs with ... left texel 5 as 54614, expected 27307.

The validation layer reported nothing, because synchronization validation is not enabled by this environment. This matches u-instinct11's result on NVIDIA and Intel. I then reverted the change.

GPU. Command, for main and for each head run:
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R "^(agc_driver_image_packed16_load|agc_driver_image_packed16_storage_135|agc_recorder_rotated_repack|agc_driver_graphics|agc_driver_image_depth24|agc_driver_image_repacked_float)$" -V

test main head 1 head 2 head 3
agc_driver_image_packed16_load Passed 0.34 s Passed 1.15 s Passed 0.36 s Passed 0.35 s
agc_driver_image_repacked_float Passed 0.28 s Passed 0.32 s Passed 0.30 s Passed 0.29 s
agc_driver_graphics (CPU) Passed 11.17 s Passed 14.72 s Passed 13.75 s Passed 13.45 s
agc_driver_image_packed16_storage_135 Passed 0.29 s Passed 0.50 s Passed 0.30 s Passed 0.31 s
agc_driver_image_depth24 Passed 0.22 s Passed 0.26 s Passed 0.23 s Passed 0.23 s
agc_recorder_rotated_repack not on main Passed 0.28 s Passed 0.16 s Passed 0.21 s

Validation. Every head and control log shows the loader inserting VK_LAYER_KHRONOS_validation 5 times, once per GPU test. The main log shows 4, because agc_recorder_rotated_repack does not exist there. The 20-run probe log shows 20. No log contains was not found but was requested by env var VK_INSTANCE_LAYERS. Every log has 0 VUID- lines and 0 SYNC-HAZARD lines.

Speed evidence. None in the PR, and none is claimed. I did not measure speed.

  • GPU: AMD Radeon AI PRO R9700 (gfx1201, 1002:7551), driver 32.0.31044.16, Vulkan 1.4.349
  • Validation layer: Khronos 1.4.363 (LunarG SDK)
  • CPU: Ryzen 9 9950X3D
  • OS: Windows 11 Pro 26300
  • Toolchain: WinLibs GCC 15.2, Release
  • Commits measured: main 434792a; head 65d079335b, merged onto main as f6aa97d7f6

AI-assisted: yes

GiannisG1 and others added 2 commits November 26, 2026 11:03
Guest format 135 was sampled as R5G5B5A1_UNORM_PACK16, which Vulkan
leaves optional; the HD Graphics 630 (Mesa ANV) lists no features for
it, so its images were created, uploaded and copied in an unsupported
format. Rotate each texel right by one bit into the mandatory
A1R5G5B5_UNORM_PACK16 on upload and in copies from storage images, the
repacked-copy path of format 43, and keep the storage image in its
R16_UINT form where the host cannot sample and copy R5G5B5A1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e a word

The rotated-repack test recorded one repack per command buffer, so it
passed with the barrier DispatchRepack records before a partial-word
read-modify-write removed. Record 64 pairs of repacks in one command
buffer whose ranges meet inside one destination word and check every
texel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@GiannisG1
GiannisG1 force-pushed the fix/agc-sample-135-through-a1r5g5b5 branch from 65d0793 to e4cb9dd Compare November 26, 2026 12:30

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The inspected changes and author-reported results support merging; no blocking defect was verified.

What I ran

Reviewed head e4cb9ddab3d20e7dabdac14e315cb7df00640e22 using the prepared diff and pinned repository reader. No test or build commands were run in this review environment; the test results in the description are author-reported.

Results

Check Result Note
Changed-line review passed All 11 changed files reviewed
Build and tests not run Results reported by the author only
Negative control not run Not independently repeated

Negative control

No negative control was run during this review. The description reports tests failing with the relevant changes removed; that result was not independently verified.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

Builds, tests, validation-layer runs, GPU behavior, and the author-reported results were not independently verified. All changed lines were reviewed across 11 files. Texture.cpp and Recorder.cpp were excluded from the prepared folder due to size; their changed ranges were read through the pinned repository reader.

To get this to a good state

Nothing is required.

@oneandonlydean
oneandonlydean merged commit ae0df0e into boykopovar:main Nov 28, 2026
14 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants