test(agc): expect no kept image table writes for a set from the shared pool chain #10651

Merged
maximilianfv merged 1 commit from upstream-pr/10651 into main 2026-10-30 00:03:02 +00:00
maximilianfv commented 2026-10-24 15:14:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by maximilianfv on 2026-10-24T15:14:17Z.


What

agc_driver_image_table_reuse and agc_driver_image_table_reuse_draw_pipeline assume that the image table's descriptor set comes from a dedicated pool. That assumption does not hold on every device. The kept-table write counters (writesKept, writesMade), added with kept descriptor sets in #6454 by EagleBearerYS (commit 1d66d852d1), count writes only for a set that DescriptorCache::Allocate takes from a dedicated pool. ShaderResources.cpp records table writes only when sampled && set < tableWrites.size() && allocation.layout != VK_NULL_HANDLE, and allocation.layout is set only in the dedicated-pool branch. A set gets a dedicated pool only when one of its sizes exceeds ChainPoolSizes (4096 storage buffers, 1024 sampled images, 1024 storage images, 512 samplers). A set from the shared pool chain is freed back to the chain, so the driver has nothing to keep and correctly records nothing.

The only size that can exceed the chain is the sampler table. SamplerTableCapacityFor sizes it as min(1024, Room(stage samplers, 64), Room(set samplers / 4, 64)), first from the plain limits and, when that gives 0, from the update-after-bind limits. MoltenVK on the M1 Pro reports (vulkaninfo) maxPerStageDescriptorSamplers 16, maxPerStageDescriptorUpdateAfterBindSamplers 1024 and maxDescriptorSetUpdateAfterBindSamplers 1024. The plain limits give 0 (16 is below the 64-sampler heap), so the update-after-bind limits apply: min(1024, 960, 192), rounded down to a multiple of 4, is 192, below the chain's 512 samplers. The test's own counters confirm it: dedicatedPools + reusedSets does not grow across the first two dispatches, which is why both tests print the chain line in the runs below. The test then fails at its first write check: three dispatches of one table in one epoch: 0 table descriptor writes kept and 0 made, expected 3 and 0.

This change reads descriptorCache->Counters() before and after the first dispatches. If dedicatedPools + reusedSets did not grow, the table's set came from the shared pool chain. The test then prints the table's descriptor set fits the shared pool chain: kept table sets are not tested, and every ExpectWrites requires 0 kept and 0 made table writes. On devices whose sampler table reaches 1024, the set still comes from a dedicated pool and the original expectations run unchanged. With APS5_NO_POOL_CACHE the descriptor cache is bypassed, so the test also takes the 0/0 path; the expectation is still correct, only the printed reason is then imprecise. The driver is not changed.

Prior art: of the whole-port PRs, #7201 and #8658 (and the PRs #8658 was split into, such as #10419) do not touch this test, but the closed #7332 (feat: macOS on Apple Silicon host support, by Ycaro Gabriel) has the same diagnosis and a test fallback in commits fba033d87e and 4fab7534d7 (2026-10-19). This PR reimplements that fallback with a different check: #7332 made ExpectWrites take the device and require 0 kept and 0 made writes whenever Counters().dedicatedPools was 0 for the device as a whole, reaching the context through a new VulkanDeviceTestAccess struct; this PR compares the counters around this test's own first dispatches and leaves the ExpectWrites signature as it is. Ycaro Gabriel is credited as co-author. Testers on #8658 reported agc_driver_image_table_reuse failing on an M1 with the same message and passing on an M4, so this expectation depends on the GPU's limits. Open #6340 (MarcZX10) and #6223 (Thunderhawkk) also edit this test, but they add element-reuse checks and change neither ExpectWrites nor the first dispatches.

Tested

Apple M1 Pro, macOS 27.0.1, x86_64 build under Rosetta 2, Vulkan through MoltenVK 1.4.2 from the LunarG Vulkan SDK 1.4.363.

