shadertools

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: Apache-2.0 Imports: 9 Imported by: 11

Documentation

Overview

Package shadertools wraps around external C code for manipulating shaders.

Index

Constants

View Source
const (
	TypeVertex         = ShaderType(C.VERTEX)
	TypeTessControl    = ShaderType(C.TESS_CONTROL)
	TypeTessEvaluation = ShaderType(C.TESS_EVALUATION)
	TypeGeometry       = ShaderType(C.GEOMETRY)
	TypeFragment       = ShaderType(C.FRAGMENT)
	TypeCompute        = ShaderType(C.COMPUTE)
)
View Source
const (
	OpenGL   = ClientType(C.OPENGL)
	OpenGLES = ClientType(C.OPENGLES)
	Vulkan   = ClientType(C.VULKAN)
)

Variables

This section is empty.

Functions

func AssembleSpirvText

func AssembleSpirvText(chars string) []uint32

AssembleSpirvText assembles the given SPIR-V text chars by calling SPIRV-Tools and returns the slice for the encoded binary. Returns nil if assembling fails.

func CompileGlsl added in v1.1.0

func CompileGlsl(source string, o CompileOptions) ([]uint32, error)

CompileGlsl compiles GLSL source code to SPIR-V binary words.

func DisassembleSpirvBinary

func DisassembleSpirvBinary(words []uint32) string

DisassembleSpirvBinary disassembles the given SPIR-V binary words by calling SPIRV-Tools and returns the disassembly. Returns an empty string if diassembling fails.

func FormatDebugInfo

func FormatDebugInfo(insts []Instruction, linePrefix string) string

FormatDebugInfo returns the instructions as a string.

func OpcodeToString

func OpcodeToString(opcode uint32) string

OpcodeToString converts opcode number to human readable string.

func ParseAllDescriptorSets added in v1.3.1

func ParseAllDescriptorSets(shader []uint32) (map[string]DescriptorSets, error)

ParseDescriptorSets determines what descriptor sets are implied by the shader

Types

type ClientType added in v1.1.0

type ClientType int

ClientType is the enumerator of client types.

type CodeWithDebugInfo

type CodeWithDebugInfo struct {
	SourceCode        string        // Modified GLSL.
	DisassemblyString string        // Diassembly of modified GLSL.
	Info              []Instruction // A set of SPIR-V debug instructions.
}

CodeWithDebugInfo is the result returned by ConvertGlsl.

func ConvertGlsl

func ConvertGlsl(source string, o *ConvertOptions) (CodeWithDebugInfo, error)

ConvertGlsl modifies the given GLSL according to the options specified via o and returns the modification status and result. Possible modifications includes creating output variables for input variables, prefixing all non-builtin symbols with a given prefix, etc.

type CompileOptions added in v1.1.0

type CompileOptions struct {
	// The type of shader.
	ShaderType ShaderType
	// Either OpenGL, OpenGLES or Vulkan
	ClientType ClientType
	// Shader source preamble.
	Preamble string
}

CompileOptions controls how CompileGlsl compile its passed-in GLSL source code.

type ConvertOptions added in v1.1.0

type ConvertOptions struct {
	// The type of shader.
	ShaderType ShaderType
	// The target GLSL version (default 330).
	TargetGLSLVersion int
	// Shader source preamble.
	Preamble string
	// Whether to add prefix to all non-builtin symbols.
	PrefixNames bool
	// The name prefix to be added to all non-builtin symbols.
	NamesPrefix string /* optional */
	// Whether to create a corresponding output variable for each input variable.
	AddOutputsForInputs bool
	// The name prefix of added output variables.
	OutputPrefix string /* optional */
	// Whether to make the generated GLSL code debuggable.
	MakeDebuggable bool
	// Whether to check the generated GLSL code compiles again.
	CheckAfterChanges bool
	// Whether to disassemble the generated GLSL code.
	Disassemble bool
	// If true, let some minor invalid statements compile.
	Relaxed bool
	// If true, optimizations that require high-end GL versions, or extensions
	// will be stripped. These optimizations should have no impact on the end
	// result of the shader, but may impact performance.
	// Example: Early Fragment Test.
	StripOptimizations bool
}

ConvertOptions controls how ConvertGlsl converts its passed-in GLSL source code.

type DescriptorBinding added in v1.2.0

type DescriptorBinding struct {
	Set             uint32
	Binding         uint32
	SpirvId         uint32
	DescriptorType  uint32
	DescriptorCount uint32
	ShaderStage     uint32
}

type DescriptorSet added in v1.2.0

type DescriptorSet []DescriptorBinding

type DescriptorSets added in v1.2.0

type DescriptorSets map[uint32]DescriptorSet

func ParseDescriptorSets added in v1.2.0

func ParseDescriptorSets(shader []uint32, entryPoint string) (DescriptorSets, error)

ParseDescriptorSets determines what descriptor sets are implied by the shader

type Instruction

type Instruction struct {
	ID     uint32   // Result identifer.
	Opcode uint32   // Opcode.
	Words  []uint32 // Operands.
	Name   string   // Optional symbol name.
}

Instruction represents a SPIR-V instruction.

type ShaderType added in v0.6.0

type ShaderType int

ShaderType is the enumerator of shader types.

func (ShaderType) String added in v0.6.0

func (t ShaderType) String() string

Jump to

Keyboard shortcuts

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