Vulkan

Pipeline dependencies

There's an awful lot of plumbing to do before you're able to output even a triangle.

flowchart LR VkDebugUtilsMessengerEXT --> VkInstance VkPhysicalDevice --> VkInstance VkDevice --> VkPhysicalDevice VkDevice -.-> VkQueue VkSurfaceKHR --> VkInstance VkSwapchainKHR --> VkDevice VkSwapchainKHR -.-> VkImage DeviceAndSurface[Device and surface] --> VkPhysicalDevice DeviceAndSurface --> VkSurfaceKHR DeviceAndSurface -.-> VkSurfaceCapabilitiesKHR DeviceAndSurface -.-> VkSurfaceFormatKHR DeviceAndSurface -.-> VkPresentModeKHR VkImageView --> VkImage VkImageView --> VkSurfaceFormatKHR VkRenderPass --> VkSurfaceFormatKHR VkFramebuffer --> VkRenderPass VkFramebuffer --> VkExtent2D VkFramebuffer --> VkImageView VkShaderModule --> VkDevice VkPipelineShaderStage --> VkShaderModule VkPipelineLayout --> VkDynamicState VkPipelineLayout --> VkViewport VkPipelineLayout --> VkPipelineShaderStage VkPipeline --> VkPipelineLayout VkPipeline --> VkRenderPass VkCommandPool -.-> VkQueue VkCommandBuffer --> VkCommandPool

Pipeline stages

    // FF = fixed function (tweak with params), P = programmable (upload own code)
    // pipeline flow:
    // - vertex/input buffer
    // - FF input assembler: collects raw vertex data from specified buffers
    // - P vertex shader: runs for every vertex, transforming positions from model space to screen space
    // - P tessellation: subdivides geometry based on rules to improve mesh quality (e.g. flattening walls)
    // - P geometry shader (unsupported on MoltenVK): runs on every primitive (triangle, line, point) to discard or output more primitives than came in
    // - FF rasterization: groups primitives into fragments, the pixel elements on the framebuffer
    // - P fragment shader: invoked once for each fragment that survives, determines output framebuffer and color/depth values, optionally using interpolated data from the vertex shader (e.g. for lighting)
    // - FF color blending: mixes fragments that map to the same pixel (overwrite, add)
    // - framebuffer

Common types

TextVulkan format
floatVK_FORMAT_R32_SFLOAT
vec2VK_FORMAT_R32G32_SFLOAT
ivec2VK_FORMAT_R32G32_SINT
vec3VK_FORMAT_R32G32B32_SFLOAT
vec4VK_FORMAT_R32G32B32A32_SFLOAT
uvec4VK_FORMAT_R32G32B32A32_UINT
doubleVK_FORMAT_R64_SFLOAT