PathBuf::from(env::var("OUT_DIR").unwrap()).join("vulkan-types.rs"),
code,
)?;
- let driver_name_prefix = if cfg!(unix) {
+ let target_family = env::var("CARGO_CFG_TARGET_FAMILY").unwrap();
+ let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
+ println!("target_family = {:?}", target_family);
+ println!("target_os = {:?}", target_os);
+ let driver_name_prefix = if target_family == "unix" {
"lib"
- } else if cfg!(target_os = "windows") {
+ } else if target_os == "windows" {
""
} else {
unimplemented!()
};
- let driver_name_suffix = if cfg!(any(target_os = "linux", target_os = "android")) {
+ let driver_name_suffix = if target_os == "linux" || target_os == "android" {
".so"
- } else if cfg!(any(target_os = "macos", target_os = "ios")) {
+ } else if target_os == "macos" || target_os == "ios" {
".dylib"
- } else if cfg!(target_os = "windows") {
+ } else if target_os == "windows" {
".dll"
} else {
unimplemented!()
use std::os::raw::{c_char, c_int, c_void};
use std::ptr::null;
use std::ptr::null_mut;
+#[cfg(unix)]
use std::ptr::NonNull;
use std::slice;
use std::str::FromStr;
standardSampleLocations: api::VK_TRUE,
optimalBufferCopyOffsetAlignment: 16,
optimalBufferCopyRowPitchAlignment: 16,
- nonCoherentAtomSize: 1, //TODO: check if this is correct
+ nonCoherentAtomSize: 1, //TODO: check if this is correct
+ ..unsafe { mem::zeroed() } // for padding fields
}
}
pub fn get_format_properties(format: api::VkFormat) -> api::VkFormatProperties {
residencyAlignedMipSize: api::VK_FALSE,
residencyNonResidentStrict: api::VK_FALSE,
},
+ ..mem::zeroed() // for padding fields
},
features: Features::new(),
system_memory_size,
pNext: null_mut(),
maxPerSetDescriptors: !0,
maxMemoryAllocationSize: isize::max_value() as u64,
+ ..mem::zeroed() // for padding fields
},
protected_memory_properties: api::VkPhysicalDeviceProtectedMemoryProperties {
sType: api::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES,
instance: api::VkInstance,
_allocator: *const api::VkAllocationCallbacks,
) {
- if !instance.is_null() {
- OwnedHandle::from(instance);
- }
+ OwnedHandle::from(instance);
}
#[allow(non_snake_case)]
device: api::VkDevice,
_allocator: *const api::VkAllocationCallbacks,
) {
- if !device.is_null() {
- OwnedHandle::from(device);
- }
+ OwnedHandle::from(device);
}
unsafe fn enumerate_extension_properties(
buffer: api::VkBuffer,
_allocator: *const api::VkAllocationCallbacks,
) {
- if !buffer.is_null() {
- OwnedHandle::from(buffer);
- }
+ OwnedHandle::from(buffer);
}
#[allow(non_snake_case)]
shader_module: api::VkShaderModule,
_allocator: *const api::VkAllocationCallbacks,
) {
- if !shader_module.is_null() {
- OwnedHandle::from(shader_module);
- }
+ OwnedHandle::from(shader_module);
}
#[allow(non_snake_case)]
sampler: api::VkSampler,
_allocator: *const api::VkAllocationCallbacks,
) {
- if !sampler.is_null() {
- OwnedHandle::from(sampler);
- }
+ OwnedHandle::from(sampler);
}
#[allow(non_snake_case)]
size: layout.size as u64,
alignment: layout.alignment as u64,
memoryTypeBits: DeviceMemoryType::Main.to_bits(),
+ ..mem::zeroed() // for padding fields
};
if !dedicated_requirements.is_null() {
let ref mut dedicated_requirements = *dedicated_requirements;
DeviceMemoryHeap::Main => physical_device.system_memory_size * 7 / 8,
},
flags: memory_heap.flags(),
+ ..mem::zeroed() // for padding fields
}
}
memory_properties.memoryProperties = properties;
surface: api::VkSurfaceKHR,
_allocator: *const api::VkAllocationCallbacks,
) {
- if !surface.is_null() {
- let surface = SharedHandle::from(surface).unwrap();
- match surface.platform {
- api::VK_ICD_WSI_PLATFORM_MIR => {
- panic!("unimplemented platform: VK_ICD_WSI_PLATFORM_MIR")
- }
- api::VK_ICD_WSI_PLATFORM_WAYLAND => {
- panic!("unimplemented platform: VK_ICD_WSI_PLATFORM_WAYLAND")
- }
- api::VK_ICD_WSI_PLATFORM_WIN32 => {
- panic!("unimplemented platform: VK_ICD_WSI_PLATFORM_WIN32")
- }
- api::VK_ICD_WSI_PLATFORM_XCB => {
- Box::from_raw(surface.take().get().unwrap().as_ptr() as *mut api::VkIcdSurfaceXcb);
- }
- api::VK_ICD_WSI_PLATFORM_XLIB => {
- panic!("unimplemented platform: VK_ICD_WSI_PLATFORM_XLIB")
- }
- api::VK_ICD_WSI_PLATFORM_ANDROID => {
- panic!("unimplemented platform: VK_ICD_WSI_PLATFORM_ANDROID")
- }
- api::VK_ICD_WSI_PLATFORM_MACOS => {
- panic!("unimplemented platform: VK_ICD_WSI_PLATFORM_MACOS")
- }
- api::VK_ICD_WSI_PLATFORM_IOS => {
- panic!("unimplemented platform: VK_ICD_WSI_PLATFORM_IOS")
- }
- api::VK_ICD_WSI_PLATFORM_DISPLAY => {
- panic!("unimplemented platform: VK_ICD_WSI_PLATFORM_DISPLAY")
- }
- platform => panic!("unknown VkSurfaceKHR platform: {:?}", platform),
- }
+ if let Some(surface) = SharedHandle::from(surface) {
+ let surface_implementation = SurfacePlatform::from(surface.platform)
+ .unwrap()
+ .get_surface_implementation();
+ surface_implementation.destroy_surface(surface.into_nonnull());
}
}
swapchain: api::VkSwapchainKHR,
_allocator: *const api::VkAllocationCallbacks,
) {
- if !swapchain.is_null() {
- OwnedHandle::from(swapchain);
- }
+ OwnedHandle::from(swapchain);
}
#[allow(non_snake_case)]