API

Warning

This section is incomplete. Readers are kindly encouraged to go through the tests and source code for more information about the API usage.

SPIRV.AnnotatedModuleType

Module annotated with instruction ranges for each logical SPIR-V section, suitable for read-only operations and analyses.

Any desired modifications of annotated modules should be staged and applied via a Diff.

Warn

This module should not be modified, and in particular must not have its structure affected in any way by the insertion or removal of instructions. Modifications can cause the annotations to become out of sync with the updated state of the module, yielding undefined behavior.

source
SPIRV.ControlTreeType

Control tree.

The leaves are labeled as REGION_BLOCK regions, with the distinguishing property that they have no children.

Children nodes of any given subtree are in reverse postorder according to the original control-flow graph.

source
SPIRV.DeltaGraphType

Graph whose vertices and edges remain identical after deletion of other vertices.

source
SPIRV.FType
x*F
(x)F

Converts an input x to a Float32 when F is right-multiplied with it.

source
SPIRV.IRType

Intermediate representation of SPIR-V modules.

The types and constants mappings can be updated at any time without explicitly notifying of the mutation behavior (i.e. functions may not end with !), so long as additions only are performed. Such additions are currently done upon construction of GlobalsInfo. The ID counter can also be incremented without notice.

source
SPIRV.ImageType

SPIR-V image type.

Type parameters:

  • Format: SPIR-V ImageFormat enumerated value.
  • Dim: SPIR-V Dim enumerated value.
  • Depth: 64-bit integer with value 0 (not a depth image), 1 (depth image) or 2 (unknown).
  • Arrayed: Bool indicating whether the image is a layer of an image array.
  • MS: Bool indicating whether the image is multisampled.
  • Sampled: 64-bit integer with value 0 (unknown), 1 (may be sampled) or 2 (read-write, no sampling).
source
SPIRV.InstructionType

Parsed SPIR-V instruction. It represents an instruction of the form %result_id = %opcode(%arguments...)::%type_id.

source
SPIRV.NativeLayoutType

" Julia layout, with a special handling of mutable fields for composite types.

Mutable fields are stored as 8-byte pointers in Julia, but in SPIR-V there is no such concept of pointer. Therefore, we treat mutable fields as if they were fully inlined - that imposes a few restrictions on the behavior of such mutable objects, but is necessary to keep some form of compatibility with GPU representations. The alternative would be to completely disallow structs which contain mutable fields.

source
SPIRV.NoPaddingType

