feat(agc): render into mipmapped 3D color targets #7310

Merged
Amoenus merged 25 commits from upstream-pr/7310 into main 2026-11-01 01:53:04 +00:00
Amoenus commented 2026-10-17 22:41:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-17T22:41:26Z.


What

Render into one mip of an uncompressed3D color surface, preserving the base dimensions and volume identity, including depth1. Use its3D mip layout, bound its slice view by the selected mip's depth, validate the full allocation, and create the resident attachment view at that mip. Unverified mipmapped3D DCC/CMASK metadata paths still throw.

Depends on: none. #7294 is merged. Earlier refreshed head 9a3ae675277b incorporates frozen main 6e9b9134f6ed14e659d870a33118d164096551df through a normal merge; published d82f817df54416cc8ad9792382f6018bb57b32a1 remains an ancestor and is archived. The eight production/test topic files retain exactly their previous added/removed lines. The #9050 buffer-range helper uses the volume's full backing-allocation address, including cached/moved binding checks; its two focused regressions are retained. No force push.

Sonic Unleashed Recompiled PPSA99902, #7260 / #4443, requests a two-level128x128x8 RGBA8_UINT SW_4KB_S_X target after the opening movie. The ordinary bring-up composition stops at the guard still present on main:

AGC graphics: mipmapped 3D color targets are unsupported

The diagnostic captured CB_COLOR_INFO=0x00070428, ATTRIB2=0x101fc07f, ATTRIB3=0x0ea54007, VIEW=0x0000e000 (mip0, slices0..7). #7274 merged the diagnostic; this capability change replaces the general refusal. Its64x4x4/mip1 descriptor test verifies the selected32x2 one-slice view. No title-specific branch or game modification is added.

Review correction: non-mipmapped depth-one volumes now bypass the2D resident-byte comparison as all other volumes do; their complete3D allocation was already validated against DescribeSurface. A single-level linear volume of depth1 retains the existing linear copy path, whose2D/3D layout is identical. Other nonresident volume cases continue to throw. Four new --mips cases cover96x32x1/one level in Linear, Standard4KB, RenderTarget and S4KBX modes, with exact per-texel readback.

Overlap review: #7199 and #7254 are merged; their 2D CMASK accounting/refusals and layered-array attachment/dirty-range handling are retained. #7256 array attachment windows remain separate. #6959 implements mesh layer windows. The author confirms #7310-first landing order; its shared fixture must retain both optional Run arguments and enough vertices for the 33-layer mesh case and eight-layer mip cases. JJenkx's attributed Linux composition results below cover that fixture union at their stated pins; our own Windows matrix does not qualify #6959.

Tested

Current refreshed head 2c1f59472aeb, tested main d2d2a866d9a9ed65e9d3871f83dcf427195aa362. Normal merge after#12862 preserves published history/authorship,identical production/regression topic deltas,and all selected test-registration properties. No force push.

Exact pins,immutable raw logs,artifact inventories,controls and analysis: 36 positives(30 verified GPU/six CPU or header). Main14GPU/twoCPU;candidate16GPU/threeCPU plus public_headers. Shared layered draw/submit/vertex/no-GPL,XOR volume,depth bounds and new heap-mirror controls run on both GPUs. Candidate additionally passes all14volume-mip selections/vendor(28total) and CPU linear-nonresident refusal. Graphics/ShaderMemory pass on both sources,including intervening descriptor force-sync changes. Full native/relinker/real-fixture builds,conventions/whitespace/public_headers pass;binary inventories stable per source.

Required Vulkan,app cache/journal off,inserted Khronos1.4.363 and actual device identity verified;verbose serial30s. Windows11Enterprise26200/WinLibsGCC15.2,RTX5080/NVIDIA621.01 and RadeonGraphics1002:13c0/AMD26.10.1. Zero validation errors/VUIDs/skips/timeouts;known layer-compatibility warnings main80/candidate100,identical IDs/counts for shared groups. Two extra volume cases account for20warnings. Max wholeGPUprocess1.231s;max anyCTest17.794s. Not warning-free or a performance comparison.

