Skip to content

RawVulkanInitSettings has difficulty handling common Vulkan patterns #20898

@tychedelia

Description

@tychedelia

We added support for custom Vulkan instance/device intiailization in #20565. However, it struggles to express some common Vulkan patterns.

Consider the following:

pub struct VulkanPlugin;

impl Plugin for VulkanPlugin {
    fn build(&self, app: &mut App) {
        let mut raw_vulkan_settings = app
            .world_mut()
            .get_resource_or_init::<RawVulkanInitSettings>();

        unsafe {
            raw_vulkan_settings.add_create_device_callback(
                move |mut args, adapter, additional_vulkan_features| {
                    let mut vk_sync_2_feature =
                        vk::PhysicalDeviceSynchronization2Features::default().synchronization2(true);
                    *args.create_info = args.create_info
                        .push_next(&mut vk_sync_2_feature);
                });
        }
    }
}

We want to push vk_sync_2_feature onto the pNext chain of create_info. However, because we are adding a callback, this requires that vk_sync_2_feature lives longer than callback.

In the regular open_with_callback flow used by wgpu, this is trivially avoided as the callback is immediately invoked in the course of returning the device.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-UsabilityA targeted quality-of-life change that makes Bevy easier to useS-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions