Skip to content

Commit

Permalink
Inline trivial Entry wrapper methods and impl functions (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Jun 5, 2022
1 parent 3624b56 commit b444d41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Inlined builder setters (partial backport from #602)
- Inlined `Default` impls and trivial `Instance`/`Device` wrapper methods (#606)
- Inlined `Default` impls and trivial `Instance`/`Device`/`Entry` wrapper methods (#606, #632)

### Added

Expand Down
12 changes: 12 additions & 0 deletions ash/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ impl Entry {
}
}

#[inline]
pub fn fp_v1_0(&self) -> &vk::EntryFnV1_0 {
&self.entry_fn_1_0
}

#[inline]
pub fn static_fn(&self) -> &vk::StaticFn {
&self.static_fn
}
Expand All @@ -190,6 +192,7 @@ impl Entry {
/// }
/// # Ok(()) }
/// ```
#[inline]
pub fn try_enumerate_instance_version(&self) -> VkResult<Option<u32>> {
unsafe {
let mut api_version = 0;
Expand Down Expand Up @@ -217,6 +220,7 @@ impl Entry {
/// In order for the created [`Instance`] to be valid for the duration of its
/// usage, the [`Entry`](Self) this was called on must be dropped later than the
/// resulting [`Instance`].
#[inline]
pub unsafe fn create_instance(
&self,
create_info: &vk::InstanceCreateInfo,
Expand All @@ -233,6 +237,7 @@ impl Entry {
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkEnumerateInstanceLayerProperties.html>
#[inline]
pub fn enumerate_instance_layer_properties(&self) -> VkResult<Vec<vk::LayerProperties>> {
unsafe {
read_into_uninitialized_vector(|count, data| {
Expand All @@ -242,6 +247,7 @@ impl Entry {
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkEnumerateInstanceExtensionProperties.html>
#[inline]
pub fn enumerate_instance_extension_properties(
&self,
layer_name: Option<&CStr>,
Expand All @@ -258,6 +264,7 @@ impl Entry {
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetInstanceProcAddr.html>
#[inline]
pub unsafe fn get_instance_proc_addr(
&self,
instance: vk::Instance,
Expand All @@ -270,6 +277,7 @@ impl Entry {
/// Vulkan core 1.1
#[allow(non_camel_case_types)]
impl Entry {
#[inline]
pub fn fp_v1_1(&self) -> &vk::EntryFnV1_1 {
&self.entry_fn_1_1
}
Expand All @@ -278,6 +286,7 @@ impl Entry {
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkEnumerateInstanceVersion.html>
///
/// Please use [`try_enumerate_instance_version()`][Self::try_enumerate_instance_version()] instead.
#[inline]
pub fn enumerate_instance_version(&self) -> VkResult<u32> {
unsafe {
let mut api_version = 0;
Expand All @@ -290,6 +299,7 @@ impl Entry {
/// Vulkan core 1.2
#[allow(non_camel_case_types)]
impl Entry {
#[inline]
pub fn fp_v1_2(&self) -> &vk::EntryFnV1_2 {
&self.entry_fn_1_2
}
Expand All @@ -298,6 +308,7 @@ impl Entry {
/// Vulkan core 1.3
#[allow(non_camel_case_types)]
impl Entry {
#[inline]
pub fn fp_v1_3(&self) -> &vk::EntryFnV1_3 {
&self.entry_fn_1_3
}
Expand All @@ -306,6 +317,7 @@ impl Entry {
#[cfg(feature = "linked")]
#[cfg_attr(docsrs, doc(cfg(feature = "linked")))]
impl Default for Entry {
#[inline]
fn default() -> Self {
Self::linked()
}
Expand Down

0 comments on commit b444d41

Please sign in to comment.