Cppcheck/clang-tidy:115.463 analyzer-seconds,18advisories at unchanged main locations,no parser/configuration failures/timeouts or automatic fixes;no static-clean/whole-program claim. Historical isolated address/metadata mutation controls and previous fixture analysis retain their original pins;no new current-main failing control claimed. Candidate-only registrations are absent on literal main,not passing main controls. Latest inspected6190 has unrelated exports/relinker changes and is not the tested base.

Independent NVIDIA Linux retest of olderd917/main73f4:2430selected passes,no new failures/validation IDs,50skips;BDA/maps/graphics timing warnings remain source-pinned and unresolved by this focused Windows qualification. Prior hosted d917 compile/link evidence is historical;new-head hosted checks pending. No new title/FPS/full-suite/Linux/macOS/console or dependent-stack execution claim.

Additional Linux composition evidence: JJenkx tested this exact head with #6959 head327addf79eae on RX6650XT/RADV Mesa26.2.4. The report has six passing checks, zero skips/VUIDs and four confirmed Khronos layer insertions, covering all14 volume-mip selections plus the33-layer mesh case. Its private base also contains capture/diagnostic changes; this is candidate-only composed evidence, not a paired plain-main qualification or title/FPS result. The shared fixture retains both optional Run arguments and enough vertices for both mip and mesh cases. The agreed #7310-first order remains; our source is unchanged.

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; #7294 merged
  • Fixes: none; #7260 remains open pending direct title validation
  • Unblocks: PPSA99902 #4443, the reproduced volume-mip refusal in its bring-up composition
  • GPUs tested: NVIDIA GeForce RTX 5080, driver621.01/32.0.16.2101; AMD Radeon(TM) Graphics (1002:13c0), driver32.0.21045.16010/Vulkan26.10.1; both Windows 11 Enterprise 26200.
  • AI-assisted: yes, Codex; author responsible
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4904545184 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7310). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-17T22:41:26Z. --- ### What Render into one mip of an uncompressed3D color surface, preserving the base dimensions and volume identity, including depth1. Use its3D mip layout, bound its slice view by the selected mip's depth, validate the full allocation, and create the resident attachment view at that mip. Unverified mipmapped3D DCC/CMASK metadata paths still throw. **Depends on: none.** #7294 is merged. [Earlier refreshed head 9a3ae675277b](https://github.com/Amoenus/AnyPS5/commit/9a3ae675277b655f26968b76b72abf664a0b3c6a) incorporates frozen main `6e9b9134f6ed14e659d870a33118d164096551df` through a normal merge; published `d82f817df54416cc8ad9792382f6018bb57b32a1` remains an ancestor and is archived. The eight production/test topic files retain exactly their previous added/removed lines. The #9050 buffer-range helper uses the volume's full backing-allocation address, including cached/moved binding checks; its two focused regressions are retained. No force push. Sonic Unleashed Recompiled **PPSA99902**, #7260 / #4443, requests a two-level128x128x8 RGBA8_UINT `SW_4KB_S_X` target after the opening movie. The ordinary bring-up composition stops at the guard still present on main: ```text AGC graphics: mipmapped 3D color targets are unsupported ``` The diagnostic captured `CB_COLOR_INFO=0x00070428`, `ATTRIB2=0x101fc07f`, `ATTRIB3=0x0ea54007`, `VIEW=0x0000e000` (mip0, slices0..7). #7274 merged the diagnostic; this capability change replaces the general refusal. Its64x4x4/mip1 descriptor test verifies the selected32x2 one-slice view. No title-specific branch or game modification is added. **Review correction:** non-mipmapped depth-one volumes now bypass the2D resident-byte comparison as all other volumes do; their complete3D allocation was already validated against `DescribeSurface`. A single-level linear volume of depth1 retains the existing linear copy path, whose2D/3D layout is identical. Other nonresident volume cases continue to throw. Four new `--mips` cases cover96x32x1/one level in Linear, Standard4KB, RenderTarget and S4KBX modes, with exact per-texel readback. Overlap review: #7199 and #7254 are merged; their 2D CMASK accounting/refusals and layered-array attachment/dirty-range handling are retained. #7256 array attachment windows remain separate. #6959 implements mesh layer windows. [The author confirms #7310-first landing order](https://github.com/boykopovar/AnyPS5/pull/6959#issuecomment-6504579841); its shared fixture must retain both optional Run arguments and enough vertices for the 33-layer mesh case and eight-layer mip cases. JJenkx's attributed Linux composition results below cover that fixture union at their stated pins; our own Windows matrix does not qualify #6959. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> **Current refreshed head [`2c1f59472aeb`](https://github.com/Amoenus/AnyPS5/commit/2c1f59472aeb2f6ebea39e037d099858ce62220a), tested main `d2d2a866d9a9ed65e9d3871f83dcf427195aa362`.** Normal merge after#12862 preserves published history/authorship,identical production/regression topic deltas,and all selected test-registration properties. No force push. [Exact pins,immutable raw logs,artifact inventories,controls and analysis](https://gist.github.com/Amoenus/26c44e98ee9d7e4fedcc5dd3af5b4fc5#file-pr7310-maind2d2-20261031-report-md): **36 positives(30 verified GPU/six CPU or header)**. Main14GPU/twoCPU;candidate16GPU/threeCPU plus public_headers. Shared layered draw/submit/vertex/no-GPL,XOR volume,depth bounds and new heap-mirror controls run on both GPUs. Candidate additionally passes all14volume-mip selections/vendor(28total) and CPU linear-nonresident refusal. Graphics/ShaderMemory pass on both sources,including intervening descriptor force-sync changes. Full native/relinker/real-fixture builds,conventions/whitespace/public_headers pass;binary inventories stable per source. Required Vulkan,app cache/journal off,inserted Khronos1.4.363 and actual device identity verified;verbose serial30s. Windows11Enterprise26200/WinLibsGCC15.2,RTX5080/NVIDIA621.01 and RadeonGraphics1002:13c0/AMD26.10.1. Zero validation errors/VUIDs/skips/timeouts;known layer-compatibility warnings main80/candidate100,identical IDs/counts for shared groups. Two extra volume cases account for20warnings. Max wholeGPUprocess1.231s;max anyCTest17.794s. Not warning-free or a performance comparison. Cppcheck/clang-tidy:115.463 analyzer-seconds,18advisories at unchanged main locations,no parser/configuration failures/timeouts or automatic fixes;no static-clean/whole-program claim. Historical isolated address/metadata mutation controls and previous fixture analysis retain [their original pins](https://gist.github.com/Amoenus/b0dd30f1bcd712a3c7f18058e9e37dba#file-pr7310-main319-report-20261029-v1-md);no new current-main failing control claimed. Candidate-only registrations are absent on literal main,not passing main controls. Latest inspected6190 has unrelated exports/relinker changes and is not the tested base. [Independent NVIDIA Linux retest of olderd917/main73f4](https://github.com/boykopovar/AnyPS5/pull/7310#issuecomment-6545848483):2430selected passes,no new failures/validation IDs,50skips;BDA/maps/graphics timing warnings remain source-pinned and unresolved by this focused Windows qualification. Prior hosted d917 compile/link evidence is historical;new-head hosted checks pending. No new title/FPS/full-suite/Linux/macOS/console or dependent-stack execution claim. <!-- codex-linux-volume-composition-7310-20261030-v2 --> **Additional Linux composition evidence:** [JJenkx tested this exact head with #6959 head327addf79eae](https://github.com/boykopovar/AnyPS5/pull/7310#issuecomment-6518888221) on RX6650XT/RADV Mesa26.2.4. The report has six passing checks, zero skips/VUIDs and four confirmed Khronos layer insertions, covering all14 volume-mip selections plus the33-layer mesh case. Its private base also contains capture/diagnostic changes; this is candidate-only composed evidence, not a paired plain-main qualification or title/FPS result. The shared fixture retains both optional Run arguments and enough vertices for both mip and mesh cases. The agreed #7310-first order remains; our source is unchanged. <!-- /codex-linux-volume-composition-7310-20261030-v2 --> ### 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; #7294 merged - [x] Fixes: none; #7260 remains open pending direct title validation - [x] Unblocks: PPSA99902 #4443, the reproduced volume-mip refusal in its bring-up composition - [x] GPUs tested: NVIDIA GeForce RTX 5080, driver621.01/32.0.16.2101; AMD Radeon(TM) Graphics (1002:13c0), driver32.0.21045.16010/Vulkan26.10.1; both Windows 11 Enterprise 26200. - [x] AI-assisted: yes, Codex; author responsible
oneandonlydean commented 2026-10-17 23:09:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T23:09:35Z.


