Documentation
Docs/en/reference/effect-format/baking.md
Effect Baking And Backends
Generated reference. Do not edit directly. Update
BuildTools/EffectFormatInterface.json, then runpython BuildTools/docs_effect_format.py --write.
| Index | Syntax | Render state | Resources | Baking | Runtime | Validation | Canonical JSON | Guide |
Every pass produces one metadata file and seven flavors per shader stage. The original .fofx source is copied to baked resources because the runtime still reads [Effect] state from it.
Stage flavors: spv, spv_sdl, glsl, glsl_es, hlsl, msl_mac, msl_ios
| Stable ID | Rule | Requirement | Why | Source |
|---|---|---|---|---|
effect-format.baking.compiler-prelude |
Generated shader prelude | The baker prepends ‘#version <Version> es’, ‘precision highp float’, MAX_SCRIPT_VALUES, and, in 3D builds, MAX_BONES and MAX_TEXTURES before ShaderCommon and stage text. | Authored shaders share one compile-time shape contract and must not duplicate these directives. | Source/Tools/EffectBaker.cpp |
effect-format.baking.compiler-target |
glslang target environment | Both stages compile as GLSL for a Vulkan 1.0 client and SPIR-V 1.0 target, then link and build reflection once per pass. | All backend flavors derive from the same validated linked program. | Source/Tools/EffectBaker.cpp |
effect-format.baking.link-interface |
Stage interface validation | Vertex and fragment stages must parse, link, and expose a valid reflection model for every pass. | Location/type mismatches and syntax errors fail the resource bake before runtime. | Source/Tools/EffectBaker.cpp |
effect-format.baking.metadata |
Per-pass metadata | Each pass emits an info artifact with [EffectInfo] native bindings, [EffectInfoSdl] per-stage dense slots and resource counts, and [EffectVertexInputs] listing every live vertex input of the first stage as Location<N> = <GLSL type> (an input without an explicit location is recorded as Unlocated<N>). | Runtime backends consume reflection results without running glslang. | Source/Tools/EffectBaker.cpp |
effect-format.baking.vertex-input-check |
Vertex layout check | EffectVertexInputs::Check matches the recorded inputs of every pass against Vertex2D (locations 0..3: vec3, vec4, vec2, vec2) or Vertex3D (locations 0..8). It rejects a missing baked effect, a pass without [EffectVertexInputs], an input without an explicit location, a location beyond the layout and a type other than the declared one. The bake applies it with Vertex2D to every authored FOFRM root Effect after all packs have baked, and to Item.SpriteEffect values while prototypes and maps are validated; ImGui, QuadSprite and Primitive share Vertex2D, so a usage distinction among them is not checked. | An effect read with the wrong vertex layout draws garbage or fails at pipeline creation on the player’s machine, so the mismatch must stop the bake. | Source/Tools/EffectBaker.cpp, Source/Tools/Baker.cpp, Source/Tests/Test_EffectBaker.cpp |
effect-format.baking.native-flavors |
Native and cross-compiled flavors | Each stage emits native Vulkan SPIR-V, desktop GLSL 330, GLSL ES 300, HLSL Shader Model 4.0, and Metal source for macOS and iOS. | One source effect supports the active renderer backends without project-side shader forks. | Source/Tools/EffectBaker.cpp |
effect-format.baking.sdl-remap |
SDL_GPU descriptor remap | The baker copies native SPIR-V, rewrites descriptor sets and bindings to SDL_GPU’s per-stage convention, and emits the result as spv_sdl. Metal source is compiled from the remapped module. | Native Vulkan bindings remain untouched while SDL_GPU gets dense stage-local slots. | Source/Tools/EffectBaker.cpp |
effect-format.baking.source-copy |
Baked source copy | The original .fofx source is written to the baked resource set after all pass artifacts. | RenderEffect reparses [Effect] state at runtime; the source file is part of the runtime artifact set. | Source/Tools/EffectBaker.cpp, Source/Frontend/Rendering.cpp |
effect-format.baking.incremental |
Incremental output set | The bake checker tracks the source copy, pass metadata, and every stage/flavor artifact for every declared pass. | A missing or stale flavor must make the effect eligible for rebaking. | Source/Tools/EffectBaker.cpp |