Repository navigation
feat(vk): built-in shaders from a folder with RX_VK_SHADER_DIR - #2878
Open
jordanella wants to merge 1 commit into
Open
jordanella wants to merge 1 commit into
jordanella wants to merge 1 commit into
Conversation
With RX_VK_SHADER_DIR=<folder>, each of the renderer's built-in shaders is taken from <folder>/<name>.spv (clear_vert.spv for clear_vert_spv.h) when that file is SPIR-V, and the log names it; otherwise, and unset, the compiled-in words. A shader edit can then be tried by compiling it into the folder and starting the game again, without a renderer build. The dev-loop proposal's B2 (NotRexed#2636). One lookup (gpu/vk/vk_builtin_spv.h, BUILTIN_SPV) serves the 52 compiled-in arrays the renderer uses; the FSR 3 tables carry each array's name. The folder is not taken from hookshot_env.txt (a _DIR switch). tests/test_builtin_spv.py builds the lookup and runs it against made-up files, and checks that no array is used around it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trying an edit to one of the renderer's own shaders (the texture decoders, the upscalers, frame generation, the write-back diff) takes a renderer build today, because their SPIR-V is compiled in. With
RX_VK_SHADER_DIRset, the renderer takes each of them from a folder when the file is there, so an edit is a glslang run and a restart. This is the dev-loop proposal's B2 (#2636), the Vulkan side of whatRX_WGSL_OVERRIDEdoes for WebGPU.Change
The switch:
RX_VK_SHADER_DIR=<folder>. Each built-in shader is taken from<folder>/<name>.spvwhen that file is SPIR-V, and the log names it once:<name>is the header's:clear_vert.spvforclear_vert_spv.h. A missing file means the compiled-in words, without a log line. A file that isn't SPIR-V (its length, or its first word) is named in the log with the reason, and the compiled-in words are used.One lookup:
gpu/vk/vk_builtin_spv.{h,cpp},builtin_spv(name, words, bytes), behind aBUILTIN_SPV(ARRAY)macro. A file is read once and kept for the process, as the compiled-in words are. It serves all 52 compiled-in arrays the renderer uses, invk_draw,vk_framegen,vk_fsr3,vk_fsr3fi,vk_fsr3_inputs,vk_memory,vk_reactive,vk_temporalandvk_texture. The two FSR 3 pass tables carry each array's name for it.Unset, nothing changes: the lookup returns the compiled-in words before looking at anything else.
Not from a shared
hookshot_env.txt: a folder of shader code is a_DIRswitch, soenv_line_allowedalready refuses it there. Only the environment the game is started with sets it.The headers stay generated from the sources, as before. The folder is for iteration only.
In the game
Windows 11, RTX 3080 (NVIDIA 621.14), this branch built with the Builder's steps, headless through the control bridge from a save, in Kokiri Forest:
astc_decoder_comp,bc_encoder_comp,block_linear_unswizzle_2d_compandwb_diff_comp, each logged once with the same size as the compiled-in one.wb_diff_comp.spvtwo bytes too long: in play, 22–29 fps, andvk: built-in shader wb_diff_comp: <folder>/wb_diff_comp.spv is not a whole number of words, or shorter than SPIR-V's header; the compiled-in one is used.An edited shader wasn't tried: there is no glslang on this PC. The files were the shipped words, so the run shows the path works, not a visible change.
Testing
tests/test_builtin_spv.py(new, game-free):gpu/vk/shadersandhost_shadersthatgpu/vkuses goes through the lookup (52 here; onmainit stops atvk_draw.cpp's seven);RX_VK_SHADER_DIRisn't taken fromhookshot_env.txt.vk_framegen.cpp(upscale_independent_test.cpp,framegen_resources_test.cpp,present_source_crop_test.cpp) defineBUILTIN_SPV_ARGSbeside their stand-in arrays, as the lookup is with the folder unset, so their pointer checks still hold.run_all.pyon Windows, rebased on today'smain: 157 pass;nx2/test_bc_storage_views.pyandtests/test_linux_driver_fault_guard.pyfail the same way onmainhere.fopen's, which is UTF-8 on Windows through the manifest.See #2636 (B2).
🤖 Generated with Claude Code