Thanks, the mip addressing and the per-texel --mips check look right, and all ten cases pass here (RTX 4090, current main 55f82fee8). One regression on non-mipmapped volumes:

The PR now decides "3D target" by color.volume in SurfaceForTarget (State.cpp:1453) and in the fallback refusal (Draw.cpp:2079). The resident check at Draw.cpp:2067 still skips the byte comparison only for color.mipCount > 1 || color.depth > 1, and it compares against the 2D ColorTargetLayout. So a non-mipmapped 3D target of depth 1 in a thick 3D mode now gets a 3D resident image whose bytes differ from the 2D layout. The lookup is refused, and the fallback then throws. On main the same target rendered (as 2D).

Repro: replace the --mips case list with one case at a time:

{96, 32, 1, 1, 0, 0, 1, ColorTileMode::Standard4KB, false}   // fails
{96, 32, 1, 1, 0, 0, 1, ColorTileMode::RenderTarget, false}  // passes
{96, 32, 1, 1, 0, 0, 1, ColorTileMode::S4KBX, false}         // fails
[gpu] color target 0x... stays non-resident: AGC graphics: resident image layout differs from the color layout
AGC graphics: rendering into a 3D color target needs the resident image of its surface

A linear depth-1 volume without an existing host import reaches the same refusal. It used to render, and linear 3D at depth 1 has the same layout as 2D.

