Documentation
¶
Overview ¶
Package shaderc provides Go bindings for Google's libshaderc shader compiler using purego for dynamic library loading without cgo.
The library compiles GLSL/HLSL source code into SPIR-V binary or assembly, and can also assemble SPIR-V assembly text into binary.
Index ¶
- func GetSpvVersion() (version, revision uint32, err error)
- func SetLibraryPath(path string) error
- type CompilationResult
- type CompilationStatus
- type CompileOptions
- func (o *CompileOptions) AddMacroDefinition(name, value string)
- func (o *CompileOptions) Clone() (*CompileOptions, error)
- func (o *CompileOptions) SetAutoBindUniforms(autoBind bool)
- func (o *CompileOptions) SetAutoCombinedImageSampler(upgrade bool)
- func (o *CompileOptions) SetAutoMapLocations(autoMap bool)
- func (o *CompileOptions) SetBindingBase(kind UniformKind, base uint32)
- func (o *CompileOptions) SetBindingBaseForStage(shaderKind ShaderKind, kind UniformKind, base uint32)
- func (o *CompileOptions) SetForcedVersionProfile(version int, profile Profile)
- func (o *CompileOptions) SetGenerateDebugInfo()
- func (o *CompileOptions) SetHLSL16BitTypes(enable bool)
- func (o *CompileOptions) SetHLSLFunctionality1(enable bool)
- func (o *CompileOptions) SetHLSLIOMapping(hlslIOMap bool)
- func (o *CompileOptions) SetHLSLOffsets(hlslOffsets bool)
- func (o *CompileOptions) SetHLSLRegisterSetAndBinding(reg, set, binding string)
- func (o *CompileOptions) SetHLSLRegisterSetAndBindingForStage(shaderKind ShaderKind, reg, set, binding string)
- func (o *CompileOptions) SetIncludeCallbacks(resolver IncludeResolver)
- func (o *CompileOptions) SetInvertY(enable bool)
- func (o *CompileOptions) SetLimit(limit Limit, value int)
- func (o *CompileOptions) SetMaxIDBound(maxIDBound uint32)
- func (o *CompileOptions) SetNaNClamp(enable bool)
- func (o *CompileOptions) SetOptimizationLevel(level OptimizationLevel)
- func (o *CompileOptions) SetPreserveBindings(preserve bool)
- func (o *CompileOptions) SetSourceLanguage(lang SourceLanguage)
- func (o *CompileOptions) SetSuppressWarnings()
- func (o *CompileOptions) SetTargetEnv(target TargetEnv, version EnvVersion)
- func (o *CompileOptions) SetTargetSpirV(version SpirVVersion)
- func (o *CompileOptions) SetVulkanRulesRelaxed(enable bool)
- func (o *CompileOptions) SetWarningsAsErrors()
- type Compiler
- func (c *Compiler) AssembleIntoSpv(sourceAssembly string, options *CompileOptions) (*CompilationResult, error)
- func (c *Compiler) CompileIntoPreprocessedText(source string, kind ShaderKind, inputFileName, entryPoint string, ...) (*CompilationResult, error)
- func (c *Compiler) CompileIntoSpv(source string, kind ShaderKind, inputFileName, entryPoint string, ...) (*CompilationResult, error)
- func (c *Compiler) CompileIntoSpvAssembly(source string, kind ShaderKind, inputFileName, entryPoint string, ...) (*CompilationResult, error)
- type EnvVersion
- type IncludeResolver
- type IncludeResult
- type IncludeType
- type Limit
- type OptimizationLevel
- type Profile
- type ShaderKind
- type SourceLanguage
- type SpirVVersion
- type TargetEnv
- type UniformKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSpvVersion ¶
GetSpvVersion returns the SPIR-V version and revision that will be produced by the compiler. Returns an error if the library cannot be loaded.
func SetLibraryPath ¶
SetLibraryPath sets a custom path for the libshaderc shared library. Must be called before any other shaderc function. Calling after the library has been loaded will return an error.
Types ¶
type CompilationResult ¶
type CompilationResult struct {
// contains filtered or unexported fields
}
CompilationResult holds the results of a compilation or assembly operation.
Resources are automatically released by the garbage collector. The byte slice returned by Bytes is a copy that remains valid independently.
func (*CompilationResult) Bytes ¶
func (r *CompilationResult) Bytes() []byte
Bytes returns a copy of the compilation output data. For SPIR-V binary output, the returned byte slice contains the SPIR-V module. For assembly or preprocessed text output, it contains the text.
The returned slice is a Go-owned copy that is always safe to use.
func (*CompilationResult) ErrorMessage ¶
func (r *CompilationResult) ErrorMessage() string
ErrorMessage returns any error or warning messages generated during compilation as a string.
func (*CompilationResult) Len ¶
func (r *CompilationResult) Len() int
Len returns the number of bytes of the compilation output data.
func (*CompilationResult) NumErrors ¶
func (r *CompilationResult) NumErrors() int
NumErrors returns the number of errors generated during compilation.
func (*CompilationResult) NumWarnings ¶
func (r *CompilationResult) NumWarnings() int
NumWarnings returns the number of warnings generated during compilation.
func (*CompilationResult) Status ¶
func (r *CompilationResult) Status() CompilationStatus
Status returns the compilation status, indicating whether compilation succeeded or failed.
type CompilationStatus ¶
type CompilationStatus int32
CompilationStatus indicates the status of a compilation.
const ( // CompilationStatusSuccess indicates successful compilation. CompilationStatusSuccess CompilationStatus = 0 // CompilationStatusInvalidStage indicates an error in stage deduction. CompilationStatusInvalidStage CompilationStatus = 1 // CompilationStatusCompilationError indicates a compilation error. CompilationStatusCompilationError CompilationStatus = 2 // CompilationStatusInternalError indicates an unexpected failure. CompilationStatusInternalError CompilationStatus = 3 // CompilationStatusNullResultObject indicates a null result object. CompilationStatusNullResultObject CompilationStatus = 4 // CompilationStatusInvalidAssembly indicates invalid SPIR-V assembly. CompilationStatusInvalidAssembly CompilationStatus = 5 // CompilationStatusValidationError indicates a SPIR-V validation error. CompilationStatusValidationError CompilationStatus = 6 // CompilationStatusTransformationError indicates a transformation error. CompilationStatusTransformationError CompilationStatus = 7 // CompilationStatusConfigurationError indicates a configuration error. CompilationStatusConfigurationError CompilationStatus = 8 )
func (CompilationStatus) String ¶
func (s CompilationStatus) String() string
String returns a human-readable string for the CompilationStatus.
type CompileOptions ¶
type CompileOptions struct {
// contains filtered or unexported fields
}
CompileOptions manages options for a single compilation. Options can be reused across multiple compilations.
Resources are automatically released by the garbage collector. There is no need to manually release the options.
func NewCompileOptions ¶
func NewCompileOptions() (*CompileOptions, error)
NewCompileOptions creates a new default-initialized set of compile options.
func (*CompileOptions) AddMacroDefinition ¶
func (o *CompileOptions) AddMacroDefinition(name, value string)
AddMacroDefinition adds a predefined macro to the compilation options. This has the same effect as passing -Dname=value to the command-line compiler. If value is empty, the macro is defined without a value (equivalent to -Dname).
func (*CompileOptions) Clone ¶
func (o *CompileOptions) Clone() (*CompileOptions, error)
Clone returns a deep copy of the compile options. The cloned options share the include callback state with the original via reference counting, so either can be garbage collected independently.
func (*CompileOptions) SetAutoBindUniforms ¶
func (o *CompileOptions) SetAutoBindUniforms(autoBind bool)
SetAutoBindUniforms sets whether the compiler should automatically assign bindings to uniforms that aren't already explicitly bound in the shader source.
func (*CompileOptions) SetAutoCombinedImageSampler ¶
func (o *CompileOptions) SetAutoCombinedImageSampler(upgrade bool)
SetAutoCombinedImageSampler sets whether the compiler should automatically remove sampler variables and convert image variables to combined image-sampler variables.
func (*CompileOptions) SetAutoMapLocations ¶
func (o *CompileOptions) SetAutoMapLocations(autoMap bool)
SetAutoMapLocations sets whether the compiler should automatically assign locations to uniform variables that don't have explicit locations in the shader source.
func (*CompileOptions) SetBindingBase ¶
func (o *CompileOptions) SetBindingBase(kind UniformKind, base uint32)
SetBindingBase sets the base binding number used for a uniform resource type when automatically assigning bindings. For GLSL compilation, sets the lowest automatically assigned number. For HLSL compilation, the register number assigned to the resource is added to this base.
func (*CompileOptions) SetBindingBaseForStage ¶
func (o *CompileOptions) SetBindingBaseForStage(shaderKind ShaderKind, kind UniformKind, base uint32)
SetBindingBaseForStage is like SetBindingBase, but only takes effect when compiling a given shader stage.
func (*CompileOptions) SetForcedVersionProfile ¶
func (o *CompileOptions) SetForcedVersionProfile(version int, profile Profile)
SetForcedVersionProfile forces the GLSL language version and profile to the given pair. The version number is the same as would appear in the #version annotation in the source. This overrides the #version annotation in the source. Use ProfileNone for GLSL versions that do not define profiles (e.g. versions below 150).
func (*CompileOptions) SetGenerateDebugInfo ¶
func (o *CompileOptions) SetGenerateDebugInfo()
SetGenerateDebugInfo sets the compiler mode to generate debug information in the output.
func (*CompileOptions) SetHLSL16BitTypes ¶
func (o *CompileOptions) SetHLSL16BitTypes(enable bool)
SetHLSL16BitTypes sets whether 16-bit types are supported in HLSL.
func (*CompileOptions) SetHLSLFunctionality1 ¶
func (o *CompileOptions) SetHLSLFunctionality1(enable bool)
SetHLSLFunctionality1 sets whether the compiler should enable the SPV_GOOGLE_hlsl_functionality1 extension.
func (*CompileOptions) SetHLSLIOMapping ¶
func (o *CompileOptions) SetHLSLIOMapping(hlslIOMap bool)
SetHLSLIOMapping sets whether the compiler should use HLSL IO mapping rules for bindings. Defaults to false.
func (*CompileOptions) SetHLSLOffsets ¶
func (o *CompileOptions) SetHLSLOffsets(hlslOffsets bool)
SetHLSLOffsets sets whether the compiler should determine block member offsets using HLSL packing rules instead of standard GLSL rules. Defaults to false. Only affects GLSL compilation. HLSL rules are always used when compiling HLSL.
func (*CompileOptions) SetHLSLRegisterSetAndBinding ¶
func (o *CompileOptions) SetHLSLRegisterSetAndBinding(reg, set, binding string)
SetHLSLRegisterSetAndBinding sets a descriptor set and binding for an HLSL register, affecting all shader stages. The library copies the string data.
func (*CompileOptions) SetHLSLRegisterSetAndBindingForStage ¶
func (o *CompileOptions) SetHLSLRegisterSetAndBindingForStage(shaderKind ShaderKind, reg, set, binding string)
SetHLSLRegisterSetAndBindingForStage sets a descriptor set and binding for an HLSL register in the given stage. The library copies the string data.
func (*CompileOptions) SetIncludeCallbacks ¶
func (o *CompileOptions) SetIncludeCallbacks(resolver IncludeResolver)
SetIncludeCallbacks sets the include resolver for handling #include directives during compilation. See the IncludeResolver interface for details.
func (*CompileOptions) SetInvertY ¶
func (o *CompileOptions) SetInvertY(enable bool)
SetInvertY sets whether the compiler should invert position.Y output in vertex shaders.
func (*CompileOptions) SetLimit ¶
func (o *CompileOptions) SetLimit(limit Limit, value int)
SetLimit sets a resource limit for compilation.
func (*CompileOptions) SetMaxIDBound ¶
func (o *CompileOptions) SetMaxIDBound(maxIDBound uint32)
SetMaxIDBound sets the maximum ID bound for the SPIR-V module.
func (*CompileOptions) SetNaNClamp ¶
func (o *CompileOptions) SetNaNClamp(enable bool)
SetNaNClamp sets whether the compiler generates code for max and min builtins which, if given a NaN operand, will return the other operand. Similarly, the clamp builtin will favour the non-NaN operands.
func (*CompileOptions) SetOptimizationLevel ¶
func (o *CompileOptions) SetOptimizationLevel(level OptimizationLevel)
SetOptimizationLevel sets the compiler optimization level. Only the last call takes effect if multiple calls are made.
func (*CompileOptions) SetPreserveBindings ¶
func (o *CompileOptions) SetPreserveBindings(preserve bool)
SetPreserveBindings sets whether the compiler should preserve all bindings, even when those bindings are not used.
func (*CompileOptions) SetSourceLanguage ¶
func (o *CompileOptions) SetSourceLanguage(lang SourceLanguage)
SetSourceLanguage sets the source language. The default is GLSL.
func (*CompileOptions) SetSuppressWarnings ¶
func (o *CompileOptions) SetSuppressWarnings()
SetSuppressWarnings sets the compiler mode to suppress warnings. This overrides the warnings-as-errors mode.
func (*CompileOptions) SetTargetEnv ¶
func (o *CompileOptions) SetTargetEnv(target TargetEnv, version EnvVersion)
SetTargetEnv sets the target shader environment, affecting which warnings or errors will be issued. The version should be either 0 or a value from EnvVersion. A version of 0 maps to Vulkan 1.0 if target is Vulkan, and OpenGL 4.5 if target is OpenGL.
func (*CompileOptions) SetTargetSpirV ¶
func (o *CompileOptions) SetTargetSpirV(version SpirVVersion)
SetTargetSpirV sets the target SPIR-V version. The generated module will use this version of SPIR-V. Defaults to the highest version of SPIR-V 1.0 which is required to be supported by the target environment.
func (*CompileOptions) SetVulkanRulesRelaxed ¶
func (o *CompileOptions) SetVulkanRulesRelaxed(enable bool)
SetVulkanRulesRelaxed enables or disables relaxed Vulkan rules. This allows most OpenGL shaders to compile under Vulkan semantics.
func (*CompileOptions) SetWarningsAsErrors ¶
func (o *CompileOptions) SetWarningsAsErrors()
SetWarningsAsErrors sets the compiler mode to treat all warnings as errors. Note that SetSuppressWarnings overrides this option.
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler manages all compiler state. It can be used to compile multiple shaders concurrently. A single Compiler instance can be reused across many compilations.
Resources are automatically released by the garbage collector. There is no need to manually release the compiler.
func NewCompiler ¶
NewCompiler creates a new shader compiler instance. Returns an error if the library cannot be loaded or the compiler cannot be initialized.
func (*Compiler) AssembleIntoSpv ¶
func (c *Compiler) AssembleIntoSpv(sourceAssembly string, options *CompileOptions) (*CompilationResult, error)
AssembleIntoSpv assembles the given SPIR-V assembly text into a SPIR-V binary module.
The sourceAssembly is SPIR-V assembly text in the format defined by the SPIRV-Tools project. If options is nil, default options are used.
func (*Compiler) CompileIntoPreprocessedText ¶
func (c *Compiler) CompileIntoPreprocessedText(source string, kind ShaderKind, inputFileName, entryPoint string, options *CompileOptions) (*CompilationResult, error)
CompileIntoPreprocessedText compiles the given source code and returns the preprocessed source text instead of a SPIR-V binary module.
See CompileIntoSpv for parameter documentation.
func (*Compiler) CompileIntoSpv ¶
func (c *Compiler) CompileIntoSpv(source string, kind ShaderKind, inputFileName, entryPoint string, options *CompileOptions) (*CompilationResult, error)
CompileIntoSpv compiles the given source code into SPIR-V binary.
The source is the shader source code. The kind specifies the shader kind. The inputFileName is a null-terminated string used as a tag in error messages; it does not have to be an actual file name. The entryPoint is the name of the entry point function.
If options is nil, default options are used.
func (*Compiler) CompileIntoSpvAssembly ¶
func (c *Compiler) CompileIntoSpvAssembly(source string, kind ShaderKind, inputFileName, entryPoint string, options *CompileOptions) (*CompilationResult, error)
CompileIntoSpvAssembly compiles the given source code into SPIR-V assembly text instead of a SPIR-V binary module. The SPIR-V assembly syntax is as defined by the SPIRV-Tools project.
See CompileIntoSpv for parameter documentation.
type EnvVersion ¶
type EnvVersion uint32
EnvVersion represents the version of the target environment.
const ( // EnvVersionVulkan1_0 targets Vulkan 1.0. EnvVersionVulkan1_0 EnvVersion = (1 << 22) // EnvVersionVulkan1_1 targets Vulkan 1.1. EnvVersionVulkan1_1 EnvVersion = (1 << 22) | (1 << 12) // EnvVersionVulkan1_2 targets Vulkan 1.2. EnvVersionVulkan1_2 EnvVersion = (1 << 22) | (2 << 12) // EnvVersionVulkan1_3 targets Vulkan 1.3. EnvVersionVulkan1_3 EnvVersion = (1 << 22) | (3 << 12) // EnvVersionVulkan1_4 targets Vulkan 1.4. EnvVersionVulkan1_4 EnvVersion = (1 << 22) | (4 << 12) // EnvVersionOpenGL4_5 targets OpenGL 4.5. EnvVersionOpenGL4_5 EnvVersion = 450 // EnvVersionWebGPU is deprecated. WebGPU env never defined versions. EnvVersionWebGPU EnvVersion = 451 )
type IncludeResolver ¶
type IncludeResolver interface {
// Resolve is called when the compiler encounters an #include directive.
//
// requestedSource is the name specified in the #include directive.
// includeType indicates whether the include is relative (#include "...")
// or standard (#include <...>).
// requestingSource is the name of the source that contains the #include.
// includeDepth is the current include nesting depth.
//
// Return an IncludeResult with the resolved source name and content.
// To signal an error, return an IncludeResult with an empty SourceName
// and the error message in Content.
Resolve(requestedSource string, includeType IncludeType, requestingSource string, includeDepth int) *IncludeResult
}
IncludeResolver handles #include directive resolution during shader compilation.
type IncludeResult ¶
type IncludeResult struct {
// SourceName is the fully resolved name of the included source. For
// example, if the includer maps source names to filesystem paths, this
// should be the absolute path. For a failed inclusion, set this to an
// empty string.
SourceName string
// Content is the text content of the included source. For a failed
// inclusion, set this to the error message.
Content string
}
IncludeResult represents the result of resolving an #include directive.
type IncludeType ¶
type IncludeType int32
IncludeType represents the kind of #include request.
const ( // IncludeTypeRelative represents a relative include: #include "source" IncludeTypeRelative IncludeType = 0 // IncludeTypeStandard represents a standard include: #include <source> IncludeTypeStandard IncludeType = 1 )
func (IncludeType) String ¶
func (t IncludeType) String() string
String returns a human-readable string for the IncludeType.
type Limit ¶
type Limit int32
Limit represents a resource limit that can be set for compilation.
const ( LimitMaxLights Limit = 0 LimitMaxClipPlanes Limit = 1 LimitMaxTextureUnits Limit = 2 LimitMaxTextureCoords Limit = 3 LimitMaxVertexAttribs Limit = 4 LimitMaxVertexUniformComponents Limit = 5 LimitMaxVaryingFloats Limit = 6 LimitMaxVertexTextureImageUnits Limit = 7 LimitMaxCombinedTextureImageUnits Limit = 8 LimitMaxTextureImageUnits Limit = 9 LimitMaxFragmentUniformComponents Limit = 10 LimitMaxDrawBuffers Limit = 11 LimitMaxVertexUniformVectors Limit = 12 LimitMaxVaryingVectors Limit = 13 LimitMaxFragmentUniformVectors Limit = 14 LimitMaxVertexOutputVectors Limit = 15 LimitMaxFragmentInputVectors Limit = 16 LimitMinProgramTexelOffset Limit = 17 LimitMaxProgramTexelOffset Limit = 18 LimitMaxClipDistances Limit = 19 LimitMaxComputeWorkGroupCountX Limit = 20 LimitMaxComputeWorkGroupCountY Limit = 21 LimitMaxComputeWorkGroupCountZ Limit = 22 LimitMaxComputeWorkGroupSizeX Limit = 23 LimitMaxComputeWorkGroupSizeY Limit = 24 LimitMaxComputeWorkGroupSizeZ Limit = 25 LimitMaxComputeUniformComponents Limit = 26 LimitMaxComputeTextureImageUnits Limit = 27 LimitMaxComputeImageUniforms Limit = 28 LimitMaxComputeAtomicCounters Limit = 29 LimitMaxComputeAtomicCounterBuffers Limit = 30 LimitMaxVaryingComponents Limit = 31 LimitMaxVertexOutputComponents Limit = 32 LimitMaxGeometryInputComponents Limit = 33 LimitMaxGeometryOutputComponents Limit = 34 LimitMaxFragmentInputComponents Limit = 35 LimitMaxImageUnits Limit = 36 LimitMaxCombinedImageUnitsAndFragmentOutputs Limit = 37 LimitMaxCombinedShaderOutputResources Limit = 38 LimitMaxImageSamples Limit = 39 LimitMaxVertexImageUniforms Limit = 40 LimitMaxTessControlImageUniforms Limit = 41 LimitMaxTessEvaluationImageUniforms Limit = 42 LimitMaxGeometryImageUniforms Limit = 43 LimitMaxFragmentImageUniforms Limit = 44 LimitMaxCombinedImageUniforms Limit = 45 LimitMaxGeometryTextureImageUnits Limit = 46 LimitMaxGeometryOutputVertices Limit = 47 LimitMaxGeometryTotalOutputComponents Limit = 48 LimitMaxGeometryUniformComponents Limit = 49 LimitMaxGeometryVaryingComponents Limit = 50 LimitMaxTessControlInputComponents Limit = 51 LimitMaxTessControlOutputComponents Limit = 52 LimitMaxTessControlTextureImageUnits Limit = 53 LimitMaxTessControlUniformComponents Limit = 54 LimitMaxTessControlTotalOutputComponents Limit = 55 LimitMaxTessEvaluationInputComponents Limit = 56 LimitMaxTessEvaluationOutputComponents Limit = 57 LimitMaxTessEvaluationTextureImageUnits Limit = 58 LimitMaxTessEvaluationUniformComponents Limit = 59 LimitMaxTessPatchComponents Limit = 60 LimitMaxPatchVertices Limit = 61 LimitMaxTessGenLevel Limit = 62 LimitMaxViewports Limit = 63 LimitMaxVertexAtomicCounters Limit = 64 LimitMaxTessControlAtomicCounters Limit = 65 LimitMaxTessEvaluationAtomicCounters Limit = 66 LimitMaxGeometryAtomicCounters Limit = 67 LimitMaxFragmentAtomicCounters Limit = 68 LimitMaxCombinedAtomicCounters Limit = 69 LimitMaxAtomicCounterBindings Limit = 70 LimitMaxVertexAtomicCounterBuffers Limit = 71 LimitMaxTessControlAtomicCounterBuffers Limit = 72 LimitMaxTessEvaluationAtomicCounterBuffers Limit = 73 LimitMaxGeometryAtomicCounterBuffers Limit = 74 LimitMaxFragmentAtomicCounterBuffers Limit = 75 LimitMaxCombinedAtomicCounterBuffers Limit = 76 LimitMaxAtomicCounterBufferSize Limit = 77 LimitMaxTransformFeedbackBuffers Limit = 78 LimitMaxTransformFeedbackInterleavedComponents Limit = 79 LimitMaxCullDistances Limit = 80 LimitMaxCombinedClipAndCullDistances Limit = 81 LimitMaxSamples Limit = 82 LimitMaxMeshOutputVerticesNV Limit = 83 LimitMaxMeshOutputPrimitivesNV Limit = 84 LimitMaxMeshWorkGroupSizeXNV Limit = 85 LimitMaxMeshWorkGroupSizeYNV Limit = 86 LimitMaxMeshWorkGroupSizeZNV Limit = 87 LimitMaxTaskWorkGroupSizeXNV Limit = 88 LimitMaxTaskWorkGroupSizeYNV Limit = 89 LimitMaxTaskWorkGroupSizeZNV Limit = 90 LimitMaxMeshViewCountNV Limit = 91 LimitMaxMeshOutputVerticesEXT Limit = 92 LimitMaxMeshOutputPrimitivesEXT Limit = 93 LimitMaxMeshWorkGroupSizeXEXT Limit = 94 LimitMaxMeshWorkGroupSizeYEXT Limit = 95 LimitMaxMeshWorkGroupSizeZEXT Limit = 96 LimitMaxTaskWorkGroupSizeXEXT Limit = 97 LimitMaxTaskWorkGroupSizeYEXT Limit = 98 LimitMaxTaskWorkGroupSizeZEXT Limit = 99 LimitMaxMeshViewCountEXT Limit = 100 LimitMaxDualSourceDrawBuffersEXT Limit = 101 )
type OptimizationLevel ¶
type OptimizationLevel int32
OptimizationLevel represents the optimization level for compilation.
const ( // OptimizationLevelZero applies no optimization. OptimizationLevelZero OptimizationLevel = 0 // OptimizationLevelSize optimizes towards reducing code size. OptimizationLevelSize OptimizationLevel = 1 // OptimizationLevelPerformance optimizes towards performance. OptimizationLevelPerformance OptimizationLevel = 2 )
func (OptimizationLevel) String ¶
func (l OptimizationLevel) String() string
String returns a human-readable string for the OptimizationLevel.
type Profile ¶
type Profile int32
Profile represents a GLSL profile.
const ( // ProfileNone is used when the GLSL version does not specify a profile // (e.g. versions below 150). ProfileNone Profile = 0 // ProfileCore specifies the core profile. ProfileCore Profile = 1 // ProfileCompatibility specifies the compatibility profile. Disabled; // this generates an error. ProfileCompatibility Profile = 2 // ProfileES specifies the ES profile. ProfileES Profile = 3 )
func ParseVersionProfile ¶
ParseVersionProfile parses a version and profile from a string like "450core". Returns the version number, profile, and whether parsing succeeded.
type ShaderKind ¶
type ShaderKind int32
ShaderKind represents the kind of shader to compile.
const ( // VertexShader forces compilation as a vertex shader. VertexShader ShaderKind = 0 // FragmentShader forces compilation as a fragment shader. FragmentShader ShaderKind = 1 // ComputeShader forces compilation as a compute shader. ComputeShader ShaderKind = 2 // GeometryShader forces compilation as a geometry shader. GeometryShader ShaderKind = 3 // TessControlShader forces compilation as a tessellation control shader. TessControlShader ShaderKind = 4 // TessEvaluationShader forces compilation as a tessellation evaluation shader. TessEvaluationShader ShaderKind = 5 // GLSLVertexShader is an alias for VertexShader. GLSLVertexShader ShaderKind = VertexShader // GLSLFragmentShader is an alias for FragmentShader. GLSLFragmentShader ShaderKind = FragmentShader // GLSLComputeShader is an alias for ComputeShader. GLSLComputeShader ShaderKind = ComputeShader // GLSLGeometryShader is an alias for GeometryShader. GLSLGeometryShader ShaderKind = GeometryShader // GLSLTessControlShader is an alias for TessControlShader. GLSLTessControlShader ShaderKind = TessControlShader // GLSLTessEvaluationShader is an alias for TessEvaluationShader. GLSLTessEvaluationShader ShaderKind = TessEvaluationShader // GLSLInferFromSource deduces the shader kind from #pragma annotation in the // source code. The compiler will emit an error if #pragma annotation is not found. GLSLInferFromSource ShaderKind = 6 // GLSLDefaultVertexShader falls back to vertex shader if #pragma is not found. GLSLDefaultVertexShader ShaderKind = 7 // GLSLDefaultFragmentShader falls back to fragment shader if #pragma is not found. GLSLDefaultFragmentShader ShaderKind = 8 // GLSLDefaultComputeShader falls back to compute shader if #pragma is not found. GLSLDefaultComputeShader ShaderKind = 9 // GLSLDefaultGeometryShader falls back to geometry shader if #pragma is not found. GLSLDefaultGeometryShader ShaderKind = 10 // GLSLDefaultTessControlShader falls back to tessellation control shader if #pragma is not found. GLSLDefaultTessControlShader ShaderKind = 11 // GLSLDefaultTessEvaluationShader falls back to tessellation evaluation shader if #pragma is not found. GLSLDefaultTessEvaluationShader ShaderKind = 12 // SpirvAssembly indicates the input is SPIR-V assembly text. SpirvAssembly ShaderKind = 13 // RaygenShader forces compilation as a ray generation shader. RaygenShader ShaderKind = 14 // AnyhitShader forces compilation as an any-hit shader. AnyhitShader ShaderKind = 15 // ClosesthitShader forces compilation as a closest-hit shader. ClosesthitShader ShaderKind = 16 // MissShader forces compilation as a miss shader. MissShader ShaderKind = 17 // IntersectionShader forces compilation as an intersection shader. IntersectionShader ShaderKind = 18 // CallableShader forces compilation as a callable shader. CallableShader ShaderKind = 19 // GLSLRaygenShader is an alias for RaygenShader. GLSLRaygenShader ShaderKind = RaygenShader // GLSLAnyhitShader is an alias for AnyhitShader. GLSLAnyhitShader ShaderKind = AnyhitShader // GLSLClosesthitShader is an alias for ClosesthitShader. GLSLClosesthitShader ShaderKind = ClosesthitShader // GLSLMissShader is an alias for MissShader. GLSLMissShader ShaderKind = MissShader // GLSLIntersectionShader is an alias for IntersectionShader. GLSLIntersectionShader ShaderKind = IntersectionShader // GLSLCallableShader is an alias for CallableShader. GLSLCallableShader ShaderKind = CallableShader // GLSLDefaultRaygenShader falls back to ray generation shader if #pragma is not found. GLSLDefaultRaygenShader ShaderKind = 20 // GLSLDefaultAnyhitShader falls back to any-hit shader if #pragma is not found. GLSLDefaultAnyhitShader ShaderKind = 21 // GLSLDefaultClosesthitShader falls back to closest-hit shader if #pragma is not found. GLSLDefaultClosesthitShader ShaderKind = 22 // GLSLDefaultMissShader falls back to miss shader if #pragma is not found. GLSLDefaultMissShader ShaderKind = 23 // GLSLDefaultIntersectionShader falls back to intersection shader if #pragma is not found. GLSLDefaultIntersectionShader ShaderKind = 24 // GLSLDefaultCallableShader falls back to callable shader if #pragma is not found. GLSLDefaultCallableShader ShaderKind = 25 // TaskShader forces compilation as a task shader. TaskShader ShaderKind = 26 // MeshShader forces compilation as a mesh shader. MeshShader ShaderKind = 27 // GLSLTaskShader is an alias for TaskShader. GLSLTaskShader ShaderKind = TaskShader // GLSLMeshShader is an alias for MeshShader. GLSLMeshShader ShaderKind = MeshShader // GLSLDefaultTaskShader falls back to task shader if #pragma is not found. GLSLDefaultTaskShader ShaderKind = 28 // GLSLDefaultMeshShader falls back to mesh shader if #pragma is not found. GLSLDefaultMeshShader ShaderKind = 29 )
func (ShaderKind) String ¶
func (k ShaderKind) String() string
String returns a human-readable string for the ShaderKind.
type SourceLanguage ¶
type SourceLanguage int32
SourceLanguage represents the source language of the shader.
const ( // SourceLanguageGLSL indicates GLSL source. SourceLanguageGLSL SourceLanguage = 0 // SourceLanguageHLSL indicates HLSL source. SourceLanguageHLSL SourceLanguage = 1 )
func (SourceLanguage) String ¶
func (l SourceLanguage) String() string
String returns a human-readable string for the SourceLanguage.
type SpirVVersion ¶
type SpirVVersion int32
SpirVVersion represents a version of SPIR-V.
const ( // SpirVVersion1_0 targets SPIR-V 1.0. SpirVVersion1_0 SpirVVersion = 0x010000 // SpirVVersion1_1 targets SPIR-V 1.1. SpirVVersion1_1 SpirVVersion = 0x010100 // SpirVVersion1_2 targets SPIR-V 1.2. SpirVVersion1_2 SpirVVersion = 0x010200 // SpirVVersion1_3 targets SPIR-V 1.3. SpirVVersion1_3 SpirVVersion = 0x010300 // SpirVVersion1_4 targets SPIR-V 1.4. SpirVVersion1_4 SpirVVersion = 0x010400 // SpirVVersion1_5 targets SPIR-V 1.5. SpirVVersion1_5 SpirVVersion = 0x010500 // SpirVVersion1_6 targets SPIR-V 1.6. SpirVVersion1_6 SpirVVersion = 0x010600 )
type TargetEnv ¶
type TargetEnv int32
TargetEnv represents the target shader environment.
const ( // TargetEnvVulkan targets SPIR-V under Vulkan semantics. TargetEnvVulkan TargetEnv = 0 // TargetEnvOpenGL targets SPIR-V under OpenGL semantics. TargetEnvOpenGL TargetEnv = 1 // TargetEnvOpenGLCompat targets SPIR-V under OpenGL semantics, including // compatibility profile functions. Note: SPIR-V code generation is not // supported for shaders under OpenGL compatibility profile. TargetEnvOpenGLCompat TargetEnv = 2 // TargetEnvWebGPU is deprecated. It targets SPIR-V under WebGPU semantics. TargetEnvWebGPU TargetEnv = 3 // TargetEnvDefault is an alias for TargetEnvVulkan. TargetEnvDefault TargetEnv = TargetEnvVulkan )
type UniformKind ¶
type UniformKind int32
UniformKind represents the kind of uniform resource.
const ( // UniformKindImage represents an image and image buffer. UniformKindImage UniformKind = 0 // UniformKindSampler represents a pure sampler. UniformKindSampler UniformKind = 1 // UniformKindTexture represents a sampled texture in GLSL, or Shader // Resource View in HLSL. UniformKindTexture UniformKind = 2 // UniformKindBuffer represents a Uniform Buffer Object (UBO) in GLSL, // or Cbuffer in HLSL. UniformKindBuffer UniformKind = 3 // UniformKindStorageBuffer represents a Shader Storage Buffer Object // (SSBO) in GLSL. UniformKindStorageBuffer UniformKind = 4 // UniformKindUnorderedAccessView represents an Unordered Access View in // HLSL (writable storage image or storage buffer). UniformKindUnorderedAccessView UniformKind = 5 )
func (UniformKind) String ¶
func (k UniformKind) String() string
String returns a human-readable string for the UniformKind.