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
impl Entry
Sourcepub unsafe fn new(loader: impl Loader + 'static) -> Result<Self, LoadError>
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");Sourcepub fn get_instance_proc_addr(&self) -> PFN_vkGetInstanceProcAddr
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.
Sourcepub fn get_device_proc_addr(&self) -> PFN_vkGetDeviceProcAddr
pub fn get_device_proc_addr(&self) -> PFN_vkGetDeviceProcAddr
Returns the raw vkGetDeviceProcAddr function pointer.
Sourcepub fn version(&self) -> VkResult<Version>
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}");Sourcepub unsafe fn create_instance(
&self,
create_info: &InstanceCreateInfo,
allocator: Option<&AllocationCallbacks>,
) -> VkResult<Instance>
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) };Sourcepub unsafe fn create_instance_raw(
&self,
create_info: &InstanceCreateInfo,
allocator: Option<&AllocationCallbacks>,
) -> VkResult<Instance>
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.
Sourcepub unsafe fn enumerate_instance_layer_properties(
&self,
) -> VkResult<Vec<LayerProperties>>
pub unsafe fn enumerate_instance_layer_properties( &self, ) -> VkResult<Vec<LayerProperties>>
Sourcepub unsafe fn enumerate_instance_extension_properties(
&self,
layer_name: Option<&CStr>,
) -> VkResult<Vec<ExtensionProperties>>
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
impl Entry
Sourcepub unsafe fn get_external_compute_queue_data_nv(
&self,
external_queue: ExternalComputeQueueNV,
params: &mut ExternalComputeQueueDataParamsNV,
) -> c_void
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.