Could you:

  1. skip the 2D byte comparison for volumes at Draw.cpp:2067 (the volume allocation is already range-checked against DescribeSurface in DecodeColorBuffer);
  2. either keep the fallback for non-mipmapped depth-1 linear volumes or explain why it should refuse;
  3. add levels = 1, depth = 1 cases to --mips? The two existing depth-1 cases have three levels, so mipCount > 1 bypasses the changed check.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6242868717 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7310#issuecomment-6242868717). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T23:09:35Z. --- Thanks, the mip addressing and the per-texel `--mips` check look right, and all ten cases pass here (RTX 4090, current main 55f82fee8). One regression on non-mipmapped volumes: The PR now decides "3D target" by `color.volume` in `SurfaceForTarget` (State.cpp:1453) and in the fallback refusal (Draw.cpp:2079). The resident check at Draw.cpp:2067 still skips the byte comparison only for `color.mipCount > 1 || color.depth > 1`, and it compares against the 2D `ColorTargetLayout`. So a **non-mipmapped 3D target of depth 1** in a thick 3D mode now gets a 3D resident image whose bytes differ from the 2D layout. The lookup is refused, and the fallback then throws. On main the same target rendered (as 2D). Repro: replace the `--mips` case list with one case at a time: ``` {96, 32, 1, 1, 0, 0, 1, ColorTileMode::Standard4KB, false} // fails {96, 32, 1, 1, 0, 0, 1, ColorTileMode::RenderTarget, false} // passes {96, 32, 1, 1, 0, 0, 1, ColorTileMode::S4KBX, false} // fails ``` ``` [gpu] color target 0x... stays non-resident: AGC graphics: resident image layout differs from the color layout AGC graphics: rendering into a 3D color target needs the resident image of its surface ``` A linear depth-1 volume without an existing host import reaches the same refusal. It used to render, and linear 3D at depth 1 has the same layout as 2D. Could you: 1. skip the 2D byte comparison for volumes at Draw.cpp:2067 (the volume allocation is already range-checked against `DescribeSurface` in `DecodeColorBuffer`); 2. either keep the fallback for non-mipmapped depth-1 linear volumes or explain why it should refuse; 3. add `levels = 1, depth = 1` cases to `--mips`? The two existing depth-1 cases have three levels, so `mipCount > 1` bypasses the changed check.
Amoenus commented 2026-10-18 01:23:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-18T01:23:20Z.


@oneandonlydean 2026-10-20 CI follow-up: I traced the failed Linux job to exact #7310 head 028ec46d836ca0f0a4a31ad00e07f517d82f7955 merged into main 43cd8f4c47f4c81185c4ca14b84240e0748e3459. It stops at Install Xvfb: sudo: a password is required. CMake, compilation and tests are skipped, so this run does not identify a volume-rendering regression.

The Windows job succeeds: 457 executed tests pass and 645 skip. agc_driver_volume_mip_targets is among those skips under CI's execution-source selection; this is not new physical-GPU coverage. The actual fourteen-case NVIDIA/AMD checks remain in the description at their stated pins.

Main has since reverted the Xvfb workflow setup. Could you start a fresh Build workflow from current main for #7310, rather than rerunning the old job with its old workflow? The PR currently merges cleanly and its attached Conventions check passes. No patch code change is indicated by this setup failure.

AI-assisted: yes (Codex); author responsible.

Earlier depth-one review response and validation

Thanks for catching the depth-one regression. Addressed in a96dad4ef, after rebasing onto mainf663 and removing the now-merged #7294 dependency.

All three requested changes are covered: volumes bypass the2D byte comparison; single-level depth-one linear volumes keep their valid existing copy path; --mips now includes Linear, Standard4KB, RenderTarget and S4KBX one-level/depth-one cases. The new test fails3/3 before correction; the linear-only correction exposes the separate thick-layout failure. Both corrections pass the fourteen-case readback3/3 on RTX5080, AMD iGPU and llvmpipe. Full Windows/Linux builds and33 selected processes pass. Existing3D barrier advisories and analyzer findings are disclosed in the updated body; no warning-clean or title-unblock claim.

AI-assisted: Codex; author responsible.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6244181157 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7310#issuecomment-6244181157). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-18T01:23:20Z. --- <!-- codex-pr7310-ci-status-v1 --> @oneandonlydean **2026-10-20 CI follow-up:** I traced the failed [Linux job](https://github.com/boykopovar/AnyPS5/actions/runs/39399771953/job/118562929939) to exact #7310 head `028ec46d836ca0f0a4a31ad00e07f517d82f7955` merged into main `43cd8f4c47f4c81185c4ca14b84240e0748e3459`. It stops at **Install Xvfb**: `sudo: a password is required`. CMake, compilation and tests are skipped, so this run does not identify a volume-rendering regression. The [Windows job](https://github.com/boykopovar/AnyPS5/actions/runs/39399771953/job/118562930429) succeeds: 457 executed tests pass and 645 skip. `agc_driver_volume_mip_targets` is among those skips under CI's execution-source selection; this is not new physical-GPU coverage. The actual fourteen-case NVIDIA/AMD checks remain in the description at their stated pins. Main has since [reverted the Xvfb workflow setup](https://github.com/boykopovar/AnyPS5/commit/7814a12b90aa29bf33c298f25092215cf3c12845). Could you start a **fresh Build workflow from current main for #7310**, rather than rerunning the old job with its old workflow? The PR currently merges cleanly and its attached Conventions check passes. No patch code change is indicated by this setup failure. AI-assisted: yes (Codex); author responsible. <!-- /codex-pr7310-ci-status-v1 --> <details> <summary>Earlier depth-one review response and validation</summary> Thanks for catching the depth-one regression. Addressed in [a96dad4ef](https://github.com/Amoenus/AnyPS5/commit/a96dad4ef2feb848c3126158be5184c54bd7e476), after rebasing onto mainf663 and removing the now-merged #7294 dependency. All three requested changes are covered: volumes bypass the2D byte comparison; single-level depth-one linear volumes keep their valid existing copy path; `--mips` now includes Linear, Standard4KB, RenderTarget and S4KBX one-level/depth-one cases. The new test fails3/3 before correction; the linear-only correction exposes the separate thick-layout failure. Both corrections pass the fourteen-case readback3/3 on RTX5080, AMD iGPU and llvmpipe. Full Windows/Linux builds and33 selected processes pass. Existing3D barrier advisories and analyzer findings are disclosed in the updated body; no warning-clean or title-unblock claim. AI-assisted: Codex; author responsible. <!-- codex-pr7310-depth-one-review-response-v1 --> </details>
jotitadev commented 2026-10-18 23:24:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T23:24:07Z.


