[go: up one dir, main page]

Struct ash::Entry

source ·
pub struct Entry { /* private fields */ }
Expand description

Holds the Vulkan functions independent of a particular instance

Implementations§

source§

impl Entry

Vulkan core 1.0

Available on crate feature loaded only.

Load default Vulkan library for the current platform

Prefer this over linked when your application can gracefully handle environments that lack Vulkan support, and when the build environment might not have Vulkan development packages installed (e.g. the Vulkan SDK, or Ubuntu’s libvulkan-dev).

Safety

dlopening native libraries is inherently unsafe. The safety guidelines for Library::new() and Library::get() apply here.

use ash::{vk, Entry};
let entry = unsafe { Entry::load()? };
let app_info = vk::ApplicationInfo {
    api_version: vk::make_api_version(0, 1, 0, 0),
    ..Default::default()
};
let create_info = vk::InstanceCreateInfo {
    p_application_info: &app_info,
    ..Default::default()
};
let instance = unsafe { entry.create_instance(&create_info, None)? };
Available on crate feature linked only.

Load entry points from a Vulkan loader linked at compile time

Compared to load, this is infallible, but requires that the build environment have Vulkan development packages installed (e.g. the Vulkan SDK, or Ubuntu’s libvulkan-dev), and prevents the resulting binary from starting in environments that do not support Vulkan.

Note that instance/device functions are still fetched via vkGetInstanceProcAddr and vkGetDeviceProcAddr for maximum performance.

use ash::{vk, Entry};
let entry = Entry::linked();
let app_info = vk::ApplicationInfo {
    api_version: vk::make_api_version(0, 1, 0, 0),
    ..Default::default()
};
let create_info = vk::InstanceCreateInfo {
    p_application_info: &app_info,
    ..Default::default()
};
let instance = unsafe { entry.create_instance(&create_info, None)? };
Available on crate feature loaded only.

Load Vulkan library at path

Safety

dlopening native libraries is inherently unsafe. The safety guidelines for Library::new() and Library::get() apply here.

Load entry points based on an already-loaded vk::StaticFn

Safety

static_fn must contain valid function pointers that comply with the semantics specified by Vulkan 1.0, which must remain valid for at least the lifetime of the returned Entry.

https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkEnumerateInstanceVersion.html

let entry = Entry::linked();
match entry.try_enumerate_instance_version()? {
    // Vulkan 1.1+
    Some(version) => {
        let major = vk::version_major(version);
        let minor = vk::version_minor(version);
        let patch = vk::version_patch(version);
    },
    // Vulkan 1.0
    None => {},
}

https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateInstance.html

Safety

In order for the created Instance to be valid for the duration of its usage, the Entry this was called on must be dropped later than the resulting Instance.

source§

impl Entry

Vulkan core 1.1

👎Deprecated: This function is unavailable and therefore panics on Vulkan 1.0, please use try_enumerate_instance_version() instead
source§

impl Entry

Vulkan core 1.2

source§

impl Entry

Vulkan core 1.3

Trait Implementations§

source§

impl Clone for Entry

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
source§

impl Default for Entry

Available on crate feature linked only.
Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Entry

§

impl Send for Entry

§

impl Sync for Entry

§

impl Unpin for Entry

§

impl UnwindSafe for Entry

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere
    T: Clone,

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

The type returned in the event of a conversion error.
Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

The type returned in the event of a conversion error.
Performs the conversion.