fix(agc): read shader user data without tail padding #2063

Merged
MarcZX10 merged 2 commits from upstream-pr/2063 into main 2026-10-10 04:43:29 +00:00
MarcZX10 commented 2026-10-09 06:24:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T06:24:12Z.


What

Read only the serialized ShaderUserData fields through sharp_resource_count; the in-memory C++ struct has trailing padding that is not present in the guest shader header. Pin the serialized size to 54 bytes and cover a header that ends at that boundary.

Overlap audit

The overlap report with #2261 is limited to core/libs/prx/libSceAgcDriver/tests/Graphics.cpp. This PR tests the serialized ShaderUserData boundary; #2261 tests registered NGG workgroup routing. They do not share production files or behavior, and this PR does not depend on #2261.

Tested

Current PR head 62298425 is rebased linearly onto upstream main at cb9734cd8a9921067c84229a529518589010175a. The complete source diff remains limited to two files.

  • Linux x86-64, GCC 12.2, Release: built libSceAgcDriver and agc_driver_graphics_tests; agc_driver_graphics passed (1/1, 8.70 s) on this head. The regression pins the serialized boundary with static_assert(userDataBytes == 54).
  • python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main...HEAD pass.
  • Windows 11 Pro 25H2, RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0, Release: the focused test passed and full CTest passed (510/510) on pre-rebase commit 1b5a314b cherry-picked onto main d70b8998 (report).
  • Independent title validation from Recapi used a build based on main f1451396 plus dependencies from #2026: with this fix, PPSA99005 got past DecodeVertexStageInfo and stopped at the next known check (sceAgcCreatePrimState: invalid context register offsets); agc_driver_graphics passed. This was not tested on current main.
  • Eligibility, Conventions, report, and all three relinker jobs pass on this head. The automated PR workflow skipped the full Linux and Windows Build jobs; an authorized collaborator must start Build for those under #2113. No console hardware was available.

Checklist

  • Based on current main; no other open PR implements this correction
  • One topic: bound reads to the serialized shader user-data fields
  • #include <cstddef> is included directly where offsetof is used
  • No notes, investigation files or images added to the repository
  • No new third-party code
  • Generic behavior, not title-specific
  • Depends on: none; the distinct overlap with #2261 is documented above
  • AI-assisted: yes; independently reviewed and tested
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4796839542 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T06:24:12Z. --- ### What Read only the serialized `ShaderUserData` fields through `sharp_resource_count`; the in-memory C++ struct has trailing padding that is not present in the guest shader header. Pin the serialized size to 54 bytes and cover a header that ends at that boundary. ### Overlap audit The overlap report with #2261 is limited to `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`. This PR tests the serialized `ShaderUserData` boundary; #2261 tests registered NGG workgroup routing. They do not share production files or behavior, and this PR does not depend on #2261. ### Tested Current PR head `62298425` is rebased linearly onto upstream `main` at `cb9734cd8a9921067c84229a529518589010175a`. The complete source diff remains limited to two files. - Linux x86-64, GCC 12.2, Release: built `libSceAgcDriver` and `agc_driver_graphics_tests`; `agc_driver_graphics` passed (1/1, 8.70 s) on this head. The regression pins the serialized boundary with `static_assert(userDataBytes == 54)`. - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check upstream/main...HEAD` pass. - Windows 11 Pro 25H2, RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0, Release: the focused test passed and full CTest passed (510/510) on pre-rebase commit `1b5a314b` cherry-picked onto `main` `d70b8998` ([report](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6081918408)). - Independent title validation from Recapi used a build based on `main` `f1451396` plus dependencies from #2026: with this fix, PPSA99005 got past `DecodeVertexStageInfo` and stopped at the next known check (`sceAgcCreatePrimState: invalid context register offsets`); `agc_driver_graphics` passed. This was not tested on current `main`. - Eligibility, Conventions, report, and all three relinker jobs pass on this head. The automated PR workflow skipped the full Linux and Windows Build jobs; an authorized collaborator must start Build for those under #2113. No console hardware was available. ### Checklist - [x] Based on current `main`; no other open PR implements this correction - [x] One topic: bound reads to the serialized shader user-data fields - [x] `#include <cstddef>` is included directly where `offsetof` is used - [x] No notes, investigation files or images added to the repository - [x] No new third-party code - [x] Generic behavior, not title-specific - [x] Depends on: none; the distinct overlap with #2261 is documented above - [x] AI-assisted: yes; independently reviewed and tested
Recapi commented 2026-10-09 06:31:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Recapi on 2026-10-09T06:31:28Z.


