fix(agc): widen a vertex format the device lacks to the buffer element's #9436

Merged
ycbuzi merged 4 commits from upstream-pr/9436 into main 2026-10-24 18:22:24 +00:00
ycbuzi commented 2026-10-21 21:59:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T21:59:04Z.


What

On a GPU without vertex buffer support for the Vulkan format DecodeVertexFormat picks, a draw stops in BuildVertexInputLayout with AGC graphics: device does not support vertex format N. MADiSON stops there on Windows with an AMD Radeon RX 5600 XT, as reported by Hiro_02 on the AnyPS5 Discord (#showcase thread "MADiSON"; Ryzen 5 5600G, RX 5600 XT, 16 GB). The menu runs, and entering the level ends with:

[videoout] presentation failed: AGC graphics: device does not support vertex format 90
terminate called after throwing an instance of 'std::runtime_error'
  what():  AGC graphics: device does not support vertex format 90

Format 90 is VK_FORMAT_R16G16B16_SFLOAT. The attribute's buffer format is 71, 16_16_16_16_FLOAT, whose elements are 8 bytes, and the shader reads three components, so DecodeVertexFormat takes the three-component format.

BuildVertexInputLayout keeps that format when the device supports it, as before. Otherwise it takes the next wider form of the same buffer format that the device supports, up to the element's own component count: four components for 8_8_8_8_*, 16_16_16_16_* and 32_32_32_32_*, two for 8_8_*, 16_16_* and 32_32_*. The read stays inside the guest element, the numeric type and component width do not change, and the shader input does not change (VertexAttributeSignature still uses the attribute's component count), since Vulkan discards the components the input does not consume ("If the vertex shader has fewer components, the extra components are discarded", Vertex Input Extraction). A format with no wider form, such as 32_32_32_*, still throws.

The wider format reads more bytes per vertex, so prepareDrawInputs adds the difference to the vertex copy and to the zero buffer of a null or out-of-range attribute; otherwise the last vertex's read would end past the copy. The difference comes from VertexReadBytes, the size of the format the layout holds, so a layout taken from the cache or a recipe gets it as well.

Tested

Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON, NVIDIA GeForce RTX 4070 SUPER (616.92), on main 0c6a5bd593.

  • agc_driver_graphics, extended: with a faked format query that lacks R16G16B16_SFLOAT and R8G8B8_UNORM but has the four-component formats, a three-component 16_16_16_16_FLOAT attribute gets R16G16B16A16_SFLOAT (8 bytes read, stride 8) with the shader input still f32x3, a three-component 8_8_8_8_UNORM one gets R8G8B8A8_UNORM, and a three-component 32_32_32_FLOAT one still throws device does not support vertex format 106; the existing four-component case still throws.
  • The same 15 focused tests on main 0c6a5bd593 and on this branch, with ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1, --repeat until-fail:2: all pass on both (agc_driver_graphics, vertex_fetch, zero_stride_vertex_fetch, zero_position_vertex, draw_cache_reuse and its _inline, _off and _verify runs, draw_offset_indices, pipelined_indirect_draw, pipelined_prefetch, draw_write_ranges, vertex_user_data_tail, queued_index_read_order, inactive_vertex_point_size).
  • Validation layer, after merging main da54c652e3 into this branch (head 7b391f8889): the same 15 tests (their ctest names start with agc_driver_) on that main and on this head, built one after the other in the same build directory, with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan SDK 1.4.363.0), ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and ctest -V, on the RTX 4070 SUPER (616.92) and on the Radeon iGPU (25.10.30.02), each picked with ANYPS5_GPU. All four runs pass 15/15. No log reports was not found but was requested by env var VK_INSTANCE_LAYERS, and none has a VUID- error. Each log has the same 10 layer warnings on both trees: 9 Undefined-Value-ShaderOutputNotConsumed-DynamicRendering and 1 Undefined-Value-ShaderOutputNotConsumed. The runs are from a non-elevated process: an elevated one ignores VK_LAYER_PATH, and runs made that way had neither those warnings nor the was not found line. main's ImageArrayWindowPastLayerLimit.cpp does not compile on MinGW (the alignment error #8310 fixes), so both trees were built with ninja -k 0; no other target failed.
  • check_conventions.py --base origin/main passes on 7b391f8889. pr_overlap.py reports #8083, which adds StripPatches right above zeroVertexBuffer in Draw.cpp; merged together, that is the only conflict. #8083's author agreed that #8083 lands first and this PR then rebases onto it, keeping both.

