glsl

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 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

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(p *shaderir.Program, version GLSLVersion, projectionMatrixUniformIndex int) (vertexShader, fragmentShader string)

Compile compiles p into GLSL vertex and fragment shaders.

projectionMatrixUniformIndex is the index of the projection matrix uniform variable, or -1 for no adjustment. While the projection matrix's Y scale is negative, the fragment shader's position, Y derivatives, and facing are adjusted as if the window coordinates started at the top.

func Fragment

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

Fragment returns p's fragment entry point as a function named name of GLSL 3.30 and GLSL ES 3.00, for a renderer's fragment shader to call, after the uniforms (U0, U1, ...), the textures (sampler2D T0, T1, ...) and the functions it reaches:

vec4 name(vec4 position, ...varyings)

The position counts its y from the top of the target, as the renderer passes it.

func FragmentPrelude

func FragmentPrelude(version GLSLVersion) 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 std140 uniform block of Fragment, and the block's size, a multiple of 16: a vector of 3 takes the room of 4, and an array's elements and a matrix's columns are 16 bytes apart at least.

func VertexPrelude

func VertexPrelude(version GLSLVersion) string

Types

type GLSLVersion

type GLSLVersion int
const (
	GLSLVersionDefault GLSLVersion = iota
	GLSLVersionES300
	GLSLVersion430
	GLSLVersionES310
)

type Options

type Options struct {
	// FlipY is a boolean expression of the renderer's, true where GL's
	// window y counts up, as the position's does not, which negates dFdy;
	// "" where it never does.
	FlipY string
	// Block, unless empty, names a uniform block, laid out as std140
	// (UniformLanes says how), whose members the uniforms are.
	Block string
	// FlipRows, unless empty, names a uniform ivec4 that the renderer sets,
	// which gives, for each texture, the height of an image whose rows go
	// up, as GL's framebuffers draw them, or 0: texel reads flip those.
	FlipRows string
}

Options are how Fragment writes a program for a renderer.

type PipelineSource

type PipelineSource struct {
	VertexSource   string
	FragmentSource string
	ComputeSource  string
	WorkgroupSize  [3]uint32
	UniformBlocks  []UniformBlockSlot
	StorageBuffers []StorageBufferSlot
	StorageImages  []StorageImageSlot
	SamplerPairs   []SamplerPair
}

PipelineSource holds GLSL 3.30 / 4.30 or GLSL ES 3.00 / 3.10 vertex, fragment, and/or compute shader sources plus resource binding tables.

func CompilePipeline

func CompilePipeline(p *shaderir.Program, version GLSLVersion) (PipelineSource, error)

CompilePipeline emits GLSL 3.30/4.30 Core or GLSL ES 3.00/3.10 vertex, fragment, and/or compute shaders for a 3D GPU pipeline program. Vertex shaders automatically remap canonical WebGPU [0, 1] clip-space depth to OpenGL [-1, 1] before exit. Compute shaders and read/write storage buffers require GLSLVersion430 or GLSLVersionES310.

type SamplerPair

type SamplerPair struct {
	Name           string
	Unit           uint32
	TextureGroup   uint32
	TextureBinding uint32
	SamplerGroup   uint32
	SamplerBinding uint32
	HasSampler     bool
	TextureType    shaderir.BasicType
	Comparison     bool
}

SamplerPair records one synthesized GLSL combined sampler uniform for a static (texture, sampler) binding pair referenced by sampling calls.

type StorageBufferSlot

type StorageBufferSlot struct {
	Group     uint32
	Binding   uint32
	BlockName string
	Slot      uint32
	ReadOnly  bool
}

StorageBufferSlot records the GLSL SSBO block name and binding slot for a @group(G) @binding(B) storage buffer.

type StorageImageSlot

type StorageImageSlot struct {
	Group   uint32
	Binding uint32
	Name    string
	Slot    uint32
}

StorageImageSlot records the GLSL image uniform name and binding slot for a @group(G) @binding(B) storage texture.

type UniformBlockSlot

type UniformBlockSlot struct {
	Group     uint32
	Binding   uint32
	BlockName string
	Slot      uint32
}

UniformBlockSlot records the GLSL uniform block name and flattened binding slot for a @group(G) @binding(B) uniform buffer.

Jump to

Keyboard shortcuts

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