Skip to main content

Entry

Struct Entry 

Source
pub struct Entry { /* private fields */ }
Expand description

Entry point into the Vulkan API.

Loads the Vulkan shared library, resolves the bootstrap function pointers, and provides access to entry-level commands (instance creation, version query, layer/extension enumeration).

The Entry keeps the shared library alive via Arc<dyn Loader> for the lifetime of all derived objects.

Guide: Hello Triangle, Part 1 covers creating an Entry and bootstrapping the API.

§Examples

use vulkan_rust::{Entry, LibloadingLoader};

let loader = unsafe { LibloadingLoader::new() }.expect("Vulkan not found");
let entry = unsafe { Entry::new(loader) }.expect("entry creation failed");

let version = entry.version().expect("version query failed");
println!("Vulkan {version}");

Implementations§

Source§

impl Entry

Source

pub unsafe fn new(loader: impl Loader + 'static) -> Result<Self, LoadError>

Create a new Entry from the given loader.

Resolves vkGetInstanceProcAddr from the library, then uses it to bootstrap vkGetDeviceProcAddr and all entry-level commands.

§Safety

The loader must return valid Vulkan function pointers. The loaded shared library must remain valid for the lifetime of this Entry and any objects created from it.

§Examples
use vulkan_rust::{Entry, LibloadingLoader};

let loader = unsafe { LibloadingLoader::new() }.expect("Vulkan not found");
let entry = unsafe { Entry::new(loader) }.expect("entry creation failed");
Source

pub fn get_instance_proc_addr(&self) -> PFN_vkGetInstanceProcAddr

Returns the raw vkGetInstanceProcAddr function pointer.

Needed by OpenXR’s XR_KHR_vulkan_enable2 which requires the application to provide this function pointer.

Source

pub fn get_device_proc_addr(&self) -> PFN_vkGetDeviceProcAddr

Returns the raw vkGetDeviceProcAddr function pointer.

Source

pub fn version(&self) -> VkResult<Version>

Query the Vulkan instance version supported by the loader.

Requires Vulkan 1.1+. On a 1.0-only system where vkEnumerateInstanceVersion is unavailable, returns 1.0.0.

§Examples
let version = entry.version().expect("version query failed");
assert!(version.major >= 1);
println!("Vulkan {version}");
Source

pub unsafe fn create_instance( &self, create_info: &InstanceCreateInfo, allocator: Option<&AllocationCallbacks>, ) -> VkResult<Instance>

Create a Vulkan instance.

§Safety

create_info must be a valid, fully populated InstanceCreateInfo. The caller is responsible for calling instance.destroy_instance when done.

§Examples
use vulkan_rust::{Entry, LibloadingLoader, Version};
use vulkan_rust::vk::*;

let loader = unsafe { LibloadingLoader::new() }.expect("Vulkan not found");
let entry = unsafe { Entry::new(loader) }.expect("entry creation failed");

let app_info = ApplicationInfo::builder()
    .api_version(Version::new(1, 0, 0).to_raw());
let create_info = InstanceCreateInfo::builder()
    .application_info(&*app_info);
let instance = unsafe { entry.create_instance(&create_info, None) }
    .expect("instance creation failed");
// Use instance...
unsafe { instance.destroy_instance(None) };
Source

pub unsafe fn create_instance_raw( &self, create_info: &InstanceCreateInfo, allocator: Option<&AllocationCallbacks>, ) -> VkResult<Instance>

Create a Vulkan instance and return the raw handle.

Use this when you need the VkInstance handle without the wrapper, for example when passing it to OpenXR which manages the instance lifetime externally.

§Safety

create_info must be a valid, fully populated InstanceCreateInfo. The caller is responsible for destroying the instance with vkDestroyInstance when done.

Source

pub unsafe fn enumerate_instance_layer_properties( &self, ) -> VkResult<Vec<LayerProperties>>

Enumerate available instance layer properties.

§Safety

The Vulkan loader must be in a valid state.

Source

pub unsafe fn enumerate_instance_extension_properties( &self, layer_name: Option<&CStr>, ) -> VkResult<Vec<ExtensionProperties>>

Enumerate available instance extension properties.

Pass None for layer_name to enumerate extensions provided by the loader and implicit layers. Pass a layer name to enumerate extensions provided by that layer.

§Safety

If layer_name is Some, it must name a layer that is present.

Source§

impl Entry

Source

pub unsafe fn get_external_compute_queue_data_nv( &self, external_queue: ExternalComputeQueueNV, params: &mut ExternalComputeQueueDataParamsNV, ) -> c_void

Wraps vkGetExternalComputeQueueDataNV. Provided by VK_NV_external_compute_queue.

§Safety
  • externalQueue (self) must be valid and not destroyed.
§Panics

Panics if vkGetExternalComputeQueueDataNV was not loaded. This can happen if the required extension or Vulkan version is not enabled on the instance or device.

§Usage Notes

Retrieves data from an external compute queue, allowing the application to read back results or state produced by work submitted outside the Vulkan runtime.

Requires VK_NV_external_compute_queue.

Auto Trait Implementations§

§

impl Freeze for Entry

§

impl !RefUnwindSafe for Entry

§

impl Send for Entry

§

impl Sync for Entry

§

impl Unpin for Entry

§

impl UnsafeUnpin for Entry

§

impl !UnwindSafe for Entry

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.