Not tested: a GPU that lacks one of these formats. The RTX 4070 SUPER, a GTX 1650 SUPER and the Radeon iGPU of a Ryzen 9 7900 (AMD 25.10.30.02) in this machine all report VERTEX_BUFFER_BIT for format 90 (vulkaninfo --show-formats), so the wider path ran only with the faked query. MADiSON was not run here; the RX 5600 XT run is the check.

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
  • 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: #8083 (lands first; this PR then resolves the one conflict in Draw.cpp)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 616.92, Windows 11 10.0.26200; AMD Radeon(TM) Graphics (Ryzen 9 7900 iGPU), driver 25.10.30.02, Windows 11 10.0.26200 (on both, the wider-format path only with a faked format query)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4958932244 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9436). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T21:59:04Z. --- ### What On a GPU without vertex buffer support for the Vulkan format `DecodeVertexFormat` picks, a draw stops in `BuildVertexInputLayout` with `AGC graphics: device does not support vertex format N`. MADiSON stops there on Windows with an AMD Radeon RX 5600 XT, as reported by Hiro_02 on the AnyPS5 Discord ([#showcase thread "MADiSON"](https://discord.com/channels/1556655479495589999/1562561308128452728); Ryzen 5 5600G, RX 5600 XT, 16 GB). The menu runs, and entering the level ends with: ``` [videoout] presentation failed: AGC graphics: device does not support vertex format 90 terminate called after throwing an instance of 'std::runtime_error' what(): AGC graphics: device does not support vertex format 90 ``` Format 90 is `VK_FORMAT_R16G16B16_SFLOAT`. The attribute's buffer format is 71, `16_16_16_16_FLOAT`, whose elements are 8 bytes, and the shader reads three components, so `DecodeVertexFormat` takes the three-component format. `BuildVertexInputLayout` keeps that format when the device supports it, as before. Otherwise it takes the next wider form of the same buffer format that the device supports, up to the element's own component count: four components for `8_8_8_8_*`, `16_16_16_16_*` and `32_32_32_32_*`, two for `8_8_*`, `16_16_*` and `32_32_*`. The read stays inside the guest element, the numeric type and component width do not change, and the shader input does not change (`VertexAttributeSignature` still uses the attribute's component count), since Vulkan discards the components the input does not consume ("If the vertex shader has fewer components, the extra components are discarded", [Vertex Input Extraction](https://docs.vulkan.org/spec/latest/chapters/fxvertex.html#fxvertex-input-extraction)). A format with no wider form, such as `32_32_32_*`, still throws. The wider format reads more bytes per vertex, so `prepareDrawInputs` adds the difference to the vertex copy and to the zero buffer of a null or out-of-range attribute; otherwise the last vertex's read would end past the copy. The difference comes from `VertexReadBytes`, the size of the format the layout holds, so a layout taken from the cache or a recipe gets it as well. ### Tested Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`, NVIDIA GeForce RTX 4070 SUPER (616.92), on `main` 0c6a5bd593. - `agc_driver_graphics`, extended: with a faked format query that lacks `R16G16B16_SFLOAT` and `R8G8B8_UNORM` but has the four-component formats, a three-component `16_16_16_16_FLOAT` attribute gets `R16G16B16A16_SFLOAT` (8 bytes read, stride 8) with the shader input still `f32x3`, a three-component `8_8_8_8_UNORM` one gets `R8G8B8A8_UNORM`, and a three-component `32_32_32_FLOAT` one still throws `device does not support vertex format 106`; the existing four-component case still throws. - The same 15 focused tests on `main` 0c6a5bd593 and on this branch, with `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`, `--repeat until-fail:2`: all pass on both (`agc_driver_graphics`, `vertex_fetch`, `zero_stride_vertex_fetch`, `zero_position_vertex`, `draw_cache_reuse` and its `_inline`, `_off` and `_verify` runs, `draw_offset_indices`, `pipelined_indirect_draw`, `pipelined_prefetch`, `draw_write_ranges`, `vertex_user_data_tail`, `queued_index_read_order`, `inactive_vertex_point_size`). - Validation layer, after merging `main` da54c652e3 into this branch (head `7b391f8889`): the same 15 tests (their ctest names start with `agc_driver_`) on that `main` and on this head, built one after the other in the same build directory, with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (Vulkan SDK 1.4.363.0), `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1` and `ctest -V`, on the RTX 4070 SUPER (616.92) and on the Radeon iGPU (25.10.30.02), each picked with `ANYPS5_GPU`. All four runs pass 15/15. No log reports `was not found but was requested by env var VK_INSTANCE_LAYERS`, and none has a `VUID-` error. Each log has the same 10 layer warnings on both trees: 9 `Undefined-Value-ShaderOutputNotConsumed-DynamicRendering` and 1 `Undefined-Value-ShaderOutputNotConsumed`. The runs are from a non-elevated process: an elevated one ignores `VK_LAYER_PATH`, and runs made that way had neither those warnings nor the `was not found` line. `main`'s `ImageArrayWindowPastLayerLimit.cpp` does not compile on MinGW (the alignment error #8310 fixes), so both trees were built with `ninja -k 0`; no other target failed. - `check_conventions.py --base origin/main` passes on `7b391f8889`. `pr_overlap.py` reports #8083, which adds `StripPatches` right above `zeroVertexBuffer` in `Draw.cpp`; merged together, that is the only conflict. #8083's author [agreed](https://github.com/boykopovar/AnyPS5/pull/8083#issuecomment-6336961908) that #8083 lands first and this PR then rebases onto it, keeping both. Not tested: a GPU that lacks one of these formats. The RTX 4070 SUPER, a GTX 1650 SUPER and the Radeon iGPU of a Ryzen 9 7900 (AMD 25.10.30.02) in this machine all report `VERTEX_BUFFER_BIT` for format 90 (`vulkaninfo --show-formats`), so the wider path ran only with the faked query. MADiSON was not run here; the RX 5600 XT run is the check. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #8083 (lands first; this PR then resolves the one conflict in `Draw.cpp`) <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 616.92, Windows 11 10.0.26200; AMD Radeon(TM) Graphics (Ryzen 9 7900 iGPU), driver 25.10.30.02, Windows 11 10.0.26200 (on both, the wider-format path only with a faked format query) <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no --> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-22 04:43:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:43:15Z.

