Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline trivial Entry wrapper methods and impl functions #633

Merged
merged 1 commit into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] - ReleaseDate

### Changed

- Replaced builders with lifetimes/setters directly on Vulkan structs (#602)
- Inlined struct setters (#602)
- Inlined `Default` impls and trivial `Instance`/`Device`/`Entry` wrapper methods (#606, #632)

### Added

- Added `VK_NV_coverage_reduction_mode` device extension (#617)
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