Skip to content

fix(agc): render all attachment layers with dynamic rendering - #3763

Merged
oneandonlydean merged 12 commits into
boykopovar:mainfrom
eljackjoestar-cmd:codex/dynamic-rendering-layers
Oct 13, 2026
Merged

oneandonlydean merged 12 commits into
boykopovar:mainfrom
eljackjoestar-cmd:codex/dynamic-rendering-layers

Conversation

@eljackjoestar-cmd

@eljackjoestar-cmd eljackjoestar-cmd commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What

With #1077's layered-target support, dynamic rendering must use the validated attachment layer count rather than one. Set VkRenderingInfoKHR::layerCount to state.renderLayers, matching the conventional framebuffer path.

Validate nonzero layers and maxFramebufferLayers before the dynamic-rendering constructor return. Retain main's nonlayered array-view admission and limit the array bit-18 rejection to non-3D targets. The mesh validation fixture uses the device target's subgroup size.

This branch carries #1077's authored implementation and layered-volume fixtures. Rebased onto main 4bb2c7f3947440d513b1dbd12143ec55b250495a, which includes merged #423. Both old copied #423 commits (995b8ee5a/21122721c, later 745dbf031/3bb16903d) are dropped from the topic history. The draw and preparation paths retain main's PositionExportLayout and add the routed layer bits at use. Clip/cull validation and its tests are retained from main.

Request serialization writes version 21 and continues reading version 20's position export field at its original boundary. Tests cover version 20, older vertex captures, and combined clip-distance/layer bits. #4451 also proposes version 21; whichever merges second must renumber.

Dependencies and merge order

#423 is merged. This branch carries #1077 rather than requiring its separate merge. The agreed sequencing with #4715 remains: #423 and #4584, then #4715, then this branch. The #4715 ordering is separate from the runtime layer-count correction. Combined validation with #4715 is not claimed here.

Tested

Final head dedb869fa2e860903d0403d8edff42211305c51f. Windows 11 x64, Ryzen 7 7800X3D, 32 GiB RAM, RTX 5070 (device subgroup size 32), WinLibs GCC 15.2, Release, BUILD_TESTING=ON.

Full Windows Release build passes. Ten focused tests pass without skips in 7.03 s:

  • agc_shader_memory
  • agc_driver_graphics
  • agc_driver_layered_volume_draw
  • agc_driver_layered_volume_submit
  • agc_driver_layered_volume_vertex
  • agc_driver_layered_volume_vertex_no_gpl
  • agc_driver_vertex_clip_cull_distances
  • agc_driver_vertex_clip_cull_draw
  • agc_driver_vertex_clip_cull_draw_no_key
  • agc_vertex_layer_export

The framebuffer regression rejects zero and excessive layer counts for both dynamic and conventional constructor paths, and accepts the dynamic path's limit boundary. Layered vertex readbacks check every channel of four slices, including routed bands and the untouched slice outside the view. The mesh case validates shader metadata on the physical subgroup size; it does not perform mesh pixel readback. Driver submission checks ordinary, uncompressed-DCC and fast-clear-DCC rendering. Its fixture now calls #423's explicit driver shutdown on success and exception paths: the first test run completed all readback checks but crashed at teardown without that call; the final run above exits cleanly.

Conventions and whitespace checks pass. Earlier title tests used a broader Lost Soul Aside PPSA26358 integration; this update does not claim a fresh game run, full-suite/CI success or complete playability.

Checklist

@github-actions github-actions Bot added build shader core/shader docs agc libSceAgc* labels Oct 11, 2026
@eljackjoestar-cmd
eljackjoestar-cmd marked this pull request as ready for review October 11, 2026 16:58
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 11, 2026
@GustavoGamarra95

Copy link
Copy Markdown
Contributor

This also fixes Beast of Reincarnation (PPSA29343, Unreal Engine). It builds its 32x32x32 color-grading LUT (an A2B10G10R10 3D color target) with one draw of 32 instances whose vertex program picks the layer (PA_CL_VS_OUT_CNTL bit 18). With layerCount at 1 only slice 0 was written, holding the last instance; the tonemapper then mapped dark colors to white and bright ones to black, and the title screen showed a luminance negative. With the same one-line change on my branch the title screen renders as on the console.

