Clean up unused std::XXX::
qualifications in examples and extensions (#852)
This commit is contained in:
parent
e6d80badc3
commit
e7dab7cb66
|
@ -1,7 +1,9 @@
|
|||
#![warn(unused_qualifications)]
|
||||
|
||||
use std::default::Default;
|
||||
use std::ffi::CStr;
|
||||
use std::io::Cursor;
|
||||
use std::mem::{self, align_of};
|
||||
use std::mem;
|
||||
use std::os::raw::c_void;
|
||||
|
||||
use ash::util::*;
|
||||
|
@ -95,7 +97,7 @@ fn main() {
|
|||
.collect();
|
||||
let index_buffer_data = [0u32, 1, 2, 2, 3, 0];
|
||||
let index_buffer_info = vk::BufferCreateInfo {
|
||||
size: std::mem::size_of_val(&index_buffer_data) as u64,
|
||||
size: mem::size_of_val(&index_buffer_data) as u64,
|
||||
usage: vk::BufferUsageFlags::INDEX_BUFFER,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
..Default::default()
|
||||
|
@ -128,7 +130,7 @@ fn main() {
|
|||
.unwrap();
|
||||
let mut index_slice = Align::new(
|
||||
index_ptr,
|
||||
align_of::<u32>() as u64,
|
||||
mem::align_of::<u32>() as u64,
|
||||
index_buffer_memory_req.size,
|
||||
);
|
||||
index_slice.copy_from_slice(&index_buffer_data);
|
||||
|
@ -156,7 +158,7 @@ fn main() {
|
|||
},
|
||||
];
|
||||
let vertex_input_buffer_info = vk::BufferCreateInfo {
|
||||
size: std::mem::size_of_val(&vertices) as u64,
|
||||
size: mem::size_of_val(&vertices) as u64,
|
||||
usage: vk::BufferUsageFlags::VERTEX_BUFFER,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
..Default::default()
|
||||
|
@ -196,7 +198,7 @@ fn main() {
|
|||
.unwrap();
|
||||
let mut slice = Align::new(
|
||||
vert_ptr,
|
||||
align_of::<Vertex>() as u64,
|
||||
mem::align_of::<Vertex>() as u64,
|
||||
vertex_input_buffer_memory_req.size,
|
||||
);
|
||||
slice.copy_from_slice(&vertices);
|
||||
|
@ -212,7 +214,7 @@ fn main() {
|
|||
_pad: 0.0,
|
||||
};
|
||||
let uniform_color_buffer_info = vk::BufferCreateInfo {
|
||||
size: std::mem::size_of_val(&uniform_color_buffer_data) as u64,
|
||||
size: mem::size_of_val(&uniform_color_buffer_data) as u64,
|
||||
usage: vk::BufferUsageFlags::UNIFORM_BUFFER,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
..Default::default()
|
||||
|
@ -251,7 +253,7 @@ fn main() {
|
|||
.unwrap();
|
||||
let mut uniform_aligned_slice = Align::new(
|
||||
uniform_ptr,
|
||||
align_of::<Vector3>() as u64,
|
||||
mem::align_of::<Vector3>() as u64,
|
||||
uniform_color_buffer_memory_req.size,
|
||||
);
|
||||
uniform_aligned_slice.copy_from_slice(&[uniform_color_buffer_data]);
|
||||
|
@ -267,7 +269,7 @@ fn main() {
|
|||
let image_extent = vk::Extent2D { width, height };
|
||||
let image_data = image.into_raw();
|
||||
let image_buffer_info = vk::BufferCreateInfo {
|
||||
size: (std::mem::size_of::<u8>() * image_data.len()) as u64,
|
||||
size: (mem::size_of::<u8>() * image_data.len()) as u64,
|
||||
usage: vk::BufferUsageFlags::TRANSFER_SRC,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
..Default::default()
|
||||
|
@ -301,7 +303,7 @@ fn main() {
|
|||
.unwrap();
|
||||
let mut image_slice = Align::new(
|
||||
image_ptr,
|
||||
std::mem::align_of::<u8>() as u64,
|
||||
mem::align_of::<u8>() as u64,
|
||||
image_buffer_memory_req.size,
|
||||
);
|
||||
image_slice.copy_from_slice(&image_data);
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#![warn(unused_qualifications)]
|
||||
|
||||
use std::default::Default;
|
||||
use std::ffi::CStr;
|
||||
use std::io::Cursor;
|
||||
use std::mem;
|
||||
use std::mem::align_of;
|
||||
|
||||
use ash::util::*;
|
||||
use ash::vk;
|
||||
|
@ -87,7 +88,7 @@ fn main() {
|
|||
|
||||
let index_buffer_data = [0u32, 1, 2];
|
||||
let index_buffer_info = vk::BufferCreateInfo::default()
|
||||
.size(std::mem::size_of_val(&index_buffer_data) as u64)
|
||||
.size(mem::size_of_val(&index_buffer_data) as u64)
|
||||
.usage(vk::BufferUsageFlags::INDEX_BUFFER)
|
||||
.sharing_mode(vk::SharingMode::EXCLUSIVE);
|
||||
|
||||
|
@ -120,7 +121,7 @@ fn main() {
|
|||
.unwrap();
|
||||
let mut index_slice = Align::new(
|
||||
index_ptr,
|
||||
align_of::<u32>() as u64,
|
||||
mem::align_of::<u32>() as u64,
|
||||
index_buffer_memory_req.size,
|
||||
);
|
||||
index_slice.copy_from_slice(&index_buffer_data);
|
||||
|
@ -130,7 +131,7 @@ fn main() {
|
|||
.unwrap();
|
||||
|
||||
let vertex_input_buffer_info = vk::BufferCreateInfo {
|
||||
size: 3 * std::mem::size_of::<Vertex>() as u64,
|
||||
size: 3 * mem::size_of::<Vertex>() as u64,
|
||||
usage: vk::BufferUsageFlags::VERTEX_BUFFER,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
..Default::default()
|
||||
|
@ -190,7 +191,7 @@ fn main() {
|
|||
|
||||
let mut vert_align = Align::new(
|
||||
vert_ptr,
|
||||
align_of::<Vertex>() as u64,
|
||||
mem::align_of::<Vertex>() as u64,
|
||||
vertex_input_buffer_memory_req.size,
|
||||
);
|
||||
vert_align.copy_from_slice(&vertices);
|
||||
|
|
|
@ -337,7 +337,7 @@ impl vk::StaticFn {
|
|||
if val.is_null() {
|
||||
return Err(MissingEntryPoint);
|
||||
} else {
|
||||
::std::mem::transmute(val)
|
||||
mem::transmute(val)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
|
|
@ -43,7 +43,7 @@ impl ShaderInfo {
|
|||
vk::ShaderInfoTypeAMD::STATISTICS => {
|
||||
let mut statistics_info = mem::MaybeUninit::<vk::ShaderStatisticsInfoAMD>::uninit();
|
||||
load_data(
|
||||
&mut std::mem::size_of_val(&statistics_info),
|
||||
&mut mem::size_of_val(&statistics_info),
|
||||
statistics_info.as_mut_ptr().cast(),
|
||||
)
|
||||
.result()?;
|
||||
|
|
|
@ -3,6 +3,7 @@ use crate::vk;
|
|||
use crate::{Entry, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_get_surface_capabilities2.html>
|
||||
#[derive(Clone)]
|
||||
|
@ -46,7 +47,7 @@ impl GetSurfaceCapabilities2 {
|
|||
physical_device,
|
||||
surface_info,
|
||||
count.as_mut_ptr(),
|
||||
std::ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
);
|
||||
err_code.assume_init_on_success(count).map(|c| c as usize)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::vk;
|
|||
use crate::{Device, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_maintenance4.html>
|
||||
#[derive(Clone)]
|
||||
|
@ -50,7 +51,7 @@ impl Maintenance4 {
|
|||
self.handle,
|
||||
memory_requirements,
|
||||
count.as_mut_ptr(),
|
||||
std::ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
);
|
||||
count.assume_init() as usize
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ use crate::vk;
|
|||
use crate::{Entry, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_NV_coverage_reduction_mode.html>
|
||||
#[derive(Clone)]
|
||||
|
@ -30,7 +31,7 @@ impl CoverageReductionMode {
|
|||
.get_physical_device_supported_framebuffer_mixed_samples_combinations_nv)(
|
||||
physical_device,
|
||||
count.as_mut_ptr(),
|
||||
std::ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
)
|
||||
.assume_init_on_success(count)
|
||||
.map(|c| c as usize)
|
||||
|
|
|
@ -3,6 +3,7 @@ use crate::{Device, Instance};
|
|||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
use std::os::raw::c_void;
|
||||
use std::ptr;
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_NV_device_diagnostic_checkpoints.html>
|
||||
#[derive(Clone)]
|
||||
|
@ -32,7 +33,7 @@ impl DeviceDiagnosticCheckpoints {
|
|||
#[inline]
|
||||
pub unsafe fn get_queue_checkpoint_data_len(&self, queue: vk::Queue) -> usize {
|
||||
let mut count = mem::MaybeUninit::uninit();
|
||||
(self.fp.get_queue_checkpoint_data_nv)(queue, count.as_mut_ptr(), std::ptr::null_mut());
|
||||
(self.fp.get_queue_checkpoint_data_nv)(queue, count.as_mut_ptr(), ptr::null_mut());
|
||||
count.assume_init() as usize
|
||||
}
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ impl RayTracing {
|
|||
(self.fp.get_acceleration_structure_handle_nv)(
|
||||
self.handle,
|
||||
accel_struct,
|
||||
std::mem::size_of_val(&handle),
|
||||
mem::size_of_val(&handle),
|
||||
handle.as_mut_ptr().cast(),
|
||||
)
|
||||
.assume_init_on_success(handle)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::convert::TryInto;
|
||||
#[cfg(feature = "debug")]
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
use crate::vk;
|
||||
pub type VkResult<T> = Result<T, vk::Result>;
|
||||
|
@ -50,7 +49,7 @@ where
|
|||
{
|
||||
loop {
|
||||
let mut count = N::default();
|
||||
f(&mut count, std::ptr::null_mut()).result()?;
|
||||
f(&mut count, ptr::null_mut()).result()?;
|
||||
let mut data =
|
||||
Vec::with_capacity(count.try_into().expect("`N` failed to convert to `usize`"));
|
||||
|
||||
|
@ -69,7 +68,7 @@ where
|
|||
///
|
||||
/// Items in the target vector are [`default()`][Default::default()]-initialized which is required
|
||||
/// for [`vk::BaseOutStructure`]-like structs where [`vk::BaseOutStructure::s_type`] needs to be a
|
||||
/// valid type and [`vk::BaseOutStructure::p_next`] a valid or [`null`][std::ptr::null_mut()]
|
||||
/// valid type and [`vk::BaseOutStructure::p_next`] a valid or [`null`][ptr::null_mut()]
|
||||
/// pointer.
|
||||
///
|
||||
/// See for example [`vkEnumerateInstanceExtensionProperties`]: the number of available items may
|
||||
|
@ -88,7 +87,7 @@ where
|
|||
{
|
||||
loop {
|
||||
let mut count = N::default();
|
||||
f(&mut count, std::ptr::null_mut()).result()?;
|
||||
f(&mut count, ptr::null_mut()).result()?;
|
||||
let mut data =
|
||||
vec![Default::default(); count.try_into().expect("`N` failed to convert to `usize`")];
|
||||
|
||||
|
@ -104,10 +103,10 @@ where
|
|||
|
||||
#[cfg(feature = "debug")]
|
||||
pub(crate) fn debug_flags<Value: Into<u64> + Copy>(
|
||||
f: &mut fmt::Formatter<'_>,
|
||||
f: &mut std::fmt::Formatter<'_>,
|
||||
known: &[(Value, &'static str)],
|
||||
value: Value,
|
||||
) -> fmt::Result {
|
||||
) -> std::fmt::Result {
|
||||
let mut first = true;
|
||||
let mut accum = value.into();
|
||||
for &(bit, name) in known {
|
||||
|
|
|
@ -28,10 +28,9 @@ pub struct AlignIter<'a, T> {
|
|||
|
||||
impl<T: Copy> Align<T> {
|
||||
pub fn copy_from_slice(&mut self, slice: &[T]) {
|
||||
use std::slice::from_raw_parts_mut;
|
||||
if self.elem_size == size_of::<T>() as u64 {
|
||||
unsafe {
|
||||
let mapped_slice = from_raw_parts_mut(self.ptr.cast(), slice.len());
|
||||
let mapped_slice = slice::from_raw_parts_mut(self.ptr.cast(), slice.len());
|
||||
mapped_slice.copy_from_slice(slice);
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue