feat(shader): name image modes and unfolded sizes in the variant trace #28387
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28387"
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 zeezey on 2026-11-30T10:43:51Z.
What
Extends the pipeline line of
APS5_TRACE_SPECIALIZATION_VARIANTS(#28296) so that it names image modes and gives the unfolded sizes, and adds a comparison with the previous boot. Animage[N].modevalue is an index into the image's runtime mode list (ResourceMaterializer::RuntimeImageModes), whose length and order depend on static flags of the program, so a line such asimage[2].mode 0x18->0did not say which mode either module uses, nor what a module that keeps every mode of the image would carry.First commit,
2162f70930feat(shader): name image modes and unfolded sizes in the variant trace:OpSwitchinstructions onimage[N].mode; an image with one mode has none unless its sampler comes from a table), with how many mode bodies (their distinct case targets) in how many words (each switch from itsOpSelectionMergeto the merge block).RecompileResult::preparedConstantsfrom #28296 becomesspecializationTrace, which holds the values and these fields;sizeof(RecompileResult)stays 584 andEncodeResultis unchanged. Graphics modules keep nothing now, since only compute pipelines print.image[N]value (the first 16, then; ...):[specialization-variant] pipeline <n> of program <address>: <words> SPIR-V words (<unfolded> unfolded), the previous one <words> (<unfolded> unfolded); compiled variant ...; differs from the previous pipeline's module in <count> of <values> values: ...; image[<N>] mode <old> (<mode>) -> <new> (<mode>): <k> modes, <s> access sites, <b> mode bodies in <w> unfolded wordsA count that differs between the two compiled variants prints as
<old>-><new>; an image only one module has prints(no mode list)on the other side; a mode value the module does not supply printsabsentwith the default mode 0 it uses. A count of one prints in the singular (1 mode,1 access site,1 mode body,1 unfolded word).conversion=andpacked=withIrBufferFormatnumbers, andcube,depth-bits,d16,srgb,layer-rows,emulated-compareandconstant-swizzlewhen set:ResourceMaterializer::RuntimeImageModeName. A null T# selects mode 0 (TryRuntimeImageMode), so a bound-to-null line names the bound mode and mode 0.Second commit,
0197c133eafeat(shader): compare the previous boot's modules in the variant trace, since a program can get another module from one boot to the next (#27759: a sampled image's W selector compiled in as the component in one boot and as the constant one in the other), which a trace of one boot cannot name. WithAPS5_TRACE_SPECIALIZATION_VARIANTS_FILE=<path>as well:APS5_TRACE_SPECIALIZATION_VARIANTS_WORDSwords is appended as one line and flushed: the program address, both word counts, the module's content hash, every value and the image modes. A module whose values and SPIR-V this boot already recorded for its program is not written again, nothing more is written once the file would exceed 64 MiB, and an unfinished last line, as a crash leaves, is left out when the file is read;[specialization-variant] program <address> against the previous boot: <words> SPIR-V words (<unfolded> unfolded), the nearest module of <k> in the previous boot <words> (<unfolded> unfolded, the same SPIR-V); differs from the previous boot's module in 1 of <n> values: image[2].w 0x7->0x1; image[2] mode ...Third commit,
ade69c3091fix(shader): bound the boot file read and check each record write(from the review): the file's first line is read before the rest, a list is read in 64 KiB pieces up to the 64 MiB limit, and a record whose write fails closes the file with one line saying that this boot's later modules are not recorded.Fourth commit,
13dd65dbfcfeat(shader): give the raw words of a slot that turns null in the variant trace. A tester's cold boot of the title (#27759) built 65 programs twice, and 64 of the second builds have a slot going from null to bound or back, such asbuffer[4].word3 0->0x14204 ... image[2].mode 0x18->0. Whether the null descriptor is a template with only its address cleared (format andDST_SELfields kept) or all zero decides the fix, and the line could not tell: a null V# has its specialization fields zeroed (#28102) before the trace sees them, and a null T# selects mode 0.BufferDescriptorPresent,ResourceMaterializer::NullImageDescriptor). These are the words after the snapshot's own substitutions: a T# of an inactive source, an optional T# with undefined words and an unbound GCN sampled image are all zero there, a registered sampled-array view can be rewritten, and a GCN guest's V# word 1 is masked and word 3 recomputed. A result patched from the masked result memo takes the words of its own snapshot.SpecializationTracegains the words;RecompileResultkeeps the same pointer, sosizeof(RecompileResult)stays 584.; ...), the words of both sides in hex, 4 for a V# and 8 for a T#:...; buffer[0] raw 63e33400 00007ff7 00000080 31014fa8 (bound) -> 00000000 00000000 00000000 31014fac (null)...; image[0] raw f763e323 c150007f 00000007 90000fac 00000000 00000000 00000000 00000000 (bound) -> f763e323 c140007f 00000007 00000fac 00000000 00000000 00000000 00000000 (null)The text before them is unchanged. A slot that stays null or stays bound prints no words.
Without
APS5_TRACE_SPECIALIZATION_VARIANTSnothing is kept, printed or written, and the modules do not change. The first and fourth commits change recompiler sources, so an existing shader disk cache is rebuilt once, as after any recompiler change; the second and third change only the driver, its tests and the documentation.Tests:
agc_pipeline_variant_trace(host only):image[2].w; the previous boot's values with other SPIR-V print one line with 0 differing values; an identical module, a repeated one, a new program and the previous boot's other module print none; a module nearer to the second of two recorded modules is compared with the second;agc_driver_pipeline_variant_trace_line(Vulkan):image_loads of one image, with a bound32_UINTT#, a bound32_SINTone, a null one and a bound11_11_10_UINTone, all with the same selectors, and checks what each load read and the three pipeline lines:uint 2d->sint 2d,sint 2d-> mode 0float 2d, and mode 0float 2d->uint 2d conversion=34, each with 2 access sites, no selector named and the unfolded module larger than the folded one;DST_SEL_Xand format kept, base and size 0; every lane reads 0) between two bound ones, so it prints 3 pipeline lines, and the two around the null one end with the raw words of both V#s.agc_driver_pipeline_variant_trace_line_modulesruns that test with and without the switch and compares every module's word count and content hash.agc_driver_pipeline_variant_trace_line_bootsruns it three times with the file. The second boot reads the first boot's 8 modules of 2 programs, prints no line and writes the same records. Against a copy whoseimage[0].wvalues were changed from 7 to 1, the 4 image modules print one line each, namingimage[0].w 0x1->0x7of the same SPIR-V.What it does not do:
APS5_NO_PIPELINE_JOURNAL(orANYPS5_NO_SHADER_CACHE, which also keeps the journal off) every module is. A module read from the shader disk cache is traced like a new one.Tested
Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release,
-DBUILD_TESTING=ON -DANYPS5_RELINKER_CLI=ON -DANYPS5_VIDEO_OUT_TEST_DRIVER=windows, NVIDIA GeForce RTX 4090 (driver 621.24), Khronos validation layer 1.4.363, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layerin every run below. This PR's head is13dd65dbfc, on #28296's headd6f40c49be; every result below is from13dd65dbfcunless it names another commit, built from a clean tree.ctest(no-R,--parallel 8) ond6f40c49beand on this PR, each in its own build directory with the same configuration:d6f40c49be: 7430 tests, 7393 passed, 36 skipped, 1 not passing;Validation Warninglines (Undefined-Value-ShaderOutputNotConsumed-DynamicRendering84,Undefined-Value-OutputNotWritten-DynamicRendering3,Undefined-Value-ShaderOutputNotConsumed1,VALIDATION-SETTINGS1), and noVUID-orValidation Errorline.agc_driver_linear_target_import_creation("private gate: a color target's import of direct memory under the settle floor was made where it would be compared"), which failed 5 of 5 times one at a time ond6f40c49be. Its test was fixed onmainin131fdc1734, afterf61eb307c0, themaincommit #28102 builds on; it passes onmain2af8e79edf.agc_test (2345) withAPS5_TRACE_SPECIALIZATION_VARIANTS=1as well, so the trace and the raw words are kept for every specialized compute module these tests create (1164variantlines and 6pipelinelines, all the trace line test's, 4 of which end with raw words; no boot file): 2318 passed, 26 skipped, and 1 not passing,agc_driver_linear_target_import_creation, which fails ond6f40c49bewith the switch set too; the layer inserted in 1677 test outputs, noVUID-line.agc_pipeline_variant_traceandagc_driver_pipeline_variant_trace_linewith_untraced,_default_size,_modulesand_boots), 20 times in a row, one at a time: 120 of 120 runs passed, noVUID-line; the longest run took 1.9 s (_boots). In every run_modulesfound the same 9 module entries (8 distinct; word count and content hash) with and without the switch.tools/vulkan_validation_gate.py,d6f40c49beagainst this PR,--repeat 5 --gpu NVIDIA, with the 6 tests both have that create a Vulkan instance (agc_driver_pipeline_variant_trace_linewith_untracedand_default_size,agc_driver_image_null_type_wave64,agc_driver_image_d16_load,agc_driver_null_buffer_specialization): complete, exit 0, 10 of 10 iterations clean (5 per side), 60 test runs, none failed or skipped, the layer inserted in all of them, and no new diagnostic. The new_modulesand_bootstests are not ond6f40c49be, so the gate cannot take them; they are in the 20 runs above.0197c133ea(before the third and fourth commits), from the earlier description:APS5_DUMP_COMPUTE_PIPELINEScaptures ofagc_driver_pipeline_variant_trace_line_untraced,agc_driver_image_null_type_wave64,agc_driver_image_d16_load,agc_driver_null_buffer_specialization,agc_driver_image_table_variants,agc_driver_image_sint8,agc_driver_image_srgb_loadandagc_driver_image_converted_unorm: all 74 capturesd6f40c49bewrites were byte-identical on this PR, with the switch unset and with it set, and this PR's 78 were byte-identical with and without the switch;agc_driver_pipeline_variant_trace_linewith the file, the first boot'simage[0].wvalues changed from 7 to 1 before the second, printed[specialization-variant] program 0x3a5000000100 against the previous boot: 1129 SPIR-V words (31575 unfolded), the nearest module of 4 in the previous boot 1129 (31575 unfolded, the same SPIR-V); differs from the previous boot's module in 1 of 39 values: image[0].w 0x1->0x7; image[0] mode 0x4 (uint 2d) -> 0x4 (uint 2d): 33 modes, 2 access sites, 66 mode bodies in 28556 unfolded wordsand one such line for each of the other three image modules (_bootschecks the same at this head).specializ,variant,identity,trace,shader_disk_cache,spirv_module,image_null_type,image_d16_load,image_sint8,image_srgb_load,image_converted_unorm,image_table_variants,null_bufferorbuffer_descriptor_runtime(247), once without and once withAPS5_TRACE_SPECIALIZATION_VARIANTS=1: 246 passed both times, noVUID-line and no line reporting the layer missing.agc_driver_image_d16_load, with "image_load d16 of 16_FLOAT texel 0x00007c01: v10 is 0x00007e01" (lavapipe quiets the signalling NaN); in the earlier run it failed 5 of 5 times ond6f40c49betoo.0197c133ea, the first commit alone (2162f70930): its five trace tests passed.python3 -I tools/check_conventions.py --base d6f40c49bewith this title and body: all checks pass.python3 tools/debt_fold.py --checkpasses,python3 tools/check_test_registration.pyon the build directory passes (3766 test executables, none built and not run), and the branch merges withmain76d0a4a7dcwithout a conflict.python3 tools/pr_overlap.py --branchfails closed: it could not compare 120 open pull requests that touch the same files, and lists 16 whose changes conflict with this branch: 15 of them conflict with #28296's head alone too, and the one this PR adds is #14871, whose signature changes inResourceMaterializer.hppsit next to the insertedRuntimeImageModeName(adjacent lines, no shared function). It also lists #28102, #28295 and #28390, which add the same new files, because #28296 builds on #28102's first three commits and #28295 and #28390 on #28102.Checklist
d6f40c49be, not on currentmain(see Depends on); 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)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T10:48:20Z.
Review: COMMENTED
Reviewed — comments
The review is incomplete because only selected code paths were inspected, so there is not enough evidence for a formal merge decision.
What I ran
Reviewed prepared patch context for head
0197c133eaf45a8b04538b6be7600b95b4b02901. No tests or build commands were run; the reported test results are author supplied.Results
Findings
Blocking
None identified in the inspected portions.
Non-blocking
No specific code feedback from the inspected portions.
Not verified
The complete patch and all changed files were not reviewed. The manifest lists 26 changed files; targeted repository source was read for
VulkanDevice.cpp,Recompiler.cpp, andSpirvSpecialization.cpp. Patch portions were inspected, but not all changed hunks. The full text ofVulkanDevice.cppis excluded from the prepared files because it is too large; only targeted lines were read throughrepo_read.py. No tests were run, and author reported test results were not independently verified.To get this to a good state
Complete review of the remaining changed files and relevant hunks before making a formal approval decision.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T10:55:32Z.
Review: COMMENTED
Actionable comments posted: 2
Architecture findings (2)
Advisory architecture findings (2)
c8956417-ce05-44dd-8b6f-3efcd01dbd39Reviewing files that changed from the base of the PR and between
dd5412d54eand0197c133ea.core/libs/prx/libSceAgcDriver/Execution/include/PipelineVariantTrace.hppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/PipelineVariantTrace.cppcore/libs/prx/libSceAgcDriver/tests/PipelineVariantTraceBoots.cmakecore/libs/prx/libSceAgcDriver/tests/PipelineVariantTraceModules.cmakecore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/SpirvModule.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_pipeline_variant_trace_line_tests.cmakecore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_runtime_formatted_store_tests.cmakecore/libs/prx/libSceAgcDriver/tests/cmake/agc_pipeline_variant_trace_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/BufferDescriptorRuntime.cppcore/libs/prx/libSceAgcDriver/tests/execution/NullBufferSpecialization.cppcore/libs/prx/libSceAgcDriver/tests/execution/PipelineVariantTraceLine.cppcore/shader/recompiler/CMakeLists.txtcore/shader/recompiler/CompiledVariant.hppcore/shader/recompiler/Optimization/include/Optimization/DescriptorBindingBuilder.hppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvSpecialization.hppcore/shader/recompiler/SpirvBackend/src/SpirvInstructionOperands.hppcore/shader/recompiler/SpirvBackend/src/SpirvSpannedUniformity.cppcore/shader/recompiler/SpirvBackend/src/SpirvSpecialization.cppdocs/dev/ENVIRONMENT.mddocs/dev/debt/changes/shader-pipeline-variant-identity.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-11-30T11:20:04Z.
Review: COMMENTED
Reviewed — comments
The main trace and boot-file paths were inspected, but the review is incomplete because several changed source ranges were not read and no checks were run.
What I ran
Reviewed head
ade69c3091e551e6863a131558106c446e6d0fd2. No build or tests were run; the prepared description reports author-run checks.Results
Negative control
Not run.
Findings
Blocking
None verified.
Non-blocking
No specific optional code changes identified in the portions inspected.
Sources
Reviewed the prepared description, commit list, manifest, diff, review-folder README, the available
VulkanDevice.cpptrace call site, and portions ofPipelineVariantTrace.hpp,PipelineVariantTrace.cpp,Recompiler.cpp, and related diff sections.Not verified
The changed files listed in the manifest include 27 files. The diff was not read in full, and not every changed line or changed file was inspected. In particular, most test and recompiler changes, the full SPIR-V normalization implementation, and full documentation changes were not verified. No independent build, test, or runtime checks were performed. The author-reported Windows and Linux checks were not rerun.
To get this to a good state
Nothing is required. Optional: complete the review of the remaining changed lines and run the relevant checks before making a formal decision.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T11:26:17Z.
Review: COMMENTED
Architecture findings (2)
Advisory architecture findings (2)
ccaeb117-c8a6-427a-ab49-744034c59e7aReviewing files that changed from the base of the PR and between
0197c133eaandade69c3091.core/libs/prx/libSceAgcDriver/Execution/include/PipelineVariantTrace.hppcore/libs/prx/libSceAgcDriver/tests/PipelineVariantTrace.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T21:21:14Z.
Review: COMMENTED
Reviewed — no blocking findings
No blocking defect was verified in the portions inspected; this review is incomplete because most changed files were not inspected.
What I ran
Reviewed head
13dd65dbfcaa072ae3ce0edd2ccad48755e0ec34; no merged-preview check or tests were run. I inspected the prepared diff and selected source ranges. No build or test tool was run.The reader command is shown by its filename; its logging attempt failed because the review folder is read-only, but it returned the requested source range. I also read portions of
PipelineVariantTrace.hpp,Recompiler.hpp,Recompiler.cpp,SpirvInstructionOperands.hpp,SpirvSpecialization.cpp, andtests/SpirvModule.cpp.Results
Negative control
Not run; no tests were run.
Findings
Blocking
None verified in the inspected portions.
Non-blocking
No code feedback offered; the review is incomplete.
Not verified
The prepared manifest lists 27 changed files as reviewed. Only portions of 7 changed paths were inspected:
core/libs/prx/libSceAgcDriver/Execution/include/PipelineVariantTrace.hpp,core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp,core/shader/recompiler/Recompiler.hpp,core/shader/recompiler/Recompiler.cpp,core/shader/recompiler/SpirvBackend/src/SpirvInstructionOperands.hpp,core/shader/recompiler/SpirvBackend/src/SpirvSpecialization.cpp, andcore/libs/prx/libSceAgcDriver/tests/SpirvModule.cpp. The other 20 changed paths were not inspected.files.jsonreports no files excluded by rule. Tests, builds, and author-reported results were not independently verified.To get this to a good state
Nothing is required. Optional: inspect the remaining changed files before treating the review as complete.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T21:25:01Z.
Review: COMMENTED
Architecture findings (3)
Advisory architecture findings (3)
f35e11e1-fd41-4476-8ef9-3a13aaa760a6Reviewing files that changed from the base of the PR and between
ade69c3091and13dd65dbfc.core/libs/prx/libSceAgcDriver/Execution/include/PipelineVariantTrace.hppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/PipelineVariantTrace.cppcore/libs/prx/libSceAgcDriver/tests/PipelineVariantTraceBoots.cmakecore/libs/prx/libSceAgcDriver/tests/execution/PipelineVariantTraceLine.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppdocs/dev/ENVIRONMENT.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 ligmaSec on 2026-12-03T18:06:09Z.
Review: COMMENTED
OpenBootFilereads and truncates the user-selected comparison file, thenNextBootkeeps writing through that stream. Its mutex only protects one process. Two overlapping boots using the same trace path can truncate each other's records or write from stale offsets, leaving a mixed or unreadable baseline. Can each boot write to its own file and publish the finished snapshot, or hold an exclusive lock for the lifetime of the writer?Source review at
13dd65dbfc. On Linux, the scalar and shader disk cache CTests passed on pinned main and the merge with this head. Both scalar runs inserted Khronos validation layer 1.4.369 with shader caching disabled and showed no missing-layer messages orVUID-errors. The candidate module, boot and pipeline-variant trace fixtures also passed. Those fixtures exercise trace output without creating a Vulkan instance.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.