Repository navigation
bottlenoselabs.SDL.ShaderCross.Native: the SDL_shadercross library for apps - #32
Merged
Merged
Conversation
…or apps that compile shaders while they run The libraries from lib/shadercross/<platform>/ (SDL_shadercross, DirectXShaderCompiler, SPIRV-Cross), without the tool or SDL, in runtimes/<rid>/native/ for the same runtime identifiers as bottlenoselabs.SDL.Native, which it depends on. The universal macOS build is packed for osx-arm64 and osx-x64. ext/build-shadercross.sh now names the libraries as .NET and SDL.Native do (libSDL3.dylib, libSDL3_shadercross.dylib; libSDL3.so, libSDL3_shadercross.so) and relinks them, so SDL_shadercross loads the app's own SDL. CI packs it with every platform, checks it has no SDL and depends on SDL.Native, and runs src/cs/tests/ShaderCrossNative, an app that compiles HLSL to SPIR-V through it and checks it loaded one SDL.
SDL's commit is no longer part of SDL_shadercross's cache key: the tool keeps the SDL it was built with, and apps using bottlenoselabs.SDL.ShaderCross.Native load SDL.Native's newer SDL, which SDL 3's stable binary interface allows. An SDL update no longer costs a 40-minute macOS build of DXC.
lithiumtoast
added a commit
that referenced
this pull request
Dec 1, 2026
…again for the same inputs (#34) Actions caches are deleted after 7 days unused, and a branch can only read its own and the default branch's. So a quiet week, or any change to a cache's key, means building SDL_shadercross again: about 40 minutes on a scarce macOS runner. This keeps every finished native build where it doesn't expire. **The store** - `ext/native-store.sh` keeps each platform's finished build of SDL or SDL_shadercross as a `.tar.gz` asset of one pre-release, `native-builds`, named after a hash of its inputs: for example `shadercross-native-osx-<hash>.tar.gz`. - Release assets don't expire, and every branch can read them. A `.tar.gz` also keeps the tool's executable permission. - The script creates the release the first time it uploads. It's marked as a pre-release and says it isn't a release of this repository. **The workflows** - `sdl-native.yml` and `shadercross-native.yml` look for each platform in the store first, then in an Actions cache, and only then build it. - **Writing:** runs on the default branch put builds into the store, including ones they found only in a cache, so existing caches move into the store without building again. Pull requests only read the store, so code that wasn't reviewed never puts binaries there. - **SDL** now builds and caches each platform on its own, like SDL_shadercross. It reads its old combined cache (`sdl-native-all-...`) once more, so the store gets SDL without building it again. That part can go once the store has this SDL commit. - **Permissions:** `main.yml` gives both native workflows `contents: write`, for the store, and `actions: read`, to list caches. **Checked** - **`ext/native-store.sh`:** `asset-name`, `has` against the real repository (no release yet) and an unknown command. `upload` and `download` first run on `main`, since pull requests don't write. - **Both lookup steps,** run locally against the real repository: SDL finds all six platforms in the combined cache, so no SDL builds, macOS included. SDL_shadercross finds `main`'s new caches, saved by `main`'s run after #32, which finished before this PR was opened. - `actionlint`. **After merging:** `main`'s next run uploads all eleven builds (6 SDL, 5 SDL_shadercross) from the caches into the store. After that, a build only happens when its inputs change. **To watch at the next release:** whether GitHub's automatic release notes compare against the `native-builds` pre-release instead of the previous version. Co-authored-by: Lucas Girouard-Stranks <lithiumtoast@users.noreply.github.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.
A native package for SDL_shadercross, as SDL.Native is for SDL, for .NET apps that compile shaders while they run, such as editors or modding tools. Load it with
[LibraryImport("SDL3_shadercross")]. C# bindings could come later, generated like SDL's.This doesn't make Assetyard smaller: a .NET tool package can't have package dependencies, so a tool always carries what it needs. Assetyard keeps its per-platform packages, 11–27 MB each.
The package
runtimes/<rid>/native/holdsSDL3_shadercross, DirectXShaderCompiler (dxcompiler,dxil) and SPIRV-Cross, fromlib/shadercross/<platform>/(Build SDL_shadercross for every platform #27). It leaves out theshadercrosstool and SDL.bottlenoselabs.SDL.Nativefor SDL, so an app loads one SDL.@loader_path/$ORIGIN). A plainruntimes/osx/didn't work for this.osx-arm64andosx-x64. That's about 24 MB extra; it could be thinned per architecture later.Zlib AND Apache-2.0 AND NCSA, with the license files inlicenses/.RequireShaderCrossToolsto require all of them.ext/build-shadercross.sh: the libraries now use the names .NET looks for and SDL.Native's name for SDL:libSDL3.dylibandlibSDL3_shadercross.dylib(were.0.dylib), andlibSDL3.soandlibSDL3_shadercross.so(were.so.0). Their load commands, install names and sonames are updated to match. Windows names were already right. The tool folder uses the same files, so the next build needs no extra step. The script changed, so CI rebuilds SDL_shadercross once, including about 40 minutes for macOS.Tests
src/cs/tests/ShaderCrossNative: an app that references the packed package from a local feed, compiles HLSL to SPIR-V through SDL_shadercross's C API, and checks the SPIR-V magic number. It also checks that the process loaded exactly one SDL library, from its own output, using dyld's image list on macOS and/proc/self/mapson Linux.main's passing run.Checked locally on macOS (with the renames applied to the existing macOS build)
ext/test-shadercross.shpasses.osx-arm64app. One SDL is loaded, SDL.Native's.