Skip to content

fix(agc): refuse 10_10_10_2 signed and 4_4 textures the device cannot sample - #22717

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
MichonGoddijn231849:fix-refuse-unsupported-10-10-10-2-signed
Nov 26, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
MichonGoddijn231849:fix-refuse-unsupported-10-10-10-2-signed

Conversation

@MichonGoddijn231849

@MichonGoddijn231849 MichonGoddijn231849 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Guest formats 51 (10_10_10_2_SNORM) and 55 (10_10_10_2_SINT) resolve to VK_FORMAT_A2B10G10R10_SNORM_PACK32 and VK_FORMAT_A2B10G10R10_SINT_PACK32, which are optional Vulkan formats. Nothing checked that the device supports them, so AnyPS5 created sampled images in a format the device reports no features for:

  • on AMD (gfx1036, Windows driver 32.0.21045.16010) every image_load of such a texture returned (0, 0, 0, 1), whatever the texels;
  • on NVIDIA (RTX 5080, driver 610.74) the process died with an integer divide-by-zero (0xc0000094) inside nvoglv64.dll, called from libSceAgcDriver.prx.

Neither device reports any linear or optimal tiling feature for either format (vulkaninfo). This is the same situation the scaled formats were in, and they already throw unsupported guest texture format through scaledSampledFormats. This PR adds the same guard for 51 and 55 so they fail loudly instead.

  • TextureFormat.cpp: OptionalSampledFormats records which of 51 and 55 the device can sample with optimal tiling, and SampledTextureFormat refuses the others with unsupported guest texture format <n>. It is a separate list rather than an extension of kScaledTextureFormats, which feat(agc): sample unsigned scaled textures through UNORM views #16260 rewrites.
  • Context.hpp, VulkanDevice.cpp: optionalSampledFormats is filled at device creation next to scaledSampledFormats and copied into the context.
  • test: optionalFormatTests in tests/TextureFormat.cpp (run by agc_driver_graphics) checks three things:
    • both formats resolve natively when the device samples them;
    • both are refused with their number when it cannot;
    • only the missing one is refused when just one is unsupported, while 50 and 54 never depend on the list.
  • debt: a new entry in libSceAgcDriver.md (fragment docs/dev/debt/changes/fix-refuse-unsupported-10-10-10-2-signed.md) states the throw and records how gfx1036 hardware decodes both formats, for a later emulated path: signed 10-bit X/Y/Z (SNORM c/511, -512 gives -1.0) and a signed 2-bit W.

Update (rebased on current main): following GiannisG1's Linux vulkaninfo data below, an optional format now needs both SAMPLED_IMAGE and TRANSFER_DST in optimal tiling (uploads copy into the image with vkCmdCopyBufferToImage), and guest format 137 (4_4, R4G4_UNORM_PACK8) joins the list, so Mesa ANV and llvmpipe/lavapipe, which list no features for R4G4, refuse 4_4 textures instead of creating an unusable image. The 32_32_32 formats are left out until someone checks what samples them. tests/TextureFormat.cpp now also checks that 137 samples natively with both features, and that it and 51/55 are refused with only SAMPLED_IMAGE or with no features. agc_driver_graphics, agc_driver_image_packed16_load and agc_driver_image_pck_n pass on the RTX 5080 and gfx1036 under the validation layer, with no VUID- messages; both devices report both features for R4G4.

Tested

Windows 11 Pro 10.0:

  • The guard on both devices. tools/hw-oracle with the vulkan runtime and agc_oracle_runner, image_load of a 2D format-55 and format-51 T#. On main: AMD returns (0, 0, 0, 1) for every texel; NVIDIA crashes as described. With this change both devices report AGC graphics: unsupported guest texture format 55 and ... 51.
  • The hardware decode in the debt entry. Measured with the same image_load on gfx1036 over eight texels covering each field's extremes.
  • The test suites. ctest --test-dir build -R '^(agc_driver_graphics|agc_driver_emulated_color_compare)$' -V with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, validation layer 1.4.363, once per GPU:
    • 2/2 passed on NVIDIA GeForce RTX 5080 (610.74) and on AMD Radeon(TM) Graphics (gfx1036, 32.0.21045.16010);
    • 0 VUID-; each log shows Insert instance layer "VK_LAYER_KHRONOS_validation" and no was not found but was requested;
    • agc_driver_emulated_color_compare already skips format 51 on devices without the format, which both of these are, and is unchanged.

pr_overlap.py --branch failed closed on 40 open PRs that conflict with main and share VulkanDevice.cpp or Context.hpp. I checked each diff: none touches scaledSampledFormats, optionalSampledFormats or the two A2B10G10R10 signed formats.

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 RTX 5080, driver 610.74, Windows 11 Pro 10.0.26200; AMD Radeon(TM) Graphics (RDNA2 iGPU, gfx1036), driver 32.0.21045.16010, Windows 11 Pro 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

@github-actions github-actions Bot added docs agc libSceAgc* labels Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 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 23360 core/libs/prx/libSceAgcDriver/Graphics/src/TextureFormat.cpp L203-204

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 1395 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4040 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4472 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 4847 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 6553 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 7643 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9289 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9356 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 9387 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 9712 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 10442 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 10652 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11435 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11436 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11483 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 12828 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 12944 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 13148 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 13863 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 13920 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 13928 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 13929 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 15296 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 15548 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 15570 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 16260 core/libs/prx/libSceAgcDriver/Graphics/src/TextureFormat.cpp
core/libs/prx/libSceAgcDriver/tests/TextureFormat.cpp
PR 16571 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 16831 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 17056 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 18173 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 19557 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20030 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 20111 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20172 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20248 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20315 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 20519 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 21059 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21211 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21238 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22071 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22190 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22424 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 22531 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 22647 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 23058 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 24661 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 25010 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 26165 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 26384 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 27269 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp

@GiannisG1

Copy link
Copy Markdown
Contributor

Data from Linux on three more drivers. Optimal-tiling features from vulkaninfo for the formats behind 51 and 55, and for two more guest formats with the same problem:

Guest format → host format GTX 1050 Ti (580.178.04) HD Graphics 630 (Mesa 25.2.8 ANV) llvmpipe (Mesa 25.2.8) lavapipe (Mesa 26.0.8)
51 → A2B10G10R10_SNORM_PACK32 none none sampled sampled
55 → A2B10G10R10_SINT_PACK32 none none not listed not listed
137 (4_4, #16253) → R4G4_UNORM_PACK8 sampled not listed not listed not listed
72-74 (32_32_32) → R32G32B32_{UINT,SINT,SFLOAT} none sampled sampled sampled

137 is the same case as 51 and 55: #16253 says hosts without R4G4_UNORM_PACK8 keep the earlier unsupported guest texture format refusal, but nothing checks it. On these devices a 4_4 texture creates an image in a format the device lists no features for. Could 137 join kOptionalTextureFormats here? I had a separate check for it ready and dropped it in favour of this list.

72-74 have no sampled feature on the Pascal card either. That needs someone to look at whether anything samples them before they join the list.

One more note: uploads copy into these images with vkCmdCopyBufferToImage, so TRANSFER_DST is needed as well as SAMPLED_IMAGE. SampledDepth24S8 checks both.

(5_5_5_1, format 135 → R5G5B5A1_UNORM_PACK16, also lists no features on the HD 630 and gives four VUIDs in agc_driver_image_packed16_load. I'm preparing a separate PR that samples it through the mandatory A1R5G5B5_UNORM_PACK16, so it shouldn't join the refusal list.)

@MichonGoddijn231849
MichonGoddijn231849 force-pushed the fix-refuse-unsupported-10-10-10-2-signed branch from 1905914 to d7cde3c Compare November 18, 2026 21:43
@GiannisG1

Copy link
Copy Markdown
Contributor

Thanks, that covers 137 and the TRANSFER_DST check. It matches the table above: the GTX 1050 Ti samples and uploads R4G4_UNORM_PACK8, so 4_4 stays native there, and the HD 630, llvmpipe and lavapipe refuse it. I've dropped my separate check.

@MichonGoddijn231849 MichonGoddijn231849 changed the title fix(agc): refuse 10_10_10_2 SNORM and SINT textures the device cannot sample fix(agc): refuse 10_10_10_2 signed and 4_4 textures the device cannot sample Nov 18, 2026
@MichonGoddijn231849

Copy link
Copy Markdown
Contributor Author

Thanks, that table is very useful. I've pushed d7cde3c (rebased on main): optional formats now need both SAMPLED_IMAGE and TRANSFER_DST, and 137 joins the list, with unit tests for both. I left 72-74 out as you suggested, since nobody has checked yet what samples them. Good to hear 135 gets its own PR through A1R5G5B5.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@MichonGoddijn231849 one question on d7cde3c: the new Require in SampledTextureFormat runs before the IsRepackedTextureFormat early return. Is guest format 137 (4_4) ever repacked or given a fallback on hosts without R4G4? If it is, a 4_4 texture that works today on those hosts would now throw. Please confirm it is not, or move the check after the repack path.

Windows is still running on this head; I will review again once it is green.

@GiannisG1

Copy link
Copy Markdown
Contributor

@oneandonlydean since 137 was my suggestion: on main it is neither remapped nor repacked. remapGuestFormat only maps 30, 34, 36, 37, 41, 43, 44 and 48, and IsRepackedTextureFormat is true only for Format10_11_11Float. 137 resolves straight to VK_FORMAT_R4G4_UNORM_PACK8 with its GRBA swizzle and has no fallback, so on a host without R4G4 a 4_4 texture already gets an image the device cannot sample; the new check turns that into unsupported guest texture format 137 and doesn't remove a working path. (My coming 135 PR adds 135 to the repacked formats; 135 is not on the optional list, so the order of the two checks doesn't affect it.)

@MichonGoddijn231849

Copy link
Copy Markdown
Contributor Author