Review: DISMISSED


The implementation is narrowly scoped and the reported wider-format path exercises the intended Vulkan fallback, but three merge blockers remain under the repository checklist:

  1. The PR changes AGC vertex input handling, and CONTRIBUTING.md requires the same focused tests on main and this change with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, and ANYPS5_REQUIRE_VULKAN=1, with ctest -V logs confirming the layer loaded and a comparison showing no new VUID- errors. The description says the layer is not installed and no comparison was made. Please rerun that paired validation on a machine with the layer, or leave this as an explicit unresolved validation blocker for a maintainer with the required environment. The hosted Linux and Windows jobs are skipped, so they do not supply this evidence.

  2. The overlap report names open PR #8083 in Draw.cpp. The description says whichever lands second will need a one-line rebase, but the checklist says Depends on: none and does not record an agreed landing order. Please coordinate the order with #8083's author and list the prerequisite on the checklist, or document that the overlap has been resolved and refresh the overlap check.

  3. The Unblocks line identifies a MADiSON stop but explicitly lacks both the title ID and a Game bring-up discussion. The repository checklist requires both for a title-blocking PR. Please add the verified title ID and discussion reference, or use none if the report cannot be tied to a qualifying bring-up entry.

The change-specific tests in the description are author-reported (15 focused tests on main and the branch, repeated twice); I did not run them locally because no matching PR checkout/build is available in this workspace. Current automated checks show conventions, eligibility, labels, and report passing; Linux, Windows, relinker, ASAN, register-context, and write-watch jobs are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609356710 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9436#pullrequestreview-5609356710). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:43:15Z. **Review:** DISMISSED --- The implementation is narrowly scoped and the reported wider-format path exercises the intended Vulkan fallback, but three merge blockers remain under the repository checklist: 1. The PR changes AGC vertex input handling, and `CONTRIBUTING.md` requires the same focused tests on `main` and this change with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, and `ANYPS5_REQUIRE_VULKAN=1`, with `ctest -V` logs confirming the layer loaded and a comparison showing no new `VUID-` errors. The description says the layer is not installed and no comparison was made. Please rerun that paired validation on a machine with the layer, or leave this as an explicit unresolved validation blocker for a maintainer with the required environment. The hosted Linux and Windows jobs are skipped, so they do not supply this evidence. 2. The overlap report names open PR #8083 in `Draw.cpp`. The description says whichever lands second will need a one-line rebase, but the checklist says `Depends on: none` and does not record an agreed landing order. Please coordinate the order with #8083's author and list the prerequisite on the checklist, or document that the overlap has been resolved and refresh the overlap check. 3. The `Unblocks` line identifies a MADiSON stop but explicitly lacks both the title ID and a Game bring-up discussion. The repository checklist requires both for a title-blocking PR. Please add the verified title ID and discussion reference, or use `none` if the report cannot be tied to a qualifying bring-up entry. The change-specific tests in the description are author-reported (15 focused tests on `main` and the branch, repeated twice); I did not run them locally because no matching PR checkout/build is available in this workspace. Current automated checks show conventions, eligibility, labels, and report passing; Linux, Windows, relinker, ASAN, register-context, and write-watch jobs are skipped.
ycbuzi commented 2026-10-22 07:23:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-22T07:23:43Z.


