Nx.Vulkan.ShaderTemplate (nx_vulkan v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

Render a %FamilySpec{} to GLSL source.

Functions

render(spec)

Render a %FamilySpec{} to GLSL source.