Documentation
¶
Overview ¶
Package shadertools wraps around external C code for manipulating shaders.
Index ¶
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) )
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 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.
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 *Options) (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 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 Options ¶ added in v0.6.2
type Options struct {
// The type of shader.
ShaderType ShaderType
// 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
}
Options controls how ConvertGlsl converts its passed-in GLSL source code.
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