Skip to content

Shader Bundler for offline shader transpilation#130

Open
kunitoki wants to merge 7 commits into
dev/gpu_graphics_try_1from
dev/gpu_graphics_shader_bundler
Open

Shader Bundler for offline shader transpilation#130
kunitoki wants to merge 7 commits into
dev/gpu_graphics_try_1from
dev/gpu_graphics_shader_bundler

Conversation

@kunitoki

@kunitoki kunitoki commented Jul 8, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a new system for building, bundling, and embedding shader programs in the YUP library. The main changes are the addition of a standalone shader bundler tool, new CMake helpers to automate shader bundling and embedding, and updates to the graphics example to use this new workflow. This makes it easier to manage cross-platform shader assets and ensures shaders are compiled and embedded at configure time, even when cross-compiling.

Shader Bundling Tool and Build Integration:

  • Added a new standalone console tool, yup_shader_bundler, which takes .vert and .frag GLSL files and produces a .ysl bundle containing transpiled variants for all target shading languages (GLSL, ESSL, HLSL, MSL, WGSL). The tool is built as a host executable, ensuring it works during cross-compilation. (CHANGELOG.md, cmake/tools/shader_bundler/CMakeLists.txt, cmake/tools/shader_bundler/source/main.cpp) [1] [2] [3]

  • Introduced a new CMake helper function, yup_add_shader_bundle(), which builds the bundler tool (if needed), generates the shader bundle at configure time, and embeds the resulting binary as a linkable object library. This works transparently across platforms and cross-compilation scenarios. (cmake/yup_shader_bundler.cmake, cmake/yup.cmake) [1] [2]

Example Usage and Demonstration:

  • Updated the graphics example to use the new yup_add_shader_bundle() function, embedding the cube's vertex and fragment shaders and linking them into the example. (examples/graphics/CMakeLists.txt, examples/graphics/data/shaders/cube.vert, examples/graphics/data/shaders/cube.frag) [1] [2] [3]

  • Modified the SpinningCubeDemo to load shaders from the embedded bundle at runtime using ShaderBundle::loadFromData(), and to compile the GPU pipeline from the bundle rather than raw GLSL source strings. (examples/graphics/source/examples/SpinningCubeDemo.h) [1] [2]

These changes significantly improve shader asset management in YUP, streamline the build process, and provide a robust foundation for cross-platform graphics development.

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.40%. Comparing base (e3184f3) to head (ad34527).

Additional details and impacted files

Impacted file tree graph

@@                    Coverage Diff                     @@
##           dev/gpu_graphics_try_1     #130      +/-   ##
==========================================================
- Coverage                   78.40%   78.40%   -0.01%     
==========================================================
  Files                         704      704              
  Lines                       69768    69768              
==========================================================
- Hits                        54703    54699       -4     
- Misses                      15065    15069       +4     
Files with missing lines Coverage Δ
modules/yup_core/yup_core.cpp 100.00% <ø> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3184f3...ad34527. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant