Skip to content

Vulkan Guide

squid233 edited this page May 5, 2025 · 1 revision

Functions

Some critical Vulkan functions are required to be loaded before creating a Vulkan instance. Use VK::create to load those functions.

VK.create(GLFW::glfwGetInstanceProcAddress);

Convention

Use MemoryStack or Arena to allocate a create info structure. The allocated create info AND the data within it MUST be alive while invoking vkCreate*.

A conventional code is below:

try (MemoryStack stack = MemoryStack.pushLocal()) {
    var ci = Vk*CreateInfo.alloc(stack)
        .sType(VK_STRUCTURE_TYPE_*_CREATE_INFO);
    // other parameters
    var p = stack.allocate(JAVA_LONG); // or ADDRESS for dispatchable handle
    vkCreate*(dispatchableHandle, ci.segment(), pAllocator, p);
    obj = p.get(JAVA_LONG, 0);
} // you can now release the create info
Clone this wiki locally