Skip to content

fix(libSceAgcDriver): retire a depth surface once another writer covers its memory - #454

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
SP4C3B4R-8:fix/aliased-depth-surface-texture
Oct 15, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
SP4C3B4R-8:fix/aliased-depth-surface-texture

Conversation

@SP4C3B4R-8

@SP4C3B4R-8 SP4C3B4R-8 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What

A depth surface lives only in its Vulkan image: nothing writes it back to guest memory. So once another pass reuses its memory, a view of that memory with another layout (another format, extent, slice or levels) can only throw, and a view that matches the plane keeps reading the stale image. This decides by the last writer, as suggested in review:

  • the surface is retired when a color target or a written storage image it does not serve overlaps its depth or stencil plane (a storage view that DepthSurfaceStorage serves, the plane's own extent and format, is not a retiring writer), or when a view the surface cannot serve finds guest memory over its planes written (CPU or driver store) since the surface was last bound;
  • a retired surface gives up its depth and stencil plane ownership and is skipped by every lookup, so the view reads the memory like any texture;
  • while the surface is still the latest writer, a view it cannot serve keeps throwing, as on main;
  • binding the depth target again brings the surface back.

Two depth surfaces at one address are already resolved on main by the plane owners from #4683 (the one bound last serves), so this PR no longer retires on bind.

The retired surface is never destroyed (its image may still be in flight). Known limit, listed in docs/dev/debt/libSceAgcDriver.md: brought back, it keeps its own depth, not the bytes written over it. Without write watching, a view the surface cannot serve still throws.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, RTX 5070 Ti.

  • New device test agc_driver_depth_surface_last_writer: depth then a view with two levels: throws; depth, color target, view: memory, and its own view is no longer served; depth, color target, depth again, view: throws; depth, CPU write, view: memory while its own view is still served before it; CPU write, depth, view: throws; depth, driver store, view: memory; a write past the plane retires nothing.
  • agc_driver_depth_storage_reuse gains one GPU case: a D32 surface drawn to 0.5, then a written storage image of another extent over it, then the plane's own sampled view returns the memory (0.25) instead of the stale 0.5.
  • With either rule disabled its test fails. Full build; ctest 1185/1185 pass (14 skipped for missing hardware features, same as main).

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 in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes (Claude). I reviewed and take responsibility for every line.

🤖 Generated with Claude Code

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks for tracking this down. My concern is the case where the memory still holds the depth surface. On main a depth surface lives only in its Vulkan image: nothing writes it back to guest memory (DepthSurface in DepthSurface.cpp creates and clears the image, and nothing copies it out). So returning nullptr makes the texture read whatever guest memory held before, with no error. That is right when a later pass reused the memory, but wrong when the title really reads the depth bits through another format. Could the decision depend on which wrote the range last? For example, retire the depth surface when a colour target, storage write or CPU write covers its range (then nullptr is exact), and keep the throw while the depth surface is still the latest writer. Also note #425 rewrites the same condition in Sampled.

@SP4C3B4R-8

Copy link
Copy Markdown
Contributor Author

Thanks, you're right: as it stands this silently returns stale guest memory whenever the title really does read the depth bits through another format, and nothing in the PR tells those two cases apart. Deciding by the last writer is the better rule. I'll rework it that way:

  • retire the depth surface when a colour target, a storage write or a CPU write covers its range, so the later read goes to memory and nullptr is exact;
  • keep the throw while the depth surface is still the latest writer of that range;
  • add tests for both orders (depth, then colour target, then texture read; and depth, then texture read).

Since #425 rewrites the same condition in Sampled, I'd rather build on top of it than race it, so I'll rebase onto #425 once it lands (or onto its branch if it is still open by then).

A note on timing: I'm away until Wednesday 7 October, so the rework comes after that. Until then please treat this PR as not ready.

Written with AI assistance (Claude Code).

@SP4C3B4R-8
SP4C3B4R-8 marked this pull request as draft October 4, 2026 10:19
@Pacuka

Pacuka commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

A data point for the rework: The Smurfs Dreams (PPSA21607, Unreal Engine) hits the case where the format does match the depth view: a compute shader samples a 2848x1600 R32_SFLOAT texture (guest format 22, tile mode 4) at the address of a 1024x1024 D32 depth surface (sampling the depth plane of depth surface ... (1024x1024, vk format 130) as a 2848x1600 texture of guest format 22). Since the extents differ, the memory has been reused by a later pass, so the last-writer rule should cover it too. Happy to test the reworked branch with it.

@SP4C3B4R-8
SP4C3B4R-8 force-pushed the fix/aliased-depth-surface-texture branch from fac1275 to fda7da9 Compare October 7, 2026 11:02
@SP4C3B4R-8 SP4C3B4R-8 changed the title fix(libSceAgcDriver): read a depth surface's memory as a texture when its format is not a depth view fix(libSceAgcDriver): retire a depth surface once another writer covers its memory Oct 7, 2026
@SP4C3B4R-8
SP4C3B4R-8 marked this pull request as ready for review October 7, 2026 11:02
@SP4C3B4R-8

Copy link
Copy Markdown
Contributor Author

@oneandonlydean reworked as agreed, on top of #425 (c50f783d, @MichonGoddijn231849's head with the stencil change); only the last commit, fda7da98, is this PR.

  • A depth surface is retired when a color target or a written storage image overlaps its planes, or when a view it can't serve finds guest memory over its planes written since it was last bound (a collect at every bind, WrittenSince at the view). The view then reads the memory like any texture.
  • While the surface is still the latest writer, that view keeps throwing.
  • A storage image at the surface's own address doesn't retire it, so feat(agc): depth planes sampled as 2D arrays, cubes and integer views #425's seed and take-back path is unchanged, including its throw for layouts the seed doesn't handle. Views the surface can serve are unchanged too: the memory rule is only consulted for the ones that would throw.
  • A retired surface isn't destroyed; binding the target again brings it back with its own depth (TechnicalDebt entry).

Tests for both orders are in the new device test agc_driver_depth_surface_last_writer, listed in the description; it fails with the memory rule disabled.

@Pacuka this should cover your 2848x1600 R32 view over the 1024x1024 D32 surface, provided whatever reused that memory was a color target, a written storage image at another address, or a CPU/DMA store. If the reuse was a storage write at exactly the depth address, it still throws, at the storage lookup this time (storage image access to depth surface ... is not implemented); that line would tell us. A run with this branch would be very welcome.

Written with AI assistance (Claude Code).

@Pacuka

Pacuka commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for the rework, I ran The Smurfs Dreams with it (on top of main def8119). It still throws at the same view, but the reason is a second depth surface at the same address, not a missed writer: the game binds a 1024x1024 D32 surface and a 2848x1600 D32 surface at 0x7fa0194d0000 (different stencil addresses). The 1024x1024 one is created later, but the 2848x1600 one is bound last, right before the compute shader samples it as 2848x1600 R32. DepthSurfaceTexture takes the most recently created surface (rbegin), so it picks the 1024x1024 one and throws.

Locally, retiring the other surfaces that overlap a depth target's depth/stencil address in DepthSurfaceView (on bind) fixes it: the abort is gone and the game keeps presenting (black for now because of unrelated skipped color draws). agc_driver_depth_surface_last_writer still passes. Maybe you'd rather handle it in the lookup (prefer the last-bound surface); either way works for this title.

@github-actions github-actions Bot added the docs label Oct 7, 2026
@SP4C3B4R-8
SP4C3B4R-8 force-pushed the fix/aliased-depth-surface-texture branch from fda7da9 to 6b56080 Compare October 7, 2026 20:15
@SP4C3B4R-8

Copy link
Copy Markdown
Contributor Author

@Pacuka thanks for tracking it down. I took your approach in 6b560806: binding a depth target retires the other depth surfaces whose depth or stencil plane overlaps its own. It fits the last-writer rule, since the bind is the latest writer of that memory. In your case the 2848x1600 surface bound last is then the only live one at 0x7fa0194d0000 and serves the 2848x1600 R32 view. Binding the 1024x1024 target again flips it back. agc_driver_depth_surface_last_writer has a case for it (two surfaces at one address, the older one bound last: it serves its own view and refuses the other's, then the reverse), and it fails without the change.

The branch is also rebased onto @MichonGoddijn231849's new #425 head (d0ca0450); this PR is the last two commits. A run on Smurfs to confirm would be great when you have time.

Written with AI assistance (Claude Code).

@Pacuka

Pacuka commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Ran The Smurfs Dreams with 6b56080 (on top of main def8119 + a few other open PRs): the depth-plane abort is gone and the game ran 180 s without a crash. The 2848x1600 R32 view now resolves to the surface bound last. agc_driver_depth_surface_last_writer passes locally (Linux, AMD). The skipped draws are the same as before (unrelated: vertex fetch range, immutable snapshot overlap). Thanks!

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 8, 2026
@Celegans12

Copy link
Copy Markdown
Contributor

I ran Ghost of Yōtei (PPSA26344 v1.008) for an hour with this PR at 6b56080, and it clears almost all of the game's depth-surface skips.

Without the PR, our previous run skipped 705 draws that sample the depth plane of a depth surface through another view (for example the 1664x936 surface read as a 1920x1080 guest format 22 texture). With it there are none. The five compute shaders that wrote depth/stencil surfaces as storage images (499 skipped dispatches before) also run now. To be precise about that part: two of them write a depth plane, which the #425 commits this PR carries cover, and the other three write the stencil plane, which I handled in a small commit stacked on yours (an R8 storage image seeded from and copied back into the stencil aspect), so that half isn't this PR alone. The world frames went from mostly dark to properly lit in the same run, though I haven't isolated which change did that.

What's left in the hour: one depth-plane dispatch in 0x800027c200, which reads the 3328x1872 view of the depth surface at 0x5002870000 as a 3840x2160 guest format 22 texture, and 31 stencil-plane sampling skips (118 before) in 0x8000316900 and 0x800027c200, all format 5 views of that surface's stencil. No FATAL and no Vulkan error.

GitHub currently shows the PR as conflicting with main: the only hunk is in TechnicalDebt.md, where the two HTILE lines this PR carries sit next to main's new scePlayerReviewDialog line. Would you be able to rebase? Once you have, I'd like to open the stencil-plane storage commit as a PR stacked on this one, if that's all right with you.

Details

Windows 11, RTX 3080 Laptop. With the PR: our integration tree on main c8a2f06 + this PR at 6b56080 (+ the stencil-plane commit on top). Without: the previous integration build.

Gone (previous run):

[gpu] skipped draw: AGC graphics: sampling the depth plane of depth surface 0x50426b0000 (1664x936, vk format 126) as a 1920x1080 texture of guest format 22 (vk 100), tile mode 4, dimension 1, levels 0-0, slice 0 is not implemented (T# 50426b00 c1600000 010dc1df 91800924 ...) [DRAW_INDEX_AUTO, color target 0x5042f20000]
#14 compute shader 0x800027c200: storage image access to depth/stencil surface 0x5004850000 is not implemented   (185 dispatches)
#28 compute shader 0x80003e6600: storage image access to depth/stencil surface 0x505f350000 is not implemented   (79)
#29 compute shader 0x7ff61ffd4900: storage image access to depth/stencil surface 0x505a820000 is not implemented  (79)
#32 compute shader 0x80003d6000: storage image access to depth/stencil surface 0x5002870000 is not implemented   (78)
#33 compute shader 0x80003cfa00: storage image access to depth/stencil surface 0x5004850000 is not implemented   (78)

Left (this run):

#26 compute shader 0x800027c200: sampling the depth plane of depth surface 0x5002870000 (3328x1872, vk format 130) as a 3840x2160 texture of guest format 22 (vk 100), tile mode 4, dimension 1, levels 0-0, slice 0 is not implemented (T# 50028700 c1600000 021bc3bf 91800924 ...)   (1)
#25 compute shader 0x8000316900: sampling the stencil plane of depth surface 0x5002870000 (3840x2160, vk format 130) as a 3328x1872 texture of guest format 5 (vk 13) ...   (1)
#28 compute shader 0x800027c200: sampling the stencil plane of depth surface 0x5002870000 (3328x1872, vk format 130) as a 3840x2160 texture of guest format 5 (vk 13) ...   (1)
#29 compute shader 0x8000316900: sampling the stencil plane of depth surface 0x5002870000 (3328x1872, vk format 130) as a 3840x2160 texture of guest format 5 (vk 13) ...   (29)

@SP4C3B4R-8
SP4C3B4R-8 force-pushed the fix/aliased-depth-surface-texture branch from 6b56080 to 8e5ba47 Compare October 8, 2026 09:33
@SP4C3B4R-8

Copy link
Copy Markdown
Contributor Author

@Celegans12 thanks for the hour-long run and the breakdown. Rebased onto main 3ce729fe: the TechnicalDebt.md hunk keeps main's scePlayerReviewDialog line and the HTILE and depth surface lines. The #425 commits are carried unchanged apart from that hunk, so this PR is still the last two commits (534006e1, 8e5ba478). ctest 428/428 on Windows.

Yes, please open the stencil-plane storage commit stacked on this one. The 3328x1872 depth view of the 3840x2160 surface you have left looks like the same extent mismatch outside the last-writer rule; I have no case for it here.

@Pacuka thanks for confirming on Smurfs.

Written with AI assistance (Claude Code).

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 8, 2026
@SP4C3B4R-8

Copy link
Copy Markdown
Contributor Author

Rebased onto main again (d92a8dad3), head af87b924c. Two conflicts, both from changes that landed since:

  • fix(agc): start a new depth surface from the storage writes over its plane #5446 (depth surface taken from storage writes) and the base-slice support for 2D array views in DepthSurfaceTexture: the planes admission test in the retire rule now uses main's new condition (extent check, base slice up to LAST_ARRAY), so a view main serves is never taken as unservable;
  • the multisampled storage Require in cachedStorageTexture is kept next to the written retire.

Full ctest: 1254/1254 pass (14 environment skips; loadexec_arguments timed out once under -j8 load and passes alone). agc_driver_depth* 11/11.

AI-assisted (Claude Code).

@SP4C3B4R-8
SP4C3B4R-8 force-pushed the fix/aliased-depth-surface-texture branch from df13acf to af87b92 Compare October 15, 2026 08:12
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 15, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 15, 2026
…rs its memory

A depth surface lives only in its Vulkan image, so a view of its memory
with another layout could only throw, and a matching view kept reading
the image after other writes over its memory. Retire the surface when a
color target or a written storage image it does not serve overlaps its
planes, or when a view it cannot serve finds guest memory over the planes
written since the surface was last bound; lookups then skip it and the
view reads the memory like any texture. Binding the target again brings
the surface back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the fix/aliased-depth-surface-texture branch from af87b92 to 626cff7 Compare October 15, 2026 09:05
@adriadam10

Copy link
Copy Markdown
Collaborator

Rebased onto main (0afa6a607e), head 626cff7d2. One conflict in DepthSurface.cpp, from the native multisampled depth sampling that landed since (#ee1ba73a2 and follow-ups):

  • SampledAccepts now takes k2DMsaa as the one-slice dimension for a multisampled target, as Sampled on main does; Sampled keeps main's multisampled Requires before the SampledAccepts check;
  • the stencil BytesPerElement early return moved up on main, so the copy this PR kept lower down is dropped; ApplyFastClear stays after the retire check as before.

Linux build + full ctest: 1234/1235, the only failure is agc_driver_tessellation (SEGFAULT inside RADV 26.2.4 LinkPipelineFromLibraries), which fails the same way here on main without this PR. The full Windows build is dispatched; it merges once that is green.

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased and retested (see above); the earlier request was only the rebase.

@adriadam10 adriadam10 removed the needs rebase Conflicts with main, rebase needed label Oct 15, 2026
@adriadam10
adriadam10 merged commit 042eb7c into boykopovar:main Oct 15, 2026
8 checks passed
@ee6aba54

Copy link
Copy Markdown
Contributor

A regression report from PPSA15304 (Linux, RTX 5080, NVIDIA 595.99.02). Since this PR is in, the gameplay scene renders almost black: the mean grey of the fixed-camera frame at the save's start position drops from about 100 to about 28. Lit surfaces keep only scattered bright specks, which looks like every shadow or depth lookup reading as occluded. Two runs on main plus our open PRs showed it, and a build of the same tree with only this merge reverted renders normally again (mean RGB 101/106/92, as before).

A local trace in retire showed that all 200 retires it logged came from the storage-write path (cachedStorageTexture with written). None came from the color-target path or the sampled OverwrittenInMemory path. The surfaces and the written ranges that retired them:

depth surface (D32_SFLOAT_S8_UINT) stencil written storage range retires
0x311e980000, 2848x1600 0x311fc30000 0x311fa40000 + 0x540000 79
0x311e980000, 2848x1600 0x311fc30000 0x311d860000 + 0x12b0000 18
0x31198f0000, 512x512 0x31199f0000 0x3119730000 ... 0x3119790000 + 0x400000 (seven bases, 64 KiB apart) 81
0x31198f0000, 512x512 0x31199f0000 0x31193f0000 + 0x9c0000 18

The 2848x1600 surface is the scene depth. By DepthSliceBytes its depth plane is 0x12b0000 bytes and ends exactly at the stencil, and the stencil plane is 0x540000 bytes. The two written ranges have exactly those sizes, so they look like another depth/stencil pair of the same extent viewed as storage images. They sit closer than those sizes allow: 0x311d860000 + 0x12b0000 overlaps the depth plane by its last 0x190000 bytes, and 0x311fa40000 + 0x540000 overlaps the last 0x1f0000 bytes of the depth plane and the start of the stencil. For the 512x512 surface, seven 4 MiB storage views whose base moves in 64 KiB steps all cover it. I have not checked whether these described ranges are what the shaders actually write, or only the size DescribeSurface gives the whole view (padding, mip chain from that base). The scene going dark while the surfaces are retired suggests that the bytes the depth planes need were not overwritten.

A possible direction: on the storage path, retire only when the written level and slice's own byte range covers the plane (as CoversPlane asks of a storage image that serves it), rather than on any overlap of the view's described size. I'm keeping this PR reverted on our test branch for now. I can trace further, for example the descriptor words of those storage views, if that helps.

@SP4C3B4R-8

Copy link
Copy Markdown
Contributor Author

@ee6aba54 thanks for the trace, that is exactly the information needed.

The storage path retires on any overlap of the view's described size, and a retired surface reads guest memory, which never received the depth image's contents. So a partial overlap throws away the whole plane, while on hardware only the overlapped bytes would change. That matches the dark frame with surviving bright specks.

The direction I'd take: on the storage path, retire only when the bytes of the written level and slice (CoveredMipBytes, no padding) cover a whole plane; a partial overlap leaves the surface alive, as before this PR.

Your offer to trace further would help: for the storage views in your table, could you log the descriptor fields (dimension, width/height, base level and mip count, base/last array, tile mode, format)? The 512x512 case worries me most: seven 4 MiB views 64 KiB apart all cover its 1 MiB plane by described size, so whether they still cover it by the written level's bytes decides if the narrower rule fixes your scene.

@ee6aba54

Copy link
Copy Markdown
Contributor

@SP4C3B4R-8 Here are the descriptor fields, from PPSA15304 at the same spot (Linux, RTX 5080, one run of 60 s). For every written storage view whose described range overlaps a live depth surface, a local trace logged the view's descriptor and how many bytes of each plane the written level's CoveredMipBytes reach (per written array layer or depth slice, whole tile blocks only). That is the narrower rule you describe. Offsets are relative to the depth surface's base. The title reuses this memory at shifting bases, so a view shape shows up at many offsets, usually 64 KiB apart.

Dimension 1 is 2D, 2 is 2D array, 4 is 3D. Tile mode 4 is Z64KB_X and 7 is R64KB_X. Formats are the guest codes with the Vulkan format the driver maps them to.

512x512 surface (D32_SFLOAT_S8_UINT, depth plane 0x100000, stencil 0x40000 at +0x100000)

view dim size base level / mips array tile format described offsets seen depth covered stencil covered
A 2D 1024x1024 0 / 1 0..0 7 36 (B10G11R11_UFLOAT) 0x400000 -0x290000, -0x1c0000 ... -0x160000 (64 KiB steps), +0x10000 0x100000 (whole) at every negative offset, 0xf0000 at +0x10000 0x40000 (whole)
B 2D 1920x1080 0 / 2, written level 0 0..0 7 71 (R16G16B16A16_SFLOAT) 0x1470000 -0x10e0000, -0x1040000, -0x260000 whole at the first two, 0 at -0x260000 same as depth
C 2D 8192x256 0 / 1 0..0 7 36 0x800000 -0x7d0000, -0x1a0000 whole at -0x1a0000, 0x30000 at -0x7d0000 whole at -0x1a0000, 0 at -0x7d0000
D 2D 2848x1600 0 / 1 0..0 7 20 (R32_UINT) 0x12b0000 -0x1a0000, -0x170000 whole whole at one of two offsets
E 2D 1024x1024 0 / 10, written level 0 0..0 7 13 (R16_SFLOAT) 0x2b0000 -0x170000 whole whole
F 3D 48x48x48 0 / 1 0..47 7 71 0x300000 -0x2e0000 ... +0x50000 0 0

So the 4 MiB views that worried you (A) do cover the 512x512 depth and stencil planes with written bytes, not just by described size. The narrower rule would still retire this surface, and B to E would retire it as well.

2848x1600 scene depth (D32_SFLOAT_S8_UINT, depth plane 0x12b0000, stencil 0x540000 at +0x12b0000)

view dim size base level / mips array tile format described offsets seen (count, range) most depth covered most stencil covered
G 2D 2848x1600 0 / 1 0..0 7 50 (A2B10G10R10_UNORM) 0x12b0000 26, -0x1120000 ... +0xc50000 0xf50000 0x500000
H 2D 2848x1600 0 / 1 0..0 4 22 (R32_SFLOAT) 0x12b0000 7, -0x1250000 ... +0x1150000 0x1080000 0x500000
I 2D 2848x1600 0 / 1 0..0 7 36 0x12b0000 3, -0x500000 ... +0x1b0000 0x1050000 0x30000
J 2D 2848x1600 0 / 1 0..0 7 71 0x23f0000 8, -0x1120000 ... +0x370000 0x11e0000 0x510000
K 2D 1424x800 0 / 1 0..0 7 22 0x540000 5, +0x1050000 ... +0x1290000 0x230000 0x400000
L 2D array 2848x1600 0 / 1 0..0 7 5 (R8_UINT) 0x540000 3, +0x1050000 ... +0x1740000 0x230000 0x2d0000
M 3D 180x102x26 0 / 1 0..25 7 36 0x340000 49, -0x120000 ... +0x1500000 0 0
N 3D 60x34x26 0 / 1 0..25 7 36 or 71 0x1a0000 34, +0xcd0000 ... +0x1790000 0 0

G and H are the 0x12b0000-sized writes from my earlier table, and K and L the 0x540000-sized ones. None of them covers either plane of the scene depth with written bytes, and neither does any other view that overlaps it (the closest is J, which reaches 0x11e0000 of 0x12b0000). The 3D views M and N contain no whole 64 KiB block per slice (a 64 KiB R64KB_X block of a 4-byte format is 128x128). By this data, the narrower rule keeps the scene depth alive and still retires the 512x512 surface. I have not run a build with the rule yet, so I can't say yet whether the scene comes out at its normal brightness. Once you have a revision, I'll run it at the same spot and compare the frame.

@SP4C3B4R-8

Copy link
Copy Markdown
Contributor Author

@ee6aba54 thanks, that table settles it. The fix is up as #7050: a written storage view retires a depth surface only when the bytes its written level holds (CoveredMipBytes per written layer or slice, whole tile blocks) cover the surface's whole depth or stencil plane. By your data that keeps the 2848x1600 scene depth alive (J reaches 0x11e0000 of 0x12b0000, the 3D views hold no whole block) and still retires the 512x512 surface (A to E cover both planes).

If you can run it at the same spot and compare the frame, that's the check I can't do here.

SP4C3B4R-8 added a commit to SP4C3B4R-8/AnyPS5 that referenced this pull request Oct 18, 2026
…te covers a whole plane

Since boykopovar#454 a written storage image retires every depth surface its described size overlaps, and a retired
surface reads guest memory, which never received the depth image. PPSA15304 writes storage views that
overlap the scene depth without covering it (the largest reaches 0x11e0000 of its 0x12b0000 depth plane),
so the whole depth was thrown away and the scene came out almost black.

A written storage view now retires a surface only when the bytes its written level holds, per array layer
or depth slice (CoveredMipBytes, whole tile blocks, no padding), cover the surface's whole depth or stencil
plane; a partial overlap leaves the surface alive, as before boykopovar#454. Thick 3D views hold no whole block per
slice and retire nothing. agc_driver_depth_storage_reuse now checks that a half-width write keeps the
surface sampled from the depth image and that a write over the whole plane retires it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GN8FJFTedayRXLHythXkZ4
TheBlenDed pushed a commit to TheBlenDed/AnyPS5 that referenced this pull request Oct 25, 2026
Main brings the pipelined-draw stack (boykopovar#1193/boykopovar#1201/boykopovar#1202), boykopovar#6316 after boykopovar#6060, boykopovar#5893, boykopovar#5910 and depth/HTILE work (boykopovar#454, boykopovar#5496, boykopovar#5554, boykopovar#5524, boykopovar#5627, 626cff7). Our SharedSpirv / cold-SPIR-V storage is replaced by main's mapped cache entries (CreateFileMappingW on Windows), so cached variants' words are views into the cache files instead of heap copies; APS5_COLD_SPIRV, APS5_COLD_SPIRV_FILE and APS5_CACHE_SPIRV_BACKING are gone. Kept local: lane hang fixes, boykopovar#5815, boykopovar#6227, table stores and storage tables, option 1 substitutes (.slots), stencil remap and alias path (a written storage view our alias path serves seeds from the depth surface instead of retiring it), 10_11_11 blending next to main's reversed-order blending, VRAM share/spill/fallbacks, diagnostics. Versions: FormatVersion 43, RuntimeAbi 17, request serializer v31. Notes in work/sync-20261013/*-4.md.

AI-assisted: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.