Last updated: 2026-06-12

Vulkan Runtime

Instance

All API Sections

Initialize Vulkan, select a compute-capable device, and expose memory utilities.

This is the entry point for GPU setup: instance creation, device selection, queue discovery, and VRAM inspection.

3 exports 5 methods src/vulkan/instance.zig

3 exports shown

constant

PushDescriptorFn

#
pub const PushDescriptorFn = *const fn ( vk.c.VkCommandBuffer, vk.c.VkPipelineBindPoint, vk.c.VkPipelineLayout, u32, u32, [*]const vk.c.VkWriteDescriptorSet, ) callconv(.c) void

Function pointer type for `vkCmdPushDescriptorSetKHR` when the extension is enabled.

src/vulkan/instance.zig:11

struct

DeviceCapabilities

#
pub const DeviceCapabilities = struct

Queried Vulkan device capabilities that affect pipeline creation choices.

src/vulkan/instance.zig:21

Methods

1

method

DeviceCapabilities.supportsRequiredSubgroupSize

#
pub fn supportsRequiredSubgroupSize(self: DeviceCapabilities, size: u32) bool

Return whether a compute shader can request the given subgroup size at pipeline creation.

Parameters
size
Desired subgroup width to validate against the device's min/max range.
Returns

`true` when subgroup size control is enabled, `size` is within the supported range, and the compute stage supports `requiredSubgroupSize`.

src/vulkan/instance.zig:50

struct

Instance

#
pub const Instance = struct

Active Vulkan instance, selected physical device, logical device, and memory metadata.

src/vulkan/instance.zig:58

Methods

4

method

Instance.init

#
pub fn init(allocator: std.mem.Allocator, preferred_device: u32) !Instance

Create a Vulkan instance and select a compute-capable device.

Parameters
allocator
Allocator used for device and queue enumeration and stored for the lifetime of the instance.
preferred_device
Preferred physical device index when multiple GPUs are present.
Returns

An initialized Instance bound to a logical device and compute queue.

src/vulkan/instance.zig:86

method

Instance.deinit

#
pub fn deinit(self: *Instance) void

Wait for outstanding work, destroy the logical device, and destroy the Vulkan instance.

Parameters
self
Vulkan instance wrapper to tear down in place.

src/vulkan/instance.zig:309

method

Instance.findMemoryType

#
pub fn findMemoryType(self: *const Instance, type_filter: u32, properties: vk.c.VkMemoryPropertyFlags) ?u32

Find a Vulkan memory type that satisfies both compatibility and property requirements.

Parameters
self
Active Vulkan instance and memory properties.
type_filter
Bitmask of compatible memory types reported by Vulkan.
properties
Required Vulkan memory property flags.
Returns

The matching memory type index, or `null` when no memory type satisfies the request.

Notes

All requested property bits must be present on the returned memory type.

src/vulkan/instance.zig:322

method

Instance.vramBytes

#
pub fn vramBytes(self: *const Instance) u64

Sum the size of all device-local memory heaps exposed by the selected GPU.

Parameters
self
Active Vulkan instance and memory properties.
Returns

The total number of bytes in device-local heaps.

Notes

Drivers may expose multiple heaps, so this is an aggregate capacity rather than a single contiguous pool.

src/vulkan/instance.zig:338