main alone does not build on macOS. I tested in a tree made of mugurc's macOS series (ci/macos-series-2, 27e968974) merged with main at 522e32e3b6, plus these local changes, all identical in every run: the macOS build parts of #10419, #10540, #10562, #10641 and #10642, and two of my unopened fixes (the posix_spawnp child in LazyResolvedAbi.cpp, an OpMemoryBarrier before 32-bit image atomics in SpirvImageEmitter.cpp). Only this PR's change was toggled. All runs used ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and ctest --test-dir build -R '^agc_driver_image_table_reuse' -E 'audio_in|voice' -V.

  • Without this change, both agc_driver_image_table_reuse and agc_driver_image_table_reuse_draw_pipeline fail (0 of 2) with three dispatches of one table in one epoch: 0 table descriptor writes kept and 0 made, expected 3 and 0.
  • With this change, both pass (2 of 2), and each prints the table's descriptor set fits the shared pool chain: kept table sets are not tested.
  • With this change and APS5_KEPT_DESCRIPTOR_SETS=0, both pass (2 of 2) and each prints the same chain line.
  • Validation output is the same in all runs: 2 Validation Error lines, both VUID-vkCreateDescriptorSetLayout-support-09582, and no was not found but was requested by env var VK_INSTANCE_LAYERS line.
  • Not tested on a device whose sampler table reaches 1024, where the dedicated-pool expectations still run. Not tested on Linux or Windows.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Apple M1 Pro, MoltenVK 1.4.2 (Vulkan SDK 1.4.363), macOS 27.0.1
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4996575467 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10651). Originally posted by [maximilianfv](https://github.com/maximilianfv) on 2026-10-24T15:14:17Z. --- ### What `agc_driver_image_table_reuse` and `agc_driver_image_table_reuse_draw_pipeline` assume that the image table's descriptor set comes from a dedicated pool. That assumption does not hold on every device. The kept-table write counters (`writesKept`, `writesMade`), added with kept descriptor sets in #6454 by EagleBearerYS (commit 1d66d852d1), count writes only for a set that `DescriptorCache::Allocate` takes from a dedicated pool. `ShaderResources.cpp` records table writes only when `sampled && set < tableWrites.size() && allocation.layout != VK_NULL_HANDLE`, and `allocation.layout` is set only in the dedicated-pool branch. A set gets a dedicated pool only when one of its sizes exceeds `ChainPoolSizes` (4096 storage buffers, 1024 sampled images, 1024 storage images, 512 samplers). A set from the shared pool chain is freed back to the chain, so the driver has nothing to keep and correctly records nothing. The only size that can exceed the chain is the sampler table. `SamplerTableCapacityFor` sizes it as `min(1024, Room(stage samplers, 64), Room(set samplers / 4, 64))`, first from the plain limits and, when that gives 0, from the update-after-bind limits. MoltenVK on the M1 Pro reports (`vulkaninfo`) `maxPerStageDescriptorSamplers` 16, `maxPerStageDescriptorUpdateAfterBindSamplers` 1024 and `maxDescriptorSetUpdateAfterBindSamplers` 1024. The plain limits give 0 (16 is below the 64-sampler heap), so the update-after-bind limits apply: min(1024, 960, 192), rounded down to a multiple of 4, is 192, below the chain's 512 samplers. The test's own counters confirm it: `dedicatedPools + reusedSets` does not grow across the first two dispatches, which is why both tests print the chain line in the runs below. The test then fails at its first write check: `three dispatches of one table in one epoch: 0 table descriptor writes kept and 0 made, expected 3 and 0`. This change reads `descriptorCache->Counters()` before and after the first dispatches. If `dedicatedPools + reusedSets` did not grow, the table's set came from the shared pool chain. The test then prints `the table's descriptor set fits the shared pool chain: kept table sets are not tested`, and every `ExpectWrites` requires 0 kept and 0 made table writes. On devices whose sampler table reaches 1024, the set still comes from a dedicated pool and the original expectations run unchanged. With `APS5_NO_POOL_CACHE` the descriptor cache is bypassed, so the test also takes the 0/0 path; the expectation is still correct, only the printed reason is then imprecise. The driver is not changed. Prior art: of the whole-port PRs, #7201 and #8658 (and the PRs #8658 was split into, such as #10419) do not touch this test, but the closed #7332 (`feat: macOS on Apple Silicon host support`, by Ycaro Gabriel) has the same diagnosis and a test fallback in commits fba033d87e and 4fab7534d7 (2026-10-19). This PR reimplements that fallback with a different check: #7332 made `ExpectWrites` take the device and require 0 kept and 0 made writes whenever `Counters().dedicatedPools` was 0 for the device as a whole, reaching the context through a new `VulkanDeviceTestAccess` struct; this PR compares the counters around this test's own first dispatches and leaves the `ExpectWrites` signature as it is. Ycaro Gabriel is credited as co-author. Testers on #8658 reported `agc_driver_image_table_reuse` failing on an M1 with the same message and passing on an M4, so this expectation depends on the GPU's limits. Open #6340 (MarcZX10) and #6223 (Thunderhawkk) also edit this test, but they add element-reuse checks and change neither `ExpectWrites` nor the first dispatches. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Apple M1 Pro, macOS 27.0.1, x86_64 build under Rosetta 2, Vulkan through MoltenVK 1.4.2 from the LunarG Vulkan SDK 1.4.363. `main` alone does not build on macOS. I tested in a tree made of mugurc's macOS series (`ci/macos-series-2`, 27e968974) merged with `main` at 522e32e3b6, plus these local changes, all identical in every run: the macOS build parts of #10419, #10540, #10562, #10641 and #10642, and two of my unopened fixes (the posix_spawnp child in LazyResolvedAbi.cpp, an OpMemoryBarrier before 32-bit image atomics in SpirvImageEmitter.cpp). Only this PR's change was toggled. All runs used `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` and `ctest --test-dir build -R '^agc_driver_image_table_reuse' -E 'audio_in|voice' -V`. - Without this change, both `agc_driver_image_table_reuse` and `agc_driver_image_table_reuse_draw_pipeline` fail (0 of 2) with `three dispatches of one table in one epoch: 0 table descriptor writes kept and 0 made, expected 3 and 0`. - With this change, both pass (2 of 2), and each prints `the table's descriptor set fits the shared pool chain: kept table sets are not tested`. - With this change and `APS5_KEPT_DESCRIPTOR_SETS=0`, both pass (2 of 2) and each prints the same chain line. - Validation output is the same in all runs: 2 `Validation Error` lines, both `VUID-vkCreateDescriptorSetLayout-support-09582`, and no `was not found but was requested by env var VK_INSTANCE_LAYERS` line. - Not tested on a device whose sampler table reaches 1024, where the dedicated-pool expectations still run. Not tested on Linux or Windows. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> Apple M1 Pro, MoltenVK 1.4.2 (Vulkan SDK 1.4.363), macOS 27.0.1 - [x] AI-assisted: <!-- yes / no --> yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-24 15:20:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T15:20:35Z.

Review: APPROVED


Reviewed exact head 3beed54422b3bc90e84670e4dc08d291f63ca343. The test classifies the descriptor set from the first two dispatches: dedicated allocations and reuse of a kept dedicated set increment the counters, while shared-chain allocations do not. The production code also records table writes only for dedicated allocations with a non-null layout, so requiring zero writes for the shared-chain case is consistent with the implementation. The test preserves the original kept-write assertions when those counters show a dedicated allocation. Exact-head diff-check, conventions, and merge-tree checks pass; hosted eligibility, conventions, intake, labels, and report pass, while product builds are skipped. I did not run the GPU test locally; I reviewed the author’s M1 Pro run and control results. No blocking issue found.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638760625 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10651#pullrequestreview-5638760625). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T15:20:35Z. **Review:** APPROVED --- Reviewed exact head `3beed54422b3bc90e84670e4dc08d291f63ca343`. The test classifies the descriptor set from the first two dispatches: dedicated allocations and reuse of a kept dedicated set increment the counters, while shared-chain allocations do not. The production code also records table writes only for dedicated allocations with a non-null layout, so requiring zero writes for the shared-chain case is consistent with the implementation. The test preserves the original kept-write assertions when those counters show a dedicated allocation. Exact-head diff-check, conventions, and merge-tree checks pass; hosted eligibility, conventions, intake, labels, and report pass, while product builds are skipped. I did not run the GPU test locally; I reviewed the author’s M1 Pro run and control results. No blocking issue found.
MarcZX10 commented 2026-10-24 15:41:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T15:41:06Z.

Review: CHANGES_REQUESTED


A new overlap check for #6223 prompted a manual three-way merge comparison. Both PRs edit ImageTableReuse.cpp; the current two-head merge-tree reports a shared-hunk conflict around the write-count helper and the RunTests dispatch section. The code additions appear conceptually compatible—#6223 adds per-element reuse assertions while this PR handles shared-pool write counters—but the branches need an agreed integration order/rebase so neither assertion set is dropped. The PR body currently says they change neither the write helper nor the first dispatches, while the overlap notice shows the same region and the checklist says Depends on: none. Please coordinate with #6223’s author and record the landing order (or explain how the current heads merge without losing either test) before merge. The prior exact-head functional review remains valid; this request is only for the newly surfaced coordination requirement.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638820184 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10651#pullrequestreview-5638820184). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T15:41:06Z. **Review:** CHANGES_REQUESTED --- A new overlap check for #6223 prompted a manual three-way merge comparison. Both PRs edit `ImageTableReuse.cpp`; the current two-head merge-tree reports a shared-hunk conflict around the write-count helper and the `RunTests` dispatch section. The code additions appear conceptually compatible—#6223 adds per-element reuse assertions while this PR handles shared-pool write counters—but the branches need an agreed integration order/rebase so neither assertion set is dropped. The PR body currently says they change neither the write helper nor the first dispatches, while the overlap notice shows the same region and the checklist says `Depends on: none`. Please coordinate with #6223’s author and record the landing order (or explain how the current heads merge without losing either test) before merge. The prior exact-head functional review remains valid; this request is only for the newly surfaced coordination requirement.
jotitadev commented 2026-10-27 06:33:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T06:33:12Z.

Review: COMMENTED


A second Apple GPU (M2 Max) on a main-based tree, with both MoltenVK builds. The other runs here are Windows.

Machine: Apple M2 Max, macOS 27.2, x86_64 Release build under Rosetta 2.
Tree: main b986c11a34 + the open macOS PRs needed to build and open a device (#10366, #7631, #10659, #10660, #11249, #11358, #10669, #10552, #7804, #10676, #11447, #11437, #11554, #11705) + this PR at 3beed54422 (clean merge). Control: the same tree without this PR. ANYPS5_NO_SHADER_CACHE=1, -j1 --timeout 30.
Drivers: MoltenVK 1.4.2 (LunarG SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704.

  • Without this PR, agc_driver_image_table_reuse and _draw_pipeline fail on both drivers with "three dispatches of one table in one epoch: 0 table descriptor writes kept and 0 made, expected 3 and 0".
  • With it, both pass 3/3 on both drivers, and both print "the table's descriptor set fits the shared pool chain: kept table sets are not tested", so the M2 Max takes the same shared-chain path you describe for the M1 Pro.
  • Full ^agc suite, 1037 tests, MoltenVK 1.4.2: 41 failures without, 39 with. Those two are the only difference, so nothing new fails.
  • Validation layer (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, SDK 1.4.363.0, loader output shows it inserted): the same 4 errors on both sides, all VUID-vkCreateDescriptorSetLayout-support-09582 ("The layout has 262341 total descriptors which is more than maxPerSetDescriptors (1212)"). They come from the driver's layout creation, not from this test change, and appear identically with and without it. No new VUID-.

GPUs tested: Apple M2 Max (MoltenVK 1.4.2 and MoltenVK main + #2704)

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5663110303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10651#pullrequestreview-5663110303). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-27T06:33:12Z. **Review:** COMMENTED --- A second Apple GPU (M2 Max) on a `main`-based tree, with both MoltenVK builds. The other runs here are Windows. **Machine:** Apple M2 Max, macOS 27.2, x86_64 Release build under Rosetta 2. **Tree:** `main` `b986c11a34` + the open macOS PRs needed to build and open a device (#10366, #7631, #10659, #10660, #11249, #11358, #10669, #10552, #7804, #10676, #11447, #11437, #11554, #11705) + this PR at `3beed54422` (clean merge). Control: the same tree without this PR. `ANYPS5_NO_SHADER_CACHE=1`, `-j1 --timeout 30`. **Drivers:** MoltenVK 1.4.2 (LunarG SDK 1.4.363.0) and MoltenVK `main` + SPIRV-Cross #2704. - Without this PR, `agc_driver_image_table_reuse` and `_draw_pipeline` fail on both drivers with "three dispatches of one table in one epoch: 0 table descriptor writes kept and 0 made, expected 3 and 0". - With it, both pass 3/3 on both drivers, and both print "the table's descriptor set fits the shared pool chain: kept table sets are not tested", so the M2 Max takes the same shared-chain path you describe for the M1 Pro. - Full `^agc` suite, 1037 tests, MoltenVK 1.4.2: 41 failures without, 39 with. Those two are the only difference, so nothing new fails. - Validation layer (`VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, SDK 1.4.363.0, loader output shows it inserted): the same 4 errors on both sides, all `VUID-vkCreateDescriptorSetLayout-support-09582` ("The layout has 262341 total descriptors which is more than maxPerSetDescriptors (1212)"). They come from the driver's layout creation, not from this test change, and appear identically with and without it. No new `VUID-`. GPUs tested: Apple M2 Max (MoltenVK 1.4.2 and MoltenVK main + #2704) Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!10651
No description provided.