Inline Default impls and trivial instance/device wrapper methods (#606)
This commit is contained in:
parent
71bb3d337c
commit
362cf83fa8
File diff suppressed because it is too large
Load diff
|
@ -33,6 +33,7 @@ impl Instance {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn handle(&self) -> vk::Instance {
|
||||
self.handle
|
||||
}
|
||||
|
@ -41,11 +42,13 @@ impl Instance {
|
|||
/// Vulkan core 1.3
|
||||
#[allow(non_camel_case_types)]
|
||||
impl Instance {
|
||||
#[inline]
|
||||
pub fn fp_v1_3(&self) -> &vk::InstanceFnV1_3 {
|
||||
&self.instance_fn_1_3
|
||||
}
|
||||
|
||||
/// Retrieve the number of elements to pass to [`get_physical_device_tool_properties()`][Self::get_physical_device_tool_properties()]
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_tool_properties_len(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -63,6 +66,7 @@ impl Instance {
|
|||
///
|
||||
/// Call [`get_physical_device_tool_properties_len()`][Self::get_physical_device_tool_properties_len()] to query the number of elements to pass to `out`.
|
||||
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_tool_properties(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -83,6 +87,7 @@ impl Instance {
|
|||
/// Vulkan core 1.2
|
||||
#[allow(non_camel_case_types)]
|
||||
impl Instance {
|
||||
#[inline]
|
||||
pub fn fp_v1_2(&self) -> &vk::InstanceFnV1_2 {
|
||||
&self.instance_fn_1_2
|
||||
}
|
||||
|
@ -91,11 +96,13 @@ impl Instance {
|
|||
/// Vulkan core 1.1
|
||||
#[allow(non_camel_case_types)]
|
||||
impl Instance {
|
||||
#[inline]
|
||||
pub fn fp_v1_1(&self) -> &vk::InstanceFnV1_1 {
|
||||
&self.instance_fn_1_1
|
||||
}
|
||||
|
||||
/// Retrieve the number of elements to pass to [`enumerate_physical_device_groups()`][Self::enumerate_physical_device_groups()]
|
||||
#[inline]
|
||||
pub unsafe fn enumerate_physical_device_groups_len(&self) -> VkResult<usize> {
|
||||
let mut group_count = 0;
|
||||
(self.instance_fn_1_1.enumerate_physical_device_groups)(
|
||||
|
@ -110,6 +117,7 @@ impl Instance {
|
|||
///
|
||||
/// Call [`enumerate_physical_device_groups_len()`][Self::enumerate_physical_device_groups_len()] to query the number of elements to pass to `out`.
|
||||
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
|
||||
#[inline]
|
||||
pub unsafe fn enumerate_physical_device_groups(
|
||||
&self,
|
||||
out: &mut [vk::PhysicalDeviceGroupProperties],
|
||||
|
@ -126,6 +134,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceFeatures2.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_features2(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -135,6 +144,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceProperties2.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_properties2(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -144,6 +154,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceFormatProperties2.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_format_properties2(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -154,6 +165,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_image_format_properties2(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -171,6 +183,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// Retrieve the number of elements to pass to [`get_physical_device_queue_family_properties2()`][Self::get_physical_device_queue_family_properties2()]
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_queue_family_properties2_len(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -190,6 +203,7 @@ impl Instance {
|
|||
///
|
||||
/// Call [`get_physical_device_queue_family_properties2_len()`][Self::get_physical_device_queue_family_properties2_len()] to query the number of elements to pass to `out`.
|
||||
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_queue_family_properties2(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -207,6 +221,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceMemoryProperties2.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_memory_properties2(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -216,6 +231,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// Retrieve the number of elements to pass to [`get_physical_device_sparse_image_format_properties2()`][Self::get_physical_device_sparse_image_format_properties2()]
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_sparse_image_format_properties2_len(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -237,6 +253,7 @@ impl Instance {
|
|||
///
|
||||
/// Call [`get_physical_device_sparse_image_format_properties2_len()`][Self::get_physical_device_sparse_image_format_properties2_len()] to query the number of elements to pass to `out`.
|
||||
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_sparse_image_format_properties2(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -256,6 +273,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceExternalBufferProperties.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_external_buffer_properties(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -272,6 +290,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceExternalFenceProperties.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_external_fence_properties(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -288,6 +307,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceExternalSemaphoreProperties.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_external_semaphore_properties(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -307,6 +327,7 @@ impl Instance {
|
|||
/// Vulkan core 1.0
|
||||
#[allow(non_camel_case_types)]
|
||||
impl Instance {
|
||||
#[inline]
|
||||
pub fn fp_v1_0(&self) -> &vk::InstanceFnV1_0 {
|
||||
&self.instance_fn_1_0
|
||||
}
|
||||
|
@ -317,6 +338,7 @@ impl Instance {
|
|||
/// In order for the created [`Device`] to be valid for the duration of its
|
||||
/// usage, the [`Instance`] this was called on must be dropped later than the
|
||||
/// resulting [`Device`].
|
||||
#[inline]
|
||||
pub unsafe fn create_device(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -335,6 +357,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceProcAddr.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_device_proc_addr(
|
||||
&self,
|
||||
device: vk::Device,
|
||||
|
@ -344,11 +367,13 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroyInstance.html>
|
||||
#[inline]
|
||||
pub unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
|
||||
(self.instance_fn_1_0.destroy_instance)(self.handle(), allocation_callbacks.as_raw_ptr());
|
||||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceFormatProperties.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_format_properties(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -364,6 +389,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_image_format_properties(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -389,6 +415,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceMemoryProperties.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_memory_properties(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -402,6 +429,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceProperties.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_properties(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
@ -429,6 +457,7 @@ impl Instance {
|
|||
}
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceFeatures.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_features(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
|
|
|
@ -6,10 +6,12 @@ use crate::vk;
|
|||
pub type VkResult<T> = Result<T, vk::Result>;
|
||||
|
||||
impl vk::Result {
|
||||
#[inline]
|
||||
pub fn result(self) -> VkResult<()> {
|
||||
self.result_with_success(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn result_with_success<T>(self, v: T) -> VkResult<T> {
|
||||
match self {
|
||||
Self::SUCCESS => Ok(v),
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1431,6 +1431,7 @@ pub fn derive_default(_struct: &vkxml::Struct, has_lifetime: bool) -> Option<Tok
|
|||
let marker = has_lifetime.then(|| quote!(_marker: PhantomData,));
|
||||
let q = quote! {
|
||||
impl ::std::default::Default for #name #lifetime {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
#(
|
||||
|
@ -2014,6 +2015,7 @@ fn generate_union(union: &vkxml::Union, has_lifetimes: &HashSet<Ident>) -> Token
|
|||
#(#fields),*
|
||||
}
|
||||
impl #lifetime ::std::default::Default for #name #lifetime {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
unsafe { ::std::mem::zeroed() }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue