shadertools

package
v3.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

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

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 ExtractDebugSource

func ExtractDebugSource(shader []uint32) (string, string, bool, error)

ExtractDebugSource returns the decompiled shader and it's source language as a string. If the decompiled shader was provided via OpSource, the function returns false. Otherwise, if SPIRV-Cross was needed to decompile the shader, it returns true.

func ParseAllDescriptorSets

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

ParseAllDescriptorSets determines what descriptor sets are implied by the shader, for all entry points of the shader.

Types

type ClientType

type ClientType int

ClientType is the enumerator of client types.

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 DescriptorBinding

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

type DescriptorSet

type DescriptorSet []DescriptorBinding

type DescriptorSets

type DescriptorSets map[uint32]DescriptorSet

type ShaderType

type ShaderType int

ShaderType is the enumerator of shader types.

func (ShaderType) String

func (t ShaderType) String() string

type StaticAnalysisCounters

type StaticAnalysisCounters struct {
	ALUInstructions    uint32
	TexInstructions    uint32
	BranchInstructions uint32
	TempRegisters      uint32
}

func Analyze

func Analyze(shader []uint32) (StaticAnalysisCounters, error)

Obtains static analysis statistics on the given shader code

Jump to

Keyboard shortcuts

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