Stride-zero OOB_SELECT=2 formatted SSBO reads truncate the Y/Z components #14439

Open
opened 2026-11-01 13:30:05 +00:00 by lgqdaxia · 0 comments
lgqdaxia commented 2026-11-01 13:30:05 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by lgqdaxia on 2026-11-01T13:30:05Z.


What happens

A nonempty, stride-zero RGB32_FLOAT buffer with OOB_SELECT=2 is bound with only NumRecords bytes. A formatted shader load through the GuestBuffers SSBO path can consequently read X correctly while returning zero for Y and Z. This is separate from native vertex attributes.

The asset-free reproducer uses one compute invocation and a 10-DWORD guest shader. It checks that the exact input descriptor reaches a storage-buffer binding, with no native vertex attributes or BDA pagetable. The input contains {1.25f, -2.5f, 19.0f}; only NumRecords changes between the two cases.

Title, test or build step

Asset-free agc_driver_buffer_format_oob2_stride_zero CTest, using BufferFormatOob2StrideZero.cpp. No game assets are used.

AnyPS5 commit

Executed main: ba627802e2210187d417deb64c8f2fed8e33011f. Production sources were unchanged; only the new fixture and its CMake fragment were added. Later candidate/rebase results are distinguished under What was checked.

System

Windows 11 Pro 10.0.26200 x86-64; WinLibs GCC 15.2.0 UCRT; Release/Ninja, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=OFF.

NVIDIA GeForce RTX 3080 Laptop GPU, driver 610.74. Vulkan execution used ANYPS5_REQUIRE_VULKAN=1, disabled shader caching, and actually loaded VK_LAYER_KHRONOS_validation.

Steps to reproduce

The fixture source and CMake fragment are public synthetic test code, with no game data.

In a separate checkout at the executed main commit, copy only those two files from the candidate, leaving all production sources on main:

git fetch --no-tags https://github.com/lgqdaxia/AnyPS5.git codex/fix-ssbo-oob2-read-extent
git restore --source=5fb8b2c27eafaaf4a430618b1c89b4a52a2acaf1 -- core/libs/prx/libSceAgcDriver/tests/execution/BufferFormatOob2StrideZero.cpp core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_buffer_format_oob2_stride_zero_tests.cmake

Configure with the normal project compiler and dependencies, adding these settings:

-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=OFF -DANYPS5_AGC_EXECUTION_TESTS=BufferFormatOob2StrideZero
cmake --build build --target agc_driver_buffer_format_oob2_stride_zero_tests --parallel 2

With the Khronos validation layer installed and discoverable, run in PowerShell:

$env:ANYPS5_REQUIRE_VULKAN = '1'
$env:ANYPS5_NO_SHADER_CACHE = '1'
$env:VK_INSTANCE_LAYERS = 'VK_LAYER_KHRONOS_validation'
ctest --test-dir build -R '^agc_driver_buffer_format_oob2_stride_zero$' -V --no-tests=error --parallel 1 --timeout 30

Log

For this nonempty OOB2 descriptor, reducing the record count to 1 should not turn the other components into zero. The input descriptor's word 3 is 0x2004a3ac (format 74, OOB_SELECT=2); stride is zero.

                        X          Y          Z          output guard
expected                3fa00000   c0200000   41980000   deadbeef
main, NumRecords=12     3fa00000   c0200000   41980000   deadbeef
main, NumRecords=1      3fa00000   00000000   00000000   deadbeef
candidate, records=12   3fa00000   c0200000   41980000   deadbeef
candidate, records=1    3fa00000   c0200000   41980000   deadbeef

The fixture source is byte-identical for the main/candidate comparison (SHA-256 ef1d411bca6f1dedfb1d6572b70b505e86638f6340bc795d470b62a4df1d1f05). The executables were rebuilt against their matching production ABI.

Root cause and candidate scope

ShaderBufferResource::GetSize() yields one byte for this descriptor. That value becomes the SSBO binding range even though this OOB mode does not use a positive record count as a byte bound. The shader's formatted load therefore encounters a host-side bound that is too short.

The relevant semantics are described in the AMD RDNA2 ISA reference, section 8.1/Table 35. Related work in #8299/#8519 addresses native vertex fetch; this reproducer explicitly uses SSBOs. I have not measured this instruction on console hardware.

