#Strange Crash with VkBootstrap

2 messages · Page 1 of 1 (latest)

junior junco
#

Hey there, I'm currently in the process of rewriting my renderer, using vkguide.dev as a base with the Odin ports of vkbootstrap and vma. However, I'm finding that whenever I simply access a specific data member, the queue_families data inside the Physical_Device struct, the entire program crashes. I don't have to even modify the data or anything, it doesn't matter if I for loop through it or just println it, the program crashes at runtime. Below is the relevant code snippet. Libs used, as mentioned, are odin-vk-bootstrap and odin-vma

GitHub

A utility wrapper that jump starts initialization of Vulkan for Odin Language. - Capati/odin-vk-bootstrap

GitHub

binding for VulkanMemoryAllocator c interface. Contribute to DanielGavin/odin-vma development by creating an account on GitHub.

#
vulkan_init :: proc(window: ^SDL.Window, conf: ^cfg.Context_Config) -> Renderer_Vulkan {
    out: Renderer_Vulkan

    inst_builder, inst_builder_err := vkb.init_instance_builder()

    inst_builder.app_name = strings.clone_from_cstring(conf.title)
    inst_builder.request_validation_layers = true
    inst_builder.use_debug_messenger = true
    inst_builder.required_api_version = vk.MAKE_VERSION(1, 3, 0)

    instance, inst_err := vkb.build_instance(&inst_builder)

    // Grab instance
    out.instance = instance.ptr
    out.debug_messenger = instance.debug_messenger

    vk.load_proc_addresses_instance(out.instance)

    // Create Surface
    SDL.Vulkan_CreateSurface(window, out.instance, &out.surface)

    // Vulkan 1.3 Features
    features13: vk.PhysicalDeviceVulkan13Features
    features13.sType = .PHYSICAL_DEVICE_VULKAN_1_3_FEATURES
    features13.dynamicRendering = true
    features13.synchronization2 = true

    // Vulkan 1.2 Features
    features12: vk.PhysicalDeviceVulkan12Features
    features12.sType = .PHYSICAL_DEVICE_VULKAN_1_2_FEATURES
    features12.bufferDeviceAddress = true
    features12.descriptorIndexing = true

    // Use VkBootstrap to select GPU
    // We want a GPU that can write to the SDL Surface and supports Vulkan 1.3
    selector, sel_err := vkb.init_physical_device_selector(instance)
    
    vkb.selector_set_minimum_version(&selector, vk.MAKE_VERSION(1, 3, 0))
    vkb.selector_set_required_features_13(&selector, features13)
    vkb.selector_set_required_features_12(&selector, features12)
    vkb.selector_set_surface(&selector, out.surface)
    vkb.selector_add_required_extension(&selector, vk.EXT_SHADER_OBJECT_EXTENSION_NAME)

    physical_device, phys_dev_err := vkb.select_physical_device(&selector)

    device_builder, device_builder_err := vkb.init_device_builder(physical_device)

    fmt.println("Error occurs here:")

    fmt.println(physical_device.queue_families)