Documentation
¶
Index ¶
- Constants
- func Compile(p *shaderir.Program) (shader string)
- func Fragment(p *shaderir.Program, name string) string
- func Prelude() string
- func UniformLanes(p *shaderir.Program) (lanes []int, size int)
- func UniformLayout(p *shaderir.Program) (offsets []int, size int)
- type BindingSlot
- type PipelineSource
Constants ¶
const ( VertexName = "Vertex" FragmentName = "Fragment" )
Variables ¶
This section is empty.
Functions ¶
func Fragment ¶
Fragment returns p's fragment entry point as a Metal function named name, for a renderer's fragment shader to call, after the functions it reaches and the prelude:
float4 name(constant Uniforms& uniforms, texture2d<float> T0, ..., float4 position, ...varyings)
The uniforms parameter is left out when p has none, and there is a texture parameter for each of p's textures.
func UniformLanes ¶
UniformLanes returns, for each lane of p's uniforms (in order, columns of matrices, elements of arrays: Type.DwordCount of each), its offset in bytes in the struct Uniforms of Fragment, and the struct's size.
func UniformLayout ¶
UniformLayout returns where each of p's uniform variables lies in the struct Uniforms of Fragment, in bytes, and the struct's size, as Metal lays it out: a vector of 3 takes the room of 4, a matrix is its columns, and an array's elements are as far apart as their alignment makes them.
Types ¶
type BindingSlot ¶
type BindingSlot struct {
Group uint32
Binding uint32
Kind shaderir.BindingKind
Slot uint32
}
BindingSlot records the Metal buffer, texture, or sampler index assigned to a WGSL @group(G) @binding(B) resource.
type PipelineSource ¶
type PipelineSource struct {
Source string
VertexEntry string
FragmentEntry string
ComputeEntry string
WorkgroupSize [3]uint32
Slots []BindingSlot
}
PipelineSource holds Metal shader source and resource slot mappings compiled from a GPU pipeline shaderir.Program.
func CompilePipeline ¶
func CompilePipeline(p *shaderir.Program) (PipelineSource, error)
CompilePipeline emits Metal Shading Language for a 3D GPU pipeline program with @vertex, @fragment, and/or @compute entry points and explicit @group/@binding resources.