Skip to content

test(agc): cover the DWORD rounding of guest buffer view ranges - #6695

Merged
1 commit merged into
boykopovar:mainfrom
xXPBSXx:test-agc-view-bytes
Oct 17, 2026
Merged

1 commit merged into
boykopovar:mainfrom
xXPBSXx:test-agc-view-bytes

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

What

GuestBufferMemory::ViewBytes gives the descriptor range of a guest buffer view that starts adjustment bytes after a storage-buffer offset boundary (added in 38e89df). No test calls it directly; BufferUnalignedBase reaches it only through a whole draw. Add guestBufferViewBytesTests to agc_driver_graphics_tests:

  • an adjustment of a whole number of DWORDs (0, 4, 16, 256) adds exactly the adjustment to the byte count;
  • an adjustment of 1, 2, 3, 5 or 7 bytes adds the DWORDs around the view (4 * ceil(adjustment / 4)), the case 38e89df describes as "the range covers the dwords around it".

Byte counts are multiples of four (4, 16, 4096). The expected values follow from that commit message and the function; the test does not change behaviour and passes on main.

Tested

Release build, MinGW-w64, Windows 10 (19045), main 5d9dcc42d plus this commit (edb74cb58; merge-tree against main is clean). ctest -R '^agc_driver_graphics$': passed (7.4 s). With the first expectation changed to bytes + adjustment + 1 the same test fails with "a view whose adjustment is a whole number of DWORDs did not add the adjustment", so the new cases run. tools/check_conventions.py --base upstream/main: all checks passed. No Vulkan device is needed by the new function; the executable itself ran against the NVIDIA GeForce RTX 4080 SUPER driver. Linux/lavapipe not tested.

Checklist

AI-assisted (Claude Code).

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx

xXPBSXx commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@adriadam10 a short request for review of this test-only PR (guestBufferViewBytesTests in agc_driver_graphics_tests: the DWORD rounding of GuestBufferMemory::ViewBytes for whole-DWORD and for odd adjustments, byte counts that are multiples of four; +13/-0, no behavior change). Head edb74cb58 is MERGEABLE / CLEAN, the Conventions, Eligibility and Intake checks are green, ctest -R ^agc_driver_graphics$ passes (and fails with a deliberately wrong expectation, so the cases run).

AI-assisted (Claude Code).

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

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/tests/Graphics.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4650 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5441 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5499 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5500 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6188 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6215 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6222 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6297 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6320 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6457 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6479 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6529 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6535 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6647 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6730 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6973 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6987 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6989 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6995 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7002 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp

@jotitadev jotitadev 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.

The new cases pass, but they only cover the case where both branches of ViewBytes are right. Every byte count in the test is a multiple of four (4, 16, 4096). Off a DWORD boundary, the function returns 4 * (adjustment / 4 + bytes / 4 + 1). That truncates bytes / 4 on its own, so when adjustment % 4 + bytes % 4 > 4 the range stops before the view's last bytes:

bytes adjustment ViewBytes bytes the view spans from the aligned start
7 2 8 9
6 3 8 9
3 3 4 6
2 3 4 5
4098 3 4100 4101

Those byte counts can happen: the size comes from ShaderBufferResource::GetSize(), which is Stride() * NumRecords(), or NumRecords() when the stride is 0, with no rounding (ShaderResources.cpp, the guest-buffer path that pushes {address, size, true, ...}). So a byte buffer with an odd record count, or a stride of 2 or 6, gets a descriptor range one to three bytes short of the bytes the shader may read. The same value also sizes the snapshot and overlap checks at the two ViewBytes(size, item.adjustment) call sites.

For the unaligned branch, the covering range is 4 * ((adjustment + bytes + 3) / 4). It equals the test's bytes + 4 * ((adjustment + 3) / 4) whenever bytes is a multiple of four. With that expectation and 7ull added to the outer list, adjustments 2, 3 and 7 fail on current main. Whether the fix belongs in this PR or a separate one is up to you. As it stands, the test only checks the formula where it agrees with the intended one.

Checked with a standalone copy of ViewBytes from this head, built with clang++ -std=c++20 on macOS: the PR's 27 cases pass, and the rows above come out as shown.

Written with AI assistance (Claude Code). I ran the checks above on my machine.

@MarcZX10

Copy link
Copy Markdown
Contributor

The #6999 report confirms a real under-coverage in the off-DWORD branch. I am preparing a separate follow-up with the production formula correction and regression sizes 2, 3, 6, and 7. Since it touches the same test file, I plan to base it on your test commit and list Depends on: #6695, preserving your commit author. Please let me know if you would prefer a different landing order.

@MarcZX10

Copy link
Copy Markdown
Contributor

The follow-up is now open as #7001, based on your test commit unchanged and declaring Depends on: #6695. The production formula and off-DWORD regression cases are included; conventions, eligibility and intake checks pass. Please let me know if you would prefer a different landing order.

@oneandonlydean oneandonlydean closed this pull request by merging all changes into boykopovar:main in 660cf7b Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants