[Impeller] Add a Stage 2 pass to the Vulkan shader compilation pipeline.#40873
[Impeller] Add a Stage 2 pass to the Vulkan shader compilation pipeline.#40873auto-submit[bot] merged 2 commits intoflutter:mainfrom
Conversation
We just used to use the output of Stage 1 for Vulkan since it was already SPIRV. But that contained debugging information that bloated the size of the SPIRV and the resulting binaries. This reworks the compiler to add a second stage that strips the debug information. While stripping the debug information is effectively what happens, I couldn't find an existing utility in the compiler toolbox that does this. So the source files are processed again for stage 2, but this time without generating the debug information. Just a rudimentary size analysis of the generated SPIRV shows that just gathering all generated shaders in the out directory and applying GZip compression yields a 2.58x size reduction with the total size of all generated shaders being about ~48k. This bring the packaged shader size more in line with the other backends. Results of compression of these shaders in an actual APK may vary. Fixes flutter/flutter#119172 Fixes flutter/flutter#121619
| spirv_options.SetOptimizationLevel( | ||
| shaderc_optimization_level::shaderc_optimization_level_performance); | ||
| case TargetPlatform::kMetalIOS: { | ||
| SPIRVCompilerTargetEnv target; |
There was a problem hiding this comment.
It looks like every switch case declares one of these. If you hoist out the declaration you can avoid the {} in the cases.
There was a problem hiding this comment.
May I get this in another patch? The compiler needs some TLC. I'm going to get rid of the unknown platforms with optionals and rework this to explicitly reference Stage1 and Stage2.
There was a problem hiding this comment.
Does "Stage 1" mean source->spirv + reflection, and "Stage 2" mean spirv->target (ideally in Vulkan's case, spirv->optimized spirv)?
There was a problem hiding this comment.
Yeah, just the diagram in the readme.
|
|
||
| static void SetDefaultLimitations(shaderc::CompileOptions& compiler_opts) { | ||
| using Limit = std::pair<shaderc_limit, int>; | ||
| static constexpr std::array<Limit, 83> limits = { |
There was a problem hiding this comment.
Not sure why only clang on Windows doesn't like this line. Maybe it wants some explicit #include?
There was a problem hiding this comment.
Yeah, I moved this to another TU but didn't move the #include<array>.
We just used to use the output of Stage 1 for Vulkan since it was already SPIRV. But that contained debugging information that bloated the size of the SPIRV and the resulting binaries. This reworks the compiler to add a second stage that strips the debug information.
While stripping the debug information is effectively what happens, I couldn't find an existing utility in the compiler toolbox that does this. So the source files are processed again for stage 2, but this time without generating the debug information.
Just a rudimentary size analysis of the generated SPIRV shows that just gathering all generated shaders in the out directory and applying GZip compression yields a 2.58x size reduction with the total size of all generated shaders being about ~48k. This bring the packaged shader size more in line with the other backends. Results of compression of these shaders in an actual APK may vary.
Fixes flutter/flutter#119172

Fixes flutter/flutter#121619