libstd/vulkan3d

Second layer over libstd/vulkan: command pools and buffers, fences, presenting a frame, shader modules, device memory and buffers, uniform-buffer descriptor sets, depth images, a colour+depth render pass and framebuffer, a position/colour pipeline and an indexed draw. example/vulkan_cube uses it to render a rotating cube.

#include <libstd/vulkan3d>

Includes libstd/vulkan, libstd/math, libstd/file.

Constants

NameValueMeaning
VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO16
VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO18
VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO19
VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO20
VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO22
VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO23
VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO24
VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO25
VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO26
VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO30
VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO28
VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO38
VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO37
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO15
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO14
VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO12
VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO5
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO32
VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO33
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO34
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET35
VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO43
VK_SHADER_STAGE_VERTEX_BIT1
VK_SHADER_STAGE_FRAGMENT_BIT16
VK_VERTEX_INPUT_RATE_VERTEX0
VK_FORMAT_R32G32B32_SFLOAT106
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST3
VK_POLYGON_MODE_FILL0
VK_CULL_MODE_NONE0
VK_FRONT_FACE_COUNTER_CLOCKWISE0
VK_SAMPLE_COUNT_1_BIT1
VK_COMPARE_OP_LESS1
VK_COLOR_COMPONENT_RGBA_ALL15
VK_ATTACHMENT_LOAD_OP_CLEAR1
VK_ATTACHMENT_LOAD_OP_DONT_CARE2
VK_ATTACHMENT_STORE_OP_STORE0
VK_ATTACHMENT_STORE_OP_DONT_CARE1
VK_PIPELINE_BIND_POINT_GRAPHICS0
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL2
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL3
VK_SUBPASS_EXTERNAL-1
VK_IMAGE_VIEW_TYPE_2D1
VK_COMPONENT_SWIZZLE_IDENTITY0
VK_IMAGE_TYPE_2D1
VK_FORMAT_D32_SFLOAT126
VK_IMAGE_TILING_OPTIMAL0
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT32
VK_IMAGE_ASPECT_DEPTH_BIT2
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT128
VK_BUFFER_USAGE_INDEX_BUFFER_BIT64
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT16
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT1
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT2
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT4
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER6
VK_INDEX_TYPE_UINT321
VK_SUBPASS_CONTENTS_INLINE0
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT1024
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT256
VK_MEMORY_PROPS_SIZE520

Classes

class
VkShaderModuleCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    _pad1 int
    codeSize long
    pCode long
class
VkPipelineShaderStageCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    stage int
    module long
    pName str
    pSpecializationInfo long
class
VkBufferCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    _pad1 int
    size long
    usage int
    sharingMode int
    queueFamilyIndexCount int
    _pad2 int
    pQueueFamilyIndices long
class
VkMemoryRequirements
    size long
    alignment long
    memoryTypeBits int
    _pad0 int
class
VkMemoryAllocateInfo
    sType int
    _pad0 int
    pNext long
    allocationSize long
    memoryTypeIndex int
    _pad1 int
class
VkDescriptorSetLayoutBinding
    binding int
    descriptorType int
    descriptorCount int
    stageFlags int
    pImmutableSamplers long
class
VkDescriptorSetLayoutCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    bindingCount int
    pBindings long
class
VkDescriptorPoolSize
    type int
    descriptorCount int
class
VkDescriptorPoolCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    maxSets int
    poolSizeCount int
    _pad1 int
    pPoolSizes long
class
VkDescriptorSetAllocateInfo
    sType int
    _pad0 int
    pNext long
    descriptorPool long
    descriptorSetCount int
    _pad1 int
    pSetLayouts long
class
VkDescriptorBufferInfo
    buffer long
    offset long
    range long
class
VkWriteDescriptorSet
    sType int
    _pad0 int
    pNext long
    dstSet long
    dstBinding int
    dstArrayElement int
    descriptorCount int
    descriptorType int
    pImageInfo long
    pBufferInfo long
    pTexelBufferView long
class
VkAttachmentDescription
    flags int
    format int
    samples int
    loadOp int
    storeOp int
    stencilLoadOp int
    stencilStoreOp int
    initialLayout int
    finalLayout int
class
VkAttachmentReference
    attachment int
    layout int
class
VkSubpassDescription
    flags int
    pipelineBindPoint int
    inputAttachmentCount int
    _pad0 int
    pInputAttachments long
    colorAttachmentCount int
    _pad1 int
    pColorAttachments long
    pResolveAttachments long
    pDepthStencilAttachment long
    preserveAttachmentCount int
    _pad2 int
    pPreserveAttachments long
class
VkSubpassDependency
    srcSubpass int
    dstSubpass int
    srcStageMask int
    dstStageMask int
    srcAccessMask int
    dstAccessMask int
    dependencyFlags int
class
VkRenderPassCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    attachmentCount int
    pAttachments long
    subpassCount int
    _pad1 int
    pSubpasses long
    dependencyCount int
    _pad2 int
    pDependencies long
class
VkFramebufferCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    _pad1 int
    renderPass long
    attachmentCount int
    _pad2 int
    pAttachments long
    width int
    height int
    layers int
    _pad3 int
class
VkImageViewCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    _pad1 int
    image long
    viewType int
    format int
    componentsR int
    componentsG int
    componentsB int
    componentsA int
    subresourceAspectMask int
    subresourceBaseMipLevel int
    subresourceLevelCount int
    subresourceBaseArrayLayer int
    subresourceLayerCount int
    _pad2 int
class
VkImageCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    imageType int
    format int
    extentWidth int
    extentHeight int
    extentDepth int
    mipLevels int
    arrayLayers int
    samples int
    tiling int
    usage int
    sharingMode int
    queueFamilyIndexCount int
    _pad1 int
    pQueueFamilyIndices long
    initialLayout int
    _pad2 int
class
VkVertexInputBindingDescription
    binding int
    stride int
    inputRate int
class
VkPipelineVertexInputStateCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    vertexBindingDescriptionCount int
    pVertexBindingDescriptions long
    vertexAttributeDescriptionCount int
    _pad1 int
    pVertexAttributeDescriptions long
class
VkPipelineInputAssemblyStateCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    topology int
    primitiveRestartEnable int
    _pad1 int
class
VkRect2D
    offsetX int
    offsetY int
    extentWidth int
    extentHeight int
class
VkPipelineViewportStateCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    viewportCount int
    pViewports long
    scissorCount int
    _pad1 int
    pScissors long
class
VkPipelineRasterizationStateCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    depthClampEnable int
    rasterizerDiscardEnable int
    polygonMode int
    cullMode int
    frontFace int
    depthBiasEnable int
    depthBiasConstantFactor int
    depthBiasClamp int
    depthBiasSlopeFactor int
    lineWidth int
    _pad1 int
class
VkPipelineMultisampleStateCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    rasterizationSamples int
    sampleShadingEnable int
    minSampleShading int
    pSampleMask long
    alphaToCoverageEnable int
    alphaToOneEnable int
class
VkPipelineDepthStencilStateCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    depthTestEnable int
    depthWriteEnable int
    depthCompareOp int
    depthBoundsTestEnable int
    stencilTestEnable int
    frontFailOp int
    frontPassOp int
    frontDepthFailOp int
    frontCompareOp int
    frontCompareMask int
    frontWriteMask int
    frontReference int
    backFailOp int
    backPassOp int
    backDepthFailOp int
    backCompareOp int
    backCompareMask int
    backWriteMask int
    backReference int
    minDepthBounds int
    maxDepthBounds int
class
VkPipelineColorBlendAttachmentState
    blendEnable int
    srcColorBlendFactor int
    dstColorBlendFactor int
    colorBlendOp int
    srcAlphaBlendFactor int
    dstAlphaBlendFactor int
    alphaBlendOp int
    colorWriteMask int
class
VkPipelineColorBlendStateCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    logicOpEnable int
    logicOp int
    attachmentCount int
    pAttachments long
    blendConstants0 int
    blendConstants1 int
    blendConstants2 int
    blendConstants3 int
class
VkPipelineLayoutCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    setLayoutCount int
    pSetLayouts long
    pushConstantRangeCount int
    _pad1 int
    pPushConstantRanges long
class
VkGraphicsPipelineCreateInfo
    sType int
    _pad0 int
    pNext long
    flags int
    stageCount int
    pStages long
    pVertexInputState long
    pInputAssemblyState long
    pTessellationState long
    pViewportState long
    pRasterizationState long
    pMultisampleState long
    pDepthStencilState long
    pColorBlendState long
    pDynamicState long
    layout long
    renderPass long
    subpass int
    _pad1 int
    basePipelineHandle long
    basePipelineIndex int
    _pad2 int
