Documentation ¶
Overview ¶
Package shadertools wraps around external C code for manipulating shaders.
Index ¶
- Constants
- func AssembleSpirvText(chars string) []uint32
- func CompileGlsl(source string, o CompileOptions) ([]uint32, error)
- func DisassembleSpirvBinary(words []uint32) string
- func FormatDebugInfo(insts []Instruction, linePrefix string) string
- func OpcodeToString(opcode uint32) string
- func ParseAllDescriptorSets(shader []uint32) (map[string]DescriptorSets, error)
- type ClientType
- type CodeWithDebugInfo
- type CompileOptions
- type ConvertOptions
- type DescriptorBinding
- type DescriptorSet
- type DescriptorSets
- type Instruction
- type ShaderType
Constants ¶
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) )
const ( OpenGL = ClientType(C.OPENGL) OpenGLES = ClientType(C.OPENGLES) Vulkan = ClientType(C.VULKAN) )
Variables ¶
This section is empty.
Functions ¶
func AssembleSpirvText ¶
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 ¶
func CompileGlsl(source string, o CompileOptions) ([]uint32, error)
CompileGlsl compiles GLSL source code to SPIR-V binary words.
func DisassembleSpirvBinary ¶
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 ¶
OpcodeToString converts opcode number to human readable string.
func ParseAllDescriptorSets ¶
func ParseAllDescriptorSets(shader []uint32) (map[string]DescriptorSets, error)
ParseDescriptorSets determines what descriptor sets are implied by the shader
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 ¶
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 ¶
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 ¶
type DescriptorSet ¶
type DescriptorSet []DescriptorBinding
type DescriptorSets ¶
type DescriptorSets map[uint32]DescriptorSet
func ParseDescriptorSets ¶
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 ¶
type ShaderType int
ShaderType is the enumerator of shader types.
func (ShaderType) String ¶
func (t ShaderType) String() string