perf(agc): stage written buffer elements up to 8 MiB on discrete GPUs #8336

Merged
saarthakpant merged 1 commit from upstream-pr/8336 into main 2026-10-23 12:19:34 +00:00
saarthakpant commented 2026-10-20 10:20:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by saarthakpant on 2026-10-20T10:20:31Z.


What

A written buffer element larger than the 2 MiB written-shadow window is bound in place in its host import, so the shader's stores go to system memory over the bus. On NVIDIA's Windows driver those stores are slow enough to dominate a frame: Ghostrunner 2's GPU skin cache writes its outputs into two pool-sized elements of 2.5 and 3.3 MiB with 16-bit tangent stores, and one 67k-thread dispatch of a 380-instruction kernel took 4.2 ms, 55 ms per frame over the frame's 13 dispatches. In isolation the same dispatch takes 0.30 ms once its outputs are device-local, and 43.9 ms when they are written in place (an execution-test benchmark built from the kernel's dumped request; numbers below).

The swept rule does not catch these elements: the dispatch writes a third of the pool, not half, and the resource template that decides the binding is keyed by the shader's content (DispatchContentKey), not by the thread count, so a rule on the dispatch's extent would bind by whichever dispatch built the template first. The change is the window itself: on a discrete GPU (Context::discreteGpu, from VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) a written element that is not swept is staged device-local up to 8 MiB instead of 2 MiB (DiscreteWrittenShadowMax). Integrated GPUs keep 2 MiB: their device-local memory is the same RAM and staging there only pays the two copies. APS5_WRITTEN_SHADOW_MAX_KIB is used as given on both device types when it is set (its default is 8192 KiB on a discrete GPU and 2048 otherwise), so APS5_WRITTEN_SHADOW_MAX_KIB=2048 restores the previous window for an A/B run, and APS5_NO_WRITTEN_SHADOW=1 turns staging off as before. docs/dev/ENVIRONMENT.md and the comment above SweptShadowMax describe the new defaults.

The cost is the existing staging cost applied to 2 to 8 MiB elements: a copy-in and a copy-back of the element per dispatch. On the title below that is about 1.8 ms more staging per frame against 55 ms of kernel time removed.

Tested

Windows 11 (10.0.26200), MinGW-w64 GCC 15.2.0 UCRT, Release, NVIDIA GeForce RTX 2060 SUPER (617.42).

  • agc_driver_recorder (boundInPlace): a written-only 4 MiB element is staged on a discrete GPU and bound in place on an integrated one; a written-only 12 MiB element is bound in place on both. The test device now sets Context::discreteGpu from the physical device type (the harness had left it false, so the test exercised the integrated branch on every GPU), and the swept-rule cases use a 12 MiB element, above the discrete window and below the swept cap. The override was checked by running the test with the variable set: it passes unset and with 8192; with 2048 it fails at "a written-only 4 MiB element was bound in place on a discrete GPU", with 16384 at "a written-only 12 MiB element was staged past the discrete written window" (a set value cannot be covered by a Require, since it is read once into a static). agc_read_written_staging with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 (ctest -V) on main 3fd1cc393 and on this branch (35ac3402c, rebased onto main 35ac3402c): passes on both, the layer was found, no VUID- lines in either log. The test's guest block grows from 8 to 16 MiB so the 12 MiB cases fit inside the import.
  • Isolated benchmark of the kernel (test agc_driver_skin_cache_bench, local, not part of this PR), 1047 groups of 64, median of 10: outputs staged 0.30 ms; outputs in place with the game's descriptor sizes 43.9 ms; APS5_WRITTEN_SHADOW_MAX_KIB=4096 on the same 0.29 ms. In the game with that override the kernel went from 4.18 to 0.09 ms per dispatch.
  • Performance, same machine, same session, warm caches, Ghostrunner 2 (PPSA09911) loaded into gameplay with scripted input (Space through the loading screen, then a fixed key cycle with the respawn key), APS5_TRACE_SECONDS=120:60, no other switches. The base is main 4b462ef60 plus #7687 (this title stops before gameplay on main alone, #7017) plus #5372 (without it 35 GB per 10 s of CPU copies of another buffer bound the frame); this change on top.

base:

{"commit":"91360fefc6ad","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:60"},"gpu":"NVIDIA GeForce RTX 2060 SUPER","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","resolution":"3840x2160","window":{"spec":"seconds 120:60","first_present":776,"ms":60222.419},"presents":196,"frame_ms":{"p50":308.178,"p90":458.490,"p99":1997.642,"max":2005.776},"gpu_busy_ms_per_present":87.020,"worker_busy_pct":{"queue worker 0x0":98.431,"queue worker 0x20":99.274},"top_phases_ms_per_frame":{"Driver.Packet":606.024,"Driver.Packet.memory_wait":300.685,"Graphics.Draw":161.834,"Driver.Packet.draw":137.449,"Driver.Draw":135.894,"Graphics.Draw.draw_and_resource_release":131.967,"Driver.Packet.device_lock":123.802,"Driver.Draw.shader_compile_and_link":60.803},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":7.127,"events_lost":1832781,"totals_full":false},"draw committer":{"events_full_after_s":23.950,"events_lost":381210,"totals_full":false}},"trace":"aps5-trace-91360fefc6ad-12200.json.gz"}

this change:

{"commit":"42a2c6a94a1d","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:60"},"gpu":"NVIDIA GeForce RTX 2060 SUPER","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","resolution":"3840x2160","window":{"spec":"seconds 120:60","first_present":860,"ms":60416.623},"presents":261,"frame_ms":{"p50":171.067,"p90":269.165,"p99":1943.903,"max":3724.421},"gpu_busy_ms_per_present":75.154,"worker_busy_pct":{"queue worker 0x0":98.508,"queue worker 0x20":99.419},"top_phases_ms_per_frame":{"Driver.Packet":457.323,"Driver.Packet.memory_wait":223.598,"Graphics.Draw":117.754,"Driver.Packet.draw":110.744,"Driver.Draw":109.796,"Driver.Packet.device_lock":83.411,"Graphics.Draw.draw_and_resource_release":81.409,"Driver.Draw.draw_enqueued":50.723},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":8.606,"events_lost":1676944,"totals_full":false},"draw committer":{"events_full_after_s":32.615,"events_lost":281459,"totals_full":false}},"trace":"aps5-trace-42a2c6a94a1d-12896.json.gz"}

Frame p50 308.2 → 171.1 ms, presents 196 → 261 in the window, GPU busy per present 87.0 → 75.2 ms. Scripted runs die and respawn at different moments (the p99 of both windows is a respawn reload), so the per-program GPU times of the profiled runs are the steadier number: the kernel at 0x200fa10000 fell from 4.2 to 0.1 ms per dispatch in every window and left the top GPU programs; staging-in and staging-out rose from 1.97 and 1.73 to 3.72 and 3.55 ms per present. Both traces and the tools/trace_digest.py output of each are attached.

tools/pr_overlap.py: no open pull request changes the same lines; 65 pull requests that conflict with main share GuestBufferMemory.cpp, VulkanDevice.cpp, Context.hpp or tests/Recorder.cpp and could not be compared. #7618 raises the swept cap on discrete GPUs and extends the swept rule to written-only elements; it touches the same stagingEligible line and adds the same discreteGpu field, so whichever lands second rebases onto the other, and the two conditions compose (an element either sweeps or falls under the written window).

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: PPSA09911 #9679
  • GPUs tested: NVIDIA GeForce RTX 2060 SUPER, driver 617.42, Windows 11 10.0.26200 (Khronos validation layer 1.4.363)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4934349324 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8336). Originally posted by [saarthakpant](https://github.com/saarthakpant) on 2026-10-20T10:20:31Z. --- ### What A written buffer element larger than the 2 MiB written-shadow window is bound in place in its host import, so the shader's stores go to system memory over the bus. On NVIDIA's Windows driver those stores are slow enough to dominate a frame: Ghostrunner 2's GPU skin cache writes its outputs into two pool-sized elements of 2.5 and 3.3 MiB with 16-bit tangent stores, and one 67k-thread dispatch of a 380-instruction kernel took 4.2 ms, 55 ms per frame over the frame's 13 dispatches. In isolation the same dispatch takes 0.30 ms once its outputs are device-local, and 43.9 ms when they are written in place (an execution-test benchmark built from the kernel's dumped request; numbers below). The swept rule does not catch these elements: the dispatch writes a third of the pool, not half, and the resource template that decides the binding is keyed by the shader's content (`DispatchContentKey`), not by the thread count, so a rule on the dispatch's extent would bind by whichever dispatch built the template first. The change is the window itself: on a discrete GPU (`Context::discreteGpu`, from `VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU`) a written element that is not swept is staged device-local up to 8 MiB instead of 2 MiB (`DiscreteWrittenShadowMax`). Integrated GPUs keep 2 MiB: their device-local memory is the same RAM and staging there only pays the two copies. `APS5_WRITTEN_SHADOW_MAX_KIB` is used as given on both device types when it is set (its default is 8192 KiB on a discrete GPU and 2048 otherwise), so `APS5_WRITTEN_SHADOW_MAX_KIB=2048` restores the previous window for an A/B run, and `APS5_NO_WRITTEN_SHADOW=1` turns staging off as before. `docs/dev/ENVIRONMENT.md` and the comment above `SweptShadowMax` describe the new defaults. The cost is the existing staging cost applied to 2 to 8 MiB elements: a copy-in and a copy-back of the element per dispatch. On the title below that is about 1.8 ms more staging per frame against 55 ms of kernel time removed. ### Tested Windows 11 (10.0.26200), MinGW-w64 GCC 15.2.0 UCRT, Release, NVIDIA GeForce RTX 2060 SUPER (617.42). - `agc_driver_recorder` (`boundInPlace`): a written-only 4 MiB element is staged on a discrete GPU and bound in place on an integrated one; a written-only 12 MiB element is bound in place on both. The test device now sets `Context::discreteGpu` from the physical device type (the harness had left it false, so the test exercised the integrated branch on every GPU), and the swept-rule cases use a 12 MiB element, above the discrete window and below the swept cap. The override was checked by running the test with the variable set: it passes unset and with `8192`; with `2048` it fails at "a written-only 4 MiB element was bound in place on a discrete GPU", with `16384` at "a written-only 12 MiB element was staged past the discrete written window" (a set value cannot be covered by a `Require`, since it is read once into a static). `agc_read_written_staging` with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1` (`ctest -V`) on `main` 3fd1cc393 and on this branch (35ac3402c, rebased onto `main` 35ac3402c): passes on both, the layer was found, no `VUID-` lines in either log. The test's guest block grows from 8 to 16 MiB so the 12 MiB cases fit inside the import. - Isolated benchmark of the kernel (test `agc_driver_skin_cache_bench`, local, not part of this PR), 1047 groups of 64, median of 10: outputs staged 0.30 ms; outputs in place with the game's descriptor sizes 43.9 ms; `APS5_WRITTEN_SHADOW_MAX_KIB=4096` on the same 0.29 ms. In the game with that override the kernel went from 4.18 to 0.09 ms per dispatch. - Performance, same machine, same session, warm caches, Ghostrunner 2 (PPSA09911) loaded into gameplay with scripted input (Space through the loading screen, then a fixed key cycle with the respawn key), `APS5_TRACE_SECONDS=120:60`, no other switches. The base is `main` 4b462ef60 plus #7687 (this title stops before gameplay on `main` alone, #7017) plus #5372 (without it 35 GB per 10 s of CPU copies of another buffer bound the frame); this change on top. base: ```json {"commit":"91360fefc6ad","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:60"},"gpu":"NVIDIA GeForce RTX 2060 SUPER","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","resolution":"3840x2160","window":{"spec":"seconds 120:60","first_present":776,"ms":60222.419},"presents":196,"frame_ms":{"p50":308.178,"p90":458.490,"p99":1997.642,"max":2005.776},"gpu_busy_ms_per_present":87.020,"worker_busy_pct":{"queue worker 0x0":98.431,"queue worker 0x20":99.274},"top_phases_ms_per_frame":{"Driver.Packet":606.024,"Driver.Packet.memory_wait":300.685,"Graphics.Draw":161.834,"Driver.Packet.draw":137.449,"Driver.Draw":135.894,"Graphics.Draw.draw_and_resource_release":131.967,"Driver.Packet.device_lock":123.802,"Driver.Draw.shader_compile_and_link":60.803},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":7.127,"events_lost":1832781,"totals_full":false},"draw committer":{"events_full_after_s":23.950,"events_lost":381210,"totals_full":false}},"trace":"aps5-trace-91360fefc6ad-12200.json.gz"} ``` this change: ```json {"commit":"42a2c6a94a1d","dirty":false,"env":{"APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:60"},"gpu":"NVIDIA GeForce RTX 2060 SUPER","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","resolution":"3840x2160","window":{"spec":"seconds 120:60","first_present":860,"ms":60416.623},"presents":261,"frame_ms":{"p50":171.067,"p90":269.165,"p99":1943.903,"max":3724.421},"gpu_busy_ms_per_present":75.154,"worker_busy_pct":{"queue worker 0x0":98.508,"queue worker 0x20":99.419},"top_phases_ms_per_frame":{"Driver.Packet":457.323,"Driver.Packet.memory_wait":223.598,"Graphics.Draw":117.754,"Driver.Packet.draw":110.744,"Driver.Draw":109.796,"Driver.Packet.device_lock":83.411,"Graphics.Draw.draw_and_resource_release":81.409,"Driver.Draw.draw_enqueued":50.723},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":8.606,"events_lost":1676944,"totals_full":false},"draw committer":{"events_full_after_s":32.615,"events_lost":281459,"totals_full":false}},"trace":"aps5-trace-42a2c6a94a1d-12896.json.gz"} ``` Frame p50 308.2 → 171.1 ms, presents 196 → 261 in the window, GPU busy per present 87.0 → 75.2 ms. Scripted runs die and respawn at different moments (the p99 of both windows is a respawn reload), so the per-program GPU times of the profiled runs are the steadier number: the kernel at 0x200fa10000 fell from 4.2 to 0.1 ms per dispatch in every window and left the top GPU programs; staging-in and staging-out rose from 1.97 and 1.73 to 3.72 and 3.55 ms per present. Both traces and the `tools/trace_digest.py` output of each are attached. `tools/pr_overlap.py`: no open pull request changes the same lines; 65 pull requests that conflict with `main` share `GuestBufferMemory.cpp`, `VulkanDevice.cpp`, `Context.hpp` or `tests/Recorder.cpp` and could not be compared. #7618 raises the *swept* cap on discrete GPUs and extends the swept rule to written-only elements; it touches the same `stagingEligible` line and adds the same `discreteGpu` field, so whichever lands second rebases onto the other, and the two conditions compose (an element either sweeps or falls under the written window). ### 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: none - [x] Fixes: none - [x] Unblocks: PPSA09911 #9679 - [x] GPUs tested: NVIDIA GeForce RTX 2060 SUPER, driver 617.42, Windows 11 10.0.26200 (Khronos validation layer 1.4.363) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
TheSovietWaffle commented 2026-10-20 11:09:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-20T11:09:48Z.


AMD data point: RTX 3080 (NVIDIA 617.42) and AMD Radeon RDNA 2 iGPU (1002:164e, 32.0.21045.5002), Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, head 2bb7a2e6d: agc_read_written_staging passes 3 of 3 on both GPUs. (The Radeon is an integrated GPU, so it does not exercise the discrete-GPU staging size this PR changes.)

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6289513603 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8336#issuecomment-6289513603). Originally posted by [TheSovietWaffle](https://github.com/TheSovietWaffle) on 2026-10-20T11:09:48Z. --- AMD data point: RTX 3080 (NVIDIA 617.42) and AMD Radeon RDNA 2 iGPU (`1002:164e`, 32.0.21045.5002), Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, head `2bb7a2e6d`: `agc_read_written_staging` passes 3 of 3 on both GPUs. (The Radeon is an integrated GPU, so it does not exercise the discrete-GPU staging size this PR changes.) AI-assisted: yes (Claude Code).
oneandonlydean commented 2026-10-20 12:35:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T12:35:14Z.


Thanks for the measurements. One change before this goes further:

The description says APS5_WRITTEN_SHADOW_MAX_KIB "still overrides both", but on a discrete GPU the new bound is std::max(writtenShadowMax(), DiscreteWrittenShadowMax) (GuestBufferMemory.cpp, stagingEligible). A value below 8192 is therefore ignored there. APS5_WRITTEN_SHADOW_MAX_KIB=2048 no longer restores the previous window, and the only way left to go back is APS5_NO_WRITTEN_SHADOW=1, which also turns off the 16 KiB to 2 MiB staging. That knob is what an A/B run against this change needs, so please make an explicit value win on both device types, for example by making 8192 the default of writtenShadowMax() on a discrete GPU and 2048 otherwise, with the environment value used as given when it is set. A boundInPlace case in readWrittenStagingTests that sets the variable can't work because the value is read once into a static, so a sentence in the description saying how you checked it is enough.

Please also update the two places that still describe the old window:

  • docs/dev/ENVIRONMENT.md, APS5_WRITTEN_SHADOW_MAX_KIB: the default is now 8192 on a discrete GPU and 2048 otherwise.
  • The comment above SweptShadowMax gives "16 / 2048" as the defaults and names 4-8 MiB memcpy kernels over video frames as the reason for the 2 MiB cap. Those elements are now staged on discrete GPUs, so the comment should say that the trade-off was revisited for discrete GPUs, or what still keeps such a kernel out.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6290964485 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8336#issuecomment-6290964485). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T12:35:14Z. --- Thanks for the measurements. One change before this goes further: The description says `APS5_WRITTEN_SHADOW_MAX_KIB` "still overrides both", but on a discrete GPU the new bound is `std::max(writtenShadowMax(), DiscreteWrittenShadowMax)` (`GuestBufferMemory.cpp`, `stagingEligible`). A value below 8192 is therefore ignored there. `APS5_WRITTEN_SHADOW_MAX_KIB=2048` no longer restores the previous window, and the only way left to go back is `APS5_NO_WRITTEN_SHADOW=1`, which also turns off the 16 KiB to 2 MiB staging. That knob is what an A/B run against this change needs, so please make an explicit value win on both device types, for example by making 8192 the default of `writtenShadowMax()` on a discrete GPU and 2048 otherwise, with the environment value used as given when it is set. A `boundInPlace` case in `readWrittenStagingTests` that sets the variable can't work because the value is read once into a static, so a sentence in the description saying how you checked it is enough. Please also update the two places that still describe the old window: - `docs/dev/ENVIRONMENT.md`, `APS5_WRITTEN_SHADOW_MAX_KIB`: the default is now 8192 on a discrete GPU and 2048 otherwise. - The comment above `SweptShadowMax` gives "16 / 2048" as the defaults and names 4-8 MiB memcpy kernels over video frames as the reason for the 2 MiB cap. Those elements are now staged on discrete GPUs, so the comment should say that the trade-off was revisited for discrete GPUs, or what still keeps such a kernel out.
saarthakpant commented 2026-10-21 08:17:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by saarthakpant on 2026-10-21T08:17:31Z.


Done in 569ce7c2d, rebased onto main f894ba69d:

  • writtenShadowMax(bool discreteGpu): the environment value is used as given on both device types; without it the window is 8192 KiB on a discrete GPU and 2048 otherwise. stagingEligible takes that bound directly for a written element that is not swept (the swept case keeps max(bound, 16 MiB) as before), so APS5_WRITTEN_SHADOW_MAX_KIB=2048 restores the previous window on a discrete GPU too.
  • docs/dev/ENVIRONMENT.md and the comment above SweptShadowMax describe the new defaults and why the discrete window takes the elements the 2 MiB cap kept out; the trade-off and what it was measured on are recorded under Functional in docs/dev/debt/libSceAgcDriver.md, which is also what the conventions check requires for a changed comment.
  • The test device now sets Context::discreteGpu from the physical device type (it was always false in the test harness, so readWrittenStagingTests had been exercising the integrated branch on a discrete GPU). With the discrete branch live, the swept-rule cases use a 12 MiB element, above the discrete window and below the swept cap, so they test the sweep and not the window.

How the override was checked (RTX 2060 SUPER, 617.42): agc_read_written_staging passes with the variable unset and with APS5_WRITTEN_SHADOW_MAX_KIB=8192; with 2048 it fails at "a written-only 4 MiB element was bound in place on a discrete GPU", with 16384 at "a written-only 12 MiB element was staged past the discrete written window", so a set value wins on a discrete GPU in both directions. Under VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 the test passes with no VUID- line and the layer found.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6311373313 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8336#issuecomment-6311373313). Originally posted by [saarthakpant](https://github.com/saarthakpant) on 2026-10-21T08:17:31Z. --- Done in 569ce7c2d, rebased onto `main` f894ba69d: - `writtenShadowMax(bool discreteGpu)`: the environment value is used as given on both device types; without it the window is 8192 KiB on a discrete GPU and 2048 otherwise. `stagingEligible` takes that bound directly for a written element that is not swept (the swept case keeps `max(bound, 16 MiB)` as before), so `APS5_WRITTEN_SHADOW_MAX_KIB=2048` restores the previous window on a discrete GPU too. - `docs/dev/ENVIRONMENT.md` and the comment above `SweptShadowMax` describe the new defaults and why the discrete window takes the elements the 2 MiB cap kept out; the trade-off and what it was measured on are recorded under Functional in `docs/dev/debt/libSceAgcDriver.md`, which is also what the conventions check requires for a changed comment. - The test device now sets `Context::discreteGpu` from the physical device type (it was always false in the test harness, so `readWrittenStagingTests` had been exercising the integrated branch on a discrete GPU). With the discrete branch live, the swept-rule cases use a 12 MiB element, above the discrete window and below the swept cap, so they test the sweep and not the window. How the override was checked (RTX 2060 SUPER, 617.42): `agc_read_written_staging` passes with the variable unset and with `APS5_WRITTEN_SHADOW_MAX_KIB=8192`; with `2048` it fails at "a written-only 4 MiB element was bound in place on a discrete GPU", with `16384` at "a written-only 12 MiB element was staged past the discrete written window", so a set value wins on a discrete GPU in both directions. Under `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1` the test passes with no `VUID-` line and the layer found. AI-assisted: yes.
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!8336
No description provided.