Drop load() functions from empty Fn structs (#752)

These functions don't contribute anything and should be removed to clean
up the `features` and `extensions` files, while now also not showing in
the documentation anymore.  The structs remain in place for associated
constants but are replaced with true unit-like structs (no curly
brackets anymore), and unneeded `unsafe impl Send/Sync` are removed as
well.

As these `load()` functions have been removed from the empty
feature-levels on `Entry` and `Device` as well, rather than
instantiating the unit structs and returning those the fields and
`fp_vX_X()` getters have been removed entirely.
This commit is contained in:
Marijn Suijten 2023-05-06 20:22:32 +02:00 committed by GitHub
parent 8b1151350e
commit cf1c92e664
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 227 additions and 2183 deletions

View file

@ -36,6 +36,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed `query_count` parameter from `get_query_pool_results()` in favour of `data.len()` (#644)
- Removed misnamed, deprecated `debug_utils_set_object_name()` and `debug_utils_set_object_tag()` entirely, use `set_debug_utils_object_name()` and `set_debug_utils_object_tag()` instead (#661)
- Removed `get_properties` helper from extension wrappers (and `ext::PhysicalDeviceDrm`). Directly call `get_physical_device_properties2()` with a possible chain of multiple structs instead (#728)
- Removed `fn load()` from empty features and extensions (#752)
- Removed empty `entry_fn_1_2`/`entry_fn_1_3` and getters from `Entry`
- Removed empty `instance_fn_1_2:` and getters from `Instance`
## [0.37.2] - 2022-01-11

View file

@ -40,7 +40,6 @@ impl Device {
}
/// Vulkan core 1.3
#[allow(non_camel_case_types)]
impl Device {
#[inline]
pub fn fp_v1_3(&self) -> &vk::DeviceFnV1_3 {
@ -531,7 +530,6 @@ impl Device {
}
/// Vulkan core 1.2
#[allow(non_camel_case_types)]
impl Device {
#[inline]
pub fn fp_v1_2(&self) -> &vk::DeviceFnV1_2 {
@ -705,7 +703,6 @@ impl Device {
}
/// Vulkan core 1.1
#[allow(non_camel_case_types)]
impl Device {
#[inline]
pub fn fp_v1_1(&self) -> &vk::DeviceFnV1_1 {
@ -952,7 +949,6 @@ impl Device {
}
/// Vulkan core 1.0
#[allow(non_camel_case_types)]
impl Device {
#[inline]
pub fn fp_v1_0(&self) -> &vk::DeviceFnV1_0 {

View file

@ -21,14 +21,11 @@ pub struct Entry {
static_fn: vk::StaticFn,
entry_fn_1_0: vk::EntryFnV1_0,
entry_fn_1_1: vk::EntryFnV1_1,
entry_fn_1_2: vk::EntryFnV1_2,
entry_fn_1_3: vk::EntryFnV1_3,
#[cfg(feature = "loaded")]
_lib_guard: Option<Arc<Library>>,
}
/// Vulkan core 1.0
#[allow(non_camel_case_types)]
impl Entry {
/// Load default Vulkan library for the current platform
///
@ -151,15 +148,11 @@ impl Entry {
};
let entry_fn_1_0 = vk::EntryFnV1_0::load(load_fn);
let entry_fn_1_1 = vk::EntryFnV1_1::load(load_fn);
let entry_fn_1_2 = vk::EntryFnV1_2::load(load_fn);
let entry_fn_1_3 = vk::EntryFnV1_3::load(load_fn);
Self {
static_fn,
entry_fn_1_0,
entry_fn_1_1,
entry_fn_1_2,
entry_fn_1_3,
#[cfg(feature = "loaded")]
_lib_guard: None,
}
@ -273,7 +266,6 @@ impl Entry {
}
/// Vulkan core 1.1
#[allow(non_camel_case_types)]
impl Entry {
#[inline]
pub fn fp_v1_1(&self) -> &vk::EntryFnV1_1 {
@ -294,24 +286,6 @@ 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
}
}
/// 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
}
}
#[cfg(feature = "linked")]
#[cfg_attr(docsrs, doc(cfg(feature = "linked")))]
impl Default for Entry {

View file

@ -13,7 +13,6 @@ pub struct Instance {
pub(crate) instance_fn_1_0: vk::InstanceFnV1_0,
pub(crate) instance_fn_1_1: vk::InstanceFnV1_1,
pub(crate) instance_fn_1_2: vk::InstanceFnV1_2,
pub(crate) instance_fn_1_3: vk::InstanceFnV1_3,
}
@ -28,7 +27,6 @@ impl Instance {
instance_fn_1_0: vk::InstanceFnV1_0::load(load_fn),
instance_fn_1_1: vk::InstanceFnV1_1::load(load_fn),
instance_fn_1_2: vk::InstanceFnV1_2::load(load_fn),
instance_fn_1_3: vk::InstanceFnV1_3::load(load_fn),
}
}
@ -40,7 +38,6 @@ impl Instance {
}
/// Vulkan core 1.3
#[allow(non_camel_case_types)]
impl Instance {
#[inline]
pub fn fp_v1_3(&self) -> &vk::InstanceFnV1_3 {
@ -84,17 +81,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
}
}
/// Vulkan core 1.1
#[allow(non_camel_case_types)]
impl Instance {
#[inline]
pub fn fp_v1_1(&self) -> &vk::InstanceFnV1_1 {
@ -325,7 +312,6 @@ impl Instance {
}
/// Vulkan core 1.0
#[allow(non_camel_case_types)]
impl Instance {
#[inline]
pub fn fp_v1_0(&self) -> &vk::InstanceFnV1_0 {

File diff suppressed because it is too large Load diff

View file

@ -4296,29 +4296,9 @@ impl DeviceFnV1_1 {
}
}
#[derive(Clone)]
pub struct EntryFnV1_2 {}
unsafe impl Send for EntryFnV1_2 {}
unsafe impl Sync for EntryFnV1_2 {}
impl EntryFnV1_2 {
pub fn load<F>(mut _f: F) -> Self
where
F: FnMut(&::std::ffi::CStr) -> *const c_void,
{
Self {}
}
}
pub struct EntryFnV1_2;
#[derive(Clone)]
pub struct InstanceFnV1_2 {}
unsafe impl Send for InstanceFnV1_2 {}
unsafe impl Sync for InstanceFnV1_2 {}
impl InstanceFnV1_2 {
pub fn load<F>(mut _f: F) -> Self
where
F: FnMut(&::std::ffi::CStr) -> *const c_void,
{
Self {}
}
}
pub struct InstanceFnV1_2;
#[derive(Clone)]
pub struct DeviceFnV1_2 {
pub cmd_draw_indirect_count: crate::vk::PFN_vkCmdDrawIndirectCount,
@ -4595,17 +4575,7 @@ impl DeviceFnV1_2 {
}
}
#[derive(Clone)]
pub struct EntryFnV1_3 {}
unsafe impl Send for EntryFnV1_3 {}
unsafe impl Sync for EntryFnV1_3 {}
impl EntryFnV1_3 {
pub fn load<F>(mut _f: F) -> Self
where
F: FnMut(&::std::ffi::CStr) -> *const c_void,
{
Self {}
}
}
pub struct EntryFnV1_3;
#[derive(Clone)]
pub struct InstanceFnV1_3 {
pub get_physical_device_tool_properties: crate::vk::PFN_vkGetPhysicalDeviceToolProperties,

View file

@ -22,6 +22,7 @@ use std::{
borrow::Cow,
collections::{BTreeMap, HashMap, HashSet},
fmt::Display,
ops::Not,
path::Path,
};
use syn::Ident;
@ -1032,25 +1033,10 @@ fn generate_function_pointers<'a>(
.to_tokens(tokens)
}
}
let pfn_typedefs = commands
.iter()
.filter(|pfn| pfn.type_needs_defining)
.map(CommandToType);
let members = commands.iter().map(CommandToMember);
let loaders = commands.iter().map(CommandToLoader);
let loader = commands.is_empty().not().then(|| {
quote! {
#(#pfn_typedefs)*
#[derive(Clone)]
pub struct #ident {
#(#members,)*
}
unsafe impl Send for #ident {}
unsafe impl Sync for #ident {}
impl #ident {
pub fn load<F>(mut _f: F) -> Self
where F: FnMut(&::std::ffi::CStr) -> *const c_void
@ -1061,6 +1047,35 @@ fn generate_function_pointers<'a>(
}
}
}
});
let pfn_typedefs = commands
.iter()
.filter(|pfn| pfn.type_needs_defining)
.map(CommandToType);
let members = commands.iter().map(CommandToMember);
let struct_contents = if commands.is_empty() {
quote! { pub struct #ident; }
} else {
quote! {
pub struct #ident {
#(#members,)*
}
unsafe impl Send for #ident {}
unsafe impl Sync for #ident {}
}
};
quote! {
#(#pfn_typedefs)*
#[derive(Clone)]
#struct_contents
#loader
}
}
pub struct ExtensionConstant<'a> {
pub name: &'a str,