Checked with the title from #2026. On the same build (main f1451396 plus the PRs listed there), with this PR in place of my local test change, PPSA99005 gets past DecodeVertexStageInfo and stops at the next known check, sceAgcCreatePrimState: invalid context register offsets. agc_driver_graphics passes with the PR, and fails with only the test applied (the driver file at main), so the new case catches the bug.

Two small points:

  • The test derives its expected size from the same offsetof(ShaderUserData, sharp_resource_count) + sizeof(...) expression the fix uses, so a mistake there would pass in both places. A static_assert(userDataBytes == 54) (or a literal 54 in the test) would tie it to what opengnm writes, RESOURCE_LAYOUT_SIZE 54u.
  • offsetof comes from <cstddef>, which neither ShaderInputState.cpp nor tests/Graphics.cpp includes; it builds now through another header.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6075681694 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6075681694). Originally posted by [Recapi](https://github.com/Recapi) on 2026-10-09T06:31:28Z. --- Checked with the title from #2026. On the same build (`main` f1451396 plus the PRs listed there), with this PR in place of my local test change, PPSA99005 gets past `DecodeVertexStageInfo` and stops at the next known check, `sceAgcCreatePrimState: invalid context register offsets`. `agc_driver_graphics` passes with the PR, and fails with only the test applied (the driver file at `main`), so the new case catches the bug. Two small points: - The test derives its expected size from the same `offsetof(ShaderUserData, sharp_resource_count) + sizeof(...)` expression the fix uses, so a mistake there would pass in both places. A `static_assert(userDataBytes == 54)` (or a literal 54 in the test) would tie it to what opengnm writes, [`RESOURCE_LAYOUT_SIZE 54u`](https://github.com/blackbearreloaded/ps5-opengl/blob/db752da4c89380af228497b5b6852163a4e61069/src/platform/ps5_agc_package.c#L16). - `offsetof` comes from `<cstddef>`, which neither `ShaderInputState.cpp` nor `tests/Graphics.cpp` includes; it builds now through another header.
MarcZX10 commented 2026-10-09 06:33:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T06:33:53Z.


Addressed: both files now include <cstddef> directly, and the regression has static_assert(userDataBytes == 54) so the serialized size is independently pinned to the opengnm layout. Rebuilt agc_driver_graphics_tests; agc_driver_graphics passes (9.11 s), and conventions plus diff checks pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6075710530 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6075710530). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T06:33:53Z. --- Addressed: both files now include `<cstddef>` directly, and the regression has `static_assert(userDataBytes == 54)` so the serialized size is independently pinned to the opengnm layout. Rebuilt `agc_driver_graphics_tests`; `agc_driver_graphics` passes (9.11 s), and conventions plus diff checks pass.
MarcZX10 commented 2026-10-09 08:15:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:15:00Z.