Measured on Linux: agc_driver_layered_volume_draw and agc_driver_layered_volume_submit failed on an RTX 3050 Laptop (NVIDIA 615.78.08) and on lavapipe with "slice 1 ... another layer's band", and pass with the change (vertex case). A Radeon 660M (RADV) passed both before and after. On the RTX 3050 the mesh case of the draw test still fails with "missing or incompatible shader execution mode" and the submit test segfaults at exit; both also happen without the change.

We are still analyzing the remaining rendering issues of this title and an improvement for GPUs with little VRAM.

@eljackjoestar-cmd
eljackjoestar-cmd force-pushed the codex/dynamic-rendering-layers branch from 0fabfa8 to 69d11c8 Compare October 13, 2026 08:54
@eljackjoestar-cmd

Copy link
Copy Markdown
Contributor Author

Addressed the runtime and fixture corrections, and removed the copied #423 implementations from the public branch:

  • maxFramebufferLayers and the nonzero-layer check now run before the dynamic-rendering return. A regression covers zero, excessive and boundary layer counts.
  • Main's array branch is retained, with its bit-18 rejection restricted to non-3D targets.
  • The mesh fixture uses device.Target().subgroupSize; the full fixture now passes on this RTX 5070's subgroup size 32.
  • Both old feat(agc): vertex clip and cull distances #423 commits, their rebased equivalents and the legacy-version adaptation are dropped. The diff no longer changes request serialization or reserves version 20.

The review fixes pass six focused tests on local validation stack 9ac0f638b (old dependency retained locally only), in 5.88 s. I also reproduced the old clip/cull fixture's push-slot failure; I am not claiming that dependency fixed.

#423 remains open at 66e1669c. The cleaned branch explicitly waits for its merge, then needs the dependency/layout integration, the next free request version if required, and fresh builds/readbacks. No standalone-main or current-#423 combined validation is claimed for the cleaned branch. The description and dependency declarations now reflect that status.

alfalfa-star and others added 12 commits October 13, 2026 13:00
A color view of several depth slices of a 3D target (CB_COLOR_VIEW
SLICE_START < SLICE_MAX) was rejected as "color views of several array
slices are unsupported". Titles render such volumes with one draw: an
instanced draw whose vertex stage picks each primitive's slice through
the misc position export (PA_CL_VS_OUT_CNTL USE_VTX_RENDER_TARGET_INDX
with VS_OUT_MISC_VEC_ENA).

Depends on boykopovar#423, which carries PA_CL_VS_OUT_CNTL to the recompiler.

- DecodeColorBuffer takes the slice range of a 3D target
  (ColorTarget::layers, clamped to the surface's last slice), allows DCC
  on 3D targets, and sizes a tiled 3D target by its whole surface
  (SurfaceForTarget moves to State.cpp for that). DecodeState sets
  State::renderLayers and, for a layered draw, USE_VTX_RENDER_TARGET_INDX
  (State::layerExports); color targets of different slice counts and
  layered draws with a depth target throw.
- The driver adds State::layerExports to the PA_CL_VS_OUT_CNTL bits boykopovar#423
  passes (it already passes VS_OUT_MISC_VEC_ENA), so the render target
  index reaches gl_Layer only for layered draws and stays ignored
  elsewhere as before.
- A vertex stage writing gl_Layer declares ShaderViewportIndexLayerEXT
  and SPV_EXT_shader_viewport_index_layer when the device offers them
  (the device enables VK_EXT_shader_viewport_index_layer when present),
  instead of SPIR-V 1.5 ShaderLayer, which a Vulkan 1.1 device cannot
  take. Graphics validation accepts the capability, the extension and a
  vertex Layer output when it is enabled, and a per-primitive Layer
  output of a mesh stage.
- The resident target's attachment view is a 2D array view of the
  slices, and the framebuffer has that many layers (Framebuffer and
  AcquireFramebuffer take the layer count).

The execution test agc_driver_layered_volume_draw draws three bands,
one per layer, into slices 1..3 of a 4-slice 64 KiB-tiled volume and
reads every slice back: slice 0 stays untouched and slice 1 + L holds
only band L. It also recompiles a mesh program with the layer export and
validates it against the layered state. The mesh case does not draw:
lavapipe's LLVM backend aborts compiling that mesh pipeline ("Cannot
emit physreg copy instruction"), which a test cannot catch. On RADV the
same mesh draw renders the bands into the right slices.

PPSA14632 (LEGO Horizon Adventures) renders its 64x64x64 RGBA16F
translucency lighting volumes (two DCC targets, 64 instances) this way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main added the GPU-visible argument to GuestAllocations::Mutation::Add.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agc_driver_layered_volume_submit submits a DCB whose context registers
alone describe a 3D render target (CB_COLOR_ATTRIB3 resource type 3D,
CB_COLOR_VIEW slices 1-3) and set PA_CL_VS_OUT_CNTL USE_VTX_RENDER_
TARGET_INDX, with both shaders registered before the draw. It checks
that each band lands in its own slice. Removing the layer export from
the vertex stage info in Driver::draw, or the bit-18 read in
DecodeState, fails it. Two more runs draw the volume under DCC keys:
uncompressed keys stay uncompressed, and 0000 fast-clear keys leave
every texel the draw does not write at the clear color and end
uncompressed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oute them

The warning fired for every draw with PA_CL_VS_OUT_CNTL layer bits,
including layered draws that now route the render target index. It is
checked after the color targets are decoded and leaves out the routed
bits and the misc vector enable. The comment that said layer exports
are never routed is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eljackjoestar-cmd
eljackjoestar-cmd force-pushed the codex/dynamic-rendering-layers branch from 69d11c8 to dedb869 Compare October 13, 2026 09:08
@eljackjoestar-cmd

Copy link
Copy Markdown
Contributor Author

Rebased onto main 4bb2c7f39 with merged #423; the new head is dedb869fa. Both old copied #423 commits, including 745dbf031c9, are removed from the topic history. The integration retains main's PositionExportLayout and clip/cull handling, with the routed layer bits added at draw/preparation use.

Both review points are now present on this head:

  • Pipeline.cpp:76 checks nonzero layers and maxFramebufferLayers before the dynamic-rendering return at line 78. The regression covers zero, excessive and boundary counts.
  • LayeredVolumeDraw.cpp:206 uses device.Target().subgroupSize; the mesh metadata case passes on this RTX 5070's subgroup size 32.

Main's ordinary-array branch is preserved, with the bit-18 rejection restricted to non-3D targets. Request serialization is version 21, retaining the version-20 read boundary and compatibility coverage. Agreed on #4451: whichever merges second must renumber.

Full Windows Release build passes. All ten focused tests pass without skips in 7.03 s: graphics, shader memory, vertex layer export, full layered-volume draw/mesh validation, driver submission, vertex readback with/without pipeline libraries, and all three merged clip/cull tests (distances, driver draw, driver draw without its key).

The new driver-submission run exposed a fixture teardown crash after its readbacks passed. Adding #423's explicit driver shutdown on success and exception paths fixes that exit; the final run above passes cleanly. Conventions and whitespace checks pass. The description now reflects validation against merged #423 rather than the old dependency stack. The existing #4715 merge-order agreement is retained; no combined #4715 build or new game run is claimed.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
#1077 core/libs/prx/libSceAgcDriver/tests/VertexLayerExport.cpp
core/libs/prx/libSceAgcDriver/tests/execution/LayeredVolumeDraw.cpp
core/libs/prx/libSceAgcDriver/tests/execution/LayeredVolumeSubmit.cpp
#1313 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp L147-148
#4201 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L1829, L1835
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp L751, L782
#4222 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L1829, L1835
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp L751, L782
#4450 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L1829, L1835
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp L751, L782
#4767 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L992-993

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@oneandonlydean
oneandonlydean merged commit 387b8a0 into boykopovar:main Oct 13, 2026
9 checks passed
hypermoist pushed a commit to hypermoist/AnyPS5 that referenced this pull request Oct 14, 2026
Where upstream now does what this branch carried, upstream's version is
kept: clip and cull distances (boykopovar#423), layered rendering (boykopovar#3763), block
copies of BC textures over storage images (126a1e4), one-layer depth
array storage views, joined and windowed host imports (importAccess).
Kept from this branch on top: the retry of host imports refused while a
heap was being committed, the shared registry lease, host-import reads
of sampled textures (not for partially resident ones), the live storage
image lookup for block copies, aligned buffer atomics, the CMASK reading
of codes other than 0 and 15, mesh draws shorter than one primitive, and
the relaxed float mode (request serialization version 24).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uzy15wqYTt6iWyxYXEzUWo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants