From f98cab47ddc9a882a8a2fc6858b1a5d64a467151 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 30 Mar 2023 11:12:36 +0200 Subject: [PATCH] extensions: Remove `get_properties()` helper from extension wrappers (#728) This helper function isn't consistently implemented across most extension wrappers, and promotes bad Vulkan patterns by not making it obvious to the caller that `get_physical_device_properties2()` can and should be used to fill multiple properties structs at once. --- Changelog.md | 1 + ash/src/extensions/ext/mod.rs | 2 -- ash/src/extensions/ext/physical_device_drm.rs | 23 ------------------- .../extensions/khr/acceleration_structure.rs | 13 ----------- .../extensions/khr/ray_tracing_pipeline.rs | 13 ----------- ash/src/extensions/nv/ray_tracing.rs | 13 ----------- 6 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 ash/src/extensions/ext/physical_device_drm.rs diff --git a/Changelog.md b/Changelog.md index 4c49a5a..dcfcaee 100644 --- a/Changelog.md +++ b/Changelog.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed experimental AMD extensions (#607) - 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) ## [0.37.2] - 2022-01-11 diff --git a/ash/src/extensions/ext/mod.rs b/ash/src/extensions/ext/mod.rs index 26a78f7..f30ee32 100644 --- a/ash/src/extensions/ext/mod.rs +++ b/ash/src/extensions/ext/mod.rs @@ -16,7 +16,6 @@ pub use self::image_compression_control::ImageCompressionControl; pub use self::image_drm_format_modifier::ImageDrmFormatModifier; pub use self::mesh_shader::MeshShader; pub use self::metal_surface::MetalSurface; -pub use self::physical_device_drm::PhysicalDeviceDrm; pub use self::private_data::PrivateData; pub use self::sample_locations::SampleLocations; pub use self::tooling_info::ToolingInfo; @@ -39,7 +38,6 @@ mod image_compression_control; mod image_drm_format_modifier; mod mesh_shader; mod metal_surface; -mod physical_device_drm; mod private_data; mod sample_locations; mod tooling_info; diff --git a/ash/src/extensions/ext/physical_device_drm.rs b/ash/src/extensions/ext/physical_device_drm.rs deleted file mode 100644 index fa9bc20..0000000 --- a/ash/src/extensions/ext/physical_device_drm.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::vk; -use crate::Instance; -use std::ffi::CStr; - -#[derive(Clone)] -pub struct PhysicalDeviceDrm; - -impl PhysicalDeviceDrm { - #[inline] - pub unsafe fn get_properties( - instance: &Instance, - pdevice: vk::PhysicalDevice, - ) -> vk::PhysicalDeviceDrmPropertiesEXT { - let mut props_drm = vk::PhysicalDeviceDrmPropertiesEXT::default(); - { - let mut props = vk::PhysicalDeviceProperties2::default().push_next(&mut props_drm); - instance.get_physical_device_properties2(pdevice, &mut props); - } - props_drm - } - - pub const NAME: &'static CStr = vk::ExtPhysicalDeviceDrmFn::NAME; -} diff --git a/ash/src/extensions/khr/acceleration_structure.rs b/ash/src/extensions/khr/acceleration_structure.rs index c758d9b..55d0303 100644 --- a/ash/src/extensions/khr/acceleration_structure.rs +++ b/ash/src/extensions/khr/acceleration_structure.rs @@ -20,19 +20,6 @@ impl AccelerationStructure { Self { handle, fp } } - #[inline] - pub unsafe fn get_properties( - instance: &Instance, - pdevice: vk::PhysicalDevice, - ) -> vk::PhysicalDeviceAccelerationStructurePropertiesKHR { - let mut props_rt = vk::PhysicalDeviceAccelerationStructurePropertiesKHR::default(); - { - let mut props = vk::PhysicalDeviceProperties2::default().push_next(&mut props_rt); - instance.get_physical_device_properties2(pdevice, &mut props); - } - props_rt - } - /// #[inline] pub unsafe fn create_acceleration_structure( diff --git a/ash/src/extensions/khr/ray_tracing_pipeline.rs b/ash/src/extensions/khr/ray_tracing_pipeline.rs index 1c9f673..77fbd6e 100644 --- a/ash/src/extensions/khr/ray_tracing_pipeline.rs +++ b/ash/src/extensions/khr/ray_tracing_pipeline.rs @@ -20,19 +20,6 @@ impl RayTracingPipeline { Self { handle, fp } } - #[inline] - pub unsafe fn get_properties( - instance: &Instance, - pdevice: vk::PhysicalDevice, - ) -> vk::PhysicalDeviceRayTracingPipelinePropertiesKHR { - let mut props_rt = vk::PhysicalDeviceRayTracingPipelinePropertiesKHR::default(); - { - let mut props = vk::PhysicalDeviceProperties2::default().push_next(&mut props_rt); - instance.get_physical_device_properties2(pdevice, &mut props); - } - props_rt - } - /// #[inline] pub unsafe fn cmd_trace_rays( diff --git a/ash/src/extensions/nv/ray_tracing.rs b/ash/src/extensions/nv/ray_tracing.rs index 805ba24..c77b144 100755 --- a/ash/src/extensions/nv/ray_tracing.rs +++ b/ash/src/extensions/nv/ray_tracing.rs @@ -20,19 +20,6 @@ impl RayTracing { Self { handle, fp } } - #[inline] - pub unsafe fn get_properties( - instance: &Instance, - pdevice: vk::PhysicalDevice, - ) -> vk::PhysicalDeviceRayTracingPropertiesNV { - let mut props_rt = vk::PhysicalDeviceRayTracingPropertiesNV::default(); - { - let mut props = vk::PhysicalDeviceProperties2::default().push_next(&mut props_rt); - instance.get_physical_device_properties2(pdevice, &mut props); - } - props_rt - } - /// #[inline] pub unsafe fn create_acceleration_structure(