Embed SPIR-V shaders into binary instead of loading from disk #30
+177
−41
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.
Summary
This PR refactors shader loading to embed compiled SPIR-V shaders directly into the application binary as C++ headers, eliminating the need to distribute and load shader files from disk at runtime.
Key Changes
cmake/EmbedShaders.cmakescript that converts compiled SPIR-V binary files into C++ headers with inline constexpr arrays and a registry function for shader lookup by namecompile_shaders()function to generate anembedded_shaders.hppheader after shader compilation, and removed the post-build copy step that distributed shader filessrc/core/shader_loader.hppwithloadEmbeddedShader()function that retrieves shader bytecode from embedded data instead of reading from diskPipeline::readFile()insrc/core/pipeline.cppto use the new embedded shader loaderreadShaderFile()insrc/render/skeleton_renderer.cppto use the new embedded shader loaderImplementation Details
EmbedShaders.cmakescript reads compiled SPIR-V files as hex and generates a C++ header with:constexpr uint8_tarrays for each shaderstd::span<const uint8_t>getShader(std::string_view name)registry function for runtime lookupBenefits
https://claude.ai/code/session_01UadMuMoxicsQ6dJ1vvEURj
Greptile Overview
Greptile Summary
This PR successfully refactors the shader loading system to embed compiled SPIR-V shaders directly into the application binary as C++ headers, eliminating runtime file I/O dependencies. The implementation is clean, well-structured, and maintains backward compatibility.
Key changes:
cmake/EmbedShaders.cmakescript that converts SPIR-V binaries to C++ headers withconstexprarrays and a name-based lookup registryCMakeLists.txtto integrate shader embedding into the build pipeline and removed the post-build shader file copyingsrc/core/shader_loader.hpputility that wraps the embedded shader access with error handlingPipeline::readFile()andreadShaderFile()to use embedded shaders while maintaining API compatibility by extracting filenames from pathsBenefits:
Confidence Score: 5/5
Important Files Changed