feat(shader): implement MIMG BY2/BY4 stores for the measured 2D subset #16321
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16321"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-11-06T08:25:06Z.
What
Implements MIMG
image_store[_mip]_by2/by4(opcodes 0x52, 0x53, 0x5a, 0x5b), the store side of the BY loads added in #1793.imageBytranslation now emitsIrOpcode::ImageWritefor the BY store opcodes and keeps throwing for PCK2/PCK4 stores, which remain unmeasured (0x76 hung a GPU in #1314).OpImageWriteper window element under the load's bounds gate: mip level in range,x + N - 1inside the level's width, y inside its height. Source lanekis written to window positionx & ~(N - 1) + kfork >= x & (N - 1)— the load's lane-to-position inverse, matching "write from the unaligned x up to the end of its dword".OpImageQuerySize(legal on storage images) shifted right by the dynamic lod, clamped to at least 1.StorageTexture::FlushPendingbefore readback, per-mip/per-texel/per-component/per-byte surface walks plus a whole-buffer compare to catch writes into padding or mip gaps, source-register-unchanged checks, and refusal cases for PCK stores and out-of-subset encodings.Two interpretation points worth a hardware-oracle re-check (flagged in the debt file): the lane-to-position mapping is the load's inverse rather than a directly measured store rule (the alternative — source lane 0 written at x — is not verified), and whether the store shares the load's all-or-nothing bounds gate is assumed from symmetry, not measured.
Tested
Windows 11, RTX 3070 (driver 617.42),
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1:agc_driver_image_byexecution tests pass (BY2 over R8/R16/RG8 and mip variants, BY4 over R8, dynamic mips, out-of-bounds/unaligned/edge-window positions, saturating component conversion, refusal cases unchanged) and theimage_bytranslation test passes (stores produce oneImageWritewithimageByElements, noImageRead).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
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T08:32:47Z.
Review: COMMENTED
Reviewed — no blocking findings
The implementation is reviewable, but the store lane mapping and bounds gate remain unverified against hardware, so a formal approval is not justified.
What I ran
Reviewed head
fd40784362b5fb61c2d74f8d73c01acb1e8f58b3using the prepared diff and targeted source reads throughrepo_read.py. I did not run tests; the Windows and RTX 3070 results in the description are author-reported.Results
Findings
Blocking
None.
Non-blocking
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp:1418: The emitted stores apply the load-inverse lane mapping and all-or-nothing bounds gate. The PR’s debt note says both assumptions still need a hardware-oracle check. Confirm these semantics on the target hardware and adjust the emitter or debt note based on that result.Not verified
ImageBy.cppexecution test,ImageTablePacked.cpp, core translation test,ResourceMaterializer.cpp,SpirvDescriptors.hpp,SpirvImageEmitter.cpp,ImageInstructions.cpp, anddocs/dev/debt/shader.mdwere read. Unchanged surrounding code was read only where needed for context.To get this to a good state
Nothing is required. Optional: verify the two flagged store semantics against the hardware oracle and update the implementation or debt record as appropriate.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T11:00:54Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the two store semantics called out in the PR description remain unverified against hardware.
What I ran
Reviewed head
e6f621fece2d9fd295be7c3077ef1ba80109133fusing the prepared diff andrepo_read.py. No build or tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp:1402Not verified
The author-reported Windows 11 / RTX 3070 tests were not independently run. PS5 gfx1013 store behavior, including lane mapping and the bounds gate, was not verified. No build or automated tests were run. The review documents read were
review/description.md,review/commits.md,review/manifest.json, andreview/diff.patch;review/files.jsonwas not available through the reader. All 10 changed files listed by the manifest were read; no changed files were excluded.To get this to a good state
Nothing is required. Optionally, verify both store semantics against the hardware oracle and update the debt note and tests with the measured result.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T11:48:32Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed code and relevant callers were inspected at the pinned head; no blocking defect was verified, but the full files and execution checks were not reviewed, so a formal approval is not justified.
What I ran
cddf2558f3b1e4bfda69a85c37bdf6e440fc0dc7.repo_read.pyreader tools only.Results
Negative control
Not run; no test assertion or code under test was changed for a negative-control check.
Findings
Blocking
None verified in the code inspected.
Non-blocking
Sources
Not verified
core/libs/prx/libSceAgcDriver/tests/execution/ImageBy.cpp,core/libs/prx/libSceAgcDriver/tests/execution/ImageTablePacked.cpp,core/libs/tests/ImageBy.cpp,core/shader/recompiler/Translation/src/MemoryInstructions/ImageInstructions.cpp,core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp,core/shader/recompiler/ShaderDiskCache.cpp,core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvMemory/SpirvDescriptors.hpp, andcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp. The diff was read for all 10 changed files.core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hppordocs/dev/debt/shader.md.To get this to a good state
Nothing is required. Optional: validate the lane mapping and bounds behavior on the PS5 gfx1013 hardware oracle.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T06:55:19Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the hardware-oracle assumptions are documented for re-check.
What I ran
Reviewed head
cd6d69e5af6e2233baa83a450a691bb980c3a6aausing the prepared diff andrepo_read.py. I ran no build or tests. The author reports Windows 11 / RTX 3070 execution and translation tests in the PR description; I did not run them.Results
Findings
Blocking
None.
Non-blocking
Not verified
No build or test commands were run. I read all 10 changed files listed as reviewed in
manifest.json. No changed files were excluded by the manifest; nofiles.jsonwas available in the review folder, so exclusion details beyond the manifest were not verified. Lockfiles, minified files,dist/,build/, and.svgfiles are omitted from the prepared diff by instruction.To get this to a good state
Nothing is required. Optional: re-check the lane mapping and bounds behavior on PS5 gfx1013 hardware and update the debt record with the result.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-28T06:58:26Z.
Review: COMMENTED
Actionable comments posted: 3
7ea44e68-3385-4c0f-8447-ad9eec3da063Reviewing files that changed from the base of the PR and between
c6331cc61bandcd6d69e5af.core/libs/prx/libSceAgcDriver/tests/execution/ImageBy.cppcore/libs/prx/libSceAgcDriver/tests/execution/ImageTablePacked.cppcore/libs/tests/ImageBy.cppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvMemory/SpirvDescriptors.hppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppcore/shader/recompiler/Translation/src/MemoryInstructions/ImageInstructions.cppdocs/dev/debt/shader.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T05:35:51Z.
Review: COMMENTED
Reviewed — no blocking findings
I reviewed the prepared diff at head
8f4a080d4ff9f3380d08a76cf1b5f4f6d6f73fef; no defect is verified, but I could not inspect source context becauserepo_read.pycould not write its read log.What I ran
Read the prepared description, commits, manifest, diff, file list, and README in the read-only Linux review environment. I also attempted a pinned-head reader command; it returned partial output before failing. No tests or builds were run.
Results
Negative control
Not run; no test was run.
Findings
Blocking
None verified.
Non-blocking
The description and debt entry identify the lane mapping and all-or-nothing bounds behavior as hardware-derived interpretations, with a further re-check requested for the target gfx1013. Keep that uncertainty visible until target behavior is confirmed.
Sources
Not verified
The diff includes all 10 changed files and no files were excluded by rule. The prepared files directory contains only three full head files; none was read. The pinned reader returned only partial output for
ImageBy.cppand failed because its read log was not writable. Consequently, callers, surrounding implementations, cache compatibility, and the reported GPU execution results were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T12:15:39Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: correct the BY texel byte width for two-component 8-bit formats so RG8 stores stop at the dword boundary.
What I ran
Reviewed head
196c45eda890c2f283a9add4533c44b29daa581dagainst the prepared diff and pinned reader context. No build or tests were run. The environment and toolchain were not verified.Results
Negative control
Not run; no tests were executed in this review.
Findings
Blocking
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp:355assignsbyTexelBytesas 1 for R8 and 2 for every other accepted format. That includes RG8, whose texels contain two 8-bit components and therefore occupy two bytes.EmitByStoreOpuses this value to computegroupTexelsand the lane limit (core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp:1673-1686). For RG8 BY2 atx = 1, the current value allows both elements to be written; the dword grouping should allow only the first. Set the decoded width from the total texel byte size, including the accepted two-component formats.Non-blocking
None.
Sources
Not verified
Author reports
agc_driver_image_byandimage_bytests passed on Windows 11 with an RTX 3070; those runs were not independently verified. No PS5 hardware-oracle measurement was performed. The changed hunks of all 10 files listed inmanifest.jsonwere inspected;files.jsonlists no excluded files. Whole-file review beyond those hunks and targeted reader ranges was not performed.To get this to a good state
Correct the per-texel byte width used for RG8 BY stores and rerun
agc_driver_image_byon the updated head.Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:21:06Z.
Review: COMMENTED
The scalar-buffer-base and packed image-table CTests passed on main and the change on Linux Mesa lavapipe with Khronos validation 1.4.369. The new image BY test also passed. All three logs show the requested validation layer being inserted, with zero missing-layer diagnostics or VUIDs.
AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.