Layout strategy which assumes no padding is required at all. This might be useful for maximally packing data when serialized, reducing size; or to improve performance by avoiding padding when not needed, e.g. if you already pad your structures manually upfront (only do that if you know what you're doing).

source
SPIRV.PhysicalModuleType

SPIR-V module, as a series of headers followed by a stream of instructions. The header embeds two magic numbers, one for the module itself and one for the tool that generated it (e.g. glslang). It also contains the version of the specification applicable to the module, the maximum ID number and an optional instruction schema.

source
SPIRV.ResultIDType

Result ID used in a SPIR-V context, following single static assignment rules for valid modules.

source
SPIRV.ShaderCompilationCacheType
ShaderCompilationCache()

Create a cache that may be used to associate shaders to be compiled (ShaderInfo) with compiled code (ShaderSource).

Although this cache will already significantly speed up shader creation by compiling only what is required, performance-critical applications will additionally want to use a high-level cache that maps a ShaderSource to a driver-dependent object generated by the graphics API chosen for that application. For Vulkan, that would be a Vk.ShaderModule, for example. It is then recommended to use an IdDict to perform the caching, to avoid hashing the whole source code.

Warning

Caching assumes the same SPIRVInterpreter to be used, and will not look into the ShaderSource's interp field. Generally, applications should use a single interpreter, and not fiddle with parameters across different shader compilation runs. This allows caching to skip hashing SPIRVInterpreter contents needlessly in what should be >99.9% of cases.

source
SPIRV.ShaderLayoutType

Shader-compatible layout strategy, where layout information is strictly read from shader decorations.

source
SPIRV.StructTypeType

SPIR-V aggregate type.

Equality is defined in terms of identity, since different aggregate types have in principle different semantics.

source
SPIRV.UType
x*U
(x)U

Converts an input x to an UInt32 when U is right-multiplied with it.

source
SPIRV.alignmentFunction
alignment(layout, T)

Memory alignment which must be respected when allocating a value of the given type.

This refers to an external alignment, i.e. this value is of interest when allocating a value of type T within a struct or array. In particular, this value does not indicate what should be the alignment of any struct member or the stride of any array element contained in T, if T is a struct or an array.

source
SPIRV.datasizeFunction
datasize(layout, T)

This is the total space occupied by a value of type T, including padding between struct elements and array strides.

source
SPIRV.disassembleMethod
disassemble(io, spir_module)

Transform the content of spir_module into a human-readable format and prints it to io.

source
SPIRV.spir_typeFunction

Get a SPIR-V type from a Julia type, caching the mapping in the IR if one is provided.

source
SPIRV.@any_hitMacro
@any_hit [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a any_hit shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_control, @tessellation_evaluation, @fragment, @compute, @ray_generation, @intersection, @closest_hit, @miss, @callable, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@callableMacro
@callable [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a callable shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_control, @tessellation_evaluation, @fragment, @compute, @ray_generation, @intersection, @closest_hit, @any_hit, @miss, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@closest_hitMacro
@closest_hit [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a closest_hit shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_control, @tessellation_evaluation, @fragment, @compute, @ray_generation, @intersection, @any_hit, @miss, @callable, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@computeMacro
@compute [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a compute shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_control, @tessellation_evaluation, @fragment, @ray_generation, @intersection, @closest_hit, @any_hit, @miss, @callable, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@fragmentMacro
@fragment [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a fragment shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_control, @tessellation_evaluation, @compute, @ray_generation, @intersection, @closest_hit, @any_hit, @miss, @callable, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@geometryMacro
@geometry [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a geometry shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @tessellation_control, @tessellation_evaluation, @fragment, @compute, @ray_generation, @intersection, @closest_hit, @any_hit, @miss, @callable, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@intersectionMacro
@intersection [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a intersection shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_control, @tessellation_evaluation, @fragment, @compute, @ray_generation, @closest_hit, @any_hit, @miss, @callable, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@loadMacro
@load address::T
@load address[index]::T

Load a value of type T, either directly (if no index is specified) or at offset = index - 1 elements from address. address should be a device address, i.e. a UInt64 value representing the address of a physical storage buffer.

Note

Although @load address::T and @load address[1]::T look semantically the same, you should use whichever is appropriate given the underlying data; if you have an array pointer, use the latter, and if you have a pointer to a single element, use the former. Otherwise, executing this on the CPU will most likely crash if attempted with a T that is a mutable type, because mutable elements are stored as object pointers in arrays, requiring an extra bit of indirection that is expressed by @load address[1]::T if one wants to get the correct address.

source
SPIRV.@meshMacro
@mesh [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a mesh shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_control, @tessellation_evaluation, @fragment, @compute, @ray_generation, @intersection, @closest_hit, @any_hit, @miss, @callable, @task

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@missMacro
@miss [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a miss shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_control, @tessellation_evaluation, @fragment, @compute, @ray_generation, @intersection, @closest_hit, @any_hit, @callable, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@ray_generationMacro
@ray_generation [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a ray_generation shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_control, @tessellation_evaluation, @fragment, @compute, @intersection, @closest_hit, @any_hit, @miss, @callable, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@storeMacro
@store value address::T
@store value address[index]::T
@store address::T = value
@store address[index]::T = value

Store a value of type T at the given address, either directly (if no index is specified) or at an offset of index - 1 elements from address.

If value is not of type T, a conversion will be attempted.

address should be a device address, i.e. a UInt64 value representing the address of a physical storage buffer.

source
SPIRV.@taskMacro
@task [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a task shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_control, @tessellation_evaluation, @fragment, @compute, @ray_generation, @intersection, @closest_hit, @any_hit, @miss, @callable, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@tessellation_controlMacro
@tessellation_control [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a tessellation_control shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_evaluation, @fragment, @compute, @ray_generation, @intersection, @closest_hit, @any_hit, @miss, @callable, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@tessellation_evaluationMacro
@tessellation_evaluation [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a tessellation_evaluation shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @vertex, @geometry, @tessellation_control, @fragment, @compute, @ray_generation, @intersection, @closest_hit, @any_hit, @miss, @callable, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.@vertexMacro
@vertex [parameters] f(::Type1::StorageClass1[{...}], ...)

Compile the provided signature f(args...) into a vertex shader.

The supported parameters are the following:

what capabilities and extensions are allowed. In application code, this should generally be a SupportedFeatures structure coming from the client API. For instance, a package extension for Vulkan.jl exists which provides SupportedFeatures(physical_device, api_version, device_extensions, device_features).

  • layout = VulkanLayout(): a VulkanLayout to use to compute alignments, strides and offsets in structures and arrays.
  • cache = nothing: an optional ShaderCompilationCache used to cache ShaderSources to prevent repeated compilation of SPIR-V modules.
  • interpreter = SPIRVInterpreter(): a SPIRVInterpreter containing method tables and optimization options for the computation. If a cache is provided, this interpreter must be identical to the one used to compile all previous cache entries.
  • assemble = false: a boolean flag indicating whether to assemble the resulting module into a ShaderSource, or leave it as a Shader for further introspection. If a cache is provided, assemble must be set to true for caching to be possible.

See also: @geometry, @tessellation_control, @tessellation_evaluation, @fragment, @compute, @ray_generation, @intersection, @closest_hit, @any_hit, @miss, @callable, @task, @mesh

Extended help

Syntax reference

The following syntax allows one to annotate function arguments with shader-specific information:

f(::Type::StorageClass{[BuiltIn], [@Decoration [= value]...]}, ...)

For each argument, the following is to be provided:

  • REQUIRED An argument type.
  • REQUIRED A SPIR-V storage class (required).
  • OPTIONAL A SPIR-V built-in category, see the Vulkan built-in variables.
  • OPTIONAL One or more SPIR-V decorations. Arguments to such decorations may be interpolated with $.

This syntax is processed via SPIRV.compile_shader.

Examples

Here are a few examples using the described syntax:

@vertex [parameters] f(::Mutable{Vec4}::Output{Position}, ::UInt32::Input{VertexIndex})

@fragment [parameters] f(::Vec4::Input, ::InvocationData::PushConstant)

@fragment [parameters] f(::Mutable{Vec4}::Output, ::Vec4::Input{FragCoord}, ::Vec2::Input{@Flat})

@compute [parameters] f(::UInt32::Workgroup)

@compute [parameters] f(::Mutable{Arr{256, Float32}}::Workgroup, ::UInt32::Input{LocalInvocationIndex})

source
SPIRV.OpCodeType

Enumerated value representing the type of an instruction. See https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#instructions3 for a list of SPIR-V opcodes (excluding extended instruction sets).

source