Repository: bevyengine/bevy
File: crates/bevy_render/src/renderer/raw_vulkan_init.rs (Rust)

Code before:
                + Sync,
        >,
    >,
}

impl RawVulkanInitSettings {
    /// Adds a new Vulkan create instance callback. See [`wgpu::hal::vulkan::Instance::init_with_callback`] for details.
    ///
    /// # Safety
    /// - Callback must not remove features.
    /// - Callback must not change anything to what the instance does not support.
    pub unsafe fn add_create_instance_callback(
        &mut self,
        callback: impl Fn(&mut wgpu::hal::vulkan::CreateInstanceCallbackArgs, &mut AdditionalVulkanFeatures)
            + Send
            + Sync
            + 'static,
    ) {
        self.create_instance_callbacks.push(Arc::new(callback));
    }

    /// Adds a new Vulkan create device callback. See [`wgpu::hal::vulkan::Adapter::open_with_callback`] for details.
    ///
    /// # Safety
    /// - Callback must not remove features.
    /// - Callback must not change anything to what the instance does not support.
    pub unsafe fn add_create_device_callback(
        &mut self,
        callback: impl Fn(
                &mut wgpu::hal::vulkan::CreateDeviceCallbackArgs,
                &wgpu::hal::vulkan::Adapter,
                &mut AdditionalVulkanFeatures,
            ) + Send
            + Sync
            + 'static,
    ) {
        self.create_device_callbacks.push(Arc::new(callback));
    }
}

pub(crate) fn create_raw_vulkan_instance(
    instance_descriptor: &InstanceDescriptor,
    settings: &RawVulkanInitSettings,
    additional_features: &mut AdditionalVulkanFeatures,
) -> Instance {
    unsafe {
        // SAFETY: Registering callbacks is unsafe. Callback authors promise not to remove features
        // or change the instance to something it does not support
        wgpu::hal::vulkan::Instance::init_with_callback(
            &wgpu::hal::InstanceDescriptor {
                name: "wgpu",

Review comment (suggestion):
```suggestion
    /// - Callback must not change anything to what the device does not support.
```

Code after:
                + Sync,
        >,
    >,
}

impl RawVulkanInitSettings {
    /// Adds a new Vulkan create instance callback. See [`wgpu::hal::vulkan::Instance::init_with_callback`] for details.
    ///
    /// # Safety
    /// - Callback must not remove features.
    /// - Callback must not change anything to what the instance does not support.
    pub unsafe fn add_create_instance_callback(
        &mut self,
        callback: impl Fn(&mut wgpu::hal::vulkan::CreateInstanceCallbackArgs, &mut AdditionalVulkanFeatures)
            + Send
            + Sync
            + 'static,
    ) {
        self.create_instance_callbacks.push(Arc::new(callback));
    }

    /// Adds a new Vulkan create device callback. See [`wgpu::hal::vulkan::Adapter::open_with_callback`] for details.
    ///
    /// # Safety
    /// - Callback must not remove features.
    /// - Callback must not change anything to what the device does not support.
    pub unsafe fn add_create_device_callback(
        &mut self,
        callback: impl Fn(
                &mut wgpu::hal::vulkan::CreateDeviceCallbackArgs,
                &wgpu::hal::vulkan::Adapter,
                &mut AdditionalVulkanFeatures,
            ) + Send
            + Sync
            + 'static,
    ) {
        self.create_device_callbacks.push(Arc::new(callback));
    }
}

pub(crate) fn create_raw_vulkan_instance(
    instance_descriptor: &InstanceDescriptor,
    settings: &RawVulkanInitSettings,
    additional_features: &mut AdditionalVulkanFeatures,
) -> Instance {
    // SAFETY: Registering callbacks is unsafe. Callback authors promise not to remove features
    // or change the instance to something it does not support
    unsafe {
        wgpu::hal::vulkan::Instance::init_with_callback(
            &wgpu::hal::InstanceDescriptor {
                name: "wgpu",