Repository navigation
perf(agc): build compute shaders' front end when they are registered - #473
adriadam10 wants to merge 2 commits into
Conversation
|
Thanks for this. Since my #457 landed, the build checks every driver call into the recompiler against a reviewed list, and main plus this PR now stops at the shader cache version step:
Separately, @boykopovar, the background worker that builds compute shaders at registration is a design call for you. It reads |
|
Thanks! Added The rebase also showed a real break: since #316 a wave32 dispatch recompiles for |
0260c7c to
33555ae
Compare
|
Thanks, both fixes look right to me. The first commit is the same patch as #471, which has since merged, so that part drops out on merge. Note that #469 also edits From my side only the design question is left: @boykopovar, the background worker that builds compute shaders at registration (reading |
Co-Authored-By: Claude <noreply@anthropic.com>
Since boykopovar#316 a wave32 dispatch recompiles for a 32-wide subgroup target, so preparing for the device target built a source the dispatch never looked up. PrepareSource is added to the shader cache's reviewed names. Co-Authored-By: Claude <noreply@anthropic.com>
33555ae to
3de13ca
Compare
|
Rebased on current
|
|
Closing: #639 moves the whole shader recompilation to |
What
The first commit is #471; this pull request is the second one.
Builds a compute shader's front end when the title registers it, on a worker thread, instead of at its first dispatch (the move discussed in #361, for compute only). With #471 the first variant compiled for a cache entry takes the program the entry was built with, so a dispatch of a prepared shader only specializes and emits.
RegisterShaderhands compute binaries (type 0) toShaderPreparation. It predicts the request a dispatch will make from the header: the code at its registered address, the user SGPR count fromCOMPUTE_PGM_RSRC2, the stage info fromCOMPUTE_NUM_THREAD_*/COMPUTE_PGM_RSRC2(DecodeComputeStageInfo, as the dispatch does), the wave size fromspecials->dispatch_modifierbit 15 (CS_W32_EN, the bit the dispatch reads from its initiator), and the current device's target.ShaderRecompiler::PrepareSource, which runsgetSource. A dispatch that arrives while the entry is being built waits on the entry's mutex, as two dispatches do today, so it never skips or duplicates work.APS5_NO_SHADER_PREPARATION=1turns it off. The worker is stopped and joined inDriver::stop, before the device is released.ShaderRecompiler::FrontEndBuilds()counts front-end runs; the test uses it.Not covered: whether
dispatch_modifieris what titles pass tosceAgcCbDispatch. I found no reference that confirms it; the name and the matching bit are the evidence. If it is not, entries are built for the wrong wave size and dispatches behave as today. Pixel and vertex shaders depend on draw state and are left for later.Tested
agc_driver_pixel_helper_lanes, which fails the same way onmainon this machine.agc_driver_shader_preparation(execution test, skips without Vulkan): registers a compute shader throughAgcDriverRegisterShader_nid_postfix, waits for exactly one front end, dispatches it through an ACB and checks the stored values and that the dispatch ran no front end; then dispatches it at the other wave size and checks it builds its own and still stores the right values. WithAPS5_NO_SHADER_PREPARATION=1it fails at the wait; with a header that predicts the wrong wave size it fails with "ran the front end again". Passes 3/3 runs, and under AddressSanitizer.FrontEndBuilds()with and withoutAPS5_NO_SHADER_PREPARATION=1over the same scene would show how many dispatches it covers.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)