msl

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	VertexName   = "Vertex"
	FragmentName = "Fragment"
)

Variables

This section is empty.

Functions

func Compile

func Compile(p *shaderir.Program) (shader string)

func Fragment

func Fragment(p *shaderir.Program, name string) string

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 Prelude

func Prelude() string

func UniformLanes

func UniformLanes(p *shaderir.Program) (lanes []int, size int)

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

func UniformLayout(p *shaderir.Program) (offsets []int, size int)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL