Replace mem::uninitialized with mem::zeroed

Fixes #214
This commit is contained in:
Aaron Loucks 2019-05-25 15:13:17 -04:00
parent 19771a8200
commit bd69ab969c
19 changed files with 57 additions and 57 deletions

View file

@ -43,7 +43,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
local_device_index: u32,
remote_device_index: u32,
) -> vk::PeerMemoryFeatureFlags {
let mut peer_memory_features = mem::uninitialized();
let mut peer_memory_features = mem::zeroed();
self.fp_v1_1().get_device_group_peer_memory_features(
self.handle(),
heap_index,
@ -106,7 +106,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
&self,
info: &vk::ImageSparseMemoryRequirementsInfo2,
) -> usize {
let mut count = mem::uninitialized();
let mut count = mem::zeroed();
self.fp_v1_1().get_image_sparse_memory_requirements2(
self.handle(),
info,
@ -147,7 +147,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
create_info: &vk::SamplerYcbcrConversionCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SamplerYcbcrConversion> {
let mut ycbcr_conversion = mem::uninitialized();
let mut ycbcr_conversion = mem::zeroed();
let err_code = self.fp_v1_1().create_sampler_ycbcr_conversion(
self.handle(),
create_info,
@ -179,7 +179,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
create_info: &vk::DescriptorUpdateTemplateCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DescriptorUpdateTemplate> {
let mut descriptor_update_template = mem::uninitialized();
let mut descriptor_update_template = mem::zeroed();
let err_code = self.fp_v1_1().create_descriptor_update_template(
self.handle(),
create_info,
@ -281,7 +281,7 @@ pub trait DeviceV1_0 {
create_info: &vk::EventCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::Event> {
let mut event = mem::uninitialized();
let mut event = mem::zeroed();
let err_code = self.fp_v1_0().create_event(
self.handle(),
create_info,
@ -592,7 +592,7 @@ pub trait DeviceV1_0 {
create_info: &vk::SamplerCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::Sampler> {
let mut sampler = mem::uninitialized();
let mut sampler = mem::zeroed();
let err_code = self.fp_v1_0().create_sampler(
self.handle(),
create_info,
@ -780,7 +780,7 @@ pub trait DeviceV1_0 {
create_info: &vk::DescriptorSetLayoutCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DescriptorSetLayout> {
let mut layout = mem::uninitialized();
let mut layout = mem::zeroed();
let err_code = self.fp_v1_0().create_descriptor_set_layout(
self.handle(),
create_info,
@ -808,7 +808,7 @@ pub trait DeviceV1_0 {
create_info: &vk::DescriptorPoolCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DescriptorPool> {
let mut pool = mem::uninitialized();
let mut pool = mem::zeroed();
let err_code = self.fp_v1_0().create_descriptor_pool(
self.handle(),
create_info,
@ -1356,7 +1356,7 @@ pub trait DeviceV1_0 {
create_info: &vk::SemaphoreCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::Semaphore> {
let mut semaphore = mem::uninitialized();
let mut semaphore = mem::zeroed();
let err_code = self.fp_v1_0().create_semaphore(
self.handle(),
create_info,
@ -1421,7 +1421,7 @@ pub trait DeviceV1_0 {
create_info: &vk::BufferCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::Buffer> {
let mut buffer = mem::uninitialized();
let mut buffer = mem::zeroed();
let err_code = self.fp_v1_0().create_buffer(
self.handle(),
create_info,
@ -1440,7 +1440,7 @@ pub trait DeviceV1_0 {
create_info: &vk::PipelineLayoutCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::PipelineLayout> {
let mut pipeline_layout = mem::uninitialized();
let mut pipeline_layout = mem::zeroed();
let err_code = self.fp_v1_0().create_pipeline_layout(
self.handle(),
create_info,
@ -1459,7 +1459,7 @@ pub trait DeviceV1_0 {
create_info: &vk::PipelineCacheCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::PipelineCache> {
let mut pipeline_cache = mem::uninitialized();
let mut pipeline_cache = mem::zeroed();
let err_code = self.fp_v1_0().create_pipeline_cache(
self.handle(),
create_info,
@ -1510,7 +1510,7 @@ pub trait DeviceV1_0 {
size: vk::DeviceSize,
flags: vk::MemoryMapFlags,
) -> VkResult<*mut c_void> {
let mut data: *mut c_void = mem::uninitialized();
let mut data: *mut c_void = mem::zeroed();
let err_code =
self.fp_v1_0()
.map_memory(self.handle(), memory, offset, size, flags, &mut data);
@ -1560,7 +1560,7 @@ pub trait DeviceV1_0 {
create_info: &vk::FramebufferCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::Framebuffer> {
let mut framebuffer = mem::uninitialized();
let mut framebuffer = mem::zeroed();
let err_code = self.fp_v1_0().create_framebuffer(
self.handle(),
create_info,
@ -1575,7 +1575,7 @@ pub trait DeviceV1_0 {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetDeviceQueue.html>"]
unsafe fn get_device_queue(&self, queue_family_index: u32, queue_index: u32) -> vk::Queue {
let mut queue = mem::uninitialized();
let mut queue = mem::zeroed();
self.fp_v1_0()
.get_device_queue(self.handle(), queue_family_index, queue_index, &mut queue);
queue
@ -1612,7 +1612,7 @@ pub trait DeviceV1_0 {
create_info: &vk::RenderPassCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::RenderPass> {
let mut renderpass = mem::uninitialized();
let mut renderpass = mem::zeroed();
let err_code = self.fp_v1_0().create_render_pass(
self.handle(),
create_info,
@ -1709,7 +1709,7 @@ pub trait DeviceV1_0 {
create_info: &vk::BufferViewCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::BufferView> {
let mut buffer_view = mem::uninitialized();
let mut buffer_view = mem::zeroed();
let err_code = self.fp_v1_0().create_buffer_view(
self.handle(),
create_info,
@ -1741,7 +1741,7 @@ pub trait DeviceV1_0 {
create_info: &vk::ImageViewCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::ImageView> {
let mut image_view = mem::uninitialized();
let mut image_view = mem::zeroed();
let err_code = self.fp_v1_0().create_image_view(
self.handle(),
create_info,
@ -1778,7 +1778,7 @@ pub trait DeviceV1_0 {
create_info: &vk::CommandPoolCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::CommandPool> {
let mut pool = mem::uninitialized();
let mut pool = mem::zeroed();
let err_code = self.fp_v1_0().create_command_pool(
self.handle(),
create_info,
@ -1797,7 +1797,7 @@ pub trait DeviceV1_0 {
create_info: &vk::QueryPoolCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::QueryPool> {
let mut pool = mem::uninitialized();
let mut pool = mem::zeroed();
let err_code = self.fp_v1_0().create_query_pool(
self.handle(),
create_info,
@ -1816,7 +1816,7 @@ pub trait DeviceV1_0 {
create_info: &vk::ImageCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::Image> {
let mut image = mem::uninitialized();
let mut image = mem::zeroed();
let err_code = self.fp_v1_0().create_image(
self.handle(),
create_info,
@ -1835,7 +1835,7 @@ pub trait DeviceV1_0 {
image: vk::Image,
subresource: vk::ImageSubresource,
) -> vk::SubresourceLayout {
let mut layout = mem::uninitialized();
let mut layout = mem::zeroed();
self.fp_v1_0().get_image_subresource_layout(
self.handle(),
image,
@ -1847,7 +1847,7 @@ pub trait DeviceV1_0 {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetImageMemoryRequirements.html>"]
unsafe fn get_image_memory_requirements(&self, image: vk::Image) -> vk::MemoryRequirements {
let mut mem_req = mem::uninitialized();
let mut mem_req = mem::zeroed();
self.fp_v1_0()
.get_image_memory_requirements(self.handle(), image, &mut mem_req);
mem_req
@ -1855,7 +1855,7 @@ pub trait DeviceV1_0 {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetBufferMemoryRequirements.html>"]
unsafe fn get_buffer_memory_requirements(&self, buffer: vk::Buffer) -> vk::MemoryRequirements {
let mut mem_req = mem::uninitialized();
let mut mem_req = mem::zeroed();
self.fp_v1_0()
.get_buffer_memory_requirements(self.handle(), buffer, &mut mem_req);
mem_req
@ -1867,7 +1867,7 @@ pub trait DeviceV1_0 {
create_info: &vk::MemoryAllocateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DeviceMemory> {
let mut memory = mem::uninitialized();
let mut memory = mem::zeroed();
let err_code = self.fp_v1_0().allocate_memory(
self.handle(),
create_info,
@ -1886,7 +1886,7 @@ pub trait DeviceV1_0 {
create_info: &vk::ShaderModuleCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::ShaderModule> {
let mut shader = mem::uninitialized();
let mut shader = mem::zeroed();
let err_code = self.fp_v1_0().create_shader_module(
self.handle(),
create_info,
@ -1905,7 +1905,7 @@ pub trait DeviceV1_0 {
create_info: &vk::FenceCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::Fence> {
let mut fence = mem::uninitialized();
let mut fence = mem::zeroed();
let err_code = self.fp_v1_0().create_fence(
self.handle(),
create_info,

View file

@ -143,7 +143,7 @@ impl<L> EntryV1_0 for EntryCustom<L> {
create_info: &vk::InstanceCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> Result<Self::Instance, InstanceError> {
let mut instance: vk::Instance = mem::uninitialized();
let mut instance: vk::Instance = mem::zeroed();
let err_code = self.fp_v1_0().create_instance(
create_info,
allocation_callbacks.as_raw_ptr(),

View file

@ -46,7 +46,7 @@ impl DebugReport {
create_info: &vk::DebugReportCallbackCreateInfoEXT,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DebugReportCallbackEXT> {
let mut debug_cb = mem::uninitialized();
let mut debug_cb = mem::zeroed();
let err_code = self.debug_report_fn.create_debug_report_callback_ext(
self.handle,
create_info,

View file

@ -113,7 +113,7 @@ impl DebugUtils {
create_info: &vk::DebugUtilsMessengerCreateInfoEXT,
allocator: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::DebugUtilsMessengerEXT> {
let mut messenger = mem::uninitialized();
let mut messenger = mem::zeroed();
let err_code = self.debug_utils_fn.create_debug_utils_messenger_ext(
self.handle,
create_info,

View file

@ -33,7 +33,7 @@ impl AndroidSurface {
create_info: &vk::AndroidSurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.android_surface_fn.create_android_surface_khr(
self.handle,
create_info,

View file

@ -35,7 +35,7 @@ impl Surface {
queue_index: u32,
surface: vk::SurfaceKHR,
) -> VkResult<bool> {
let mut b = mem::uninitialized();
let mut b = mem::zeroed();
let err_code = self.surface_fn.get_physical_device_surface_support_khr(
physical_device,
queue_index,
@ -85,7 +85,7 @@ impl Surface {
physical_device: vk::PhysicalDevice,
surface: vk::SurfaceKHR,
) -> VkResult<vk::SurfaceCapabilitiesKHR> {
let mut surface_capabilities = mem::uninitialized();
let mut surface_capabilities = mem::zeroed();
let err_code = self
.surface_fn
.get_physical_device_surface_capabilities_khr(

View file

@ -50,7 +50,7 @@ impl Swapchain {
semaphore: vk::Semaphore,
fence: vk::Fence,
) -> VkResult<(u32, bool)> {
let mut index = mem::uninitialized();
let mut index = mem::zeroed();
let err_code = self.swapchain_fn.acquire_next_image_khr(
self.handle,
swapchain,
@ -72,7 +72,7 @@ impl Swapchain {
create_info: &vk::SwapchainCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SwapchainKHR> {
let mut swapchain = mem::uninitialized();
let mut swapchain = mem::zeroed();
let err_code = self.swapchain_fn.create_swapchain_khr(
self.handle,
create_info,

View file

@ -33,7 +33,7 @@ impl WaylandSurface {
create_info: &vk::WaylandSurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.wayland_surface_fn.create_wayland_surface_khr(
self.handle,
create_info,

View file

@ -33,7 +33,7 @@ impl Win32Surface {
create_info: &vk::Win32SurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.win32_surface_fn.create_win32_surface_khr(
self.handle,
create_info,

View file

@ -33,7 +33,7 @@ impl XcbSurface {
create_info: &vk::XcbSurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.xcb_surface_fn.create_xcb_surface_khr(
self.handle,
create_info,

View file

@ -33,7 +33,7 @@ impl XlibSurface {
create_info: &vk::XlibSurfaceCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.xlib_surface_fn.create_xlib_surface_khr(
self.handle,
create_info,

View file

@ -33,7 +33,7 @@ impl IOSSurface {
create_info: &vk::IOSSurfaceCreateInfoMVK,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.ios_surface_fn.create_ios_surface_mvk(
self.handle,
create_info,

View file

@ -33,7 +33,7 @@ impl MacOSSurface {
create_info: &vk::MacOSSurfaceCreateInfoMVK,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::uninitialized();
let mut surface = mem::zeroed();
let err_code = self.macos_surface_fn.create_mac_os_surface_mvk(
self.handle,
create_info,

View file

@ -41,7 +41,7 @@ impl RayTracing {
create_info: &vk::AccelerationStructureCreateInfoNV,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::AccelerationStructureNV> {
let mut accel_struct = mem::uninitialized();
let mut accel_struct = mem::zeroed();
let err_code = self.ray_tracing_fn.create_acceleration_structure_nv(
self.handle,
create_info,
@ -72,7 +72,7 @@ impl RayTracing {
&self,
info: &vk::AccelerationStructureMemoryRequirementsInfoNV,
) -> vk::MemoryRequirements2KHR {
let mut requirements = mem::uninitialized();
let mut requirements = mem::zeroed();
self.ray_tracing_fn
.get_acceleration_structure_memory_requirements_nv(
self.handle,
@ -181,7 +181,7 @@ impl RayTracing {
create_info: &[vk::RayTracingPipelineCreateInfoNV],
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<Vec<vk::Pipeline>> {
let mut pipelines = vec![mem::uninitialized(); create_info.len()];
let mut pipelines = vec![mem::zeroed(); create_info.len()];
let err_code = self.ray_tracing_fn.create_ray_tracing_pipelines_nv(
self.handle,
pipeline_cache,

View file

@ -40,7 +40,7 @@ impl InstanceV1_0 for Instance {
create_info: &vk::DeviceCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> Result<Self::Device, vk::Result> {
let mut device: vk::Device = mem::uninitialized();
let mut device: vk::Device = mem::zeroed();
let err_code = self.fp_v1_0().create_device(
physical_device,
create_info,
@ -72,7 +72,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
fn fp_v1_1(&self) -> &vk::InstanceFnV1_1;
unsafe fn enumerate_physical_device_groups_len(&self) -> usize {
let mut group_count = mem::uninitialized();
let mut group_count = mem::zeroed();
self.fp_v1_1().enumerate_physical_device_groups(
self.handle(),
&mut group_count,
@ -291,7 +291,7 @@ pub trait InstanceV1_0 {
physical_device: vk::PhysicalDevice,
format: vk::Format,
) -> vk::FormatProperties {
let mut format_prop = mem::uninitialized();
let mut format_prop = mem::zeroed();
self.fp_v1_0().get_physical_device_format_properties(
physical_device,
format,
@ -310,7 +310,7 @@ pub trait InstanceV1_0 {
usage: vk::ImageUsageFlags,
flags: vk::ImageCreateFlags,
) -> VkResult<vk::ImageFormatProperties> {
let mut image_format_prop = mem::uninitialized();
let mut image_format_prop = mem::zeroed();
let err_code = self.fp_v1_0().get_physical_device_image_format_properties(
physical_device,
format,
@ -332,7 +332,7 @@ pub trait InstanceV1_0 {
&self,
physical_device: vk::PhysicalDevice,
) -> vk::PhysicalDeviceMemoryProperties {
let mut memory_prop = mem::uninitialized();
let mut memory_prop = mem::zeroed();
self.fp_v1_0()
.get_physical_device_memory_properties(physical_device, &mut memory_prop);
memory_prop
@ -343,7 +343,7 @@ pub trait InstanceV1_0 {
&self,
physical_device: vk::PhysicalDevice,
) -> vk::PhysicalDeviceProperties {
let mut prop = mem::uninitialized();
let mut prop = mem::zeroed();
self.fp_v1_0()
.get_physical_device_properties(physical_device, &mut prop);
prop
@ -375,7 +375,7 @@ pub trait InstanceV1_0 {
&self,
physical_device: vk::PhysicalDevice,
) -> vk::PhysicalDeviceFeatures {
let mut prop = mem::uninitialized();
let mut prop = mem::zeroed();
self.fp_v1_0()
.get_physical_device_features(physical_device, &mut prop);
prop
@ -383,7 +383,7 @@ pub trait InstanceV1_0 {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumeratePhysicalDevices.html>"]
unsafe fn enumerate_physical_devices(&self) -> VkResult<Vec<vk::PhysicalDevice>> {
let mut num = mem::uninitialized();
let mut num = mem::zeroed();
self.fp_v1_0()
.enumerate_physical_devices(self.handle(), &mut num, ptr::null_mut());
let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);

View file

@ -30,8 +30,8 @@ fn assert_ffi_array_param_is_pointer() {
unsafe {
// don't run it, just make sure it compiles
if false {
let device: ash::Device = std::mem::uninitialized();
let cmd_buffer = std::mem::uninitialized();
let device: ash::Device = std::mem::zeroed();
let cmd_buffer = std::mem::zeroed();
let blend_constants: [f32; 4] = [0.0, 0.0, 0.0, 0.0];

View file

@ -791,7 +791,7 @@ fn main() {
device.cmd_end_render_pass(draw_command_buffer);
},
);
//let mut present_info_err = mem::uninitialized();
//let mut present_info_err = mem::zeroed();
let present_info = vk::PresentInfoKHR {
wait_semaphore_count: 1,
p_wait_semaphores: &base.rendering_complete_semaphore,

View file

@ -441,7 +441,7 @@ fn main() {
device.cmd_end_render_pass(draw_command_buffer);
},
);
//let mut present_info_err = mem::uninitialized();
//let mut present_info_err = mem::zeroed();
let wait_semaphors = [base.rendering_complete_semaphore];
let swapchains = [base.swapchain];
let image_indices = [present_index];

View file

@ -46,7 +46,7 @@ macro_rules! offset_of {
($base:path, $field:ident) => {{
#[allow(unused_unsafe)]
unsafe {
let b: $base = mem::uninitialized();
let b: $base = mem::zeroed();
(&b.$field as *const _ as isize) - (&b as *const _ as isize)
}
}};