Python API Reference¶
- class vkdispatch.AddressMode(*values)¶
Bases:
Enum
Defines how to handle out-of-bounds addresses when accessing an image.
- REPEAT¶
Repeat the image data when accessing out-of-bounds addresses.
- Type:
int
- MIRRORED_REPEAT¶
Mirror and repeat the image data when accessing out-of-bounds addresses.
- Type:
int
- CLAMP_TO_EDGE¶
Clamp out-of-bounds addresses to the edge of the image.
- Type:
int
- CLAMP_TO_BORDER¶
Clamp out-of-bounds addresses to a specific border color.
- Type:
int
- MIRROR_CLAMP_TO_EDGE¶
Mirror the image and clamp out-of-bounds addresses to the edge of the image.
- Type:
int
- CLAMP_TO_BORDER = 3¶
- CLAMP_TO_EDGE = 2¶
- MIRRORED_REPEAT = 1¶
- MIRROR_CLAMP_TO_EDGE = 4¶
- REPEAT = 0¶
- class vkdispatch.BorderColor(*values)¶
Bases:
Enum
Defines the border color used when clamping out-of-bounds addresses.
- FLOAT_TRANSPARENT_BLACK¶
A fully transparent black border.
- Type:
int
- INT_TRANSPARENT_BLACK¶
A fully transparent black border.
- Type:
int
- FLOAT_OPAQUE_BLACK¶
An opaque black border with a specific alpha value.
- Type:
int
- INT_OPAQUE_BLACK¶
An opaque black border with a specific alpha value.
- Type:
int
- FLOAT_OPAQUE_WHITE¶
An opaque white border with a specific alpha value.
- Type:
int
- INT_OPAQUE_WHITE¶
An opaque white border with a specific alpha value.
- Type:
int
- FLOAT_OPAQUE_BLACK = 2¶
- FLOAT_OPAQUE_WHITE = 4¶
- FLOAT_TRANSPARENT_BLACK = 0¶
- INT_OPAQUE_BLACK = 3¶
- INT_OPAQUE_WHITE = 5¶
- INT_TRANSPARENT_BLACK = 1¶
- class vkdispatch.Buffer(shape: Tuple[int, ...], var_type: dtype)¶
Bases:
Handle
,Generic
[_ArgType
]TODO: Docstring
- mem_size: int¶
- read(index: int | None = None) ndarray ¶
Read the data in the buffer at the specified device index and return it as a numpy array.
Parameters: index (int): The index to read the data from. Default is 0.
Returns: (np.ndarray): The data in the buffer as a numpy array.
- shape: Tuple[int]¶
- size: int¶
- write(data: bytes | ndarray, index: int = -1) None ¶
Given data in some numpy array, write that data to the buffer at the specified index. The default index of -1 will write to all buffers.
Parameters: data (np.ndarray): The data to write to the buffer. index (int): The index to write the data to. Default is -1 and
will write to all buffers.
Returns: None
- class vkdispatch.BufferBindInfo(buffer: Buffer, binding: int, shape_name: str, read_access: bool, write_access: bool)¶
Bases:
object
A dataclass to hold information about a buffer binding.
- binding: int¶
- read_access: bool¶
- shape_name: str¶
- write_access: bool¶
- class vkdispatch.BufferBuilder(struct_alignment: int | None = None, usage: BufferUsage | None = None)¶
Bases:
object
A class for building buffers in memory that can be submitted to a compute pipeline.
- struct_alignment¶
The alignment of the struct in the buffer.
- Type:
int
- instance_bytes¶
The size of the struct in bytes.
- Type:
int
- instance_count¶
The number of instances of the struct.
- Type:
int
- backing_buffer¶
The backing buffer for the struct.
- Type:
np.ndarray
- element_map¶
A map of the elements in the
- Type:
Dict[Tuple[str, str], BufferedStructEntry]
- backing_buffer: ndarray = None¶
- element_map: Dict[Tuple[str, str], BufferedStructEntry]¶
- instance_bytes: int = 0¶
- instance_count: int = 0¶
- prepare(instance_count: int) None ¶
- register_struct(name: str, elements: List[StructElement]) Tuple[int, int] ¶
- reset() None ¶
- struct_alignment: int = -1¶
- tobytes()¶
- toints()¶
- class vkdispatch.BufferedStructEntry(memory_slice: slice, dtype: numpy.dtype | None, shape: Tuple[int, ...])¶
Bases:
object
- dtype: dtype | None¶
- memory_slice: slice¶
- shape: Tuple[int, ...]¶
- class vkdispatch.CommandGraph(reset_on_submit: bool = False, submit_on_record: bool = False)¶
Bases:
CommandList
TODO: Docstring
- bind_var(name: str)¶
- buffers_valid: bool¶
- name_to_pc_key_dict: Dict[str, List[Tuple[str, str]]]¶
- pc_builder: BufferBuilder¶
- pc_values: Dict[Tuple[str, str], Any]¶
- queued_pc_values: Dict[Tuple[str, str], Any]¶
- record_shader(plan: ComputePlan, shader_description: ShaderDescription, exec_limits: Tuple[int, int, int], blocks: Tuple[int, int, int], bound_buffers: List[BufferBindInfo], bound_samplers: List[ImageBindInfo], uniform_values: Dict[str, Any] = {}, pc_values: Dict[str, Any] = {}, shader_uuid: str = None) None ¶
- reset() None ¶
Reset the command graph by clearing the push constant buffer and descriptor set lists.
- set_var(name: str, value: Any)¶
- submit(instance_count: int = None, queue_index: int = -2) None ¶
Submit the command list to the specified device with additional data to append to the front of the command list.
Parameters: device_index (int): The device index to submit the command list to.
Default is 0.
data (bytes): The additional data to append to the front of the command list.
- submit_any(instance_count: int = None) None ¶
- submit_on_record: bool¶
- uniform_bindings: Any¶
- uniform_builder: BufferBuilder¶
- uniform_constants_size: int¶
- uniform_descriptors: List[Tuple[DescriptorSet, int, int]]¶
- uniform_values: Dict[Tuple[str, str], Any]¶
- class vkdispatch.CommandList¶
Bases:
Handle
A class for recording and submitting command lists to the device.
- _handle¶
The handle to the command list.
- Type:
int
- get_instance_size() int ¶
Get the total size of the command list in bytes.
- record_compute_plan(plan: ComputePlan, descriptor_set: DescriptorSet, blocks: Tuple[int, int, int]) None ¶
Record a compute plan to the command list.
- Parameters:
plan (ComputePlan) – The compute plan to record to the command list.
descriptor_set (DescriptorSet) – The descriptor set to bind to the compute plan.
blocks (Tuple[int, int, int]) – The number of blocks to run the compute shader in.
- reset() None ¶
Reset the command list.
- submit(data: bytes | None = None, queue_index: int = -2, instance_count: int | None = None) None ¶
Submit the command list to the specified device with additional data to
- class vkdispatch.ComputePlan(shader_source: str, binding_type_list: list, pc_size: int, shader_name: str)¶
Bases:
Handle
ComputePlan is a wrapper for the native functions which create and dispatch Vulkan compute shaders.
- pc_size¶
The size of the push constants for the compute shader (in bytes)
- Type:
int
- shader_source¶
The source code of the compute shader (in GLSL)
- Type:
str
- binding_list¶
A list of binding types for the shader resources.
- Type:
list
- _handle¶
A pointer to the compute plan created by the native Vulkan dispatch.
- Type:
int
- class vkdispatch.DescriptorSet(compute_plan: ComputePlan)¶
Bases:
Handle
TODO: Docstring
- class vkdispatch.DeviceInfo(dev_index: int, version_variant: int, version_major: int, version_minor: int, version_patch: int, driver_version: int, vendor_id: int, device_id: int, device_type: int, device_name: str, shader_buffer_float32_atomics: int, shader_buffer_float32_atomic_add: int, float_64_support: int, float_16_support: int, int_64_support: int, int_16_support: int, storage_buffer_16_bit_access: int, uniform_and_storage_buffer_16_bit_access: int, storage_push_constant_16: int, storage_input_output_16: int, max_workgroup_size: Tuple[int, int, int], max_workgroup_invocations: int, max_workgroup_count: Tuple[int, int, int], max_bound_descriptor_sets: int, max_push_constant_size: int, max_storage_buffer_range: int, max_uniform_buffer_range: int, uniform_buffer_alignment: int, sub_group_size: int, supported_stages: int, supported_operations: int, quad_operations_in_all_stages: int, max_compute_shared_memory_size: int, queue_properties: List[Tuple[int, int]])¶
Bases:
object
A class which represents all the features and properties of a Vulkan device.
NOTE: This class is not meant to be instantiated by the user. Instead, the user should call the get_devices() function to get a list of DeviceInfo instances.
- dev_index¶
The index of the device.
- Type:
int
- version_variant¶
The Vulkan variant version.
- Type:
int
- version_major¶
The Vulkan major version.
- Type:
int
- version_minor¶
The Vulkan minor version.
- Type:
int
- version_patch¶
The Vulkan patch version.
- Type:
int
- driver_version¶
The version of the driver.
- Type:
int
- vendor_id¶
The vendor ID of the device.
- Type:
int
- device_id¶
The device ID of the device.
- Type:
int
- device_type¶
The device type, which is one of the following: 0: Other 1: Integrated GPU 2: Discrete GPU 3: Virtual GPU 4: CPU
- Type:
int
- device_name¶
The name of the device.
- Type:
str
- shader_buffer_float32_atomics¶
float32 atomics support.
- Type:
int
- shader_buffer_float32_atomic_add¶
float32 atomic add support.
- Type:
int
- float_64_support¶
64-bit float support.
- Type:
int
- int_64_support¶
64-bit integer support.
- Type:
int
- int_16_support¶
16-bit integer support.
- Type:
int
- max_workgroup_size¶
Maximum workgroup size.
- Type:
Tuple[int, int, int]
- max_workgroup_invocations¶
Maximum workgroup invocations.
- Type:
int
- max_workgroup_count¶
Maximum workgroup count.
- Type:
Tuple[int, int, int]
- max_bound_descriptor_sets¶
Maximum bound descriptor sets.
- Type:
int
- max_push_constant_size¶
Maximum push constant size.
- Type:
int
- max_storage_buffer_range¶
Maximum storage buffer range.
- Type:
int
- max_uniform_buffer_range¶
Maximum uniform buffer range.
- Type:
int
- uniform_buffer_alignment¶
Uniform buffer alignment.
- Type:
int
- sub_group_size¶
Subgroup size.
- Type:
int
- supported_stages¶
Supported subgroup stages.
- Type:
int
- supported_operations¶
Supported subgroup operations.
- Type:
int
- quad_operations_in_all_stages¶
Quad operations in all stages.
- Type:
int
Maximum compute shared memory size.
- Type:
int
- queue_properties¶
Queue properties.
- Type:
List[Tuple[int, int]]
- get_info_string(verbose: bool = False) str ¶
A method which returns a string representation of the device information.
- Parameters:
verbose (bool) – A flag to enable verbose output.
- Returns:
A string representation of the device information.
- Return type:
str
- is_nvidia() bool ¶
A method which checks if the device is an NVIDIA device.
- Returns:
A flag indicating whether the device is an NVIDIA device.
- Return type:
bool
- class vkdispatch.ExectionBounds(names_and_defaults, local_size, workgroups, exec_size)¶
Bases:
object
- exec_size: Tuple[int, int, int] | Callable | None¶
- get_blocks_and_limits(args, kwargs) Tuple[Tuple[int, int, int], Tuple[int, int, int]] ¶
- local_size: Tuple[int, int, int]¶
- names_and_defaults: List[Tuple[str, Any]]¶
- process_input(in_val, args, kwargs) Tuple[int, int, int] ¶
- workgroups: Tuple[int, int, int] | Callable | None¶
- class vkdispatch.Filter(*values)¶
Bases:
Enum
Defines the filter used for image sampling.
- NEAREST¶
Nearest neighbor filtering.
- Type:
int
- LINEAR¶
Linear interpolation filtering.
- Type:
int
- LINEAR = 1¶
- NEAREST = 0¶
- class vkdispatch.Image(shape: Tuple[int, ...], layers: int, dtype: type, channels: int, view_type: image_view_type, enable_mipmaps: bool = False)¶
Bases:
Handle
- read(device_index: int = 0) ndarray ¶
- sample(mag_filter: Filter = Filter.LINEAR, min_filter: Filter = Filter.LINEAR, mip_filter: Filter = Filter.LINEAR, address_mode: AddressMode = AddressMode.CLAMP_TO_EDGE, mip_lod_bias: float = 0.0, min_lod: float = 0.0, max_lod: float = 0.0, border_color: BorderColor = BorderColor.FLOAT_OPAQUE_WHITE) Sampler ¶
- write(data: ndarray, device_index: int = -1) None ¶
- class vkdispatch.Image1D(shape: int, dtype: type, channels: int = 1, enable_mipmaps: bool = False)¶
Bases:
Image
- class vkdispatch.Image2D(shape: ~typing.Tuple[int, int], dtype: type = <class 'numpy.float32'>, channels: int = 1, enable_mipmaps: bool = False)¶
Bases:
Image
- class vkdispatch.Image2DArray(shape: ~typing.Tuple[int, int], layers: int, dtype: type = <class 'numpy.float32'>, channels: int = 1, enable_mipmaps: bool = False)¶
Bases:
Image
- class vkdispatch.Image3D(shape: ~typing.Tuple[int, int, int], dtype: type = <class 'numpy.float32'>, channels: int = 1, enable_mipmaps: bool = False)¶
Bases:
Image
- class vkdispatch.ImageBindInfo(sampler: Sampler, binding: int, read_access: bool, write_access: bool)¶
Bases:
object
A dataclass to hold information about an image binding.
- binding: int¶
- read_access: bool¶
- write_access: bool¶
- class vkdispatch.LaunchParametersHolder(names_and_defaults, args, kwargs)¶
Bases:
object
- get_names() List[str] ¶
- get_values() List[Any] ¶
- class vkdispatch.LogLevel(*values)¶
Bases:
Enum
An enumeration which represents the log levels.
- VERBOSE¶
All possible logs are printed. Module must be compiled with debug mode enabled to see these logs.
- Type:
int
- INFO¶
All release mode logs are printed. Useful for debugging the publicly available module.
- Type:
int
- WARNING¶
Only warnings and errors are printed. Default log level.
- Type:
int
- ERROR¶
Only errors are printed. Useful for muting annoying warnings that you know are harmless.
- Type:
int
- ERROR = 3¶
- INFO = 1¶
- VERBOSE = 0¶
- WARNING = 2¶
- class vkdispatch.MappingFunction(buffer_types: List[vkdispatch.base.dtype.dtype], register_types: List[vkdispatch.base.dtype.dtype], return_type: vkdispatch.base.dtype.dtype, mapping_function: Callable, instance_id: uuid.UUID = <factory>)¶
Bases:
object
- instance_id: UUID¶
- mapping_function: Callable¶
- class vkdispatch.RFFTBuffer(shape: Tuple[int, ...])¶
Bases:
Buffer
- read_fourier(index: int | None = None) ndarray ¶
- read_real(index: int | None = None) ndarray ¶
- write_fourier(data: ndarray, index: int = -1)¶
- write_real(data: ndarray, index: int = -1)¶
- class vkdispatch.ReductionObject(reduction: ReductionOperation, group_size: int = None, axes: List[int] = None, mapping_function: MappingFunction = None)¶
Bases:
object
- make_stages()¶
- class vkdispatch.ReductionOperation(name: str, reduction: Callable[[vkdispatch.codegen.builder.ShaderVariable, vkdispatch.codegen.builder.ShaderVariable], vkdispatch.codegen.builder.ShaderVariable], identity: int | float | str, subgroup_reduction: Callable[[vkdispatch.codegen.builder.ShaderVariable], vkdispatch.codegen.builder.ShaderVariable] | None = None)¶
Bases:
object
- identity: int | float | str¶
- name: str¶
- reduction: Callable[[ShaderVariable, ShaderVariable], ShaderVariable]¶
- subgroup_reduction: Callable[[ShaderVariable], ShaderVariable] | None = None¶
- class vkdispatch.ReductionParams(input_offset: vkdispatch.base.dtype._I32, input_size: vkdispatch.base.dtype._I32, input_stride: vkdispatch.base.dtype._I32, input_y_batch_stride: vkdispatch.base.dtype._I32, input_z_batch_stride: vkdispatch.base.dtype._I32, output_offset: vkdispatch.base.dtype._I32, output_stride: vkdispatch.base.dtype._I32, output_y_batch_stride: vkdispatch.base.dtype._I32, output_z_batch_stride: vkdispatch.base.dtype._I32)¶
Bases:
object
- input_offset: _I32¶
- input_size: _I32¶
- input_stride: _I32¶
- input_y_batch_stride: _I32¶
- input_z_batch_stride: _I32¶
- output_offset: _I32¶
- output_stride: _I32¶
- output_y_batch_stride: _I32¶
- output_z_batch_stride: _I32¶
- class vkdispatch.Sampler(image: Image, mag_filter: Filter = Filter.LINEAR, min_filter: Filter = Filter.LINEAR, mip_filter: Filter = Filter.LINEAR, address_mode: AddressMode = AddressMode.CLAMP_TO_EDGE, mip_lod_bias: float = 0.0, min_lod: float = 0.0, max_lod: float = 0.0, border_color: BorderColor = BorderColor.FLOAT_OPAQUE_WHITE)¶
Bases:
Handle
- class vkdispatch.ShaderArgument(name: str, arg_type: vkdispatch.shader_generation.signature.ShaderArgumentType, default_value: Any, shader_name: str | Dict[str, str], shader_shape_name: str | None, binding: int | None)¶
Bases:
object
- arg_type: ShaderArgumentType¶
- binding: int | None¶
- default_value: Any¶
- name: str¶
- shader_name: str | Dict[str, str]¶
- shader_shape_name: str | None¶
- class vkdispatch.ShaderArgumentType(*values)¶
Bases:
Enum
- BUFFER = 0¶
- CONSTANT = 3¶
- CONSTANT_DATACLASS = 4¶
- IMAGE = 1¶
- VARIABLE = 2¶
- class vkdispatch.ShaderObject(description: ShaderDescription, signature: ShaderSignature, local_size=None, workgroups=None, exec_count=None)¶
Bases:
object
- bounds: ExectionBounds¶
- build()¶
- make_repr(line_numbers: bool = True) str ¶
- plan: ComputePlan¶
- ready: bool¶
- shader_description: ShaderDescription¶
- shader_signature: ShaderSignature¶
- source: str¶
- class vkdispatch.ShaderSignature¶
Bases:
object
- arguments: List[ShaderArgument]¶
- classmethod from_argument_list(arguments: List[ShaderArgument] | None = None) ShaderSignature ¶
- classmethod from_inspectable_function(builder: ShaderBuilder, func: Callable) ShaderSignature ¶
- classmethod from_type_annotations(builder: ShaderBuilder, annotations: List, names: List[str] | None = None, defaults: List[Any] | None = None) ShaderSignature ¶
- get_names_and_defaults() List[Tuple[str, Any]] ¶
- get_variables() List[ShaderVariable] ¶
- variables: List[ShaderVariable]¶
- vkdispatch.asrfftbuffer(data: ndarray) RFFTBuffer ¶
- vkdispatch.check_for_compute_stage_errors()¶
Check for errors in the shader compilation stage of the vkdispatch_native library and raise a RuntimeError if found.
- vkdispatch.check_for_errors()¶
Check for errors in the vkdispatch_native library and raise a RuntimeError if found.
- vkdispatch.complex64¶
alias of
_CF64
- vkdispatch.default_graph() CommandGraph ¶
- class vkdispatch.dtype¶
Bases:
object
- child_count: int¶
- dimentions: int¶
- format_str: str¶
- glsl_type: str¶
- glsl_type_extern: str | None = None¶
- item_size: int¶
- name: str¶
- numpy_shape: tuple¶
- shape: tuple¶
- true_numpy_shape: tuple¶
- vkdispatch.float32¶
alias of
_F32
- vkdispatch.get_context() Context ¶
- vkdispatch.get_context_handle() int ¶
- vkdispatch.get_devices() List[DeviceInfo] ¶
Get a list of DeviceInfo instances representing all the Vulkan devices on the system.
- Returns:
A list of DeviceInfo instances.
- Return type:
List[DeviceInfo]
- vkdispatch.global_graph() CommandGraph ¶
- class vkdispatch.image_format(*values)¶
Bases:
Enum
- R16G16B16A16_SFLOAT = 97¶
- R16G16B16A16_SINT = 96¶
- R16G16B16A16_UINT = 95¶
- R16G16B16_SFLOAT = 90¶
- R16G16B16_SINT = 89¶
- R16G16B16_UINT = 88¶
- R16G16_SFLOAT = 83¶
- R16G16_SINT = 82¶
- R16G16_UINT = 81¶
- R16_SFLOAT = 76¶
- R16_SINT = 75¶
- R16_UINT = 74¶
- R32G32B32A32_SFLOAT = 109¶
- R32G32B32A32_SINT = 108¶
- R32G32B32A32_UINT = 107¶
- R32G32B32_SFLOAT = 106¶
- R32G32B32_SINT = 105¶
- R32G32B32_UINT = 104¶
- R32G32_SFLOAT = 103¶
- R32G32_SINT = 102¶
- R32G32_UINT = 101¶
- R32_SFLOAT = 100¶
- R32_SINT = 99¶
- R32_UINT = 98¶
- R64G64B64A64_SFLOAT = 121¶
- R64G64B64A64_SINT = 120¶
- R64G64B64A64_UINT = 119¶
- R64G64B64_SFLOAT = 118¶
- R64G64B64_SINT = 117¶
- R64G64B64_UINT = 116¶
- R64G64_SFLOAT = 115¶
- R64G64_SINT = 114¶
- R64G64_UINT = 113¶
- R64_SFLOAT = 112¶
- R64_SINT = 111¶
- R64_UINT = 110¶
- R8G8B8A8_SINT = 42¶
- R8G8B8A8_UINT = 41¶
- R8G8B8_SINT = 28¶
- R8G8B8_UINT = 27¶
- R8G8_SINT = 21¶
- R8G8_UINT = 20¶
- R8_SINT = 14¶
- R8_UINT = 13¶
- class vkdispatch.image_type(*values)¶
Bases:
Enum
Defines the type of an image.
- TYPE_1D¶
A 1-dimensional image.
- Type:
int
- TYPE_2D¶
A 2-dimensional image.
- Type:
int
- TYPE_3D¶
A 3-dimensional image.
- Type:
int
- TYPE_1D = (0,)¶
- TYPE_2D = (1,)¶
- TYPE_3D = (2,)¶
- class vkdispatch.image_view_type(*values)¶
Bases:
Enum
Defines the type of an image view.
- VIEW_TYPE_1D¶
A 1-dimensional image view.
- Type:
int
- VIEW_TYPE_2D¶
A 2-dimensional image view.
- Type:
int
- VIEW_TYPE_3D¶
A 3-dimensional image view.
- Type:
int
- VIEW_TYPE_2D_ARRAY¶
A 2D array of images.
- Type:
int
- VIEW_TYPE_1D = (0,)¶
- VIEW_TYPE_2D = (1,)¶
- VIEW_TYPE_2D_ARRAY = (5,)¶
- VIEW_TYPE_3D = (2,)¶
- vkdispatch.initialize(debug_mode: bool = False, log_level: LogLevel = LogLevel.WARNING, loader_debug_logs: bool = False)¶
A function which initializes the Vulkan dispatch library.
- Parameters:
debug_mode (bool) – A flag to enable debug mode.
log_level (LogLevel) – The log level, which is one of the following: LogLevel.VERBOSE LogLevel.INFO LogLevel.WARNING LogLevel.ERROR
loader_debug_logs (bool) – A flag to enable vulkan loader debug logs.
- vkdispatch.int32¶
alias of
_I32
- vkdispatch.is_context_initialized() bool ¶
- vkdispatch.is_initialized() bool ¶
A function which checks if the Vulkan dispatch library has been initialized.
- Returns:
A flag indicating whether the Vulkan dispatch library has been initialized.
- Return type:
bool
- vkdispatch.ivec2¶
alias of
_V2I32
- vkdispatch.ivec3¶
alias of
_V3I32
- vkdispatch.ivec4¶
alias of
_V4I32
- vkdispatch.log(text: str, end: str = '\n', level: LogLevel = LogLevel.ERROR, stack_offset: int = 1)¶
A function which logs a message at the specified log level.
- Parameters:
level (LogLevel) – The log level.
message (str) – The message to log.
- vkdispatch.log_error(text: str, end: str = '\n')¶
A function which logs an error message.
- Parameters:
message (str) – The message to log.
- vkdispatch.log_info(text: str, end: str = '\n')¶
A function which logs an info message.
- Parameters:
message (str) – The message to log.
- vkdispatch.log_verbose(text: str, end: str = '\n')¶
A function which logs a verbose message.
- Parameters:
message (str) – The message to log.
- vkdispatch.log_warning(text: str, end: str = '\n')¶
A function which logs a warning message.
- Parameters:
message (str) – The message to log.
- vkdispatch.make_context(device_ids: int | List[int] | None = None, device_count: int | None = None, queue_counts: int | List[int] | None = None, queue_families: List[List[int]] | None = None, use_cpu: bool = False, multi_device: bool = False, multi_queue: bool = False) Context ¶
- vkdispatch.make_reduction_stage(reduction: ReductionOperation, out_type: dtype, group_size: int, output_is_input: bool, name: str = None, map_func: Callable = None, input_types: List = None) ShaderObject ¶
- vkdispatch.map(func: Callable, register_types: List[dtype] = None, return_type: dtype = None, input_types: List[dtype] = None) MappingFunction ¶
- vkdispatch.map_reduce(reduction: ReductionOperation, axes=None, group_size=None)¶
- vkdispatch.map_registers(register_types: List[dtype]) Callable[[Callable], MappingFunction] ¶
- vkdispatch.mat2¶
alias of
_M2F32
- vkdispatch.mat4¶
alias of
_M4F32
- vkdispatch.queue_wait_idle(queue_index: int = None) None ¶
Wait for the specified queue to finish processing. For all queues, leave queue_index as None.
- Parameters:
queue_index (int) – The index of the queue.
- vkdispatch.reduce(identity, axes=None, group_size=None, mapping_function: MappingFunction = None)¶
- vkdispatch.select_queue_families(device_index: int, queue_count: int = None) List[int] ¶
- vkdispatch.set_global_graph(graph: CommandGraph = None) CommandGraph ¶
- vkdispatch.set_log_level(level: LogLevel)¶
A function which sets the log level.
- Parameters:
level (LogLevel) – The log level.
- vkdispatch.shader(exec_size=None, local_size=None, workgroups=None, enable_subgroup_ops: bool = True, enable_atomic_float_ops: bool = True, enable_printf: bool = True, enable_exec_bounds: bool = True)¶
- vkdispatch.uint32¶
alias of
_U32
- vkdispatch.uvec2¶
alias of
_V2U32
- vkdispatch.uvec3¶
alias of
_V3U32
- vkdispatch.uvec4¶
alias of
_V4U32
- vkdispatch.vec2¶
alias of
_V2F32
- vkdispatch.vec3¶
alias of
_V3F32
- vkdispatch.vec4¶
alias of
_V4F32
- class vkdispatch.codegen.Buffer¶
Bases:
BufferVariable
,Generic
[_ArgType
]
- class vkdispatch.codegen.BufferVariable(append_func: Callable[[str], None], name_func: Callable[[str], Tuple[str, str]], var_type: dtype, binding: int, name: str | None = None, shape_var: ShaderVariable = None, shape_name: str | None = None, raw_name: str | None = None, read_lambda: Callable[[], None] = None, write_lambda: Callable[[], None] = None)¶
Bases:
BoundVariable
- read_callback()¶
- read_lambda: Callable[[], None]¶
- write_callback()¶
- write_lambda: Callable[[], None]¶
- vkdispatch.codegen.ConstArr¶
alias of
ConstantArray
- class vkdispatch.codegen.Constant¶
Bases:
ShaderVariable
,Generic
[_ArgType
]
- class vkdispatch.codegen.ConstantArray¶
Bases:
ShaderVariable
,Generic
[_ArgType
,_ArgCount
]
- class vkdispatch.codegen.Image1D¶
Bases:
ImageVariable
,Generic
[_ArgType
]
- class vkdispatch.codegen.Image2D¶
Bases:
ImageVariable
,Generic
[_ArgType
]
- class vkdispatch.codegen.Image3D¶
Bases:
ImageVariable
,Generic
[_ArgType
]
- class vkdispatch.codegen.ImageVariable(append_func: Callable[[str], None], name_func: Callable[[str], Tuple[str, str]], var_type: dtype, binding: int, dimensions: int, name: str | None = None, read_lambda: Callable[[], None] = None, write_lambda: Callable[[], None] = None)¶
Bases:
BoundVariable
- dimensions: int = 0¶
- read_callback()¶
- read_lambda: Callable[[], None]¶
- sample(coord: ShaderVariable, lod: ShaderVariable = None) ShaderVariable ¶
- write_callback()¶
- write_lambda: Callable[[], None]¶
- class vkdispatch.codegen.ShaderBinding(dtype: dtype, name: str, dimension: int, binding_type: BindingType)¶
Bases:
object
A dataclass that represents a bound resource in a shader. Either a buffer or an image.
- dtype¶
The dtype of the resource. If the resource is an image, this should be vd.vec4 (since all images are sampled with 4 channels in shaders).
- Type:
vd.dtype
- name¶
The name of the resource within the shader code.
- Type:
str
- dimension¶
The dimension of the resource. Set to 0 for buffers and 1, 2, or 3 for images.
- Type:
int
- binding_type¶
The type of the binding. Either STORAGE_BUFFER, UNIFORM_BUFFER, or SAMPLER.
- Type:
BindingType
- binding_type: BindingType¶
- dimension: int¶
- name: str¶
- class vkdispatch.codegen.ShaderBuilder(enable_subgroup_ops: bool = True, enable_atomic_float_ops: bool = True, enable_printf: bool = True, enable_exec_bounds: bool = True)¶
Bases:
object
- abs(arg: ShaderVariable)¶
- acos(arg: ShaderVariable)¶
- acosh(arg: ShaderVariable)¶
- append_contents(contents: str) None ¶
- asin(arg: ShaderVariable)¶
- asinh(arg: ShaderVariable)¶
- atan(arg: ShaderVariable)¶
- atan2(arg1: ShaderVariable, arg2: ShaderVariable)¶
- atanh(arg: ShaderVariable)¶
- atomic_add(arg1: ShaderVariable, arg2: ShaderVariable)¶
- barrier()¶
- binding_count: int¶
- binding_list: List[ShaderBinding]¶
- binding_read_access: Dict[int, bool]¶
- binding_write_access: Dict[int, bool]¶
- build(name: str) ShaderDescription ¶
- ceil(arg: ShaderVariable)¶
- clamp(arg: ShaderVariable, min_val: ShaderVariable, max_val: ShaderVariable)¶
- comment(comment: str) None ¶
- complex_from_euler_angle(angle: ShaderVariable)¶
- compose_struct_decleration(elements: List[StructElement]) str ¶
- contents: str¶
- cos(arg: ShaderVariable)¶
- cosh(arg: ShaderVariable)¶
- cross(arg1: ShaderVariable, arg2: ShaderVariable)¶
- declare_image(dimensions: int, var_name: str | None = None)¶
- degrees(arg: ShaderVariable)¶
- determinant(arg: ShaderVariable)¶
- distance(arg1: ShaderVariable, arg2: ShaderVariable)¶
- dot(arg1: ShaderVariable, arg2: ShaderVariable)¶
- else_if_all(*args: List[ShaderVariable])¶
- else_if_any(*args: List[ShaderVariable])¶
- else_if_statement(arg: ShaderVariable)¶
- else_statement()¶
- end()¶
- exec_count: ShaderVariable | None¶
- exp(arg: ShaderVariable)¶
- exp2(arg: ShaderVariable)¶
- float_bits_to_int(arg: ShaderVariable)¶
- float_bits_to_uint(arg: ShaderVariable)¶
- floor(arg: ShaderVariable)¶
- fma(arg1: ShaderVariable, arg2: ShaderVariable, arg3: ShaderVariable)¶
- get_name_func(prefix: str | None = None, suffix: str | None = None)¶
- if_all(*args: List[ShaderVariable])¶
- if_any(*args: List[ShaderVariable])¶
- if_statement(arg: ShaderVariable, command: str | None = None)¶
- int_bits_to_float(arg: ShaderVariable)¶
- inverse(arg: ShaderVariable)¶
- inverse_sqrt(arg: ShaderVariable)¶
- isinf(arg: ShaderVariable)¶
- isnan(arg: ShaderVariable)¶
- length(arg: ShaderVariable)¶
- log(arg: ShaderVariable)¶
- log2(arg: ShaderVariable)¶
- logical_and(arg1: ShaderVariable, arg2: ShaderVariable)¶
- logical_or(arg1: ShaderVariable, arg2: ShaderVariable)¶
- make_var(var_type: dtype, var_name: str | None, parents: List[ShaderVariable], prefix: str | None = None, suffix: str | None = None, lexical_unit: bool = False, settable: bool = False) ShaderVariable ¶
- max(arg1: ShaderVariable, arg2: ShaderVariable)¶
- memory_barrier()¶
- min(arg1: ShaderVariable, arg2: ShaderVariable)¶
- mix(arg1: ShaderVariable, arg2: ShaderVariable, arg3: ShaderVariable)¶
- mod(arg1: ShaderVariable, arg2: ShaderVariable)¶
- mult_c64(arg1: ShaderVariable, arg2: ShaderVariable)¶
- mult_c64_by_const(arg1: ShaderVariable, number: complex)¶
- mult_conj_c64(arg1: ShaderVariable, arg2: ShaderVariable)¶
- new_float(*args, var_name: str | None = None)¶
- new_int(*args, var_name: str | None = None)¶
- new_ivec2(*args, var_name: str | None = None)¶
- new_ivec3(*args, var_name: str | None = None)¶
- new_ivec4(*args, var_name: str | None = None)¶
- new_uint(*args, var_name: str | None = None)¶
- new_uvec2(*args, var_name: str | None = None)¶
- new_uvec3(*args, var_name: str | None = None)¶
- new_uvec4(*args, var_name: str | None = None)¶
- new_vec2(*args, var_name: str | None = None)¶
- new_vec3(*args, var_name: str | None = None)¶
- new_vec4(*args, var_name: str | None = None)¶
- normalize(arg: ShaderVariable)¶
- pc_struct: StructBuilder¶
- pow(arg1: ShaderVariable, arg2: ShaderVariable)¶
- pre_header: str¶
- print_vars(*args: ShaderVariable | str, seperator=' ')¶
- printf(format: str, *args: ShaderVariable | str, seperator=' ')¶
- radians(arg: ShaderVariable)¶
- reset() None ¶
- return_statement(arg=None)¶
- round(arg: ShaderVariable)¶
- round_even(arg: ShaderVariable)¶
- scope_num: int¶
- set_kernel_index(index: ShaderVariable)¶
- set_mapping_index(index: ShaderVariable)¶
- set_mapping_registers(registers: ShaderVariable)¶
- sign(arg: ShaderVariable)¶
- sin(arg: ShaderVariable)¶
- sinh(arg: ShaderVariable)¶
- smoothstep(arg1: ShaderVariable, arg2: ShaderVariable, arg3: ShaderVariable)¶
- sqrt(arg: ShaderVariable)¶
- step(arg1: ShaderVariable, arg2: ShaderVariable)¶
- subgroup_add(arg1: ShaderVariable)¶
- subgroup_and(arg1: ShaderVariable)¶
- subgroup_barrier()¶
- subgroup_elect()¶
- subgroup_max(arg1: ShaderVariable)¶
- subgroup_min(arg1: ShaderVariable)¶
- subgroup_mul(arg1: ShaderVariable)¶
- subgroup_or(arg1: ShaderVariable)¶
- subgroup_xor(arg1: ShaderVariable)¶
- tan(arg: ShaderVariable)¶
- tanh(arg: ShaderVariable)¶
- transpose(arg: ShaderVariable)¶
- trunc(arg: ShaderVariable)¶
- uint_bits_to_float(arg: ShaderVariable)¶
- uniform_struct: StructBuilder¶
- unravel_index(index: ShaderVariable, shape: ShaderVariable)¶
- var_count: int¶
- while_statement(arg: ShaderVariable)¶
- class vkdispatch.codegen.ShaderDescription(header: str, body: str, name: str, pc_size: int, pc_structure: List[StructElement], uniform_structure: List[StructElement], binding_type_list: List[BindingType], binding_access: List[Tuple[bool, bool]], exec_count_name: str)¶
Bases:
object
A dataclass that represents a description of a shader object.
- source¶
The source code of the shader.
- Type:
str
- pc_size¶
The size of the push constant buffer in bytes.
- Type:
int
- pc_structure¶
The structure of the push constant buffer.
- Type:
List[vc.StructElement]
- uniform_structure¶
The structure of the uniform buffer.
- Type:
List[vc.StructElement]
- binding_type_list¶
The list of binding types.
- Type:
List[BindingType]
- binding_access: List[Tuple[bool, bool]]¶
- binding_type_list: List[BindingType]¶
- body: str¶
- exec_count_name: str¶
- header: str¶
- make_source(x: int, y: int, z: int) str ¶
- name: str¶
- pc_size: int¶
- pc_structure: List[StructElement]¶
- uniform_structure: List[StructElement]¶
- class vkdispatch.codegen.ShaderVariable(append_func: Callable[[str], None], name_func: Callable[[str], Tuple[str, str]], var_type: dtype, name: str | None = None, lexical_unit: bool = False, settable: bool = False, parent_variables: List[ShaderVariable] = None)¶
Bases:
object
- append_func: Callable[[str], None]¶
- can_index: bool = False¶
- copy(var_name: str = None)¶
Create a new variable with the same value as the current variable.
- index_suffix: str = ''¶
- lexical_unit: bool = False¶
- name: str¶
- name_func: Callable[[str], str]¶
- new(var_type: dtype, name: str, parents: List[ShaderVariable], lexical_unit: bool = False, settable: bool = False) ShaderVariable ¶
- new_scaled_and_offset_int(var_type: dtype, name: str, parents: List[ShaderVariable] = None) ScaledAndOfftsetIntVariable ¶
- parent_variables: List[ShaderVariable]¶
- printf_args() str ¶
- raw_name: str¶
- read_callback()¶
- settable: bool = False¶
- use_child_type: bool = True¶
- write_callback()¶
- class vkdispatch.codegen.StructBuilder¶
Bases:
object
A class for describing a struct in shader code (includes both the memory layout and code generation).
- elements¶
A list of the elements of the struct. Given as StructElement objects, which contain the name, index, dtype, and count of the element.
- Type:
List[StructElement]
- size¶
The size of the struct in bytes.
- Type:
int
- build() List[StructElement] ¶
- elements: List[StructElement]¶
- size: int¶
- class vkdispatch.codegen.StructElement(name: str, dtype: dtype, count: int)¶
Bases:
object
A dataclass that represents an element of a struct.
- name¶
The name of the element.
- Type:
str
- dtype¶
The dtype of the element.
- Type:
vd.dtype
- count¶
The count of the element.
- Type:
int
- count: int¶
- name: str¶
- vkdispatch.codegen.VarArr¶
alias of
VariableArray
- class vkdispatch.codegen.Variable¶
Bases:
ShaderVariable
,Generic
[_ArgType
]
- class vkdispatch.codegen.VariableArray¶
Bases:
ShaderVariable
,Generic
[_ArgType
,_ArgCount
]
- vkdispatch.codegen.abs(arg: ShaderVariable)¶
- vkdispatch.codegen.acos(arg: ShaderVariable)¶
- vkdispatch.codegen.acosh(arg: ShaderVariable)¶
- vkdispatch.codegen.asin(arg: ShaderVariable)¶
- vkdispatch.codegen.asinh(arg: ShaderVariable)¶
- vkdispatch.codegen.atan(arg: ShaderVariable)¶
- vkdispatch.codegen.atan2(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.atanh(arg: ShaderVariable)¶
- vkdispatch.codegen.atomic_add(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.barrier()¶
- vkdispatch.codegen.builder_context(enable_subgroup_ops: bool = True, enable_atomic_float_ops: bool = True, enable_printf: bool = True, enable_exec_bounds: bool = True)¶
- vkdispatch.codegen.c64¶
alias of
_CF64
- vkdispatch.codegen.ceil(arg: ShaderVariable)¶
- vkdispatch.codegen.clamp(arg: ShaderVariable, min_val: ShaderVariable, max_val: ShaderVariable)¶
- vkdispatch.codegen.comment(text: str)¶
- vkdispatch.codegen.complex_from_euler_angle(angle: ShaderVariable)¶
- vkdispatch.codegen.cos(arg: ShaderVariable)¶
- vkdispatch.codegen.cosh(arg: ShaderVariable)¶
- vkdispatch.codegen.cross(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.degrees(arg: ShaderVariable)¶
- vkdispatch.codegen.determinant(arg: ShaderVariable)¶
- vkdispatch.codegen.distance(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.dot(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.else_if_all(*args: List[ShaderVariable])¶
- vkdispatch.codegen.else_if_any(*args: List[ShaderVariable])¶
- vkdispatch.codegen.else_if_statement(arg: ShaderVariable)¶
- vkdispatch.codegen.else_statement()¶
- vkdispatch.codegen.end()¶
- vkdispatch.codegen.exp(arg: ShaderVariable)¶
- vkdispatch.codegen.exp2(arg: ShaderVariable)¶
- vkdispatch.codegen.f32¶
alias of
_F32
- vkdispatch.codegen.float_bits_to_int(arg: ShaderVariable)¶
- vkdispatch.codegen.float_bits_to_uint(arg: ShaderVariable)¶
- vkdispatch.codegen.floor(arg: ShaderVariable)¶
- vkdispatch.codegen.fma(arg1: ShaderVariable, arg2: ShaderVariable, arg3: ShaderVariable)¶
- vkdispatch.codegen.global_invocation()¶
- vkdispatch.codegen.i32¶
alias of
_I32
- vkdispatch.codegen.if_all(*args: List[ShaderVariable])¶
- vkdispatch.codegen.if_any(*args: List[ShaderVariable])¶
- vkdispatch.codegen.if_statement(arg: ShaderVariable, command: str | None = None)¶
- vkdispatch.codegen.int_bits_to_float(arg: ShaderVariable)¶
- vkdispatch.codegen.inverse(arg: ShaderVariable)¶
- vkdispatch.codegen.inverse_sqrt(arg: ShaderVariable)¶
- vkdispatch.codegen.isinf(arg: ShaderVariable)¶
- vkdispatch.codegen.isnan(arg: ShaderVariable)¶
- vkdispatch.codegen.iv2¶
alias of
_V2I32
- vkdispatch.codegen.iv3¶
alias of
_V3I32
- vkdispatch.codegen.iv4¶
alias of
_V4I32
- vkdispatch.codegen.kernel_index()¶
- vkdispatch.codegen.length(arg: ShaderVariable)¶
- vkdispatch.codegen.local_invocation()¶
- vkdispatch.codegen.log(arg: ShaderVariable)¶
- vkdispatch.codegen.log2(arg: ShaderVariable)¶
- vkdispatch.codegen.logical_and(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.logical_or(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.m2¶
alias of
_M2F32
- vkdispatch.codegen.m4¶
alias of
_M4F32
- vkdispatch.codegen.mapping_index()¶
- vkdispatch.codegen.mapping_registers()¶
- vkdispatch.codegen.max(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.memory_barrier()¶
- vkdispatch.codegen.min(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.mix(arg1: ShaderVariable, arg2: ShaderVariable, arg3: ShaderVariable)¶
- vkdispatch.codegen.mod(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.mult_c64(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.mult_c64_by_const(arg1: ShaderVariable, number: complex)¶
- vkdispatch.codegen.mult_conj_c64(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.new_float(*args, var_name: str | None = None)¶
- vkdispatch.codegen.new_int(*args, var_name: str | None = None)¶
- vkdispatch.codegen.new_ivec2(*args, var_name: str | None = None)¶
- vkdispatch.codegen.new_ivec3(*args, var_name: str | None = None)¶
- vkdispatch.codegen.new_ivec4(*args, var_name: str | None = None)¶
- vkdispatch.codegen.new_uint(*args, var_name: str | None = None)¶
- vkdispatch.codegen.new_uvec2(*args, var_name: str | None = None)¶
- vkdispatch.codegen.new_uvec3(*args, var_name: str | None = None)¶
- vkdispatch.codegen.new_uvec4(*args, var_name: str | None = None)¶
- vkdispatch.codegen.new_vec2(*args, var_name: str | None = None)¶
- vkdispatch.codegen.new_vec3(*args, var_name: str | None = None)¶
- vkdispatch.codegen.new_vec4(*args, var_name: str | None = None)¶
- vkdispatch.codegen.normalize(arg: ShaderVariable)¶
- vkdispatch.codegen.num_subgroups()¶
- vkdispatch.codegen.num_workgroups()¶
- vkdispatch.codegen.pow(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.print(*args: ShaderVariable | str, seperator=' ')¶
- vkdispatch.codegen.printf(format: str, *args: ShaderVariable | str, seperator=' ')¶
- vkdispatch.codegen.radians(arg: ShaderVariable)¶
- vkdispatch.codegen.return_statement(arg=None)¶
- vkdispatch.codegen.round(arg: ShaderVariable)¶
- vkdispatch.codegen.round_even(arg: ShaderVariable)¶
- vkdispatch.codegen.set_global_builder(builder: ShaderBuilder)¶
- vkdispatch.codegen.set_kernel_index(index: ShaderVariable)¶
- vkdispatch.codegen.set_mapping_index(index: ShaderVariable)¶
- vkdispatch.codegen.set_mapping_registers(registers: ShaderVariable)¶
- vkdispatch.codegen.sign(arg: ShaderVariable)¶
- vkdispatch.codegen.sin(arg: ShaderVariable)¶
- vkdispatch.codegen.sinh(arg: ShaderVariable)¶
- vkdispatch.codegen.smoothstep(arg1: ShaderVariable, arg2: ShaderVariable, arg3: ShaderVariable)¶
- vkdispatch.codegen.sqrt(arg: ShaderVariable)¶
- vkdispatch.codegen.step(arg1: ShaderVariable, arg2: ShaderVariable)¶
- vkdispatch.codegen.subgroup_add(arg1: ShaderVariable)¶
- vkdispatch.codegen.subgroup_and(arg1: ShaderVariable)¶
- vkdispatch.codegen.subgroup_barrier()¶
- vkdispatch.codegen.subgroup_elect()¶
- vkdispatch.codegen.subgroup_id()¶
- vkdispatch.codegen.subgroup_invocation()¶
- vkdispatch.codegen.subgroup_max(arg1: ShaderVariable)¶
- vkdispatch.codegen.subgroup_min(arg1: ShaderVariable)¶
- vkdispatch.codegen.subgroup_mul(arg1: ShaderVariable)¶
- vkdispatch.codegen.subgroup_or(arg1: ShaderVariable)¶
- vkdispatch.codegen.subgroup_size()¶
- vkdispatch.codegen.subgroup_xor(arg1: ShaderVariable)¶
- vkdispatch.codegen.tan(arg: ShaderVariable)¶
- vkdispatch.codegen.tanh(arg: ShaderVariable)¶
- vkdispatch.codegen.transpose(arg: ShaderVariable)¶
- vkdispatch.codegen.trunc(arg: ShaderVariable)¶
- vkdispatch.codegen.u32¶
alias of
_U32
- vkdispatch.codegen.uint_bits_to_float(arg: ShaderVariable)¶
- vkdispatch.codegen.unravel_index(index: ShaderVariable, shape: ShaderVariable)¶
- vkdispatch.codegen.uv2¶
alias of
_V2U32
- vkdispatch.codegen.uv3¶
alias of
_V3U32
- vkdispatch.codegen.uv4¶
alias of
_V4U32
- vkdispatch.codegen.v2¶
alias of
_V2F32
- vkdispatch.codegen.v3¶
alias of
_V3F32
- vkdispatch.codegen.v4¶
alias of
_V4F32
- vkdispatch.codegen.while_statement(arg: ShaderVariable)¶
- vkdispatch.codegen.workgroup()¶
- vkdispatch.codegen.workgroup_size()¶