@oneandonlydean confirmed, 137 has no repack or fallback path. IsRepackedTextureFormat is true only for 10_11_11_FLOAT, remapGuestFormat doesn't map 137, and neither RemapTextureFormat nor RemapStorageTextureFormat (5_6_5, 5_5_5_1, 1_5_5_5 and 4_4_4_4 only) touches it. So SampledTextureFormat(137) always resolved straight to R4G4_UNORM_PACK8, and on a host without it the image was already unusable; the Require only turns that into a clear refusal. The order relative to the repack return only matters for a repacked format on the optional list, and there is none.

@MichonGoddijn231849

Copy link
Copy Markdown
Contributor Author

@oneandonlydean the red Windows run on d7cde3c (run 44404476899) is not from this change. The only failures are guest_libressl3_aes and guest_libressl3_aes_wrap (exit 0xc0000409). They come from the AES wrap length change on main at the time, which #23365 reverted at 23:13 UTC. Every AGC and texture-format test in that run passed. A re-run on current main should be green; I can't trigger one without admin rights.

@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

The reviewed code guards sampled texture formats 51, 55, and 137 against missing optimal tiling support for both sampled images and transfer destinations; tests and hardware checks were not run in this review.

What I ran

Reviewed head d7cde3ca36502f4b46883062c06e525f16da37ec using repo_read.py to read the prepared description, commits, manifest and diff, and changed-file ranges. No build or test commands were run.

Results

Check Result Note
Changed code review passed All changed files read
Build and tests not run No execution environment available
Negative control not run Requires running the test suite

Negative control

Not run; the test suite was not executed.

Findings

Blocking

None.

Non-blocking

None.

Sources

The optional format feature checks and sampled-format rejection are in TextureFormat.cpp at the reviewed head.

Not verified

Build and test results, including the hardware and validation-layer results described by the author, were not independently verified. All six changed files listed in the manifest were read; VulkanDevice.cpp was read at its three changed ranges because its full text was excluded by size. No changed files were excluded from review.

To get this to a good state

Nothing is required. The build and test suite can be run for additional verification.

@Colewiz7

Copy link
Copy Markdown
Contributor

Head d7cde3ca36 merged onto main 973026d9b0 as f25ab144f6, 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
full suite (6163 tests), new failures vs main none none
-R '^agc' (1936 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

MichonGoddijn231849 and others added 2 commits November 19, 2026 06:37
… sample

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 4_4 textures

Optional sampled formats now also need VK_FORMAT_FEATURE_TRANSFER_DST_BIT,
since texture uploads copy into the image, and guest format 137 (4_4,
R4G4_UNORM_PACK8) joins the list, so a device that lists no features
for it refuses the texture instead of creating an image it cannot use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MichonGoddijn231849
MichonGoddijn231849 force-pushed the fix-refuse-unsupported-10-10-10-2-signed branch from d7cde3c to 2027f7f Compare November 19, 2026 05:41

@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

Nothing blocks this change; the review found no verified defect in the inspected code.

What I ran

Reviewed head 2027f7f1f5adeb4979d139210f53edae13040f8a. I read the prepared description, commits, manifest and diff, then used repo_read.py to inspect the changed files and the texture construction caller. No build or test commands were run; test results in the PR description are author-reported.

Results

Check Result Note
Diff and description passed Claims match inspected changes
Targeted source review passed Capability flow and resolver inspected
Build and tests not run PR reports hardware test results

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full VulkanDevice.cpp was excluded from the review bundle; only the three changed ranges were read through repo_read.py. The prepared manifest lists five changed files, all marked included except that file. I read the full text of the four included files and the three changed ranges of VulkanDevice.cpp. Build/test results and physical GPU behavior were not independently verified.

To get this to a good state

Nothing is required.

@Lyrnc

Lyrnc commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Reproduced on main 8c254da48b with a newer NVIDIA driver: RTX 5080 on 610.88 (you had 610.74) still dies with 0xc0000094 inside nvoglv64.dll. The gfx1036 iGPU returns (0, 0, 0, 1) for every texel of an image_load of format 51. vulkaninfo on both devices lists no optimal-tiling features at all for A2B10G10R10_SNORM_PACK32. Writing to format 51 fails in the same way once you get past the storage-format refusal: the image is still created in the unsupported format, so only part of the texels reach memory on AMD, and NVIDIA crashes.

On the later emulated path your debt entry mentions: I measured 51 and 55 on gfx1036 hardware. Loads match signed 10-bit X/Y/Z with c/511 (−512 → −1.0) and a signed 2-bit W, bit-exact, as you describe. Stores round to nearest even in the 10-bit fields, but the 2-bit W rounds ±0.5 away from zero (→ ±1). #17623's R32_UINT conversion already decodes exactly this way for the other signed packed formats (details in #17623 (comment)). So 51/55 can move from this refusal to that conversion on devices your optionalSampledFormats marks as unsupported, and stay native where they are supported (llvmpipe/lavapipe). I plan to do that as a follow-up once both have landed.

AI-assisted: yes (Claude Code)

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

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants