Skip to content

Games cook their assets with Assetyard, with hot reload in Debug - #31

Merged
lithiumtoast merged 3 commits into
mainfrom
assets-cooked-in-games
Dec 1, 2026
Merged

lithiumtoast merged 3 commits into
mainfrom
assets-cooked-in-games

Conversation

@lithiumtoast

Copy link
Copy Markdown
Member

Part 3 of 3 for assets and hot reload, after Assetyard (#29) and loading shaders with hot reload (#30).

GameApp SDK

  • Copying assets (GameAssetsDirectory, still Assets by default):
    • Assets/Cooked's contents are copied next to the executable into Assets/, so a game loads Assets/Shaders/Sprite.frag.spv;
    • Assets/Raw is never copied, but IDEs still show it;
    • other files directly in Assets/ are copied as before, so games without Assetyard keep working;
    • Assetyard's *.assetyard-tmp files are never copied.
  • Debug builds record the project's Assets/Cooked path as AssemblyMetadata. bottlenoselabs.SDL (SDL: load shaders from cooked assets by name, with hot reload #30) reads it to load assets straight from there and turn hot reload on. Release builds don't have it.
  • A build message when Assets/Raw exists but was never cooked.

bl-game template

  • .config/dotnet-tools.json pins bottlenoselabs.Assetyard to the SDK's own version.
  • An Assets/Raw/ folder, and Assets/Cooked/ in .gitignore.
  • A README section on dotnet tool restore, dotnet assetyard cook and watch.

Reusable workflows: cs-build.yml and cs-game-publish.yml restore tools and run dotnet assetyard cook before building when .config/dotnet-tools.json has Assetyard. Existing repositories need no workflow changes.

src/cs/games/Lava: blobs of lava drawn by one fragment shader over the whole window with SDL's GPU API, given the time and the window's size. Its colors are in an include file, to try hot reload.

  • GpuCommandBuffer.PushVertexShaderUniformData<T> and PushFragmentShaderUniformData<T> push any unmanaged value.
  • It needs a GPU, so CI builds it and cooks its shaders with Assetyard from source, but doesn't run it.

Tests (test.sh)

  • The consumer game has a Raw and a Cooked file. In Debug and in the publish folder (inside the macOS .app or Linux AppDir), it checks that the cooked and plain files are in Assets/, and that Raw and Cooked aren't.
  • Debug loads from the project's Assets/Cooked with hot reload; Release loads from next to the executable without it.
  • The template's game restores its pinned Assetyard from the local feed, cooks a raw file, and the file reaches the published game. It uses its own DOTNET_CLI_HOME, because the .NET CLI remembers local tool paths per user.
  • CI's build jobs now also download SDL_shadercross, for the Assetyard packages test.sh packs.

Checked locally on macOS

  • test.sh passes, and the solution builds.
  • Lava ran with assetyard watch. The Debug build found Assets/Cooked by itself, and editing Palette.hlsli while it ran reloaded both shaders and rebuilt the pipeline.

After merging, before releasing: nuget.org's trusted publishing policy has to allow bottlenoselabs.Assetyard*, since new bl-game repositories restore it from nuget.org.

GameApp SDK: Assets/Cooked's contents are copied next to the executable as Assets/, Assets/Raw never is, and other files in Assets/ are copied as before. Debug builds record the project's Assets/Cooked in AssemblyMetadata, so bottlenoselabs.SDL loads assets from it and reloads what assetyard watch cooks again. A message says when Assets/Raw was never cooked.

bl-game template: .config/dotnet-tools.json pins Assetyard to the SDK's version, an Assets/Raw folder, Assets/Cooked/ in .gitignore, and a README section. cs-build.yml and cs-game-publish.yml cook assets first when the tool manifest has Assetyard.

src/cs/games/Lava: a shader over the whole window with SDL's GPU API, for trying hot reload. GpuCommandBuffer gets PushVertexShaderUniformData and PushFragmentShaderUniformData for any unmanaged value. CI cooks the games' assets with Assetyard from source; test.sh checks the copied assets in Debug and publish, Debug's hot reload, and the template's Assetyard.
A GitHub release download failed with HTTP 618 for a moment and failed the Linux publish; retry up to 3 times on any error.
@lithiumtoast
lithiumtoast merged commit fbc902a into main Dec 1, 2026
27 checks passed
@lithiumtoast
lithiumtoast deleted the assets-cooked-in-games branch December 1, 2026 00:00
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