You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(agc): select the alpha clear value for single-channel Vulkan storage images - #1995
Source commit: 335d7fc6a14643873c56fccdbe637b0b944cce9c. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.
What
A single-channel storage image can represent alpha. On GFX10, the DCC keys 0001 and 1110 give color and alpha opposite values. Vulkan clears the only component from the red slot, and the storage path always put the color value there. An R16 alpha image therefore received the opposite value. Use the descriptor's alpha value on upload and refill. When a new descriptor keeps the image and key addresses but changes alpha placement, rebuild the resident image. Repeated binds with unchanged placement still reuse it. AMD PAL's GFX10 rule.
Found while reviewing boykopovar#28192, which handles clear values decoded into guest bytes. This PR covers the command that clears the Vulkan storage image. boykopovar#28118 proposes rejecting these mixed keys on single-channel surfaces. boykopovar#24445 touches the same upload condition for uncompressed images.
Tested
Windows 11, NVIDIA RTX 3080 Laptop GPU (621.14). All seven existing DCC first-write and key-update tests passed on both main (e0ef70639d7e) and this PR (335d7fc6a146). The PR's new regression also passed all 16 full-image pixel readbacks across upload, same-address rebind and refill. The logs show Khronos validation 1.4.368 loaded for every case, with zero skips, VUID errors or synchronization errors on either revision.
On Arch Linux, all eight tests passed on the same PR revision with an RX 6650 XT (RADV Mesa 26.3.1), zero skips and no VUID or synchronization messages. Linux recheck
Earlier Windows regression results · 2026-11-29
On main f61eb307c0, four alpha-selected R16 readbacks returned the opposite value. The initial fix at 58a294887015 passed all 12 upload and refill checks on separate images. Switching only alpha placement on the same image still gave the opposite value on all four rebinds and their following refills.
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 and the licence notice of code adapted from upstream (see AGENTS.md)
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
Storage texture clears now handle single-channel formats with alpha-on-most-significant-bit settings more accurately.
Texture images are reused only when their metadata is compatible with the requested resource, helping prevent incorrect results when sampling, drawing, or clearing textures.
Tests
Added coverage for storage texture clears across multiple formats and metadata configurations.
No actionable comments were generated in the recent review.
Walkthrough
Changes: DCC Metadata and Storage Clears
Layer / File(s)
Summary
Metadata compatibility and clear values core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp, core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp, core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
Adds StorageImageServesMetadata, which checks alpha placement for nonzero DCC addresses. Storage key clear values account for alpha placement on single-channel formats.
Compatibility checks and execution tests core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp, core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp, core/libs/prx/libSceAgcDriver/tests/execution/DccKeysFirstWrite.cpp, core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_dcc_keys_first_write_tests.cmake
Sampled views, storage images, attachment memos, and draw recipes use metadata compatibility checks. The new execution mode tests storage clear values and verifies cache reuse behavior when alpha placement changes.
This change fixes single-channel storage-image clears when alpha is placed in the most significant bit, and rebuilds a cached image when its alpha placement changes. No concrete defect was found, and pending GPU results are written back before the image is replaced. It looks safe to merge.
Security architecture risk: Minimal · up to 335d7
AGC Graphics now rebuilds DCC-backed images when the requested alpha placement differs, instead of reusing an image that can clear to the wrong value. Replacement uses the existing path for preserving pending GPU writes. The reviewed change does not introduce a new guest-facing operation or expand what it can access.
Security review details
Security Blast Radius
inferred — A guest descriptor can cause more cache misses by changing alpha placement at the same DCC address. In the inspected paths this changes reuse within the existing device-and-surface cache and the clear value sent to the selected Vulkan image; it does not grant access to a new resource class.
Resilience and Maintainability Implications
observed — Replacement runs under the cache mutex and does not publish the new entry until after creation and adoption. If creation unwinds with a detached image still held by the handover, the handover destructor flushes it. If sampled storage creation fails, the sampled path can fall back to a snapshot and checks for pending writes before reading guest bytes.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 80c8eb80-2725-4919-8609-f0058bc6993e
Commits
Reviewing files that changed from the base of the PR and between 4131f51 and 335d7fc.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A single-channel storage image can represent alpha. On GFX10, the DCC keys
0001and1110give color and alpha opposite values. Vulkan clears the only component from the red slot, and the storage path always put the color value there. An R16 alpha image therefore received the opposite value. Use the descriptor's alpha value on upload and refill. When a new descriptor keeps the image and key addresses but changes alpha placement, rebuild the resident image. Repeated binds with unchanged placement still reuse it. AMD PAL's GFX10 rule.Found while reviewing boykopovar#28192, which handles clear values decoded into guest bytes. This PR covers the command that clears the Vulkan storage image. boykopovar#28118 proposes rejecting these mixed keys on single-channel surfaces. boykopovar#24445 touches the same upload condition for uncompressed images.
Tested
Windows 11, NVIDIA RTX 3080 Laptop GPU (621.14). All seven existing DCC first-write and key-update tests passed on both main (
e0ef70639d7e) and this PR (335d7fc6a146). The PR's new regression also passed all 16 full-image pixel readbacks across upload, same-address rebind and refill. The logs show Khronos validation 1.4.368 loaded for every case, with zero skips, VUID errors or synchronization errors on either revision.On Arch Linux, all eight tests passed on the same PR revision with an RX 6650 XT (RADV Mesa 26.3.1), zero skips and no VUID or synchronization messages. Linux recheck
Earlier Windows regression results · 2026-11-29
On main
f61eb307c0, four alpha-selected R16 readbacks returned the opposite value. The initial fix at58a294887015passed all 12 upload and refill checks on separate images. Switching only alpha placement on the same image still gave the opposite value on all four rebinds and their following refills.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)Summary by CodeRabbit