Globally remove all allow(dead_code) exceptions and make extensions public (#430)

* GetPhysicalDeviceProperties2: Make API functions public

Fixes: 5eb39fe ("Add VK_KHR_get_physical_device_properties2 extension (#400)")

* BufferDeviceAddress: Make API functions public

Fixes: 98d66c6 ("Add VK_KHR/EXT_buffer_device_address extension (#405)")

* GetMemoryRequirements2: Make API functions public

Fixes: d8d7423 ("Add VK_KHR_get_memory_requirements2 extension (#401)")

* Maintenance1/Maintenance3: Make API functions public

Fixes: a0a1f5d ("Add VK_KHR_maintenance extensions (#406)")

* Globally remove all `allow(dead_code)` exceptions

This is hiding the fact that some extension functions are inadvertently
not public and hence unusable by crate users, nor does it enforce clean
coding practices.

In addition remove `ash/src/allocator.rs` which does not appear to be
used (anymore?) and isn't in a working state anyway.
This commit is contained in:
Marijn Suijten 2021-05-08 21:04:31 +02:00 committed by GitHub
parent c7216f1c1e
commit 28b6253748
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 19 additions and 175 deletions

View file

@ -1,120 +0,0 @@
#![allow(dead_code)]
use vk;
use std::os::raw::c_void;
use std::ptr;
pub trait VkAllocation {
unsafe extern "system" fn allocation(
*mut (),
usize,
usize,
vk::SystemAllocationScope,
) -> *mut ();
unsafe extern "system" fn reallocation(
*mut c_void,
*mut c_void,
usize,
usize,
vk::SystemAllocationScope,
) -> *mut c_void;
unsafe extern "system" fn free(*mut c_void, *mut c_void);
unsafe extern "system" fn internal_allocation(
*mut c_void,
usize,
vk::InternalAllocationType,
vk::SystemAllocationScope,
);
unsafe extern "system" fn internal_free(
*mut c_void,
usize,
vk::InternalAllocationType,
vk::SystemAllocationScope,
);
fn create_allocation_callback() -> Option<vk::AllocationCallbacks> {
let alloc = vk::AllocationCallbacks {
p_user_data: ptr::null_mut(),
pfn_allocation: Self::allocation,
pfn_reallocation: Self::reallocation,
pfn_free: Self::free,
pfn_internal_allocation: Self::internal_allocation,
pfn_internal_free: Self::internal_free,
};
Some(alloc)
}
}
pub struct DefaultAllocatorCallback;
pub struct TestAlloc;
impl VkAllocation for TestAlloc {
unsafe extern "system" fn allocation(
_: *mut (),
_: usize,
_: usize,
_: vk::SystemAllocationScope,
) -> *mut () {
ptr::null_mut()
}
unsafe extern "system" fn reallocation(
_: *mut c_void,
_: *mut c_void,
_: usize,
_: usize,
_: vk::SystemAllocationScope,
) -> *mut c_void {
ptr::null_mut()
}
unsafe extern "system" fn free(_: *mut c_void, _: *mut c_void) {}
unsafe extern "system" fn internal_allocation(
_: *mut c_void,
_: usize,
_: vk::InternalAllocationType,
_: vk::SystemAllocationScope,
) {
}
unsafe extern "system" fn internal_free(
_: *mut c_void,
_: usize,
_: vk::InternalAllocationType,
_: vk::SystemAllocationScope,
) {
}
}
impl VkAllocation for DefaultAllocatorCallback {
unsafe extern "system" fn allocation(
_: *mut (),
_: usize,
_: usize,
_: vk::SystemAllocationScope,
) -> *mut () {
ptr::null_mut()
}
unsafe extern "system" fn reallocation(
_: *mut c_void,
_: *mut c_void,
_: usize,
_: usize,
_: vk::SystemAllocationScope,
) -> *mut c_void {
ptr::null_mut()
}
unsafe extern "system" fn free(_: *mut c_void, _: *mut c_void) {}
unsafe extern "system" fn internal_allocation(
_: *mut c_void,
_: usize,
_: vk::InternalAllocationType,
_: vk::SystemAllocationScope,
) {
}
unsafe extern "system" fn internal_free(
_: *mut c_void,
_: usize,
_: vk::InternalAllocationType,
_: vk::SystemAllocationScope,
) {
}
fn create_allocation_callback() -> Option<vk::AllocationCallbacks> {
None
}
}

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
@ -22,7 +21,7 @@ impl BufferDeviceAddress {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferDeviceAddressEXT.html>"]
unsafe fn get_buffer_device_address(
pub unsafe fn get_buffer_device_address(
&self,
info: &vk::BufferDeviceAddressInfoEXT,
) -> vk::DeviceAddress {

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::{Device, Instance};

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::{vk, RawPtr};
use crate::{EntryCustom, Instance};

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::{Device, Instance};

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::{EntryCustom, Instance};

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
@ -22,7 +21,7 @@ impl BufferDeviceAddress {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferDeviceAddressKHR.html>"]
unsafe fn get_buffer_device_address(
pub unsafe fn get_buffer_device_address(
&self,
info: &vk::BufferDeviceAddressInfoKHR,
) -> vk::DeviceAddress {
@ -30,7 +29,7 @@ impl BufferDeviceAddress {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferOpaqueCaptureAddressKHR.html>"]
unsafe fn get_buffer_opaque_capture_address(
pub unsafe fn get_buffer_opaque_capture_address(
&self,
info: &vk::BufferDeviceAddressInfoKHR,
) -> u64 {
@ -39,7 +38,7 @@ impl BufferDeviceAddress {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceMemoryOpaqueCaptureAddressKHR.html>"]
unsafe fn get_device_memory_opaque_capture_address(
pub unsafe fn get_device_memory_opaque_capture_address(
&self,
info: &vk::DeviceMemoryOpaqueCaptureAddressInfoKHR,
) -> u64 {

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
@ -27,7 +26,7 @@ impl GetMemoryRequirements2 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferMemoryRequirements2KHR.html>"]
unsafe fn get_buffer_memory_requirements2(
pub unsafe fn get_buffer_memory_requirements2(
&self,
info: &vk::BufferMemoryRequirementsInfo2KHR,
memory_requirements: &mut vk::MemoryRequirements2KHR,
@ -37,7 +36,7 @@ impl GetMemoryRequirements2 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetImageMemoryRequirements2KHR.html>"]
unsafe fn get_image_memory_requirements2(
pub unsafe fn get_image_memory_requirements2(
&self,
info: &vk::ImageMemoryRequirementsInfo2KHR,
memory_requirements: &mut vk::MemoryRequirements2KHR,
@ -46,7 +45,7 @@ impl GetMemoryRequirements2 {
.get_image_memory_requirements2_khr(self.handle, info, memory_requirements);
}
unsafe fn get_image_sparse_memory_requirements2_len(
pub unsafe fn get_image_sparse_memory_requirements2_len(
&self,
info: &vk::ImageSparseMemoryRequirementsInfo2KHR,
) -> usize {
@ -62,7 +61,7 @@ impl GetMemoryRequirements2 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetImageSparseMemoryRequirements2KHR.html>"]
unsafe fn get_image_sparse_memory_requirements2(
pub unsafe fn get_image_sparse_memory_requirements2(
&self,
info: &vk::ImageSparseMemoryRequirementsInfo2KHR,
sparse_memory_requirements: &mut [vk::SparseImageMemoryRequirements2KHR],

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::{EntryCustom, Instance};
@ -29,7 +28,7 @@ impl GetPhysicalDeviceProperties2 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFeatures2KHR.html>"]
unsafe fn get_physical_device_features2(
pub unsafe fn get_physical_device_features2(
&self,
physical_device: vk::PhysicalDevice,
features: &mut vk::PhysicalDeviceFeatures2KHR,
@ -39,7 +38,7 @@ impl GetPhysicalDeviceProperties2 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFormatProperties2KHR.html>"]
unsafe fn get_physical_device_format_properties2(
pub unsafe fn get_physical_device_format_properties2(
&self,
physical_device: vk::PhysicalDevice,
format: vk::Format,
@ -50,7 +49,7 @@ impl GetPhysicalDeviceProperties2 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2KHR.html>"]
unsafe fn get_physical_device_image_format_properties2(
pub unsafe fn get_physical_device_image_format_properties2(
&self,
physical_device: vk::PhysicalDevice,
image_format_info: &vk::PhysicalDeviceImageFormatInfo2KHR,
@ -66,7 +65,7 @@ impl GetPhysicalDeviceProperties2 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceMemoryProperties2KHR.html>"]
unsafe fn get_physical_device_memory_properties2(
pub unsafe fn get_physical_device_memory_properties2(
&self,
physical_device: vk::PhysicalDevice,
memory_properties: &mut vk::PhysicalDeviceMemoryProperties2KHR,
@ -76,7 +75,7 @@ impl GetPhysicalDeviceProperties2 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceProperties2KHR.html>"]
unsafe fn get_physical_device_properties2(
pub unsafe fn get_physical_device_properties2(
&self,
physical_device: vk::PhysicalDevice,
properties: &mut vk::PhysicalDeviceProperties2KHR,
@ -85,7 +84,7 @@ impl GetPhysicalDeviceProperties2 {
.get_physical_device_properties2_khr(physical_device, properties);
}
unsafe fn get_physical_device_queue_family_properties2_len(
pub unsafe fn get_physical_device_queue_family_properties2_len(
&self,
physical_device: vk::PhysicalDevice,
) -> usize {
@ -100,7 +99,7 @@ impl GetPhysicalDeviceProperties2 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceQueueFamilyProperties2KHR.html>"]
unsafe fn get_physical_device_queue_family_properties2(
pub unsafe fn get_physical_device_queue_family_properties2(
&self,
physical_device: vk::PhysicalDevice,
queue_family_properties: &mut [vk::QueueFamilyProperties2KHR],
@ -114,7 +113,7 @@ impl GetPhysicalDeviceProperties2 {
);
}
unsafe fn get_physical_device_sparse_image_format_properties2_len(
pub unsafe fn get_physical_device_sparse_image_format_properties2_len(
&self,
physical_device: vk::PhysicalDevice,
format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR,
@ -131,7 +130,7 @@ impl GetPhysicalDeviceProperties2 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSparseImageFormatProperties2KHR.html>"]
unsafe fn get_physical_device_sparse_image_format_properties2(
pub unsafe fn get_physical_device_sparse_image_format_properties2(
&self,
physical_device: vk::PhysicalDevice,
format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR,

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
@ -26,7 +25,7 @@ impl Maintenance1 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkTrimCommandPoolKHR.html>"]
unsafe fn trim_command_pool(
pub unsafe fn trim_command_pool(
&self,
command_pool: vk::CommandPool,
flags: vk::CommandPoolTrimFlagsKHR,

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
@ -26,7 +25,7 @@ impl Maintenance3 {
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDescriptorSetLayoutSupportKHR.html>"]
unsafe fn get_descriptor_set_layout_support(
pub unsafe fn get_descriptor_set_layout_support(
&self,
create_info: &vk::DescriptorSetLayoutCreateInfo,
out: &mut vk::DescriptorSetLayoutSupportKHR,

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::{EntryCustom, Instance};

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::vk;
use crate::{Device, Instance};
use std::ffi::c_void;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::{EntryCustom, Instance};

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;

View file

@ -1,4 +1,3 @@
#![allow(dead_code)]
use crate::device::Device;
use crate::prelude::*;
use crate::vk;