ebiten: github.com/hajimehoshi/ebiten/internal/shaderir Index | Files | Directories

package shaderir

import "github.com/hajimehoshi/ebiten/internal/shaderir"

Package shaderir offers intermediate representation for shader programs.

Index

Package Files

program.go type.go

func IsValidSwizzling Uses

func IsValidSwizzling(s string) bool

type BasicType Uses

type BasicType int
const (
    None BasicType = iota
    Bool
    Int
    Float
    Vec2
    Vec3
    Vec4
    Mat2
    Mat3
    Mat4
    Array
    Struct
)

type Block Uses

type Block struct {
    LocalVars           []Type
    LocalVarIndexOffset int
    Stmts               []Stmt
}

type BuiltinFunc Uses

type BuiltinFunc string
const (
    Len         BuiltinFunc = "len"
    BoolF       BuiltinFunc = "bool"
    IntF        BuiltinFunc = "int"
    FloatF      BuiltinFunc = "float"
    Vec2F       BuiltinFunc = "vec2"
    Vec3F       BuiltinFunc = "vec3"
    Vec4F       BuiltinFunc = "vec4"
    Mat2F       BuiltinFunc = "mat2"
    Mat3F       BuiltinFunc = "mat3"
    Mat4F       BuiltinFunc = "mat4"
    Radians     BuiltinFunc = "radians"
    Degrees     BuiltinFunc = "degrees"
    Sin         BuiltinFunc = "sin"
    Cos         BuiltinFunc = "cos"
    Tan         BuiltinFunc = "tan"
    Asin        BuiltinFunc = "asin"
    Acos        BuiltinFunc = "acos"
    Atan        BuiltinFunc = "atan"
    Atan2       BuiltinFunc = "atan2"
    Pow         BuiltinFunc = "pow"
    Exp         BuiltinFunc = "exp"
    Log         BuiltinFunc = "log"
    Exp2        BuiltinFunc = "exp2"
    Log2        BuiltinFunc = "log2"
    Sqrt        BuiltinFunc = "sqrt"
    Inversesqrt BuiltinFunc = "inversesqrt"
    Abs         BuiltinFunc = "abs"
    Sign        BuiltinFunc = "sign"
    Floor       BuiltinFunc = "floor"
    Ceil        BuiltinFunc = "ceil"
    Fract       BuiltinFunc = "fract"
    Mod         BuiltinFunc = "mod"
    Min         BuiltinFunc = "min"
    Max         BuiltinFunc = "max"
    Clamp       BuiltinFunc = "clamp"
    Mix         BuiltinFunc = "mix"
    Step        BuiltinFunc = "step"
    Smoothstep  BuiltinFunc = "smoothstep"
    Length      BuiltinFunc = "length"
    Distance    BuiltinFunc = "distance"
    Dot         BuiltinFunc = "dot"
    Cross       BuiltinFunc = "cross"
    Normalize   BuiltinFunc = "normalize"
    Faceforward BuiltinFunc = "faceforward"
    Reflect     BuiltinFunc = "reflect"
    Transpose   BuiltinFunc = "transpose"
    Texture2DF  BuiltinFunc = "texture2D"
    Dfdx        BuiltinFunc = "dfdx"
    Dfdy        BuiltinFunc = "dfdy"
    Fwidth      BuiltinFunc = "fwidth"
)

func ParseBuiltinFunc Uses

func ParseBuiltinFunc(str string) (BuiltinFunc, bool)

type ConstType Uses

type ConstType int
const (
    ConstTypeNone ConstType = iota
    ConstTypeBool
    ConstTypeInt
    ConstTypeFloat
)

type Expr Uses

type Expr struct {
    Type        ExprType
    Exprs       []Expr
    Const       constant.Value
    ConstType   ConstType
    BuiltinFunc BuiltinFunc
    Swizzling   string
    Index       int
    Op          Op
}

type ExprType Uses

type ExprType int
const (
    Blank ExprType = iota
    NumberExpr
    UniformVariable
    TextureVariable
    LocalVariable
    StructMember
    BuiltinFuncExpr
    SwizzlingExpr
    FunctionExpr
    Unary
    Binary
    Selection
    Call
    FieldSelector
    Index
)

type FragmentFunc Uses

type FragmentFunc struct {
    Block *Block
}

FragmentFunc takes pseudo params, and the number is len(varyings) + 2. If index == 0, the param represents the coordinate of the fragment (gl_FragCoord in GLSL). If index == len(varyings), the param represents (index-1)th verying variable. If index == len(varyings)+1, the param is an out-param representing the color of the pixel (gl_FragColor in GLSL).

type Func Uses

type Func struct {
    Index     int
    InParams  []Type
    OutParams []Type
    Return    Type
    Block     *Block
}

type Op Uses

type Op string
const (
    Add                Op  = "+"
    Sub                Op  = "-"
    NotOp              Op  = "!"
    Mul                Op  = "*"
    Div                Op  = "/"
    ModOp              Op  = "%"
    LeftShift          Op  = "<<"
    RightShift         Op  = ">>"
    LessThanOp         Op  = "<"
    LessThanEqualOp    Op  = "<="
    GreaterThanOp      Op  = ">"
    GreaterThanEqualOp Op  = ">="
    EqualOp            Op  = "=="
    NotEqualOp         Op  = "!="
    And                Op  = "&"
    Xor                Op  = "^"
    Or                 Op  = "|"
    AndAnd             Op  = "&&"
    OrOr               Op  = "||"
)

func OpFromToken Uses

func OpFromToken(t token.Token) (Op, bool)

type Program Uses

type Program struct {
    UniformNames []string
    Uniforms     []Type
    TextureNum   int
    Attributes   []Type
    Varyings     []Type
    Funcs        []Func
    VertexFunc   VertexFunc
    FragmentFunc FragmentFunc
}

func (*Program) LocalVariableType Uses

func (p *Program) LocalVariableType(topBlock, block *Block, idx int) Type

type Stmt Uses

type Stmt struct {
    Type        StmtType
    Exprs       []Expr
    Blocks      []*Block
    ForVarType  Type
    ForVarIndex int
    ForInit     constant.Value
    ForEnd      constant.Value
    ForOp       Op
    ForDelta    constant.Value
    InitIndex   int
}

type StmtType Uses

type StmtType int
const (
    ExprStmt StmtType = iota
    BlockStmt
    Assign
    Init
    If
    For
    Continue
    Break
    Return
    Discard
)

type Type Uses

type Type struct {
    Main   BasicType
    Sub    []Type
    Length int
}

func (*Type) Equal Uses

func (t *Type) Equal(rhs *Type) bool

func (*Type) FloatNum Uses

func (t *Type) FloatNum() int

func (*Type) String Uses

func (t *Type) String() string

type VertexFunc Uses

type VertexFunc struct {
    Block *Block
}

VertexFunc takes pseudo params, and the number if len(attributes) + len(varyings) + 1. If 0 <= index < len(attributes), the params are in-params and represent attribute variables. If index == len(attributes), the param is an out-param and repesents the position in vec4 (gl_Position in GLSL) If len(attributes) + 1 <= index < len(attributes) + len(varyings) + 1, the params are out-params and represent varying variables.

Directories

PathSynopsis
glsl
metal

Package shaderir imports 4 packages (graph) and is imported by 13 packages. Updated 2020-09-23. Refresh now. Tools for package owners.