The candidate expands only a statically proven base formatted read of a full unpacked 32-bit element, and only for a currently nonempty, linear, stride-zero OOB2 descriptor. Dynamic/unproved addresses, packed/typed/raw accesses, writes and atomics are excluded. This is a bounded subset of the remaining unbounded-buffer problem, recorded in the AGC debt file.

What was checked

On the executed main, only the new regression failed; four existing GPU control CTests passed. The candidate on the same base passed all five. Reverting only the driver's range expansion brought back exactly the Y/Z failure, with the four controls still passing. All three GPU runs had zero skipped tests and no reported VUIDs, with the requested validation layer loaded.

The candidate also passed five CPU CTests covering compiler proof exclusions and descriptor-presence changes, shader disk-cache round trips, resource keys, initial binding, draw/dispatch buffer moves, alias checks, queued read ranges and the forced-written override. After rebasing to main f1a7b02028ae50adaf6c5aaaef892a51841b25bf, final head 5fb8b2c27eafaaf4a430618b1c89b4a52a2acaf1 was rebuilt and passed the same five GPU and five CPU CTests, with zero skips and no reported VUIDs. The real configured-build registration audit passed for 1690 executables; conventions and diff checks passed.

These are focused component tests. Linux/macOS, other GPUs, hosted CI, the full product/full test suite and game behavior were not tested. No title fix or performance improvement is claimed. Independent fixes are welcome; adopting this candidate is optional.

14 November follow-up: The complete replacement is now PR #19852, covering both the original static case and zero offsets loaded through runtime SRT fields, with the matching KeyMiss fixture correction. The same asset-free GPU fixture fails both cases on main 860c2a432293 and passes on 454a7f5896e9, with the validation layer loaded, intact guards and zero skips or VUIDs. Game bring-up #19851 records the two-frame backpack result and its gameplay-integration prerequisites.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6147451103 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/14439). Originally posted by [lgqdaxia](https://github.com/lgqdaxia) on 2026-11-01T13:30:05Z. --- ### What happens A nonempty, stride-zero `RGB32_FLOAT` buffer with `OOB_SELECT=2` is bound with only `NumRecords` bytes. A formatted shader load through the `GuestBuffers` SSBO path can consequently read X correctly while returning zero for Y and Z. This is separate from native vertex attributes. The asset-free reproducer uses one compute invocation and a 10-DWORD guest shader. It checks that the exact input descriptor reaches a storage-buffer binding, with no native vertex attributes or BDA pagetable. The input contains `{1.25f, -2.5f, 19.0f}`; only `NumRecords` changes between the two cases. ### Title, test or build step Asset-free `agc_driver_buffer_format_oob2_stride_zero` CTest, using `BufferFormatOob2StrideZero.cpp`. No game assets are used. ### AnyPS5 commit Executed main: `ba627802e2210187d417deb64c8f2fed8e33011f`. Production sources were unchanged; only the new fixture and its CMake fragment were added. Later candidate/rebase results are distinguished under What was checked. ### System Windows 11 Pro 10.0.26200 x86-64; WinLibs GCC 15.2.0 UCRT; Release/Ninja, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`. NVIDIA GeForce RTX 3080 Laptop GPU, driver 610.74. Vulkan execution used `ANYPS5_REQUIRE_VULKAN=1`, disabled shader caching, and actually loaded `VK_LAYER_KHRONOS_validation`. ### Steps to reproduce The [fixture source](https://github.com/lgqdaxia/AnyPS5/blob/5fb8b2c27eafaaf4a430618b1c89b4a52a2acaf1/core/libs/prx/libSceAgcDriver/tests/execution/BufferFormatOob2StrideZero.cpp) and [CMake fragment](https://github.com/lgqdaxia/AnyPS5/blob/5fb8b2c27eafaaf4a430618b1c89b4a52a2acaf1/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_buffer_format_oob2_stride_zero_tests.cmake) are public synthetic test code, with no game data. In a separate checkout at the executed main commit, copy only those two files from the candidate, leaving all production sources on main: ```text git fetch --no-tags https://github.com/lgqdaxia/AnyPS5.git codex/fix-ssbo-oob2-read-extent git restore --source=5fb8b2c27eafaaf4a430618b1c89b4a52a2acaf1 -- core/libs/prx/libSceAgcDriver/tests/execution/BufferFormatOob2StrideZero.cpp core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_buffer_format_oob2_stride_zero_tests.cmake ``` Configure with the normal project compiler and dependencies, adding these settings: ```text -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=OFF -DANYPS5_AGC_EXECUTION_TESTS=BufferFormatOob2StrideZero cmake --build build --target agc_driver_buffer_format_oob2_stride_zero_tests --parallel 2 ``` With the Khronos validation layer installed and discoverable, run in PowerShell: ```powershell $env:ANYPS5_REQUIRE_VULKAN = '1' $env:ANYPS5_NO_SHADER_CACHE = '1' $env:VK_INSTANCE_LAYERS = 'VK_LAYER_KHRONOS_validation' ctest --test-dir build -R '^agc_driver_buffer_format_oob2_stride_zero$' -V --no-tests=error --parallel 1 --timeout 30 ``` ### Log For this nonempty OOB2 descriptor, reducing the record count to 1 should not turn the other components into zero. The input descriptor's word 3 is `0x2004a3ac` (format 74, `OOB_SELECT=2`); stride is zero. ```text X Y Z output guard expected 3fa00000 c0200000 41980000 deadbeef main, NumRecords=12 3fa00000 c0200000 41980000 deadbeef main, NumRecords=1 3fa00000 00000000 00000000 deadbeef candidate, records=12 3fa00000 c0200000 41980000 deadbeef candidate, records=1 3fa00000 c0200000 41980000 deadbeef ``` The fixture source is byte-identical for the main/candidate comparison (SHA-256 `ef1d411bca6f1dedfb1d6572b70b505e86638f6340bc795d470b62a4df1d1f05`). The executables were rebuilt against their matching production ABI. ### Root cause and candidate scope `ShaderBufferResource::GetSize()` yields one byte for this descriptor. That value becomes the SSBO binding range even though this OOB mode does not use a positive record count as a byte bound. The shader's formatted load therefore encounters a host-side bound that is too short. The relevant semantics are described in the [AMD RDNA2 ISA reference, section 8.1/Table 35](https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture). Related work in #8299/#8519 addresses native vertex fetch; this reproducer explicitly uses SSBOs. I have not measured this instruction on console hardware. The [candidate](https://github.com/lgqdaxia/AnyPS5/commit/5fb8b2c27eafaaf4a430618b1c89b4a52a2acaf1) expands only a statically proven base formatted read of a full unpacked 32-bit element, and only for a currently nonempty, linear, stride-zero OOB2 descriptor. Dynamic/unproved addresses, packed/typed/raw accesses, writes and atomics are excluded. This is a bounded subset of the remaining unbounded-buffer problem, recorded in the AGC debt file. ### What was checked On the executed main, only the new regression failed; four existing GPU control CTests passed. The candidate on the same base passed all five. Reverting only the driver's range expansion brought back exactly the Y/Z failure, with the four controls still passing. All three GPU runs had zero skipped tests and no reported VUIDs, with the requested validation layer loaded. The candidate also passed five CPU CTests covering compiler proof exclusions and descriptor-presence changes, shader disk-cache round trips, resource keys, initial binding, draw/dispatch buffer moves, alias checks, queued read ranges and the forced-written override. After rebasing to main `f1a7b02028ae50adaf6c5aaaef892a51841b25bf`, final head `5fb8b2c27eafaaf4a430618b1c89b4a52a2acaf1` was rebuilt and passed the same five GPU and five CPU CTests, with zero skips and no reported VUIDs. The real configured-build registration audit passed for 1690 executables; conventions and diff checks passed. These are focused component tests. Linux/macOS, other GPUs, hosted CI, the full product/full test suite and game behavior were not tested. No title fix or performance improvement is claimed. Independent fixes are welcome; adopting this candidate is optional. **14 November follow-up:** The complete replacement is now [PR #19852](https://github.com/boykopovar/AnyPS5/pull/19852), covering both the original static case and zero offsets loaded through runtime SRT fields, with the matching KeyMiss fixture correction. The same asset-free GPU fixture fails both cases on main `860c2a432293` and passes on `454a7f5896e9`, with the validation layer loaded, intact guards and zero skips or VUIDs. [Game bring-up #19851](https://github.com/boykopovar/AnyPS5/discussions/19851) records the two-frame backpack result and its gameplay-integration prerequisites. AI-assisted: yes
Sign in to join this conversation.
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#14439
No description provided.