Apple GPU / MoltenVK run of the new --mips cases, as another vendor next to RTX 5080, AMD iGPU and llvmpipe. Under MoltenVK, a 3D mip attachment view becomes a Metal render target on one level of a 3D texture, so this path differs from the desktop drivers.

Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head bf984211f. Method: main 81cb86339 + @mugurc's ci/macos-series-2 (fa6d8ae0b, which has the MoltenVK device bring-up) + the open fixes it uses as stand-ins, then this PR merged on top (clean). Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363), and MoltenVK main with SPIRV-Cross #2704. ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1.

Test MoltenVK 1.4.2 MoltenVK main + #2704
agc_driver_volume_mip_targets (new) 3/3 pass 3/3 pass
agc_driver_layered_volume_submit 3/3 pass 3/3 pass
agc_driver_layered_volume_draw, _vertex, _vertex_no_gpl fail, same as without the PR fail, same as without the PR
  • --mips runs all 14 cases here, each "preserves other mips and slices": 96x32x8 at mips 0/1/2, the 96x32x1 depth-one volume, and the 128x128x8 RGBA8_UINT two-level target from the title, including the XOR=500 case.

  • The three layered tests fail the same way with and without the PR: SPIR-V requires unsupported device capability 2. That's the Geometry capability, which MoltenVK doesn't have. It's a device gap this PR doesn't touch.

  • With only the test and CMake changes on the tree without the fix, agc_driver_volume_mip_targets fails: a depth-one volume mip was treated as a 2D image. So the new test catches the missing support on this device too.

Not done: the full suite with the PR.

GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6256463939 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7310#issuecomment-6256463939). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-18T23:24:07Z. --- Apple GPU / MoltenVK run of the new `--mips` cases, as another vendor next to RTX 5080, AMD iGPU and llvmpipe. Under MoltenVK, a 3D mip attachment view becomes a Metal render target on one level of a 3D texture, so this path differs from the desktop drivers. Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head bf984211f. Method: main 81cb86339 + @mugurc's `ci/macos-series-2` (fa6d8ae0b, which has the MoltenVK device bring-up) + the open fixes it uses as stand-ins, then this PR merged on top (clean). Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363), and MoltenVK main with SPIRV-Cross #2704. `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`. | Test | MoltenVK 1.4.2 | MoltenVK main + #2704 | |---|---|---| | `agc_driver_volume_mip_targets` (new) | 3/3 pass | 3/3 pass | | `agc_driver_layered_volume_submit` | 3/3 pass | 3/3 pass | | `agc_driver_layered_volume_draw`, `_vertex`, `_vertex_no_gpl` | fail, same as without the PR | fail, same as without the PR | - `--mips` runs all 14 cases here, each "preserves other mips and slices": 96x32x8 at mips 0/1/2, the 96x32x1 depth-one volume, and the 128x128x8 RGBA8_UINT two-level target from the title, including the XOR=500 case. - The three layered tests fail the same way with and without the PR: `SPIR-V requires unsupported device capability 2`. That's the Geometry capability, which MoltenVK doesn't have. It's a device gap this PR doesn't touch. - With only the test and CMake changes on the tree without the fix, `agc_driver_volume_mip_targets` fails: `a depth-one volume mip was treated as a 2D image`. So the new test catches the missing support on this device too. Not done: the full suite with the PR. GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704) Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
ahmadmuj commented 2026-10-25 13:24:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T13:24:29Z.

Review: COMMENTED


Reviewed head b49ce040799d on main 4017310678562c (both the head as-is and a local merge onto main, which is clean). Linux, GCC 13 Release, lavapipe (llvmpipe, Mesa 25.2.8). No AMD/NVIDIA here, so nothing on the GPL-off question.

What I ran, each --repeat until-fail:3 with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: agc_driver_volume_mip_targets, linear_volume_nonresident, layered_volume_{draw,submit,vertex,vertex_no_gpl}, image_xor_swizzle_volume, graphics.

  • Head and head-merged-onto-main: all 8 pass 3/3, and every --mips run prints all 14 cases.
  • Control (main's State.cpp/Draw.cpp/Texture.cpp with this PR's tests): volume_mip_targets fails with "a depth-one volume mip was treated as a 2D image". graphics and linear_volume_nonresident fail on main's "mipmapped 3D color targets are unsupported". The 5 shared tests pass on both sides.
  • Validation output is the same on main and on the PR. The only message is VUID-VkDeviceCreateInfo-pNext-pNext at device creation, which comes from my older layer.

