shadertools

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2017 License: Apache-2.0 Imports: 8 Imported by: 11

Documentation

Overview

Package shadertools wraps around external C code for manipulating shaders.

Index

Constants

This section is empty.

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 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

func OpcodeToString

func OpcodeToString(opcode uint32) string

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, option *Option) (CodeWithDebugInfo, error)

ConvertGlsl modifies the given GLSL according to the options specified via option 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 id.
	Opcode uint32   // Opcode.
	Words  []uint32 // Operands.
	Name   string   // Optional symbol name.
}

Instruction represents a SPIR-V instruction.

type Option

type Option struct {
	// Whether the passed-in shader is of the fragment stage.
	IsFragmentShader bool
	// Whether the passed-in shader is of the vertex stage.
	IsVertexShader bool
	// 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
}

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

Jump to

Keyboard shortcuts

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