pub struct Entry { /* private fields */ }
Expand description
Holds the Vulkan functions independent of a particular instance
Implementations§
Source§impl Entry
Vulkan core 1.0
impl Entry
Vulkan core 1.0
Sourcepub unsafe fn load() -> Result<Self, LoadingError>
Available on crate feature loaded
only.
pub unsafe fn load() -> Result<Self, LoadingError>
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
dlopen
ing native libraries is inherently unsafe. The safety guidelines
for Library::new()
and Library::get()
apply here.
No Vulkan functions loaded directly or indirectly from this Entry
may be called after it is dropped.
§Example
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)? };
Sourcepub fn linked() -> Self
Available on crate feature linked
only.
pub fn linked() -> Self
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.
Any Vulkan function acquired directly or indirectly from this Entry
may be called after it
is dropped.
§Example
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)? };
Sourcepub unsafe fn load_from(path: impl AsRef<OsStr>) -> Result<Self, LoadingError>
Available on crate feature loaded
only.
pub unsafe fn load_from(path: impl AsRef<OsStr>) -> Result<Self, LoadingError>
loaded
only.Load Vulkan library at path
§Safety
dlopen
ing native libraries is inherently unsafe. The safety guidelines
for Library::new()
and Library::get()
apply here.
No Vulkan functions loaded directly or indirectly from this Entry
may be called after it is dropped.
Sourcepub unsafe fn from_static_fn(static_fn: StaticFn) -> Self
pub unsafe fn from_static_fn(static_fn: StaticFn) -> Self
Load entry points based on an already-loaded crate::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
.
pub fn from_parts_1_1( static_fn: StaticFn, entry_fn_1_0: EntryFnV1_0, entry_fn_1_1: EntryFnV1_1, ) -> Self
pub fn fp_v1_0(&self) -> &EntryFnV1_0
pub fn static_fn(&self) -> &StaticFn
Sourcepub unsafe fn try_enumerate_instance_version(&self) -> VkResult<Option<u32>>
pub unsafe fn try_enumerate_instance_version(&self) -> VkResult<Option<u32>>
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkEnumerateInstanceVersion.html
§Example
let entry = Entry::linked();
match unsafe { 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 => {},
}
Sourcepub unsafe fn create_instance(
&self,
create_info: &InstanceCreateInfo<'_>,
allocation_callbacks: Option<&AllocationCallbacks<'_>>,
) -> VkResult<Instance>
pub unsafe fn create_instance( &self, create_info: &InstanceCreateInfo<'_>, allocation_callbacks: Option<&AllocationCallbacks<'_>>, ) -> VkResult<Instance>
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateInstance.html
§Safety
The resulting Instance
and any function-pointer objects (e.g. Device
and extensions like khr::swapchain::Device
) loaded from it may not be used after
this Entry
object is dropped, unless it was crated using Entry::linked()
or
Entry::from_parts_1_1()
.
Instance
does not implement drop semantics and can only be destroyed via
destroy_instance()
.
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>>
Sourcepub unsafe fn get_instance_proc_addr(
&self,
instance: Instance,
p_name: *const c_char,
) -> PFN_vkVoidFunction
pub unsafe fn get_instance_proc_addr( &self, instance: Instance, p_name: *const c_char, ) -> PFN_vkVoidFunction
Source§impl Entry
Vulkan core 1.1
impl Entry
Vulkan core 1.1
pub fn fp_v1_1(&self) -> &EntryFnV1_1
Sourcepub unsafe fn enumerate_instance_version(&self) -> VkResult<u32>
👎Deprecated: This function is unavailable and therefore panics on Vulkan 1.0, please use try_enumerate_instance_version()
instead
pub unsafe fn enumerate_instance_version(&self) -> VkResult<u32>
try_enumerate_instance_version()
instead