5. Boost — selection, builders, block brackets, conveniences

The hand-written ergonomic core: device/queue selection helpers, combined builders that fold several Vulkan objects into one owner (build_offscreen_target, create_host_buffer), block brackets (run_cmd_sync, record_render_pass, map_memory_to_array) that pair a begin/end or map/unmap around a block, and small conveniences (full_area, clear_color). This is the layer the examples are written against.

5.1. Structures

OffscreenTarget

struct OffscreenTarget

HostBuffer

struct HostBuffer

5.2. Device selection

find_memory_type(phys: VkPhysicalDevice; type_bits: uint; want: VkMemoryPropertyFlags ): uint

def find_memory_type (phys: VkPhysicalDevice; type_bits: uint; want: VkMemoryPropertyFlags) : uint

Arguments:
select_graphics_queue_family(phys: VkPhysicalDevice ): uint

def select_graphics_queue_family (phys: VkPhysicalDevice) : uint

Arguments:
select_physical_device(instance: Instance ): VkPhysicalDevice

def select_physical_device (instance: Instance) : VkPhysicalDevice

Arguments:

5.3. Instance & device

5.3.1. create_device

create_device(phys: VkPhysicalDevice; queue_family: uint ): Device

def create_device (phys: VkPhysicalDevice; queue_family: uint) : Device

Arguments:
create_device(phys: VkPhysicalDevice; queue_family: uint; extensions: array<string> ): Device

5.3.2. create_instance

create_instance(application_name: string = ""; api_version: uint = 0x0 ): Instance

def create_instance (application_name: string = “”; api_version: uint = 0x0) : Instance

Arguments:
  • application_name : string

  • api_version : uint

create_instance(application_name: string; api_version: uint; extensions: array<string> ): Instance

get_device_queue(device: Device; queue_family: uint; index: uint ): VkQueue

def get_device_queue (device: Device; queue_family: uint; index: uint) : VkQueue

Arguments:
  • device : Device

  • queue_family : uint

  • index : uint

5.4. Shaders & pipelines

create_compute_pipeline(device: Device; layout: PipelineLayout; shader: ShaderModule; entry: string = "main" ): Pipeline

def create_compute_pipeline (device: Device; layout: PipelineLayout; shader: ShaderModule; entry: string = “main”) : Pipeline

Arguments:
create_graphics_pipeline_simple(device: Device; render_pass: RenderPass; layout: PipelineLayout; vert: ShaderModule; frag: ShaderModule; width: int; height: int; dynamic_viewport: bool = false ): Pipeline

def create_graphics_pipeline_simple (device: Device; render_pass: RenderPass; layout: PipelineLayout; vert: ShaderModule; frag: ShaderModule; width: int; height: int; dynamic_viewport: bool = false) : Pipeline

Arguments:
create_pipeline_layout(device: Device ): PipelineLayout

def create_pipeline_layout (device: Device) : PipelineLayout

Arguments:

5.4.1. create_shader_module

create_shader_module(device: Device; code: array<uint8> ): ShaderModule

def create_shader_module (device: Device; var code: array<uint8>) : ShaderModule

Arguments:
  • device : Device

  • code : array<uint8>

create_shader_module(device: Device; code: array<uint> ): ShaderModule

5.5. Render passes

create_render_pass_single_color(device: Device; format: VkFormat; final_layout: VkImageLayout = vulkan::VkImageLayout.TRANSFER_SRC_OPTIMAL ): RenderPass

def create_render_pass_single_color (device: Device; format: VkFormat; final_layout: VkImageLayout = vulkan::VkImageLayout.TRANSFER_SRC_OPTIMAL) : RenderPass

Arguments:

5.6. Builders

build_offscreen_target(device: Device; phys: VkPhysicalDevice; width: int; height: int; format: VkFormat ): OffscreenTarget

def build_offscreen_target (device: Device; phys: VkPhysicalDevice; width: int; height: int; format: VkFormat) : OffscreenTarget

Arguments:
create_host_buffer(device: Device; phys: VkPhysicalDevice; size: uint64 ): HostBuffer

def create_host_buffer (device: Device; phys: VkPhysicalDevice; size: uint64) : HostBuffer

Arguments:

5.7. Memory & brackets

map_memory_to_array(device: Device; memory: DeviceMemory; size: uint64; blk: block<(data:array<uint8>):void> )

def map_memory_to_array (device: Device; memory: DeviceMemory; size: uint64; blk: block<(data:array<uint8>):void>)

Arguments:
  • device : Device

  • memory : DeviceMemory

  • size : uint64

  • blk : block<(data:array<uint8>):void>

read_memory(device: Device; memory: DeviceMemory; elem: type<auto(TT) const>; count: int ): array<TT>

def read_memory (device: Device; memory: DeviceMemory; elem: type<auto(TT) const>; count: int) : array<TT>

Arguments:
record_render_pass(cmd: CommandBuffer; render_pass: RenderPass; framebuffer: Framebuffer; area: VkRect2D; clear: VkClearValue; blk: block<():void> )

def record_render_pass (cmd: CommandBuffer; render_pass: RenderPass; framebuffer: Framebuffer; area: VkRect2D; clear: VkClearValue; blk: block<():void>)

Arguments:
run_cmd_sync(device: Device; pool: CommandPool; queue: VkQueue; blk: block<(cmd:CommandBuffer):void> )

def run_cmd_sync (device: Device; pool: CommandPool; queue: VkQueue; blk: block<(cmd:CommandBuffer):void>)

Arguments:

5.8. Command recording

cmd_bind_pipeline(cmd: CommandBuffer; pipeline: Pipeline; bind_point: VkPipelineBindPoint = vulkan::VkPipelineBindPoint.GRAPHICS )

def cmd_bind_pipeline (cmd: CommandBuffer; pipeline: Pipeline; bind_point: VkPipelineBindPoint = vulkan::VkPipelineBindPoint.GRAPHICS)

Arguments:
cmd_draw(cmd: CommandBuffer; vertex_count: uint; instance_count: uint = 0x1 )

def cmd_draw (cmd: CommandBuffer; vertex_count: uint; instance_count: uint = 0x1)

Arguments:
copy_image_to_buffer(cmd: CommandBuffer; image: Image; buffer: HostBuffer; width: int; height: int )

def copy_image_to_buffer (cmd: CommandBuffer; image: Image; buffer: HostBuffer; width: int; height: int)

Arguments:

5.9. Conveniences

clear_color(r: float; g: float; b: float; a: float ): VkClearValue

def clear_color (r: float; g: float; b: float; a: float) : VkClearValue

Arguments:
  • r : float

  • g : float

  • b : float

  • a : float

full_area(width: int; height: int ): VkRect2D

def full_area (width: int; height: int) : VkRect2D

Arguments:
  • width : int

  • height : int