fix(shader): decode a T# with an unset format field as null #10556
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10556"
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 mixyt on 2026-10-24T09:47:24Z.
What
A directly bound sampled image T# whose 9-bit format field names no texture format (0, or all ones 0x1ff — the zero-format and the 0xffffffff-filled words of an unbound texture slot) now decodes like a null descriptor, with no view behind it, instead of throwing. The rule requires the descriptor's TYPE to be an image type the decode implements (8 to 14): a reserved or non-image TYPE keeps its rejection however the format field reads, so the replay tool's invalid request (TYPE 2, all-ones words) fails exactly as on
mainwith its fixture unchanged. The null decode applies to the compile-time descriptor decode and to the runtime SRT materialization alike. The driver'sIsNullSampledTextureResourceapplies the same TYPE and format rule to sampled-image consumers; storage bindings and written-buffer tracking keep the base-and-type null rule, so an unset-format storage or atomic image still throws. An image-table entry with an unset format stays poison, and a format that names a real but unimplemented texture still throws. The console's result of sampling such a slot is not measured; the null decode follows the existing all-zero descriptor rule (noted indocs/dev/debt/shader.md).Tested
Windows 11, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh r7), NVIDIA GTX 1650.
mainaborts on the first rendered frame withsampled image descriptor uses an unsupported format (T# ffffffff ffffffff 00000019 ...)(format 0x1ff, TYPE 12), then withruntime image descriptor is invalid(format 0) once the first is passed. With this PR the title runs its Idea Factory logo animation, title menu, intro dialogue and tutorial at 24-28 fps with pad input (screenshots and VideoOut telemetry attached); the first 3D section still stops onguest sampler descriptor requests a LOD bias beyond the device limit, a separate gap.c88b87df3, with the complete libs set rebuilt from that tree, the title ran our full 300 s cap: 7,316 presents (about 24 fps), no exception and no descriptor rejection; the time cap ended the run and it did not reach the earlier head's LOD-bias stop within it. (A single rebuilt driver launched over an older libs set fails to load on alibSceSystemService.prximport, so the whole libs set is rebuilt for this run.)c88b87df3(Windows 11, GTX 1650, driver 621.01,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1):agc_shader_memory,agc_driver_image_table,agc_driver_graphics,agc_shader_replay_requests,agc_shader_replay_toolandagc_shader_type_zero_image_materializationpass, both without and withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(layer 1.4.363; the loader log showsVkLayer_khronos_validation.dllloaded and the instance layer inserted, and the verbose run has noVUID-messages).agc_shader_memorymaterializes the measured TYPE 12 words with format 0 and 0x1ff as null, refuses a reserved TYPE 2 T# with the same format fields (runtime image descriptor is invalid) and keeps storage/atomic unset-format images invalid;agc_driver_graphicsrefuses a sampled reserved TYPE 2 T# atShaderResourcesconstruction (unsupported image type 2) and accepts a sampled TYPE 12 one as null, plus the storage andDispatchWriteRangescases;RunGuestTextureResourceTestspinsIsNullTextureResourcevsIsNullSampledTextureResourceacross TYPE 2, 12 and 15.agc_driver_sample_order,agc_driver_sample_order_grid_referenceandagc_driver_sample_order_recipe_depth_locationsfail on this GTX 1650 both onmainand with this PR (device-behavior expectation; the same tests skip on this machine's Intel UHD, which reports 1x1 sample location grids).Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T10:34:44Z.
Review: CHANGES_REQUESTED
The unset-format null rule currently applies to every directly bound image resource, not only the sampled reads described in the PR.
nullImageDescriptor(const ImageResource&, ...)returns true for anyimage.table == NoTablewhen format is 0 or 0x1ff. That helper is also used by runtime storage-image inspection/materialization; an invalid-format storage image can therefore be accepted as null and its writes/atomics silently skipped instead of rejected. Please scope this exception to the measured sampled/read-only case (for example, sampled + read + !written + !atomic), leaving storage and atomic resources invalid unless their behavior is separately established, and add a regression proving an unset-format storage descriptor still fails. The new shader-memory cases cover sampled descriptors, so they do not currently catch this path.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T14:02:25Z.
Review: CHANGES_REQUESTED
Follow-up review of exact head
ab264470df68f2dc9a5e0dcc714340cd81078729. The newResourceMaterializerpredicate correctly limits its new null rule to a direct sampled read that is neither written nor atomic, andverifyUnsetFormatImageMaterializationnow asserts that its storage/atomic materialization cases are rejected.The driver-side classification is still global, though:
IsNullTextureResourceinGuestTextureResource.cppnow returns true for formats 0 and 0x1ff regardless of resource class. The currentShaderResources.cppstorage-image branches call it and skip the binding as null (plannedStorageImagesis decremented);WrittenBuffers.cppalso skips the storage range. Those consumers can therefore silently drop an invalid-format storage image if it reaches the runtime descriptor path. The new materializer unit test does not exercise those driver consumers.Please scope the format-based null rule to sampled-image consumers (for example, pass descriptor role/class to the helper or use a sampled-only predicate), and add a regression showing an unset-format storage image is rejected by the driver path and is not omitted from written-buffer tracking. The sample-only change and reported Windows/NVIDIA results are useful, but I did not run the GPU tests locally.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T19:51:04Z.
Review: DISMISSED
Re-reviewed exact head
6d96cec31a1213af58799cfe6a975ef608ca24cb. The implementation now uses the sampled-only null predicate at sampled consumers and preserves the base/type predicate for storage and written-buffer paths, which addresses the behavior I flagged. The remaining test gap from my prior review is still open: the newGuestTextureResourcetest proves the predicate split and format rejection, but does not exerciseShaderResourcesrejecting an unset-format storage image or prove that the corresponding range is not skipped by written-buffer tracking. Please add focused coverage for those consumer paths, or point to existing tests that exercise them. The reported Windows/NVIDIA and AMD title runs used the earlierab264470head; please confirm the focused validation-layer tests on this scoped head. No new review action on GPU behavior until those checks are current.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T22:11:56Z.
Review: CHANGES_REQUESTED
Reviewing exact head
556257c5a0b84cfe66da043321495688cfd1dc09.What I ran
Results
Findings
Blocking
IsNullSampledTextureResourceaccepts any sampled descriptor whose format is 0 or 0x1ff, without first validating its TYPE. The PR discussion demonstrated the consequence: the existing replay fixture had an unset-format T# with reserved TYPE 2, and the new rule made that invalid request materialize successfully as null. The fixture was then changed to use a valid format so the replay test continued to fail, but that does not restore rejection for the invalid descriptor itself. The only reported title descriptors use TYPE 12; the console behavior for unset-format TYPE 2–7 is not measured. Please preserve rejection for reserved/non-image types (including TYPE 2) before applying the unset-format null rule, and add sampled descriptor/materialization regressions for both a measured valid image TYPE and an invalid TYPE with an unset format.Non-blocking
Sources
Not verified
To get this to a good state
Validate the descriptor type before applying the unset-format null shortcut, and cover valid-image versus reserved-type descriptors with unset formats; then request a re-review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T09:43:57Z.
Review: APPROVED
Re-checked — approved
The current implementation resolves the prior type-order concern: descriptor TYPE is validated before the unset-format rule, so only supported image types 8–14 take the sampled-null path. Reserved and non-image types with format 0 or 0x1ff still fail. The replay fixture again uses the original all-ones descriptor and is rejected for the same non-image TYPE as on
main.What I checked
c88b87df3d4088695bcb2a91a1f4964ba710d003is based on currentmainaaccd0ba39b7d40fdbf19664575a7e567d8542f7; merge preview is clean.agc_shader_memory,agc_driver_image_table,agc_driver_graphics,agc_shader_replay_requests,agc_shader_replay_tool, andagc_shader_type_zero_image_materializationpassing on this head; conventions pass. The reported host did not have the validation layer installed. The new hosted conventions/labels checks are pending.I did not run a local build or GPU test. The exact-head results above are author-reported; no console behavior is claimed. No blocking source issue remains.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T22:18:12Z.
Review: APPROVED
Reviewed — approved
A directly bound sampled T# whose TYPE is 8–14 and whose format field is 0 or 0x1ff now decodes as null in the materializer and at the driver's sampled consumers. Reserved TYPEs, storage images and atomic images keep their rejection. The focused tests pass, and the negative control fails as it should.
What I ran
Head
e1eda1a2aedf73874ea2e28bc2e981a8ef0fac94, merged with--no-ffintomain9090972b7e91fd266819cbd77a8b058e177b5682(merged tree9f16b8a122e8a8cb0f2aeb7d153c4357579aa7c7). Machine: Debian 13 VM, 2× Xeon Gold 6136 (32 vCPU), GCC 14.2.0, Release/Ninja, Vulkan through lavapipe (Mesa 26.1.6, LLVM 19).Results
git diff --checkcheck_conventions.pylibs(script)check_skips.py), 0 new failures, 0 timeouts; 7 known failures that also fail onmain(agc_driver_division,agc_driver_f32_denormal_flush,agc_driver_f64_div_scale_denormal_modes,agc_driver_f64_fma_denormal_modes,agc_driver_mullit_f32_denormal_modes,unwrap_self,vector_constant_factor_tininess)VUID-lines vsmainagc_shader_replay_requests0.01 s,agc_shader_type_zero_image_materialization0.01 s,agc_shader_replay_tool0.24 s,agc_shader_memory7.9 s,agc_driver_image_table8.4 s,agc_driver_graphics34.5 sI confirm what babyhuey and wachi35676 found: the earlier
agc_shader_replay_toolregression is gone on this head. Theinvalid.reqfixture is back to its upstream words, and capture rejects it again for its non-image TYPE.Negative control
I restored
ShaderResources.cppandResourceMaterializer.cppfrommain. I kept the PR'sGuestTextureResource.{hpp,cpp}so the predicate unit test still compiles. Then I rebuilt and ran the tests.agc_shader_memoryfails:runtime image descriptor is invalid: image 0 ... T# ffffffff e00fffff 00000019 c0017901 .... This is the measured TYPE 12 word set with format 0x1ff.agc_driver_graphicsfails:AGC graphics: unsupported guest texture format 0. This is the sampled unset-format binding inunsetFormatStorageImageTests.After that I restored the merged files, rebuilt, and both tests passed again.
git status --porcelainis empty.Findings
Blocking
None.
Non-blocking
ShaderResources::PresyncSurfacesis atcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:5648-5653(at head). This branch runs when Stage A left noimageRecords, for example withAPS5_NO_PRECOLLECT=1(line 4932–4934). It walks sampled and storage elements throughforEachImageElementbut filters only withIsNullTextureResource.DecodeTextureResourcethere and throwsunsupported guest texture format. The normal path accepts the same T# as null. It does not affect the default configuration, which builds image records, but the sampled-consumer split is incomplete.binding.kind == DescriptorKind::SampledImage ? IsNullSampledTextureResource(words) : IsNullTextureResource(words). This matches line 4962. It could also usefirstLayerWords, as the record path does.agc_driver_graphicsexceeds the 30 s limit. It took 34.5 s here, and the AMD CI comment reports 82.9 s with validation layers. The PR adds only a few mockShaderResourcesconstructions, so the test was already slow before this change. I did not time it onmain, so this is not counted against the PR. It is still worth splitting the test eventually.Not verified
VUID-lines.IsNullSampledTextureResourcereads the raw word-1 bits 20–28 without GCN remapping. I did not exercise the GCN-guest path.