One problem: for a mip that isn't at offset 0, the color target's byte window runs past the end of the volume.

DecodeColorBuffer now sets color.bytes to the whole surface (State.cpp:2113), but color.address is still surfaceAddress + mipOffset (State.cpp:2032). Everything that uses the two together sees [surface + mipOffset, surface + mipOffset + guestBytes). That's the end of the volume plus mipOffset extra bytes. The buffer alias checks (CheckBufferAliases Draw.cpp:1043, ShaderResources.cpp:4381) and the index/vertex alias checks (Draw.cpp:1344, 1561) all read that window.

Example: I changed the --mips fixture to put the vertex buffer right after the volume allocation. Two cases then throw shader buffer aliases the render target:

  • 96x32x8 RenderTarget, 3 levels, mip 0 (mip offset 64 KiB)
  • 128x128x8 S4KBX UINT, 2 levels, mip 0 (mip offset 128 KiB), which is the same shape as the Sonic target

The other 12 cases still pass. As a probe, I ended the window at the surface end (bytes = guestBytes - mipOffset), and then all 14 pass. So a title that allocates a buffer right after a mipmapped volume would fail its draw.

A fix could check [surfaceAddress, surfaceAddress + guestBytes) at those sites, or keep color.bytes per view and carry the surface size separately. A --mips case with a buffer right after the volume would pin it.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643376470 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7310#pullrequestreview-5643376470). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T13:24:29Z. **Review:** COMMENTED --- Reviewed head `b49ce040799d` on main `4017310678562c` (both the head as-is and a local merge onto main, which is clean). Linux, GCC 13 Release, lavapipe (llvmpipe, Mesa 25.2.8). No AMD/NVIDIA here, so nothing on the GPL-off question. What I ran, each `--repeat until-fail:3` with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`: `agc_driver_volume_mip_targets`, `linear_volume_nonresident`, `layered_volume_{draw,submit,vertex,vertex_no_gpl}`, `image_xor_swizzle_volume`, `graphics`. - Head and head-merged-onto-main: all 8 pass 3/3, and every `--mips` run prints all 14 cases. - Control (main's State.cpp/Draw.cpp/Texture.cpp with this PR's tests): `volume_mip_targets` fails with "a depth-one volume mip was treated as a 2D image". `graphics` and `linear_volume_nonresident` fail on main's "mipmapped 3D color targets are unsupported". The 5 shared tests pass on both sides. - Validation output is the same on main and on the PR. The only message is `VUID-VkDeviceCreateInfo-pNext-pNext` at device creation, which comes from my older layer. One problem: for a mip that isn't at offset 0, the color target's byte window runs past the end of the volume. `DecodeColorBuffer` now sets `color.bytes` to the whole surface (State.cpp:2113), but `color.address` is still `surfaceAddress + mipOffset` (State.cpp:2032). Everything that uses the two together sees `[surface + mipOffset, surface + mipOffset + guestBytes)`. That's the end of the volume plus `mipOffset` extra bytes. The buffer alias checks (`CheckBufferAliases` Draw.cpp:1043, ShaderResources.cpp:4381) and the index/vertex alias checks (Draw.cpp:1344, 1561) all read that window. Example: I changed the `--mips` fixture to put the vertex buffer right after the volume allocation. Two cases then throw `shader buffer aliases the render target`: - 96x32x8 RenderTarget, 3 levels, mip 0 (mip offset 64 KiB) - 128x128x8 S4KBX UINT, 2 levels, mip 0 (mip offset 128 KiB), which is the same shape as the Sonic target The other 12 cases still pass. As a probe, I ended the window at the surface end (`bytes = guestBytes - mipOffset`), and then all 14 pass. So a title that allocates a buffer right after a mipmapped volume would fail its draw. A fix could check `[surfaceAddress, surfaceAddress + guestBytes)` at those sites, or keep `color.bytes` per view and carry the surface size separately. A `--mips` case with a buffer right after the volume would pin it.
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!7310
No description provided.