class
VkRenderPassBeginInfo
    sType int
    _pad0 int
    pNext long
    renderPass long
    framebuffer long
    renderAreaOffsetX int
    renderAreaOffsetY int
    renderAreaExtentWidth int
    renderAreaExtentHeight int
    clearValueCount int
    _pad1 int
    pClearValues long

Functions

extern def vkCreateShaderModule(device: long, pCreateInfo: VkShaderModuleCreateInfo, pAllocator: long, pShaderModule: &long) -> int

C library function, called as declared in the library's own documentation.

extern def vkDestroyShaderModule(device: long, shaderModule: long, pAllocator: long) -> None

C library function, called as declared in the library's own documentation.

def vk_load_shader_module(device: long, path: str) -> long

Loads a SPIR-V file into a shader module.

extern def vkGetPhysicalDeviceMemoryProperties(physicalDevice: long, pMemoryProperties: long) -> None

C library function, called as declared in the library's own documentation.

def vk_get_memory_properties(physicalDevice: long) -> long

The physical device memory properties (a raw_alloc buffer).

def vk_find_memory_type(memProps: long, typeFilter: int, propertyFlags: int) -> int

Index of a memory type satisfying the filter and property flags, -1 if none.

extern def vkCreateBuffer(device: long, pCreateInfo: VkBufferCreateInfo, pAllocator: long, pBuffer: &long) -> int

C library function, called as declared in the library's own documentation.