@MarcZX10 thanks. On the three points:

  1. Validation layer. I merged main da54c652e3 into the branch (head 7b391f8889) and ran the 15 focused tests on that main and on this head with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and ctest -V, on an RTX 4070 SUPER (616.92) and a Radeon iGPU (25.10.30.02), Windows 11. All four runs pass 15/15, none reports was not found but was requested by env var VK_INSTANCE_LAYERS, and none has a VUID- error. The layer loaded in each: every log has the same 10 layer warnings on both trees (9 Undefined-Value-ShaderOutputNotConsumed-DynamicRendering, 1 Undefined-Value-ShaderOutputNotConsumed). The description has the details.

    One thing for other Windows runs: from an elevated (administrator) process the loader ignores VK_LAYER_PATH. My first runs were elevated, and they had neither the layer's warnings nor the was not found line, so that check alone did not catch the missing layer. The runs above are from a non-elevated process.

  2. #8083: I proposed there that it lands first and this PR rebases onto it; the only conflict is StripPatches landing right above zeroVertexBuffer. I'll put it in Depends on once its author agrees.

  3. Unblocks is now none: the report has no title ID and there is no Game bring-up discussion. The MADiSON report and its log line stay in the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6335183609 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9436#issuecomment-6335183609). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-22T07:23:43Z. --- @MarcZX10 thanks. On the three points: 1. Validation layer. I merged `main` da54c652e3 into the branch (head `7b391f8889`) and ran the 15 focused tests on that `main` and on this head with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1` and `ctest -V`, on an RTX 4070 SUPER (616.92) and a Radeon iGPU (25.10.30.02), Windows 11. All four runs pass 15/15, none reports `was not found but was requested by env var VK_INSTANCE_LAYERS`, and none has a `VUID-` error. The layer loaded in each: every log has the same 10 layer warnings on both trees (9 `Undefined-Value-ShaderOutputNotConsumed-DynamicRendering`, 1 `Undefined-Value-ShaderOutputNotConsumed`). The description has the details. One thing for other Windows runs: from an elevated (administrator) process the loader ignores `VK_LAYER_PATH`. My first runs were elevated, and they had neither the layer's warnings nor the `was not found` line, so that check alone did not catch the missing layer. The runs above are from a non-elevated process. 2. #8083: I [proposed there](https://github.com/boykopovar/AnyPS5/pull/8083#issuecomment-6333112005) that it lands first and this PR rebases onto it; the only conflict is `StripPatches` landing right above `zeroVertexBuffer`. I'll put it in `Depends on` once its author agrees. 3. `Unblocks` is now `none`: the report has no title ID and there is no Game bring-up discussion. The MADiSON report and its log line stay in the description.
ycbuzi commented 2026-10-22 09:09:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-22T09:09:53Z.


@MarcZX10 #8083's author agreed to the order: #8083 lands first, and this PR then rebases onto it. Depends on now lists #8083.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337078111 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9436#issuecomment-6337078111). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-22T09:09:53Z. --- @MarcZX10 #8083's author [agreed](https://github.com/boykopovar/AnyPS5/pull/8083#issuecomment-6336961908) to the order: #8083 lands first, and this PR then rebases onto it. `Depends on` now lists #8083.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9436
No description provided.