perf(agc): allocate sampled textures from their base level #28240
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28240"
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 Meh7an on 2026-11-29T11:35:37Z.
What
A sampled texture's view starts at its T#'s base level, so it cannot reach the levels above it, but the snapshot constructor allocated, detiled and uploaded the whole chain. For a 2D or 2D array snapshot, the image is now created from the base level on: its extent is the base level's, it holds
mipCount - baseLevellevels, the detile and the upload start at the base level, each copy writes levellevel - baseLevel, and the view's base level and its minimum LOD clamps (the view's and the sRGB view's, both in image levels) move down by the levels left out. The view reads the same texels at every LOD as before: its base level has the same extent, and Vulkan's LOD is taken from the view's base level.APS5_NO_BASE_LEVEL_TRIM=1keeps the whole chain (ENVIRONMENT.md).Tested
agc_driver_image_sample_lod_clamp, which checks the level and texel everyimage_sample_d_cl,image_sample_cl,image_sample_d_cl_o,image_sample_landimage_sample_lzresult comes from, now also samples:agc_driver_image_sample_lod_clamp_untrimmedruns the same test withAPS5_NO_BASE_LEVEL_TRIM=1and--untrimmed: every sample reads the same level and texel as with the trim, and both textures allocate 1399808 bytes. The trimmed run with the switch set fails at "the 512x512 T# with BASE_LEVEL 2 allocates 1399808 bytes and the one with BASE_LEVEL 0 1399808", and the untrimmed one without it at "allocates 89088 bytes and the one with BASE_LEVEL 0 1399808".agc_driver_image_sample_lod_clamp: without the view's minimum LOD shift it fails at "image_sample_d_cl with T# MIN_LOD 512 over BASE_LEVEL 1 ...: thread 0 component 0 is 3.000000, expected 2"; without the sRGB view's it fails at "image_sample_d_cl with T# MIN_LOD 768 over BASE_LEVEL 2 ..., through FORCE_DEGAMMA: thread 0 component 0 is 0.000000, expected 3", withVUID-VkImageViewMinLodCreateInfoEXT-minLod-06456.agc_driver_graphicsandagc_graphics_profile_draw, ran withctest --test-dir build -R <those names> -V, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer(validation layer 1.4.363.1). Onmain55106ef002all 58 pass; on this change they and the new_untrimmedentry pass (59). The loader inserts the layer in every test that creates a Vulkan instance (56 onmain, 57 here; the two graphics unit tests create none), neither log haswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither has aVUID-line.main, and no trace summaries are attached.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
APS5_NO_BASE_LEVEL_TRIM=1to retain the full mip chain.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T11:38:50Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes trim eligible sampled 2D texture images from the descriptor’s base level and adjust image views and minimum LOD clamps accordingly; I found no verified blocking defect.
What I ran
Reviewed head
619d0f7b7c1638adf2c0a4e450323357d109b686using the prepared diff andrepo_read.py. No tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests and runtime behavior were not independently verified.
Texture.cppis too large to be included in the review folder; I read the ranges around the changed logic and upload/view paths. The other changed files were read in full. Excluded by review-folder rule: the full text ofTexture.cpp.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-29T11:44:49Z.
Review: COMMENTED
ecc0715e-7186-412f-9df0-721e7f7962a9Reviewing files that changed from the base of the PR and between
1341e2228eand619d0f7b7c.core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_sample_lod_clamp_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cppdocs/dev/ENVIRONMENT.mddocs/dev/debt/changes/perf-agc-texture-base-level-trim.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by arcwiser on 2026-11-29T12:07:22Z.
Review: APPROVED
Reviewed exact head
619d0f7b7c1638adf2c0a4e450323357d109b686against merge base55106ef00221f3e29a4b6a16ca378e52318ab2df.I read the complete five-file diff and the surrounding allocation, detile/upload, sparse-level, view, minimum-LOD, and dump paths. The trim predicate stays limited to plain 2D/2D-array snapshots; image extents and mip counts, source-to-image copy levels, view base levels, and both minimum-LOD clamps are rebased consistently. I found no blocking correctness issue. The BC1 work below
firstUploadedis already covered by CodeRabbit's exact-head comment, so I am not duplicating it.Windows 11, MSYS2 UCRT64 GCC 16.2.0, Release, NVIDIA GeForce RTX 4070 SUPER driver 610.88:
agc_driver_image_sample_lod_clamp_testsbuilt successfully;agc_driver_image_sample_lod_clamp,_shader_lane, and_untrimmed: 3/3 passed withANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1;python tools/check_conventions.py: passed;python tools/debt_fold.py --check: passed;git diff --check: passed;upstream/main(32fb6dadc1) is clean.I requested
VK_LAYER_KHRONOS_validation, but this machine does not have it installed and the loader explicitly reported that it was not found. Therefore this review makes no validation-layer or VUID claim.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T18:47:57Z.
Review: COMMENTED
The current merge conflict is in
ImageSampleLodClamp.cpp. Please retain the main branch'sCheckPairingcases for filtering and a separate second view, alongside the trim-on and trim-off cases. The new allocation test exercises a 2D descriptor. An array case with a nonzero base layer would cover the other trimmed image type and check that dropping mips leaves the selected layer unchanged.Source review of
619d0f7b7c. The local merge of the fixture is blocked by that conflict.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-04T14:38:47Z.
Review: COMMENTED
Actionable comments
firstUploaded.core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp, lines842· 🚀 Performance & Scalability · ⚡ Quick winAPS5_BC1_RDNA2_DECODE=1andbaseLevel=2, an eligible BC1 snapshot can take the trimmed path.IsRepackedTextureFormatdoes not exclude BC1. (raw.githubusercontent.com)skip=0. It decodes the omitted leading levels from unwritten scratch regions, although those decoded levels are never uploaded. UsefirstUploadedto keep decoding aligned with detiling. This preserves the existing start when no levels are dropped. (raw.githubusercontent.com)Proposed change
12758234-4c4e-4ff2-9390-36401a5a34aaReviewing files that changed from the base of the PR and between
619d0f7b7cand0e9ad65876.core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/execution/ImageSampleLodClamp.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T14:42:23Z.
Review: COMMENTED
Reviewed — no blocking findings
No code defect was verified in the reviewed changes, but approval is not justified because the performance evidence is incomplete.
What I ran
Reviewed head
0e9ad65876946d1bbe812fe4dacec4221013c54a. I inspected the prepared diff and metadata, then usedrepo_read.pyto read relevantTexture.cppranges and changed test code. I did not run tests or compile anything.The reader returned the requested ranges, then reported that it could not append its read log in the read-only workspace. Test results in the PR description are author-reported, not runs performed for this review.
Results
Negative control
Not run independently. The author reports that mutants omitting the view minimum-LOD adjustments were caught.
Findings
Blocking
None.
Non-blocking
None.
Sources
The texture change shifts the allocated mip range, upload copies, and view LOD clamps for eligible textures; the added tests exercise LOD sampling and allocation size. Texture.cpp at the reviewed head · ImageSampleLodClamp.cpp at the reviewed head
Not verified
The full
Texture.cppfile was not read; I inspected the changed hunks and relevant surrounding ranges. All five changed files listed as reviewed infiles.jsonwere covered through the prepared diff or targeted reader ranges; no files were excluded. The reported performance run has no matchedmainbaseline, trace summaries, or digest output attached, so the performance benefit is not verified. Runtime behavior outside the inspected LOD and allocation paths was not independently tested.To get this to a good state
Nothing is required. Optional: attach matched baseline and PR performance captures, summary records, traces, and digest output to support the performance claim.
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.