Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace mem::zeroed() in AllocatorCreateInfo::default() #39

Merged
merged 3 commits into from Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/lib.rs
Expand Up @@ -11,7 +11,7 @@ extern crate failure;
pub mod error;
pub mod ffi;
pub use crate::error::{Error, ErrorKind, Result};
use ash::vk::Handle;
use ash::{version::InstanceV1_0, vk::Handle};
use std::mem;

/// Main allocator object
Expand Down Expand Up @@ -264,12 +264,30 @@ pub struct AllocatorCreateInfo {
}

/// Construct `AllocatorCreateInfo` with default values
///
/// Note that the default `device` and `instance` fields are filled with dummy
/// implementations that will panic if used. These fields must be overwritten.
impl Default for AllocatorCreateInfo {
fn default() -> Self {
extern "C" fn get_device_proc_addr(
_: ash::vk::Instance,
_: *const std::os::raw::c_char,
) -> *const std::os::raw::c_void {
std::ptr::null()
}
extern "C" fn get_instance_proc_addr(
_: ash::vk::Instance,
name: *const std::os::raw::c_char,
) -> *const std::os::raw::c_void {
get_device_proc_addr as *const _
}
let static_fn = ash::vk::StaticFn::load(|_| get_instance_proc_addr as *const _);
let instance = unsafe { ash::Instance::load(&static_fn, ash::vk::Instance::null()) };
let device = unsafe { ash::Device::load(&instance.fp_v1_0(), ash::vk::Device::null()) };
AllocatorCreateInfo {
physical_device: ash::vk::PhysicalDevice::null(),
device: unsafe { mem::zeroed() },
instance: unsafe { mem::zeroed() },
device,
instance,
flags: AllocatorCreateFlags::NONE,
preferred_large_heap_block_size: 0,
frame_in_use_count: 0,
Expand Down