Repository navigation
perf(agc): read depth planes into storage images in a compute pass - #12120
Conversation
|
I independently ran the repository-required Main (
|
| thread | busy | wait | untraced | in slices < 20 us | largest |
|---|---|---|---|---|---|
| title | 0.4 (1 %) | 0.0 (0 %) | 62.7 | 0.5 | Shader.ResolveGraphicsStagesAbi 0.1, Shader.ResolveGraphicsAbi 0.1 |
| queue worker 0x0 | 14.9 (24 %) | 0.0 (0 %) | 48.1 | 49.4 | Driver.Packet 14.6, Driver.EndSubmission 0.3 |
| draw committer | 27.7 (44 %) | 0.2 (0 %) | 35.1 | 36.0 | Graphics.Draw 26.2, Recorder.Submit 1.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| presenter | 0.9 (1 %) | 36.3 (58 %) | 25.8 | 0.0 | VideoOut.Flip 37.0, Driver.Present 0.1 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.1, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 62.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveAbi 0.0 |
| gpu | 60.6 (96 %) | 0.0 (0 %) | 2.4 | 0.0 | batch 60.6 |
Largest slices (ms per frame, inclusive, all threads): batch 60.6, VideoOut.Flip 37.0, Driver.Present 37.0, VideoOut.Flip.present 36.8, Driver.Present.render_fence_wait 36.0, Vulkan.Retire 36.0, Vulkan.Retire.wait 36.0, Graphics.Draw 26.2, Graphics.Draw.draw_and_resource_release 22.1, Driver.Packet 14.6
Longest waits
- Driver.Present.render_fence_wait (presenter) 58.3 ms at 9563 ms, present 4144
- Driver.Present.render_fence_wait (presenter) 56.3 ms at 12800 ms, present 4196
- Driver.Present.render_fence_wait (presenter) 54.1 ms at 8756 ms, present 4131
- Driver.Present.render_fence_wait (presenter) 52.8 ms at 8629 ms, present 4129
- Driver.Present.render_fence_wait (presenter) 52.7 ms at 10632 ms, present 4161
- Driver.Present.render_fence_wait (presenter) 52.6 ms at 12860 ms, present 4197
- Driver.Present.render_fence_wait (presenter) 52.4 ms at 9505 ms, present 4143
- Driver.Present.render_fence_wait (presenter) 52.0 ms at 10572 ms, present 4160
- Driver.Present.render_fence_wait (presenter) 51.6 ms at 11755 ms, present 4179
- Driver.Present.render_fence_wait (presenter) 51.3 ms at 9632 ms, present 4145
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
- batch 2191: 12.1 ms at 2673 ms, present 4031: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.5, Graphics.Draw.draw_and_resource_release (draw committer) 0.5
- batch 2248: 11.8 ms at 2739 ms, present 4032: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.4, Graphics.Draw.draw_and_resource_release (draw committer) 0.4
- batch 13637: 11.4 ms at 14708 ms, present 4227: GPU no ranges; recorded by no CPU slices
- batch 6051: 11.3 ms at 6708 ms, present 4098: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.6, Graphics.Draw.draw_and_resource_release (draw committer) 0.5
- batch 2885: 11.3 ms at 3407 ms, present 4043: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.6, Graphics.Draw.draw_and_resource_release (draw committer) 0.5
### PR (`88bf0fd0654a`)
```text
**seconds 200:15** from present 4399: 245 presents, frame p50 60.4 / p90 64.3 / p99 82.1 / max 89.7 ms, GPU busy 60.0 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit 88bf0fd0654a, dropped: yes
```json
{"commit":"88bf0fd0654a","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"200:15"},"gpu":"NVIDIA GeForce RTX 2080 Ti","driver":"NVIDIA 617.14","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz","cpu_threads":16,"memory_mib":32684,"title_id":"PPSA05324","title":"Sonic Origins","content_version":"02.002.000","resolution":"3840x2160","window":{"spec":"seconds 200:15","first_present":4399,"ms":15003.238},"presents":245,"frame_ms":{"p50":60.433,"p90":64.331,"p99":82.109,"max":89.67},"gpu_busy_ms_per_present":60.001,"worker_busy_pct":{"queue worker 0x0":97.177},"top_phases_ms_per_frame":{"Driver.Packet":58.635,"Graphics.Draw":46.156,"Driver.Packet.draw":44.922,"Driver.Draw":44.19,"Graphics.Draw.draw_and_resource_release":37.959,"VideoOut.Flip":30.616,"Driver.Present":30.509,"VideoOut.Flip.present":30.402},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.525,"events_lost":444053,"totals_full":false},"draw committer":{"events_full_after_s":12.798,"events_lost":44954,"totals_full":false}},"trace":"aps5-trace-88bf0fd0654a-32060.json.gz"}
Slowest frames (largest slices inside each, inclusive)
- present 4399: 89.7 ms at 0 ms: batch (gpu) 77.5, Driver.Packet (queue worker 0x0) 61.8, Driver.Packet.draw (queue worker 0x0) 54.5, Driver.Draw (queue worker 0x0) 53.8
- present 4559: 85.1 ms at 9753 ms: batch (gpu) 84.2, VideoOut.Flip (presenter) 53.8, VideoOut.Flip.present (presenter) 53.7, Driver.Present (presenter) 53.7
- present 4591: 82.1 ms at 11744 ms: batch (gpu) 81.4, VideoOut.Flip (presenter) 48.7, VideoOut.Flip.present (presenter) 48.3, Driver.Present (presenter) 48.3
- present 4605: 69.6 ms at 12623 ms: batch (gpu) 68.9, VideoOut.Flip (presenter) 42.4, VideoOut.Flip.present (presenter) 41.6, Driver.Present (presenter) 41.6
- present 4537: 69.1 ms at 8407 ms: batch (gpu) 68.6, Graphics.Draw (draw committer) 35.1, VideoOut.Flip (presenter) 32.4, VideoOut.Flip.present (presenter) 32.2
Threads (ms per frame)
| thread | busy | wait | untraced | in slices < 20 us | largest |
|---|---|---|---|---|---|
| title | 0.4 (1 %) | 0.0 (0 %) | 60.9 | 0.5 | Shader.ResolveGraphicsStagesAbi 0.2, Shader.ResolveGraphicsAbi 0.1 |
| queue worker 0x0 | 12.7 (21 %) | 0.0 (0 %) | 48.5 | 45.7 | Driver.Packet 12.4, Driver.EndSubmission 0.3 |
| draw committer | 25.6 (42 %) | 0.3 (0 %) | 35.3 | 34.5 | Graphics.Draw 24.0, Recorder.Submit 1.1 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.0 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| presenter | 0.9 (1 %) | 29.8 (49 %) | 30.5 | 0.0 | VideoOut.Flip 30.6, Driver.Present 0.1 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.1 | Shader.ResolveGraphicsAbi 0.1, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.1 | Shader.ResolveGraphicsAbi 0.1, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.0 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| title | 0.1 (0 %) | 0.0 (0 %) | 61.1 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 |
| gpu | 60.0 (98 %) | 0.0 (0 %) | 1.2 | 0.0 | batch 60.0 |
Largest slices (ms per frame, inclusive, all threads): batch 60.0, VideoOut.Flip 30.6, Driver.Present 30.5, VideoOut.Flip.present 30.4, Driver.Present.render_fence_wait 29.6, Vulkan.Retire 29.6, Vulkan.Retire.wait 29.6, Graphics.Draw 24.0, Graphics.Draw.draw_and_resource_release 19.8, Driver.Packet 12.4
Longest waits
- Driver.Present.render_fence_wait (presenter) 51.1 ms at 9756 ms, present 4559
- Driver.Present.render_fence_wait (presenter) 50.8 ms at 9382 ms, present 4553
- Driver.Present.render_fence_wait (presenter) 50.8 ms at 11626 ms, present 4589
- Driver.Present.render_fence_wait (presenter) 50.7 ms at 11249 ms, present 4583
- Driver.Present.render_fence_wait (presenter) 50.3 ms at 11501 ms, present 4587
- Driver.Present.render_fence_wait (presenter) 48.3 ms at 11439 ms, present 4586
- Driver.Present.render_fence_wait (presenter) 47.8 ms at 11373 ms, present 4585
- Driver.Present.render_fence_wait (presenter) 47.6 ms at 11564 ms, present 4588
- Driver.Present.render_fence_wait (presenter) 47.5 ms at 11685 ms, present 4590
- Driver.Present.render_fence_wait (presenter) 47.3 ms at 11745 ms, present 4591
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
- batch 13361: 13.6 ms at 13976 ms, present 4626: GPU no ranges; recorded by no CPU slices
- batch 5534: 13.5 ms at 5785 ms, present 4493: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.4, Graphics.Draw.draw_and_resource_release (draw committer) 0.4
- batch 3427: 13.3 ms at 3604 ms, present 4457: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.5, Graphics.Draw.draw_and_resource_release (draw committer) 0.4
- batch 8462: 13.3 ms at 8843 ms, present 4544: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.5, Graphics.Draw.draw_and_resource_release (draw committer) 0.5
- batch 2847: 13.3 ms at 3003 ms, present 4448: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.5, Graphics.Draw.draw_and_resource_release (draw committer) 0.5
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
@Meh7an thanks for the traces and the clear write-up. Two changes at
Please keep the copy fallbacks and the existing data, partial-rectangle and stencil checks. Nothing here asks for a test that pins an unimplemented path to throw. The spec sections I used are https://docs.vulkan.org/spec/latest/chapters/fragops.html#fragops-depth-clamp and https://docs.vulkan.org/spec/latest/chapters/copies.html (the depth-copy range rule). |
MarcZX10
left a comment
There was a problem hiding this comment.
I independently checked the two concerns raised in the discussion on exact head 2c401e31988c7b18308bade0e7ed3a81ba4ed0df. Both are confirmed from the code: the pass is selected for 32-bit depth/storage pairs without constraining stored values, while the store-back shader writes the integer payload as gl_FragDepth; and agc_driver_depth_storage asserts a pass ran even when APS5_NO_DEPTH_TRANSFER_PASS disables them. I also ran glslangValidator -V --target-env vulkan1.1 on both new shaders successfully, and rechecked git diff --check, current-main merge preview, the attached round-2 digest output, and the author's reported validation results. I am requesting changes for the two concrete issues below; the 16/16 focused GPU test result does not cover the arbitrary-bit round trip or the opt-out test configuration.
|
|
||
| bool depthTransferPass(const Context& context, VkFormat depthFormat, VkFormat colorFormat) { | ||
| if (!context.pushDescriptors || !depthTransferPasses.load(std::memory_order_relaxed)) return false; | ||
| return aspectCopyBytes(depthFormat, VK_IMAGE_ASPECT_DEPTH_BIT) == 4 && singleComponent(colorFormat, 4); |
There was a problem hiding this comment.
The dispatch is enabled for every D32 + 32-bit single-component pair, but this does not restrict values already present in the storage alias. StorageToDepth.frag interprets each uint payload as a float and writes it through gl_FragDepth; finite out-of-range values, signed zero, subnormals, and NaNs therefore do not have demonstrated bit-preserving equivalence to CopyPlane on all device-feature/format paths. Please keep the copy path for values the pass cannot reproduce exactly, or leave this pass opt-in until the equivalence is established. Add enabled-vs-copy round-trip checks for representative out-of-range finite values and bit patterns where supported, and narrow the description to what those checks prove.
| RunPairings(context, block); | ||
| ClearDepthSurfaces(context.device); | ||
| } | ||
| Require(!context.pushDescriptors || DepthTransferPassCount() > 0, "the device enables VK_KHR_push_descriptor but no depth plane transfer ran in shader passes"); |
There was a problem hiding this comment.
This assertion fails whenever APS5_NO_DEPTH_TRANSFER_PASS is present on a device with push descriptors: the environment switch disables the pass counter increments, but this test does not account for the switch. Please make the expectation conditional on the switch, then run agc_driver_depth_storage with the pass enabled and disabled, verifying zero passes in the latter run while the depth and stencil checks still pass.
adriadam10
left a comment
There was a problem hiding this comment.
Agreeing with the two points already raised at 2c401e3198, neither addressed yet:
DepthSurface.cpp:80-82:depthTransferPassgates on format and push descriptors only, whileStorageToDepth.fragwrites any stored word throughgl_FragDepthandFromStoragefixes the viewport to 0..1. Values outside [0, 1] or NaN written through the storage alias are not kept bit for bit, andVK_EXT_depth_range_unrestrictedis enabled where available. Either keepmain's copy for values the pass can't reproduce exactly, or leave the pass opt-in until the equivalence is shown. Replace the blanket range claim with an argument per device configuration, and add enabled-versus-copy round-trip checks (-0.5, 2.0, signed zero, subnormals, NaN) stating bit preservation only as far as it holds.DepthStorage.cpp:367requiresDepthTransferPassCount() > 0wheneverpushDescriptorsis set, butAPS5_NO_DEPTH_TRANSFER_PASSstops every increment, so the test fails with the switch. Honor the switch there (asDepthPlanePartialStore.cpp:135does) and runagc_driver_depth_storageboth ways, expecting zero passes in the off run.
Keep the copy fallbacks and the existing data, partial-rectangle and stencil checks.
2c401e3 to
57d63ac
Compare
|
@oneandonlydean @adriadam10 thanks, both points were right. The PR is now 57d63ac, rebased onto 1. Values the pass can't reproduce. I added enabled-versus-copy round trips to
So the PR now keeps only the compute pass, for depth to storage. Storage to depth always uses For each configuration: with or without the extension, the pass reads the 32-bit depth texel with
2. The switch in On the Sonic 3 & Knuckles menu page, the copy class drops from 2.76 to 1.68 ms per frame, measured against |
|
@Meh7an Thanks, dropping the storage-to-depth draw settles the range question, and the off-switch arm in @adriadam10 we'll merge this once the request above is addressed and exact-head CI is green, unless you'd rather merge it yourself. |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 57d63ac306f22ea71b02075e0d738113c4728aa5. The earlier test concerns are addressed in this head: RunRoundTrips compares the pass with the copy path across the signed-zero, out-of-range, subnormal, infinity and NaN words, and its pass-count assertion now permits APS5_NO_DEPTH_TRANSFER_PASS; the pass-off case is separately selectable. The remaining blocker is the behavior limit raised in the latest review: depthToStoragePass is enabled by default for eligible format/push-descriptor devices, while the test only requires exact input preservation for [0,1] values and for out-of-range values when unrestricted depth is available. Please add the still-unmeasured bit-preservation scope and the APS5_NO_DEPTH_TRANSFER_PASS fallback to docs/dev/debt/libSceAgcDriver.md as requested, so the default behavior and its limits are explicit. Current-main merge preview is clean; exact-head Windows workflow passes, product Linux/GPU jobs are skipped. I did not run local GPU tests.
57d63ac to
f227dc3
Compare
✅ NVIDIA GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)Validated but not compared (3, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 436 tests)Skipped (39)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
A D32 depth plane is copied into the 32-bit color storage image that holds its texels whenever a shader accesses the plane as a storage image: with vkCmdCopyImage where VK_KHR_maintenance8 allows it, else through a staging buffer. Where the device has VK_KHR_push_descriptor, which is now enabled when present (Context::pushDescriptors), DepthSurface reads the plane into the image in a compute pass instead. The pass fetches the depth aspect through a sampled view and stores the bits through an r32ui view, rectangle by rectangle, so partial unit stores use it too. Its two views are pushed, so a recorded pass holds no descriptor set, and the pass of each device is released in ClearDepthSurfaces. Copies back into the depth plane keep the existing copies: a fragment shader's depth write flushes subnormals, does not keep NaN, and clamps to [0, 1] without VK_EXT_depth_range_unrestricted. D16, the stencil plane, multisampled surfaces and the layered copies keep the copies as well, as does APS5_NO_DEPTH_TRANSFER_PASS=1. agc_embedded_shader adds a Graphics/shaders source as an embedded SPIR-V header.
f227dc3 to
badf4cd
Compare
✅ NVIDIA GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (5, not counted against this PR)Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)Validated but not compared (3, not in the main baseline's validation pass)Validation IDs already present on main (5 IDs in 433 tests)Skipped (40)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
An AMD RDNA 4 run on Windows of Windows 11 Pro 10.0.22631, AMD Radeon RX 9070 XT (
AI-assisted: yes (Claude Code) |
# Conflicts: # core/libs/prx/libSceAgcDriver/CMakeLists.txt
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validation IDs already present on main (4 IDs in 528 tests)Skipped (49)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
On RX 9060 XT / RADV, the D32 depth-to-storage shader pass matched the copy control for the exercised round trips, including the tested NaN payloads in unrestricted-depth mode; the round trip changed three subnormal inputs in both paths.
Reproductioncmake --build build-main --target agc_driver_depth_storage_tests agc_driver_depth_plane_partial_store_tests -j4
export ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1
export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer
export VK_LAYER_PATH="$HOME/.local/share/anyps5-tester/vk-layers/usr/share/vulkan/explicit_layer.d"
ctest --test-dir build-main -R '^(agc_driver_depth_storage|agc_driver_depth_plane_partial_store|agc_driver_depth_plane_partial_store_unimported|agc_driver_depth_plane_partial_store_buffer_copy)$' --timeout 90 -VRepeat three times on each tree. On the candidate also run AI-assisted independent hardware test run (gpt-6.1-terra, medium). |
What
A depth surface's plane and the 32-bit color storage image that holds its texels are copied into each other whenever a shader reads or writes the plane as a storage image. On
main(#11685) that is onevkCmdCopyImagebetween the depth aspect and the color image whereVK_KHR_maintenance8allows it, else a copy through a staging buffer. On an RTX 2080 Ti the copy costs about 1.4 ms per 4K plane. Sonic Origins Plus does two per frame on its main menu, 2.88 ms of GPU time per frame.Where the device has
VK_KHR_push_descriptor, this PR reads a D32 plane into the storage image in a compute pass instead (DepthToStorage.comp):OpImageFetch, no sampler) and stores the bits unchanged through anr32uiview of the storage image (StorageTexture::AtomicView).copyPlane's rectangles as push constants, one dispatch each, so partial unit stores (StoreDepthPlane) use it too.vkCmdPushDescriptorSetKHR), so a recorded pass holds no descriptor set. The pipeline and its layouts are made once per device on first use and released inClearDepthSurfaces. Each surface keeps its depth-aspect view until it is released.VulkanDeviceenablesVK_KHR_push_descriptorwhen the device has it, and the graphicsContextcarries it aspushDescriptors. The newagc_embedded_shaderCMake function compiles aGraphics/shaderssource into an embedded SPIR-V header.Copies back into the depth plane keep
main's copy. A fragment shader's depth write can't stand in for it: on the 2080 Ti it flushed subnormals to ±0 and turned every NaN into -inf, and withoutVK_EXT_depth_range_unrestrictedit clamped to [0, 1]. Finite values outside [0, 1] survived with the extension only because the driver didn't clamp them: with a [0, 1] viewport the spec leaves them undefined, and a ±FLT_MAXviewport, which would make them defined, broke the store-back test on this driver. The round-trip results are under Tested.These keep
main's copies too: D16 planes, the stencil plane, multisampled surfaces,TakeStorageand the layered copies (LayeredDepthStorage::Copy). So does every plane whenAPS5_NO_DEPTH_TRANSFER_PASS=1is set; the variable has its row inENVIRONMENT.md. The copies still take #11685's direct path where it applies, andAPS5_NO_DIRECT_DEPTH_COPY=1still forces the staging buffer.What the pass keeps, by device configuration:
VK_EXT_depth_range_unrestricted: the pass gives back exactly whatmain's copy gives back, word for word. It reads the 32-bit texel without a sampler and stores its bits, and the spec defines no conversion for that read.FLT_MAX, ±inf, and quiet and signalling NaNs with payloads.Tests:
agc_driver_depth_storagestores the 16 words into a D32 plane and a D32S8 plane, then reads them back twice, copies only and with the pass. It requires word-for-word equal results and that the pass ran. It requires 0.25, 1 and +0 back in every configuration, and -0.5 and 2.0 back where the depth range is unrestricted. It reports which of the other words the copy changed: none on this GPU. Its device enablesVK_KHR_push_descriptorwhen the queue can draw, andVK_EXT_depth_range_unrestrictedunless--restricted-depthis given. The existing whole-plane data and stencil checks run through the pass as well.agc_driver_depth_storage_copiesruns it withAPS5_NO_DEPTH_TRANSFER_PASS=1and requires zero passes, with the data and stencil checks unchanged. Newagc_driver_depth_storage_restricted_depthruns it without the extension.agc_driver_depth_plane_partial_store(partial stores) runs in three modes. The default requires the pass where the device hasVK_KHR_push_descriptor. The newagc_driver_depth_plane_partial_store_image_copy(--image-copy) turns the pass off and requires direct copies whereVK_KHR_maintenance8is enabled.--buffer-copyturns both off.DepthSurfacegainsSetDepthTransferPassesandDepthTransferPassCountfor these tests, like feat(agc): copy depth planes to and from color storage images directly where maintenance8 allows #11685'sSetDirectDepthCopyandDirectDepthCopyCount.No open PR reads depth planes in a compute pass or enables
VK_KHR_push_descriptor.tools/pr_overlap.pyfinds no other open PR that changes the same code. It could not compare 92 PRs that conflict withmainand share a file with this one, and none of their diffs adds push descriptors or changescopyPlaneorDirectDepthCopy.Tested
Rebased onto
main2227f13 (57d63ac). The round trips and S3K numbers below were measured onmainc02d287, with this change as 05addcdbd1. The 120 commits between them change eight lines of the files this PR touches, inCMakeLists.txtandVulkanDevice.cpp, and nothing in the transfer path. On the rebased head the validation run below gives 18/18 again, with noVUID-line and no missing-layer line, andctestpasses 2815 of 2815.Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 2080 Ti, driver 617.14, i9-9900K.
Round trips. These ran with a temporary build that could also turn on the fragment depth write, which the review asked about. They store the 16 words into a D32 plane and a D32S8 plane through the store-back, then read them back through a storage view. Both formats gave the same results.
VK_EXT_depth_range_unrestrictedenabled--restricted-depth)main's copies, direct and through the staging bufferFLT_MAXand ±inf kept; subnormals flushed to ±0; every NaN came back as -infFLT_MAXviewport (dropped)S3K. Sonic Origins Plus (PPSA05324) on the Sonic 3 & Knuckles page of the main menu,
main's defaults.mainc02d287 againstmainwith this PR (05addcdbd1), both built from the same tree; nothing else is applied. Each build got a warm-up boot and oneAPS5_PROFILE_GPU=1boot. Then came two interleaved traced rounds (main, PR,main, PR;APS5_TRACE_SECONDS=200:15, six title FPS readings each).main[gputime]copy class per present (2 transfers, 63.3 MiB)[gputime]GPU time per present, all ranges, the same six blocks on the pagemain's copy, about 1.5 ms of the remaining 1.68 ms.Driver.Draw.shader_compile_and_linkinside the window,main's included, so the rounds compare like with like.Tests.
ctestonmainc02d287 plus this PR: 2776 of 2777 pass. The failure,agc_driver_mesh_barycentric_emulation, wasmain's own and passes on the rebased head.ctest --test-dir build -R "depth_plane_partial_store|depth_storage|depth_plane_sampling|depth_copy|native_depth" -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: 15/15 onmainand 18/18 on this PR. The three extra tests areagc_driver_depth_plane_partial_store_image_copy,agc_driver_depth_storage_copiesandagc_driver_depth_storage_restricted_depth. Neither log haswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither has aVUID-line. On this PR, the threedepth_storageruns report that the pass matches the copy and that the copy changed none of the 16 words. The copies run reports zero passes.All four traces are attached, one zip per round with the
mainand PR traces.depth-to-storage-s3k-c02d-round1.zip
depth-to-storage-s3k-c02d-round2.zip
Sonic 3 & Knuckles page, round 1, main
seconds 200:15 from present 4373: 250 presents, frame p50 58.3 / p90 65.6 / p99 82.2 / max 82.7 ms, GPU busy 53.6 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit c02d287, dropped: yes
{"commit":"c02d287bd0eb","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"200:15"},"gpu":"NVIDIA GeForce RTX 2080 Ti","driver":"NVIDIA 617.14","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz","cpu_threads":16,"memory_mib":32684,"title_id":"PPSA05324","title":"Sonic Origins","content_version":"02.002.000","resolution":"3840x2160","window":{"spec":"seconds 200:15","first_present":4373,"ms":15052.654},"presents":250,"frame_ms":{"p50":58.279,"p90":65.626,"p99":82.192,"max":82.663},"gpu_busy_ms_per_present":53.633,"worker_busy_pct":{"queue worker 0x0":97.349},"top_phases_ms_per_frame":{"Driver.Packet":57.742,"Graphics.Draw":46.63,"Driver.Packet.draw":44.825,"Driver.Draw":44.135,"Graphics.Draw.draw_and_resource_release":38.531,"Driver.Draw.shader_compile_and_link":27.402,"VideoOut.Flip":22.641,"Driver.Present":22.551},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.78,"events_lost":412503,"totals_full":false},"draw committer":{"events_full_after_s":12.591,"events_lost":50581,"totals_full":false}},"trace":"aps5-trace-c02d287bd0eb-25464.json.gz"}Sonic 3 & Knuckles page, round 1, this PR
seconds 200:15 from present 4517: 248 presents, frame p50 59.2 / p90 64.0 / p99 82.2 / max 86.7 ms, GPU busy 52.6 ms per present
NVIDIA GeForce RTX 2080 Ti, NVIDIA 617.14, Windows 10.0.26300, 3840x2160, commit 05addcdbd111, dropped: yes
{"commit":"05addcdbd111","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"200:15"},"gpu":"NVIDIA GeForce RTX 2080 Ti","driver":"NVIDIA 617.14","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz","cpu_threads":16,"memory_mib":32684,"title_id":"PPSA05324","title":"Sonic Origins","content_version":"02.002.000","resolution":"3840x2160","window":{"spec":"seconds 200:15","first_present":4517,"ms":15035.38},"presents":248,"frame_ms":{"p50":59.151,"p90":64.026,"p99":82.243,"max":86.691},"gpu_busy_ms_per_present":52.563,"worker_busy_pct":{"queue worker 0x0":97.386},"top_phases_ms_per_frame":{"Driver.Packet":58.162,"Graphics.Draw":46.448,"Driver.Packet.draw":45.247,"Driver.Draw":44.514,"Graphics.Draw.draw_and_resource_release":38.293,"Driver.Draw.shader_compile_and_link":27.879,"VideoOut.Flip":21.614,"Driver.Present":21.506},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.69,"events_lost":434140,"totals_full":false},"draw committer":{"events_full_after_s":12.691,"events_lost":49445,"totals_full":false}},"trace":"aps5-trace-05addcdbd111-12292.json.gz"}Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)