Rebased the fix and its regression test onto current upstream main 25f10087; pushed head c22c8e9c. The complete diff still covers only the serialized ShaderUserData bound and the literal 54-byte regression. Linux agc_driver_graphics passes (1/1, 8.99 s); conventions and diff checks pass. Fork Build 37903776529 is running on this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077133449 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6077133449). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T08:15:00Z. --- Rebased the fix and its regression test onto current upstream `main` `25f10087`; pushed head `c22c8e9c`. The complete diff still covers only the serialized `ShaderUserData` bound and the literal 54-byte regression. Linux `agc_driver_graphics` passes (1/1, 8.99 s); conventions and diff checks pass. Fork Build [37903776529](https://github.com/MarcZX100/AnyPS5/actions/runs/37903776529) is running on this head.
MarcZX10 commented 2026-10-09 08:26:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:26:57Z.


Rebased the reviewed diff onto current upstream main 6cc0503d and pushed head 97833579. The updated Linux agc_driver_graphics CTest passes (1/1, 8.69 s); conventions and diff checks pass. Fork Build 37904987707 is running on the new head. The description records the previous full-build failure from the missing SPIR-V test include path, addressed by #2093.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077303890 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6077303890). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T08:26:57Z. --- Rebased the reviewed diff onto current upstream `main` `6cc0503d` and pushed head `97833579`. The updated Linux `agc_driver_graphics` CTest passes (1/1, 8.69 s); conventions and diff checks pass. Fork Build [37904987707](https://github.com/MarcZX100/AnyPS5/actions/runs/37904987707) is running on the new head. The description records the previous full-build failure from the missing SPIR-V test include path, addressed by #2093.
MarcZX10 commented 2026-10-09 08:38:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:38:54Z.


Latest fork Build completed with the same baseline failure on Linux and Windows: agc_shader_fusion_tests cannot include spirv/unified1/spirv.hpp from VulkanTestDevice.hpp. The relinker jobs passed. This matches #2093; I recorded the exact result in the PR description and kept this PR's scope separate.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077475602 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6077475602). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T08:38:54Z. --- Latest fork Build completed with the same baseline failure on Linux and Windows: `agc_shader_fusion_tests` cannot include `spirv/unified1/spirv.hpp` from `VulkanTestDevice.hpp`. The relinker jobs passed. This matches #2093; I recorded the exact result in the PR description and kept this PR's scope separate.
MarcZX10 commented 2026-10-09 11:36:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T11:36:47Z.


Rebased PR #2063 linearly onto current main (d70b8998). On head 1b5a314b, agc_driver_graphics_tests builds and agc_driver_graphics passes (1/1, 9.18 s); conventions and diff checks pass, and GitHub reports the PR mergeable. The previously reported PPSA99005 run remains identified as an older-main validation. Under #2113, could a collaborator with write access run Actions → Build for this PR so the full Linux, Windows and relinker checks are recorded on the current head?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6080078427 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6080078427). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T11:36:47Z. --- Rebased PR #2063 linearly onto current `main` (`d70b8998`). On head `1b5a314b`, `agc_driver_graphics_tests` builds and `agc_driver_graphics` passes (1/1, 9.18 s); conventions and diff checks pass, and GitHub reports the PR mergeable. The previously reported PPSA99005 run remains identified as an older-main validation. Under #2113, could a collaborator with write access run Actions → Build for this PR so the full Linux, Windows and relinker checks are recorded on the current head?
rmz-24 commented 2026-10-09 13:31:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rmz-24 on 2026-10-09T13:31:03Z.


Windows run: Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON, full build plus libs. 1b5a314b cherry-picked onto current main d70b8998 (applies cleanly).

  • agc_driver_graphics passes.
  • Full ctest: 510/510.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081918408 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6081918408). Originally posted by [rmz-24](https://github.com/rmz-24) on 2026-10-09T13:31:03Z. --- Windows run: Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`, full build plus `libs`. 1b5a314b cherry-picked onto current `main` d70b8998 (applies cleanly). - `agc_driver_graphics` passes. - Full ctest: 510/510. AI-assisted: yes
MarcZX10 commented 2026-10-09 13:32:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T13:32:28Z.


Thanks for the Windows report: it covers the exact PR head 1b5a314b on current main, and the full Windows CTest passes (510/510), including agc_driver_graphics. That supplies the Windows evidence. The upstream PR still reports only Conventions; under CONTRIBUTING, could an authorized collaborator run the official Build for this head to record Linux and the relinker matrix?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081948172 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6081948172). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T13:32:28Z. --- Thanks for the Windows report: it covers the exact PR head `1b5a314b` on current `main`, and the full Windows CTest passes (510/510), including `agc_driver_graphics`. That supplies the Windows evidence. The upstream PR still reports only Conventions; under CONTRIBUTING, could an authorized collaborator run the official Build for this head to record Linux and the relinker matrix?
MarcZX10 commented 2026-10-09 19:28:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T19:28:28Z.