extern def vkDestroyBuffer(device: long, buffer: long, pAllocator: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkGetBufferMemoryRequirements(device: long, buffer: long, pMemoryRequirements: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkAllocateMemory(device: long, pAllocateInfo: VkMemoryAllocateInfo, pAllocator: long, pMemory: &long) -> int

C library function, called as declared in the library's own documentation.

extern def vkFreeMemory(device: long, memory: long, pAllocator: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkBindBufferMemory(device: long, buffer: long, memory: long, memoryOffset: long) -> int

C library function, called as declared in the library's own documentation.

extern def vkMapMemory(device: long, memory: long, offset: long, size: long, flags: int, ppData: &long) -> int

C library function, called as declared in the library's own documentation.

extern def vkUnmapMemory(device: long, memory: long) -> None

C library function, called as declared in the library's own documentation.

def vk_create_buffer_and_memory(device: long, physicalDevice: long, size: long, usage: int, memPropertyFlags: int) -> (long, long)

Creates a buffer with bound device memory of the requested properties; returns (buffer, memory).

def vk_map_buffer(device: long, memory: long, size: long) -> long

Maps device memory and returns the host pointer.

def vk_write_mat4_f32(dst: long, m: float[16]) -> None

Writes a float[16] matrix as 32-bit floats at dst.

extern def vkCreateDescriptorSetLayout(device: long, pCreateInfo: VkDescriptorSetLayoutCreateInfo, pAllocator: long, pSetLayout: &long) -> int

C library function, called as declared in the library's own documentation.

extern def vkDestroyDescriptorSetLayout(device: long, descriptorSetLayout: long, pAllocator: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkCreateDescriptorPool(device: long, pCreateInfo: VkDescriptorPoolCreateInfo, pAllocator: long, pDescriptorPool: &long) -> int

C library function, called as declared in the library's own documentation.

extern def vkDestroyDescriptorPool(device: long, descriptorPool: long, pAllocator: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkAllocateDescriptorSets(device: long, pAllocateInfo: VkDescriptorSetAllocateInfo, pDescriptorSets: long) -> int

C library function, called as declared in the library's own documentation.

extern def vkUpdateDescriptorSets(device: long, descriptorWriteCount: int, pDescriptorWrites: long, descriptorCopyCount: int, pDescriptorCopies: long) -> None

C library function, called as declared in the library's own documentation.

def vk_create_ubo_descriptor_set_layout(device: long) -> long

A descriptor set layout with one uniform buffer at binding 0.

def vk_create_descriptor_pool(device: long) -> long

A descriptor pool for one uniform buffer set.

def vk_allocate_descriptor_set(device: long, pool: long, setLayout: long) -> long

Allocates a descriptor set from the pool.

def vk_update_ubo_descriptor(device: long, descriptorSet: long, uboBuffer: long, uboSize: long) -> None

Points binding 0 of a descriptor set at a uniform buffer.

extern def vkCreateRenderPass(device: long, pCreateInfo: VkRenderPassCreateInfo, pAllocator: long, pRenderPass: &long) -> int

C library function, called as declared in the library's own documentation.

extern def vkDestroyRenderPass(device: long, renderPass: long, pAllocator: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkCreateFramebuffer(device: long, pCreateInfo: VkFramebufferCreateInfo, pAllocator: long, pFramebuffer: &long) -> int

C library function, called as declared in the library's own documentation.

extern def vkDestroyFramebuffer(device: long, framebuffer: long, pAllocator: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkCreateImageView(device: long, pCreateInfo: VkImageViewCreateInfo, pAllocator: long, pView: &long) -> int

C library function, called as declared in the library's own documentation.

extern def vkDestroyImageView(device: long, imageView: long, pAllocator: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkCreateImage(device: long, pCreateInfo: VkImageCreateInfo, pAllocator: long, pImage: &long) -> int

C library function, called as declared in the library's own documentation.

extern def vkDestroyImage(device: long, image: long, pAllocator: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkGetImageMemoryRequirements(device: long, image: long, pMemoryRequirements: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkBindImageMemory(device: long, image: long, memory: long, memoryOffset: long) -> int

C library function, called as declared in the library's own documentation.

def vk_create_image_view_2d(device: long, image: long, format: int, aspectMask: int) -> long

A 2D image view.

def vk_create_depth_image(device: long, physicalDevice: long, width: int, height: int) -> (long, long)

A depth image with its memory; returns (image, memory).

def vk_create_render_pass_color_depth(device: long, colorFormat: int) -> long

A render pass with one colour and one depth attachment.

def vk_create_framebuffer_color_depth(device: long, renderPass: long, colorView: long, depthView: long, width: int, height: int) -> long

A framebuffer for that render pass.

extern def vkCreatePipelineLayout(device: long, pCreateInfo: VkPipelineLayoutCreateInfo, pAllocator: long, pPipelineLayout: &long) -> int

C library function, called as declared in the library's own documentation.

extern def vkDestroyPipelineLayout(device: long, pipelineLayout: long, pAllocator: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkCreateGraphicsPipelines(device: long, pipelineCache: long, createInfoCount: int, pCreateInfos: long, pAllocator: long, pPipelines: long) -> int

C library function, called as declared in the library's own documentation.

extern def vkDestroyPipeline(device: long, pipeline: long, pAllocator: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkCmdBeginRenderPass(commandBuffer: long, pRenderPassBegin: VkRenderPassBeginInfo, contents: int) -> None

C library function, called as declared in the library's own documentation.

extern def vkCmdEndRenderPass(commandBuffer: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkCmdBindPipeline(commandBuffer: long, pipelineBindPoint: int, pipeline: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkCmdBindVertexBuffers(commandBuffer: long, firstBinding: int, bindingCount: int, pBuffers: long, pOffsets: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkCmdBindIndexBuffer(commandBuffer: long, buffer: long, offset: long, indexType: int) -> None

C library function, called as declared in the library's own documentation.

extern def vkCmdBindDescriptorSets(commandBuffer: long, pipelineBindPoint: int, layout: long, firstSet: int, descriptorSetCount: int, pDescriptorSets: long, dynamicOffsetCount: int, pDynamicOffsets: long) -> None

C library function, called as declared in the library's own documentation.

extern def vkCmdDrawIndexed(commandBuffer: long, indexCount: int, instanceCount: int, firstIndex: int, vertexOffset: int, firstInstance: int) -> None

C library function, called as declared in the library's own documentation.

def vk_create_pipeline_pos3_color3(device: long, renderPass: long, descriptorSetLayout: long, vertPath: str, fragPath: str, width: int, height: int, vertexStride: int) -> (long, long)

A graphics pipeline for vertices with a 3-float position and a 3-float colour; returns (pipeline, layout).

def vk_record_draw_indexed_cmdbuf(cmdbuf: long, renderPass: long, framebuffer: long, pipeline: long, pipelineLayout: long, descriptorSet: long, vertexBuffer: long, indexBuffer: long, width: int, height: int, indexCount: int) -> None

Records a full frame: begin render pass, bind pipeline/descriptors/buffers, indexed draw, end.