API
This section is incomplete. Readers are kindly encouraged to go through the tests and source code for more information about the API usage.
SPIRV.REGION_BLOCK
SPIRV.SPIR_TYPE_STRUCT
SPIRV.πF
SPIRV.AnnotatedModule
SPIRV.ControlTree
SPIRV.DeltaGraph
SPIRV.F
SPIRV.FeatureSupport
SPIRV.IR
SPIRV.Image
SPIRV.Instruction
SPIRV.LayoutStrategy
SPIRV.Module
SPIRV.NativeLayout
SPIRV.NoPadding
SPIRV.OpCode
SPIRV.PhysicalInstruction
SPIRV.PhysicalModule
SPIRV.ResultID
SPIRV.SPIRVTarget
SPIRV.ShaderCompilationCache
SPIRV.ShaderLayout
SPIRV.ShaderSource
SPIRV.SupportedFeatures
SPIRV.TypeMetadata
SPIRV.U
SPIRV.VulkanLayout
SPIRV.alignment
SPIRV.datasize
SPIRV.disassemble
SPIRV.spir_type
SPIRV.@any_hit
SPIRV.@callable
SPIRV.@closest_hit
SPIRV.@compute
SPIRV.@for
SPIRV.@fragment
SPIRV.@geometry
SPIRV.@intersection
SPIRV.@load
SPIRV.@mesh
SPIRV.@miss
SPIRV.@ray_generation
SPIRV.@store
SPIRV.@task
SPIRV.@tessellation_control
SPIRV.@tessellation_evaluation
SPIRV.@vertex
SPIRV.SPIR_TYPE_STRUCT
— ConstantSPIR-V aggregate type.
Equality is defined in terms of identity, since different aggregate types have in principle different semantics.
SPIRV.πF
— Constant32-bit floating-point representation of π
.
SPIRV.AnnotatedModule
— TypeModule 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
.
SPIRV.ControlTree
— TypeControl 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.
SPIRV.DeltaGraph
— TypeGraph whose vertices and edges remain identical after deletion of other vertices.
SPIRV.F
— Typex*F
(x)F
Converts an input x
to a Float32
when F
is right-multiplied with it.
SPIRV.FeatureSupport
— TypeAbstract type expressing SPIR-V which capabilities and extensions are supported.
SPIRV.IR
— TypeIntermediate 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.
SPIRV.Image
— TypeSPIR-V image type.
Type parameters:
Format
: SPIR-VImageFormat
enumerated value.Dim
: SPIR-VDim
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).
SPIRV.Instruction
— TypeParsed SPIR-V instruction. It represents an instruction of the form %result_id = %opcode(%arguments...)::%type_id
.
SPIRV.LayoutStrategy
— TypeLayout strategy used to compute alignments, offsets and strides.
SPIRV.NativeLayout
— Type" 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.
SPIRV.NoPadding
— TypeLayout 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).
SPIRV.PhysicalInstruction
— TypeSPIR-V instruction in binary format.
SPIRV.PhysicalModule
— TypeSPIR-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.
SPIRV.ResultID
— TypeResult ID used in a SPIR-V context, following single static assignment rules for valid modules.
SPIRV.SPIRVTarget
— TypeSPIR-V target for compilation through the Julia frontend.
SPIRV.ShaderCompilationCache
— TypeShaderCompilationCache()
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.
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.
SPIRV.ShaderLayout
— TypeShader-compatible layout strategy, where layout information is strictly read from shader decorations.
SPIRV.ShaderSource
— TypeSPIR-V shader code, with stage and entry point information.
SPIRV.SupportedFeatures
— TypeExtensions and capabilities supported by a client API.
SPIRV.TypeMetadata
— TypeType metadata meant to be analyzed and modified to generate appropriate decorations.
SPIRV.U
— Typex*U
(x)U
Converts an input x
to an UInt32
when U
is right-multiplied with it.
SPIRV.VulkanLayout
— TypeVulkan-compatible layout strategy.
SPIRV.alignment
— Functionalignment(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.
SPIRV.datasize
— Functiondatasize(layout, T)
This is the total space occupied by a value of type T
, including padding between struct elements and array strides.
SPIRV.disassemble
— Methoddisassemble(io, spir_module)
Transform the content of spir_module
into a human-readable format and prints it to io
.
SPIRV.spir_type
— MethodGet a SPIR-V type from a Julia type, caching the mapping in the IR
if one is provided.
SPIRV.@any_hit
— Macro@any_hit [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a any_hit shader.
The supported parameters are the following:
options = CommonExecutionOptions()
: aCommonExecutionOptions
structure providing any_hit-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@callable
— Macro@callable [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a callable shader.
The supported parameters are the following:
options = CommonExecutionOptions()
: aCommonExecutionOptions
structure providing callable-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@closest_hit
— Macro@closest_hit [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a closest_hit shader.
The supported parameters are the following:
options = CommonExecutionOptions()
: aCommonExecutionOptions
structure providing closest_hit-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@compute
— Macro@compute [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a compute shader.
The supported parameters are the following:
options = ComputeExecutionOptions()
: aComputeExecutionOptions
structure providing compute-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@for
— Macro@for i in iter begin #= ... do something with i ... =# end @for i in iter1, j in iter2 begin #= ... do something with i and j ... =# end
Define a C-style for
loop.
This loop does not rely on the standard iteration protocol in Julia, and will instead mimic how loops work in C: a loop entry point usually defines loop variables, a condition guards the loop body, and a continue block usually increments loop variables on subsequent iterations.
SPIRV.@fragment
— Macro@fragment [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a fragment shader.
The supported parameters are the following:
options = FragmentExecutionOptions()
: aFragmentExecutionOptions
structure providing fragment-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@geometry
— Macro@geometry [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a geometry shader.
The supported parameters are the following:
options = GeometryExecutionOptions()
: aGeometryExecutionOptions
structure providing geometry-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@intersection
— Macro@intersection [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a intersection shader.
The supported parameters are the following:
options = CommonExecutionOptions()
: aCommonExecutionOptions
structure providing intersection-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@load
— Macro@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.
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.
SPIRV.@mesh
— Macro@mesh [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a mesh shader.
The supported parameters are the following:
options = MeshExecutionOptions()
: aMeshExecutionOptions
structure providing mesh-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@miss
— Macro@miss [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a miss shader.
The supported parameters are the following:
options = CommonExecutionOptions()
: aCommonExecutionOptions
structure providing miss-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@ray_generation
— Macro@ray_generation [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a ray_generation shader.
The supported parameters are the following:
options = CommonExecutionOptions()
: aCommonExecutionOptions
structure providing ray_generation-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@store
— Macro@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.
SPIRV.@task
— Macro@task [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a task shader.
The supported parameters are the following:
options = CommonExecutionOptions()
: aCommonExecutionOptions
structure providing task-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@tessellation_control
— Macro@tessellation_control [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a tessellation_control shader.
The supported parameters are the following:
options = TessellationExecutionOptions()
: aTessellationExecutionOptions
structure providing tessellation_control-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@tessellation_evaluation
— Macro@tessellation_evaluation [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a tessellation_evaluation shader.
The supported parameters are the following:
options = TessellationExecutionOptions()
: aTessellationExecutionOptions
structure providing tessellation_evaluation-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.@vertex
— Macro@vertex [parameters] f(::Type1::StorageClass1[{...}], ...)
Compile the provided signature f(args...)
into a vertex shader.
The supported parameters are the following:
options = CommonExecutionOptions()
: aCommonExecutionOptions
structure providing vertex-specific options.features = AllSupported()
: aSPIRV.FeatureSupport
structure informing the SPIR-V compiler
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()
: aVulkanLayout
to use to compute alignments, strides and offsets in structures and arrays.cache = nothing
: an optionalShaderCompilationCache
used to cacheShaderSource
s to prevent repeated compilation of SPIR-V modules.interpreter = SPIRVInterpreter()
: aSPIRVInterpreter
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 aShaderSource
, or leave it as aShader
for further introspection. If a cache is provided,assemble
must be set totrue
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([33m::Type[32m::StorageClass[39m[32m{[35m[BuiltIn][39m[38;5;168m, [@Decoration [= value]...][32m}[36m, ...)
For each argument, the following is to be provided:
- [33mREQUIRED[39m An argument type.
- [32mREQUIRED[39m A SPIR-V storage class (required).
- [35mOPTIONAL[39m A SPIR-V built-in category, see the Vulkan built-in variables.
- [38;5;168mOPTIONAL[39m 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([33m::Mutable{Vec4}[32m::Output[39m[32m{[35mPosition[39m[38;5;168m[32m}[36m, [33m::UInt32[32m::Input[39m[32m{[35mVertexIndex[39m[38;5;168m[32m}[36m)
@fragment [parameters] f([33m::Vec4[32m::Input[39m[36m, [33m::InvocationData[32m::PushConstant[39m[36m)
@fragment [parameters] f([33m::Mutable{Vec4}[32m::Output[39m[36m, [33m::Vec4[32m::Input[39m[32m{[35mFragCoord[39m[38;5;168m[32m}[36m, [33m::Vec2[32m::Input[39m[32m{[38;5;168m@Flat[32m}[36m)
@compute [parameters] f([33m::UInt32[32m::Workgroup[39m[36m)
@compute [parameters] f([33m::Mutable{Arr{256, Float32}}[32m::Workgroup[39m[36m, [33m::UInt32[32m::Input[39m[32m{[35mLocalInvocationIndex[39m[38;5;168m[32m}[36m)
SPIRV.Module
— TypeLogical representation of a SPIR-V module.
SPIRV.REGION_BLOCK
— ConstantSequence of blocks u
─→ [v
, vs...
] ─→ w
SPIRV.OpCode
— TypeEnumerated 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).