fix(shader): split scalar-address descriptor phis #7694
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7694"
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 Ondra97 on 2026-10-19T00:46:24Z.
What
An image descriptor merged from a literal T# and a scalar-address load was rejected during preparation with
GetImageResource dword 0 is not a valid runtime value. Recreate the loaded descriptor arm when its offset is a memory-independent expression of user data and constants. Pointer reuse still requires dominance and same-block instruction order; memory-derived offsets remain refused after SRT planning.Copied raw reads retain their original block dependencies. Both the SRT tape and interpreted evaluators activate a descriptor only after all its required load blocks are reached. A skipped loaded arm stays null even with a stale nonzero pointer; a taken unmapped read still fails. The copies are planning-only and add no GPU memory access.
The rebase preserves main's descriptor-web state-limit diagnostic, 32-field
MemoryInfoencoding, newer image/artifact fields and 144-byteIrValueassertion. Required block indices remain serialized, validated on decode and included in source interning. Main uses cache format 50, so this combined schema uses 51. The Linux/libstdc++ guards remainsizeof(DescriptorSource) == 216with four aggregate fields andsizeof(TableColumn) == 112.A dedicated
agc_shader_descriptor_phismode runs the existing Phi scenarios with both SRT cross-verifiers enabled. The full shader-memory test and the existing type-zero/pending-write tests are retained.Tested
November 1 current-main refresh: base
f2d874c1fdccf781c0fa5d86619bb5dd8894b958, submitted head4c4b442a12a9a109d023d809d1baea7b6a3c6973. The existing topic/review-fix history and authorship are preserved. The registration conflict is resolved withagc_test_split.py resolve: the isolated descriptor-Phi test now belongs totests/cmake/agc_shader_memory_tests.cmake, preserving its 30-second limit and both SRT cross-verification properties. All other registered shader-memory and disk-cache modes remain.The merged code retains main's 144-byte
IrValuecheck, its 32-fieldMemoryInfoand newer image/artifact fields, plus this PR's 216-byte/four-fieldDescriptorSource,requiredBlocksserialization and decoded-index validation. Standalone cache format remains 51 versus main's 50; this refresh adds no new instruction semantics.Windows 11 Pro 10.0.26300, AMD Ryzen 9 7900X, 31.7 GiB RAM, WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT, Ninja Release,
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=ON, pinned bundled dependencies. NVIDIA GeForce RTX 4070 Ti SUPER, driver 621.01 / 32.0.16.2101; Khronos validation manifest API 1.4.335.relinker/libsand every selected shader/cache/replay/GPU fixture build on both revisions.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, serial verbose CTest. Logs confirm actual RTX selection and instance/device layer insertion, with no missing requested layer, VUID or validation warning/error. The isolated Phi case enablesAPS5_VERIFY_SRT_TAPE=1andAPS5_VERIFY_SRT_COMPACT=1through its CTest properties; the remaining tests keep their standard settings.ResourceTracker.cppwith its exact base blob, while retaining the PR fixture/schema, makesagc_shader_descriptor_phisfail withGetImageResource dword 0 is not a valid runtime valueatLoadAddressU32@pc=0x00000058. The fixed tracker is restored byte-for-byte and SHA-256 checked, then all production targets are rebuilt and the full final selection above passes on exact submitted sources. The failed control is not counted as a pass.Reproduction with the supported toolchain/layer configured:
Other standalone schema changes, including #10351's
stencilAttachmentExport, use format 51 for different layouts. Their unchanged heads are not a combined schema. When one lands, the other must rebase, retain both serialized field sets and advance the combined version (52 for exactly these two changes); downstream #11551 must then use the next combined version. No new functional dependency between the unrelated features or mixed-stack execution is claimed.The historical native Linux executions below belong to their exact older heads. These new executions are Windows; they do not claim a fresh native Linux run. The previously documented optional global SRT-verifier/all-Raw callback-count interaction is not reported as fixed by this rebase; standard memory modes and the isolated verified-Phi mode are all retained and executed. No original title shader, title/homebrew run, full CTest suite or speedup is claimed.
Earlier validation (historical source pins and environments)
Revalidated on 2026-10-30: final base
1edecd693c36f2f2d37851db54b990c56c6f5900, submitted head0f2c8f4cc7b9a3468583e53e1978cda985d6ff3e. Main was merged into the existing branch, retaining the five original topic patches and their history.Windows 11 Pro 10.0.26300; AMD Ryzen 9 7900X, 31.7 GiB RAM; WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT; Release,
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=ON, pinned bundled dependencies. NVIDIA GeForce RTX 4070 Ti SUPER, driver 621.01 / 32.0.16.2101; Khronos validation 1.4.335.relinker/libsand every selected shader/cache/replay/GPU fixture build passed on the submitted sources. All 374 patched libraries loaded, zero failures.e049725553c4cf9770eb06d2ab1a211059efd29d; 44/44 passed on the submitted head, zero failures or skips. The extra case is the dedicated descriptor-Phi cross-verification mode. The selection includes every registered shader-memory/disk-cache mode, both replay tests, image-table execution, depth-clear HLE and patched libraries. Main advanced with unrelated library/tool changes; the shader, driver, kernel/libc and CMake inputs used by the paired GPU tests are unchanged between the tested main and the final base, and the final head was fully rebuilt and retested.agc_driver_depth_clear_hlecrash/common-parent diagnostic from the older contributor run did not reproduce on either current Windows tree. This does not establish that the earlier native-GPU report is fixed.APS5_VERIFY_SRT_TAPE=1andAPS5_VERIFY_SRT_COMPACT=1through CTest. It checks planning-only copied reads, skipped mapped/unmapped/null roots, taken-unmapped refusal, explicit interpreted/tape queries, cache round trips and rejected invalid block indices. It stops at validated SPIR-V; image-table/depth-clear provide actual GPU coverage.ResourceTracker.cpp, while keeping the new fixture and schema, makes the isolated Phi case fail atLoadAddressU32@pc=0x00000058with the original invalid-runtime-value error. The fixed file was restored byte-for-byte, touched, rebuilt and the same case passed; the submitted tree was subsequently rebuilt and the complete focused selection rerun.Optional global cross-verification control: exporting both SRT verification flags to the entire suite produced the same two failures on clean main and the preliminary rebased PR:
agc_shader_type_zero_image_materializationandagc_shader_memory, both at main's synthetic all-Raw pending-write assertion. That assertion includes an exact eight-read callback count. These failed controls are not counted as passes. Standard execution passes both existing cases; the new dedicated mode enables cross-verification specifically for the descriptor-Phi scenarios, without removing or skipping the other tests. No fix for the broader optional-mode interaction is claimed.Exact-head native Linux verification checked out submitted SHA
0f2c8f4cc7b9a3468583e53e1978cda985d6ff3edirectly; the workflow lives only on the separate verification branch, outside this PR.Ubuntu 24.04.5 LTS x86-64, AMD EPYC 9V74 80-Core Processor, 15Gi visible RAM, g++-14 (Ubuntu 14.2.0-4ubuntu2~24.04.1) 14.2.0; Release,
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=ON, pinned recursive dependencies. Both shader-memory and shader-disk-cache targets built, including the native libstdc++ layout assertions (DescriptorSource216 bytes/four fields,MemoryInfo32 fields) and cache format 51.ctest --test-dir build -R '^agc_shader_(memory|disk_cache|descriptor_phis)$' -V --output-on-failure --no-tests=error --repeat until-fail:3passed 3/3 tests in all three repetitions (9 executions), zero failures or skips. The dedicated Phi case enables both SRT verification flags through its CTest properties; the full memory and cache tests retain their standard environment. The guarded-read marker appears six times, from the full-memory and isolated-Phi executions. These are CPU preparation, serialization and SPIR-V-validation checks; this job uses no GPU.Conventions, strict main synchronization, whitespace and registration checks pass. The final overlap scan lists 85 peers. Shared production patches from the original 44 were inspected, with no second implementation of copied-read
requiredBlocksprovenance. The 41 additional entries share test/registration areas and add no changes to the affected production paths; none uses the new descriptor-Phi mode name. #7223/#7395 and their table follow-ups change independent layout/decoder fields, while #6488/#7642/#10193 add lane/device-table paths and #7684 bounds keys. Composing these schemas must retain both field sets, recalculate size/count/minimum-list assertions and select a new combined cache version. Version numbers on other standalone branches do not identify the same schema. No peer merge-order agreement or mixed-stack runtime validation is claimed.No complete CTest suite, original title shader, title/homebrew execution or performance improvement is claimed. Earlier validation is retained below with its own revisions, hardware and scope.
Earlier submitted-revision validation (historical)
Base
12686b52de3db682868a420d196682bdf539dd83; submitted headfefe7bc97e80948a20f11e715c5e24f92f3b4f16.Windows 11 Pro 10.0.26300, Ryzen 9 7900X, 31.7 GiB RAM, WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT, CMake 4.3.1, Ninja 1.13.2, Release,
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=ON, pinned bundled dependencies. NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42 / 32.0.16.1742; Khronos validation 1.4.335.relinker,libs,patched_libraries_tests,agc_shader_memory_tests,agc_shader_disk_cache_tests,agc_shader_replay,agc_shader_replay_requests_testsandagc_driver_image_table_testson both exact revisions withcmake --build <build> --target <targets> --parallel 8.agc_shader_memory_tests, shader disk cache, both shader replay tests, patched libraries and driver image table. The selection now includes main's three result-memo budget modes as well as the earlier 23 cases. Each library-load check loaded 368 patched libraries, zero failures.APS5_VERIFY_SRT_TAPE=1,APS5_VERIFY_SRT_COMPACT=1,ANYPS5_GPU='RTX 4070 Ti SUPER',ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Loader logs confirm instance and device validation-layer insertion and the actual selected RTX. Both have zero VUIDs, validation warnings, validation errors and missing-layer reports.agc_driver_image_tableis the hardware GPU check.ResourceTracker.cppand the current regression kept,agc_shader_memoryfails atLoadAddressU32@pc=0x58with the original invalid-runtime-value error. Restoring the tracker byte-for-byte, rebuilding and rerunning the registered test passes with the skipped/taken-arm regression marker.Native Linux verification is recorded in the exact-head run. Its workflow is on a separate verification branch and checks out the submitted head directly.
Ubuntu 24.04.5 LTS x86_64, AMD EPYC 7763, approximately 15 GiB visible RAM, GCC 14.2.0, Release,
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=ON, pinned bundled dependencies. Nativeagc_shader_memory_testsandagc_shader_disk_cache_testsbuild, including the Linux-only layout assertions.ctest --test-dir build -R '^agc_shader_(memory|disk_cache)$' -V --output-on-failure --no-tests=error --repeat until-fail:3with both SRT verification flags passes 2/2 in all three repetitions, zero skips. The guarded-read regression marker appears on every memory-test run. These are CPU shader preparation, serialization and SPIR-V validation checks.Conventions, strict main-sync, whitespace and test registration checks pass. Registration counts 1,452 Windows test executables, with none unregistered; the executed Windows selection is the 26 tests above.
The overlap scanner reports a direct cache layout/decoder collision with #7223 and shared files it cannot automatically compare. I inspected the shared changes of all 48 peer PRs from the fetched heads. None adds this copied-read
requiredBlocksprovenance. #7223/#7395 and their pointer-table follow-ups add independentTableColumnfields; #6488/#7642/#10193 add lane/device-table paths; #7684 bounds table keys. Composing them must preserve both sets of fields, recompute layout assertions and decoder limits, and choose a cache version for the combined schema. Source-lead tracing in #5609 belongs after guard activity is applied. No peer implementation, agreed merge order or mixed-stack validation is claimed here.No complete CTest suite, original title shader, title/homebrew execution or speedup is claimed.
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)Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T07:42:54Z.
Intel and AMD Windows data: the 15 shader tests this PR touches pass on an Intel UHD 770 and an AMD RX 9070 XT.
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This head30d44b39amerged intomain6b8228b2b.tests/ShaderMemory.cpp(agc_shader_memory,agc_shader_bindless,agc_shader_frontend_pair,agc_shader_layout_pairand the others)tests/ShaderMemory.cpphas changed onmainsince this branch's base, so I have no clean before-run.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T17:22:08Z.
First AMD-on-Linux (RADV) run of this PR. Merged onto
maindbac9fa15(clean merge), built in full and compared with the samemain, on the same machine.AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.
Full suite (
ANYPS5_REQUIRE_VULKAN=1 ctest -j8): 1638/1640 with this PR, against 1638/1640 onmain. The failures are the same two on both, so this PR adds none:agc_driver_image_table_vouched_lookups(#7766, fixed by #7916) andagc_driver_guest_memory_lifetime(#7784).agc_shader_memorypasses. The PR adds no new ctest entry, and no test is skipped or removed compared withmain.GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T18:16:54Z.
First AMD-on-Linux (RADV) run of this PR. Merged onto
maindbac9fa15(clean merge), built in full and compared with the samemain, on the same machine.AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.
Full suite (
ANYPS5_REQUIRE_VULKAN=1 ctest -j8) ate46aefc56: 1638/1640 with this PR, against 1638/1640 onmain. The two failures are the same on both, so this PR adds none:agc_driver_image_table_vouched_lookups(#7766, fixed by #7916) andagc_driver_guest_memory_lifetime(#7784).Comparing the JUnit output with
main: this PR adds no ctest entry, and none is skipped or removed.This checks correctness only; I did not measure performance.
GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T11:57:32Z.
Review: COMMENTED
Reviewed head
30d44b39amerged onto current maina5a780eaa(clean merge). Linux, GCC 13.3, Release, built onlyagc_shader_memory_tests. CPU side only; the new case stops at SPIR-V, so no GPU needed.What I ran:
agc_shader_memoryon the merge: passes, 3 of 3.ResourceTracker.cppwith your test: fails withGetImageResource dword 0 is not a valid runtime value; chain: Phi(Immediate, LoadAddressU32@pc=0x00000058(...)). pc 0x58 is the news_load_dwordx8, so the red run really comes from the new case.-DANYPS5_ENABLE_SPIRV_TOOLS=ON(what the Linux CI job configures): passes, so the module from the new case gets through validation.tools/check_conventions.py --base origin/main: passes.One gap: the loaded arm now gets read even when its branch is skipped.
The copied
LoadAddressU32lands in the merge block, so capture evaluates it on both paths. I ran your shader again withrawUserData[7] = 0, sos_cbranch_scc1jumps over thes_load:rawUserData[0]0x500000(mapped)0x21080...read from memory the shader never loads on this path0x900000(nonzero, outsiderawRegions)CaptureResourcesandRecompilethrowEvaluateRuntimeSources failed to evaluate runtime sources: descriptor source 1 dword 0: LoadAddressU32(...)0Main treats this as wrong elsewhere:
verifyGuardedDescriptorSourcesrequires a skipped T# to stay null ("a valid T# behind a skipped branch was read",tests/ShaderMemory.cpp:1495on main). With this PR, a draw that takes the literal arm while s[0:1] holds a stale nonzero pointer fails on the CPU side, even though the shader never touches that address. Main fails this shader for every input, so this isn't a regression, just a part the fix doesn't cover yet.Could the copied read stay under its arm's condition, the way guarded sources already do? Or, if reading it on both paths is intended, could the test add the
s7 = 0case with an unmapped pointer so the behaviour is pinned down?Not checked: running it on a GPU (I only have lavapipe, and the new case doesn't dispatch), and whether the copied read also runs unconditionally in the generated SPIR-V.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T17:39:46Z.
Review: COMMENTED
Re-checked head
97b4b5d63merged onto main2e1c72239(clean merge). Linux x86-64, GCC 13.3, libstdc++, Release,-DANYPS5_ENABLE_SPIRV_TOOLS=ONlike the linux CI job. Builtagc_shader_memory_testsandagc_shader_disk_cache_testsonly.This head doesn't build on Linux.
ShaderDiskCache.cpp:112:That block sits under
#if defined(__linux__) && defined(__x86_64__) && defined(__GLIBCXX__), so a Windows build never sees it. The newstd::vector<std::uint32_t> requiredBlocksadds 24 bytes, so it needs to be 216. The linux job is skipped on this head, so CI hasn't caught it yet.With only that line changed locally to 216, the fix itself checks out:
agc_shader_memoryandagc_shader_disk_cachepass, 3 of 3.s7 = 0and roots0x500000,0x900000and0, the loaded T# stays null, nothing reports a null root or fault, and capture and recompile succeed. The taken unmapped arm still fails withfailed to evaluate runtime sources.ApplySourceBlockGuardsreturningtrueat the top: fails withdescriptor Phi: a skipped scalar-address T# was read.SrtTape::Runguard call removed: same failure, so the tape path is pinned on its own too.encodePlanwriting an emptyrequiredBlocks: fails withdescriptor Phi: the cached plan lost its raw read guard, so the cache round trip is really tested.tools/check_conventions.py --base origin/mainpasses.Not checked: a GPU run (the synthetic case stops at validated SPIR-V, and I only have lavapipe), and other open PRs that also bump the cache to 48.
AI-assisted: yes