Skip to content
This repository was archived by the owner on Oct 28, 2026. It is now read-only.

fix(agc): treat other-shaped views of a depth surface's stencil plane as reused memory - #26

Closed
AlxcBTW wants to merge 1 commit into
mainfrom
fix/agc-stencil-view-reuse
Closed

AlxcBTW wants to merge 1 commit into
mainfrom
fix/agc-stencil-view-reuse

Conversation

@AlxcBTW

@AlxcBTW AlxcBTW commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

What

FPV Simulator (PPSA10698 v01.006.000, Unity 2021.3 URP) ends when it presents a frame:

[gpu] color target 0x231590000 stays non-resident: AGC graphics: storage image access to depth/stencil surface 0x231590000 is not implemented
[videoout] presentation failed: AGC graphics: sampling the stencil plane of depth surface 0x230cd0000 (1920x1080, vk format 130) as a 1920x1080 texture of guest format 130 (vk 43), tile mode 7, dimension 1, levels 0-0, slice 0 is not implemented (T# 02315900 c8200000 010dc1df 91b00fac 00000000 00700000 00000000 00000000)
terminate called after throwing an instance of 'std::runtime_error'

Unity reuses the memory of transient render targets. The T# base, 0x231590000, is the stencil plane of the D32S8 surface at 0x230cd0000, and the first line shows the title binding that address as a color target. The view is a 1920x1080 RGBA8 sRGB texture, which reads the color data, not an 8-bit stencil plane.

9d65003 (boykopovar#1495) already treats this as memory reuse for the depth plane: a view with another extent, or a depth-plane view in a format that cannot hold the plane, falls through to the ordinary texture path. Stencil-plane views of the same extent kept the old handling: they all went to the depth surface, which throws for any format other than R8 uint. This applies the same rule to the stencil plane: a view whose texels are not one byte wide cannot hold the 8-bit plane, so DepthSurfaceTexture returns nothing and the memory is read like any texture.

  • An 8-bit view of the plane's own extent still samples the stencil plane.
  • An 8-bit view in another format than R8 uint still throws, as before.

Related: boykopovar#454 (open) is broader: it retires a depth surface once another writer covers its depth or stencil plane. This PR extends only the format rule from boykopovar#1495 and doesn't track writers. Both change the same lines in DepthSurfaceTexture, so whichever lands second needs a small rebase.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, Release, RTX 5070 Laptop (driver 616.92).

  • New cases in DepthSurfaceReuse.cpp (agc_driver_graphics), on a 320x180 D32S8 surface: an R8 uint view of the stencil plane still samples the plane; RGBA8 and R32F views of the same extent are read as reused memory. Without the source change, agc_driver_graphics fails on the RGBA8 case with the original error: sampling the stencil plane of depth surface 0x60000000 (320x180, vk format 130) as a 320x180 texture of guest format 56 (vk 37) ... is not implemented.
  • Related tests (agc_driver_graphics, agc_driver_depth_bias_per_face, agc_driver_pending_exact_surface, agc_driver_prepared_graphics, agc_driver_cmask_fast_clear, agc_pass_hazards): 6/6.
  • Suites:
    • Non-GPU tests: 446/446.
    • agc_driver on NVIDIA RTX 5070 Laptop: 253/253.
    • check_conventions.py passes.
  • In-game: not re-run on this branch. The stop above is from a local build of main with other patches.

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 Code)

🤖 Generated with Claude Code

Upstream issue: boykopovar#2994

… as reused memory

Unity reuses the memory of transient render targets: in FPV Simulator
(PPSA10698) an RGBA8 1920x1080 color texture is sampled at the address
that a D32S8 surface's stencil plane occupied earlier. The lookup found
the stencil plane and threw "sampling the stencil plane ... is not
implemented", which ended the presentation.

9d65003 made depth-plane views in a format that cannot hold the plane
fall through to the ordinary texture path. A stencil-plane view whose
texels are not one byte wide cannot hold the 8-bit stencil plane
either, so it now falls through the same way.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AlxcBTW

AlxcBTW commented Oct 11, 2026

Copy link
Copy Markdown
Owner Author

Merged upstream as boykopovar#3277 (carried unchanged by @oneandonlydean, authorship kept).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant