# `Nx.Vulkan.ShaderTemplate`
[🔗](https://github.com/borodark/nx_vulkan/blob/main/lib/nx_vulkan/shader_template.ex#L1)

Phase 1 — templated GLSL shader synthesis.

Renders a chain shader from a per-family spec. The template skeleton is
~80 lines of GLSL identical across families (push-constants, bindings,
per-thread state, leapfrog control flow, parallel reduction). The spec
fills in three holes:

  * `push_fields`   — additional push-constant scalars
  * `grad_expr(qi)` — `dlogp/dq` formula referencing the position `qi`
  * `logp_expr(qi)` — per-element log-density contribution
  * `logp_final`    — how the workgroup-reduced sum becomes the
                       per-step `logp_chain[k]` (e.g. add a constant
                       host-side normalizer × n)

Call `render/1` with a `%FamilySpec{}` to get a GLSL source string.
Pipe to `Nx.Vulkan.Synthesis.compile/2` to land SPIR-V on
disk + load via Vulkan.

See `Nx.Vulkan.ChainShaderSpecs` for the catalog of family specs.

# `render`

Render a `%FamilySpec{}` to GLSL source.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