Rebased the existing PR linearly onto current main (ae3d5f95) at head 36762dcf. The production change and its 54-byte serialized-boundary regression remain intact. Linux agc_driver_graphics_tests builds and agc_driver_graphics passes (1/1); local and GitHub Conventions pass. I documented that the overlap with #2261 is only the shared test source file: its registered NGG-routing tests and this PR’s serialized-user-data test exercise different behavior, with no production-file overlap or dependency.\n\nCould a collaborator with write access run the required upstream Build and relinker matrix on this exact head under #2113?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6087804885 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6087804885). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T19:28:28Z. --- Rebased the existing PR linearly onto current `main` (`ae3d5f95`) at head `36762dcf`. The production change and its 54-byte serialized-boundary regression remain intact. Linux `agc_driver_graphics_tests` builds and `agc_driver_graphics` passes (1/1); local and GitHub Conventions pass. I documented that the overlap with #2261 is only the shared test source file: its registered NGG-routing tests and this PR’s serialized-user-data test exercise different behavior, with no production-file overlap or dependency.\n\nCould a collaborator with write access run the required upstream Build and relinker matrix on this exact head under #2113?
MarcZX10 commented 2026-10-09 20:05:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T20:05:59Z.


Updated head and validation

I rebased the existing branch linearly onto upstream main at 8b393b6e and pushed head 37e7963f. The complete diff remains limited to ShaderInputState.cpp and its 54-byte regression in Graphics.cpp. On the updated source, libSceAgcDriver and agc_driver_graphics_tests build, and agc_driver_graphics passes (1/1); local Conventions and git diff --check pass. The Windows full-suite report and title run remain labeled as pre-rebase evidence.

The overlap audit still concerns only the shared test source with #2261; that PR tests NGG routing, while this one tests the serialized user-data boundary. There is no shared production change or dependency. Could a collaborator with write access run Actions → Build for PR #2063 on this head? The required upstream Linux/Windows and relinker matrix has not run for it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088383266 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6088383266). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T20:05:59Z. --- ### Updated head and validation I rebased the existing branch linearly onto upstream `main` at `8b393b6e` and pushed head `37e7963f`. The complete diff remains limited to `ShaderInputState.cpp` and its 54-byte regression in `Graphics.cpp`. On the updated source, `libSceAgcDriver` and `agc_driver_graphics_tests` build, and `agc_driver_graphics` passes (1/1); local Conventions and `git diff --check` pass. The Windows full-suite report and title run remain labeled as pre-rebase evidence. The overlap audit still concerns only the shared test source with #2261; that PR tests NGG routing, while this one tests the serialized user-data boundary. There is no shared production change or dependency. Could a collaborator with write access run Actions → Build for PR #2063 on this head? The required upstream Linux/Windows and relinker matrix has not run for it.
MarcZX10 commented 2026-10-09 22:56:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T22:56:45Z.


Rebase and current-head validation

Rebased the existing branch onto upstream main at cb9734cd8a9921067c84229a529518589010175a; the new head is 62298425. The reviewed diff remains limited to the serialized ShaderUserData read and its 54-byte boundary regression.

On Linux x86-64 with GCC 12.2 in Release mode, libSceAgcDriver and agc_driver_graphics_tests build, and agc_driver_graphics passes (1/1, 8.70 s). The local Conventions check and git diff --check pass. The Windows full-suite report and PPSA99005 run in the description are from earlier bases and are not represented as current-head validation.

The official upstream Build and relinker matrix has not run on this head; under #2113 it needs a collaborator with write access to dispatch it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090669934 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2063#issuecomment-6090669934). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T22:56:45Z. --- ### Rebase and current-head validation Rebased the existing branch onto upstream `main` at `cb9734cd8a9921067c84229a529518589010175a`; the new head is `62298425`. The reviewed diff remains limited to the serialized `ShaderUserData` read and its 54-byte boundary regression. On Linux x86-64 with GCC 12.2 in Release mode, `libSceAgcDriver` and `agc_driver_graphics_tests` build, and `agc_driver_graphics` passes (1/1, 8.70 s). The local Conventions check and `git diff --check` pass. The Windows full-suite report and PPSA99005 run in the description are from earlier bases and are not represented as current-head validation. The official upstream Build and relinker matrix has not run on this head; under #2113 it needs a collaborator with write access to dispatch it.
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!2063
No description provided.