interp

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 6 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

Overview

Package interp runs shaders on the CPU, for Golet's CPU renderer: it compiles a program of package shaderir into Go closures, which compute what the GPU renderers' code computes, within the rounding of their floats.

Values are lanes of 32 bits in a register file, floats as their bits, ints as their two's complement and bools as 0 and 1; vectors, matrices (by columns) and arrays are runs of lanes. Shaders call no function recursively, so each function has registers of its own, and running one allocates nothing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniformWords

func UniformWords(p *shaderir.Program) []int

UniformWords returns how many words each of p's uniform variables takes in Inputs.Uniforms.

Types

type Image

type Image interface {
	Size() (w, h int)
	At(x, y int) [4]float32
}

Image is an image a shader reads: its size in pixels, and its pixels, premultiplied, from 0 to 1.

type Inputs

type Inputs struct {
	Uniforms []uint32
	Images   []Image
}

Inputs are what a program reads: its uniform variables, as the words of their lanes, in the order of the program's, and its images.

type Program

type Program struct {
	// contains filtered or unexported fields
}

Program is a shader compiled for the CPU. It is safe for concurrent use.

func New

func New(p *shaderir.Program) (prog *Program, err error)

New compiles p, a program with a fragment entry point.

func (*Program) Color

func (p *Program) Color(in *Inputs, position [4]float32, varyings ...float32) ([4]float32, bool)

Color returns the color the entry point returns for the pixel at position, with the varyings' lanes in order, and false where it discards the pixel.

Jump to

Keyboard shortcuts

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