cargo fmt

This commit is contained in:
Maik Klein 2018-03-09 23:44:10 +01:00
parent b622fd7993
commit eb70d0e899
19 changed files with 1455 additions and 1480 deletions

View file

@ -85,10 +85,8 @@ pub trait EntryV1_0 {
return Err(InstanceError::VkError(err_code)); return Err(InstanceError::VkError(err_code));
} }
let instance_fp = let instance_fp =
<Self::Fp as FunctionPointers>::InstanceFp::load( <Self::Fp as FunctionPointers>::InstanceFp::load(&self.static_fn(), instance)
&self.static_fn(), .map_err(InstanceError::LoadError)?;
instance,
).map_err(InstanceError::LoadError)?;
Ok(Instance::from_raw(instance, instance_fp)) Ok(Instance::from_raw(instance, instance_fp))
} }
@ -161,9 +159,8 @@ impl<V: FunctionPointers> Entry<V> {
.unwrap_or(ptr::null_mut()) .unwrap_or(ptr::null_mut())
}).map_err(LoadingError::StaticLoadError)?; }).map_err(LoadingError::StaticLoadError)?;
let entry_fn = unsafe { let entry_fn =
V::EntryFp::load(&static_fn) unsafe { V::EntryFp::load(&static_fn) }.map_err(LoadingError::EntryLoadError)?;
}.map_err(LoadingError::EntryLoadError)?;
Ok(Entry { Ok(Entry {
static_fn, static_fn,

View file

@ -18,10 +18,7 @@ impl AndroidSurface {
instance: &I, instance: &I,
) -> Result<AndroidSurface, Vec<&'static str>> { ) -> Result<AndroidSurface, Vec<&'static str>> {
let surface_fn = vk::AndroidSurfaceFn::load(|name| unsafe { let surface_fn = vk::AndroidSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr( mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
instance.handle(),
name.as_ptr(),
))
})?; })?;
Ok(AndroidSurface { Ok(AndroidSurface {
handle: instance.handle(), handle: instance.handle(),

View file

@ -3,7 +3,7 @@ use prelude::*;
use std::mem; use std::mem;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use version::{InstanceV1_0, DeviceV1_0}; use version::{DeviceV1_0, InstanceV1_0};
#[derive(Clone)] #[derive(Clone)]
pub struct DebugMarker { pub struct DebugMarker {
@ -13,13 +13,10 @@ pub struct DebugMarker {
impl DebugMarker { impl DebugMarker {
pub fn new<I: InstanceV1_0, D: DeviceV1_0>( pub fn new<I: InstanceV1_0, D: DeviceV1_0>(
instance: &I, instance: &I,
device: &D device: &D,
) -> Result<DebugMarker, Vec<&'static str>> { ) -> Result<DebugMarker, Vec<&'static str>> {
let debug_marker_fn = vk::DebugMarkerFn::load(|name| unsafe { let debug_marker_fn = vk::DebugMarkerFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr( mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
device.handle(),
name.as_ptr(),
))
})?; })?;
Ok(DebugMarker { Ok(DebugMarker {
debug_marker_fn: debug_marker_fn, debug_marker_fn: debug_marker_fn,
@ -33,46 +30,36 @@ impl DebugMarker {
pub unsafe fn debug_marker_set_object_name_ext( pub unsafe fn debug_marker_set_object_name_ext(
&self, &self,
device: vk::Device, device: vk::Device,
name_info: &vk::DebugMarkerObjectNameInfoEXT name_info: &vk::DebugMarkerObjectNameInfoEXT,
) -> VkResult<()> { ) -> VkResult<()> {
let err_code = self.debug_marker_fn.debug_marker_set_object_name_ext( let err_code = self.debug_marker_fn
device, .debug_marker_set_object_name_ext(device, name_info);
name_info
);
match err_code { match err_code {
vk::Result::Success => Ok(()), vk::Result::Success => Ok(()),
_ => Err(err_code) _ => Err(err_code),
} }
} }
pub unsafe fn cmd_debug_marker_begin_ext( pub unsafe fn cmd_debug_marker_begin_ext(
&self, &self,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
marker_info: &vk::DebugMarkerMarkerInfoEXT marker_info: &vk::DebugMarkerMarkerInfoEXT,
) { ) {
self.debug_marker_fn.cmd_debug_marker_begin_ext( self.debug_marker_fn
command_buffer, .cmd_debug_marker_begin_ext(command_buffer, marker_info);
marker_info
);
} }
pub unsafe fn cmd_debug_marker_end_ext( pub unsafe fn cmd_debug_marker_end_ext(&self, command_buffer: vk::CommandBuffer) {
&self, self.debug_marker_fn
command_buffer: vk::CommandBuffer, .cmd_debug_marker_end_ext(command_buffer);
) {
self.debug_marker_fn.cmd_debug_marker_end_ext(
command_buffer,
);
} }
pub unsafe fn cmd_debug_marker_insert_ext( pub unsafe fn cmd_debug_marker_insert_ext(
&self, &self,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
marker_info: &vk::DebugMarkerMarkerInfoEXT marker_info: &vk::DebugMarkerMarkerInfoEXT,
) { ) {
self.debug_marker_fn.cmd_debug_marker_insert_ext( self.debug_marker_fn
command_buffer, .cmd_debug_marker_insert_ext(command_buffer, marker_info);
marker_info
);
} }
} }

View file

@ -18,10 +18,7 @@ impl DebugReport {
instance: &I, instance: &I,
) -> Result<DebugReport, Vec<&'static str>> { ) -> Result<DebugReport, Vec<&'static str>> {
let debug_report_fn = vk::DebugReportFn::load(|name| unsafe { let debug_report_fn = vk::DebugReportFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr( mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
instance.handle(),
name.as_ptr(),
))
})?; })?;
Ok(DebugReport { Ok(DebugReport {
handle: instance.handle(), handle: instance.handle(),

View file

@ -4,7 +4,7 @@ use std::mem;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use RawPtr; use RawPtr;
use version::{InstanceV1_0, DeviceV1_0}; use version::{DeviceV1_0, InstanceV1_0};
#[derive(Clone)] #[derive(Clone)]
pub struct DisplaySwapchain { pub struct DisplaySwapchain {
@ -18,10 +18,7 @@ impl DisplaySwapchain {
device: &D, device: &D,
) -> Result<DisplaySwapchain, Vec<&'static str>> { ) -> Result<DisplaySwapchain, Vec<&'static str>> {
let swapchain_fn = vk::DisplaySwapchainFn::load(|name| unsafe { let swapchain_fn = vk::DisplaySwapchainFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr( mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
device.handle(),
name.as_ptr(),
))
})?; })?;
Ok(DisplaySwapchain { Ok(DisplaySwapchain {
handle: device.handle(), handle: device.handle(),

View file

@ -18,10 +18,7 @@ impl IOSSurface {
instance: &I, instance: &I,
) -> Result<IOSSurface, Vec<&'static str>> { ) -> Result<IOSSurface, Vec<&'static str>> {
let surface_fn = vk::IOSSurfaceFn::load(|name| unsafe { let surface_fn = vk::IOSSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr( mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
instance.handle(),
name.as_ptr(),
))
})?; })?;
Ok(IOSSurface { Ok(IOSSurface {
handle: instance.handle(), handle: instance.handle(),

View file

@ -18,10 +18,7 @@ impl MacOSSurface {
instance: &I, instance: &I,
) -> Result<MacOSSurface, Vec<&'static str>> { ) -> Result<MacOSSurface, Vec<&'static str>> {
let surface_fn = vk::MacOSSurfaceFn::load(|name| unsafe { let surface_fn = vk::MacOSSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr( mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
instance.handle(),
name.as_ptr(),
))
})?; })?;
Ok(MacOSSurface { Ok(MacOSSurface {
handle: instance.handle(), handle: instance.handle(),

View file

@ -18,10 +18,7 @@ impl MirSurface {
instance: &I, instance: &I,
) -> Result<MirSurface, Vec<&'static str>> { ) -> Result<MirSurface, Vec<&'static str>> {
let surface_fn = vk::MirSurfaceFn::load(|name| unsafe { let surface_fn = vk::MirSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr( mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
instance.handle(),
name.as_ptr(),
))
})?; })?;
Ok(MirSurface { Ok(MirSurface {
handle: instance.handle(), handle: instance.handle(),

View file

@ -19,10 +19,7 @@ impl Surface {
instance: &I, instance: &I,
) -> Result<Surface, Vec<&'static str>> { ) -> Result<Surface, Vec<&'static str>> {
let surface_fn = vk::SurfaceFn::load(|name| unsafe { let surface_fn = vk::SurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr( mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
instance.handle(),
name.as_ptr(),
))
})?; })?;
Ok(Surface { Ok(Surface {
handle: instance.handle(), handle: instance.handle(),

View file

@ -5,7 +5,7 @@ use std::mem;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use RawPtr; use RawPtr;
use version::{InstanceV1_0, DeviceV1_0}; use version::{DeviceV1_0, InstanceV1_0};
#[derive(Clone)] #[derive(Clone)]
pub struct Swapchain { pub struct Swapchain {
@ -19,10 +19,7 @@ impl Swapchain {
device: &D, device: &D,
) -> Result<Swapchain, Vec<&'static str>> { ) -> Result<Swapchain, Vec<&'static str>> {
let swapchain_fn = vk::SwapchainFn::load(|name| unsafe { let swapchain_fn = vk::SwapchainFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr( mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
device.handle(),
name.as_ptr(),
))
})?; })?;
Ok(Swapchain { Ok(Swapchain {
handle: device.handle(), handle: device.handle(),

View file

@ -18,10 +18,7 @@ impl WaylandSurface {
instance: &I, instance: &I,
) -> Result<WaylandSurface, Vec<&'static str>> { ) -> Result<WaylandSurface, Vec<&'static str>> {
let surface_fn = vk::WaylandSurfaceFn::load(|name| unsafe { let surface_fn = vk::WaylandSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr( mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
instance.handle(),
name.as_ptr(),
))
})?; })?;
Ok(WaylandSurface { Ok(WaylandSurface {
handle: instance.handle(), handle: instance.handle(),

View file

@ -18,10 +18,7 @@ impl Win32Surface {
instance: &I, instance: &I,
) -> Result<Win32Surface, Vec<&'static str>> { ) -> Result<Win32Surface, Vec<&'static str>> {
let surface_fn = vk::Win32SurfaceFn::load(|name| unsafe { let surface_fn = vk::Win32SurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr( mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
instance.handle(),
name.as_ptr(),
))
})?; })?;
Ok(Win32Surface { Ok(Win32Surface {
handle: instance.handle(), handle: instance.handle(),

View file

@ -18,10 +18,7 @@ impl XcbSurface {
instance: &I, instance: &I,
) -> Result<XcbSurface, Vec<&'static str>> { ) -> Result<XcbSurface, Vec<&'static str>> {
let surface_fn = vk::XcbSurfaceFn::load(|name| unsafe { let surface_fn = vk::XcbSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr( mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
instance.handle(),
name.as_ptr(),
))
})?; })?;
Ok(XcbSurface { Ok(XcbSurface {
handle: instance.handle(), handle: instance.handle(),

View file

@ -18,10 +18,7 @@ impl XlibSurface {
instance: &I, instance: &I,
) -> Result<XlibSurface, Vec<&'static str>> { ) -> Result<XlibSurface, Vec<&'static str>> {
let surface_fn = vk::XlibSurfaceFn::load(|name| unsafe { let surface_fn = vk::XlibSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr( mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
instance.handle(),
name.as_ptr(),
))
})?; })?;
Ok(XlibSurface { Ok(XlibSurface {
handle: instance.handle(), handle: instance.handle(),

View file

@ -85,8 +85,7 @@ pub trait InstanceV1_0 {
if err_code != vk::Result::Success { if err_code != vk::Result::Success {
return Err(DeviceError::VkError(err_code)); return Err(DeviceError::VkError(err_code));
} }
let device_fn = let device_fn = <<Self as InstanceV1_0>::Fp as FunctionPointers>::DeviceFp::load(
<<Self as InstanceV1_0>::Fp as FunctionPointers>::DeviceFp::load(
self.fp_v1_0(), self.fp_v1_0(),
device, device,
).map_err(|err| DeviceError::LoadError(err))?; ).map_err(|err| DeviceError::LoadError(err))?;
@ -102,10 +101,8 @@ pub trait InstanceV1_0 {
} }
unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) { unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
self.fp_v1_0().destroy_instance( self.fp_v1_0()
self.handle(), .destroy_instance(self.handle(), allocation_callbacks.as_raw_ptr());
allocation_callbacks.as_raw_ptr(),
);
} }
fn get_physical_device_format_properties( fn get_physical_device_format_properties(
@ -158,10 +155,8 @@ pub trait InstanceV1_0 {
) -> vk::PhysicalDeviceMemoryProperties { ) -> vk::PhysicalDeviceMemoryProperties {
unsafe { unsafe {
let mut memory_prop = mem::uninitialized(); let mut memory_prop = mem::uninitialized();
self.fp_v1_0().get_physical_device_memory_properties( self.fp_v1_0()
physical_device, .get_physical_device_memory_properties(physical_device, &mut memory_prop);
&mut memory_prop,
);
memory_prop memory_prop
} }
} }
@ -172,10 +167,8 @@ pub trait InstanceV1_0 {
) -> vk::PhysicalDeviceProperties { ) -> vk::PhysicalDeviceProperties {
unsafe { unsafe {
let mut prop = mem::uninitialized(); let mut prop = mem::uninitialized();
self.fp_v1_0().get_physical_device_properties( self.fp_v1_0()
physical_device, .get_physical_device_properties(physical_device, &mut prop);
&mut prop,
);
prop prop
} }
} }
@ -208,10 +201,8 @@ pub trait InstanceV1_0 {
) -> vk::PhysicalDeviceFeatures { ) -> vk::PhysicalDeviceFeatures {
unsafe { unsafe {
let mut prop = mem::uninitialized(); let mut prop = mem::uninitialized();
self.fp_v1_0().get_physical_device_features( self.fp_v1_0()
physical_device, .get_physical_device_features(physical_device, &mut prop);
&mut prop,
);
prop prop
} }
} }
@ -219,11 +210,8 @@ pub trait InstanceV1_0 {
fn enumerate_physical_devices(&self) -> VkResult<Vec<vk::PhysicalDevice>> { fn enumerate_physical_devices(&self) -> VkResult<Vec<vk::PhysicalDevice>> {
unsafe { unsafe {
let mut num = mem::uninitialized(); let mut num = mem::uninitialized();
self.fp_v1_0().enumerate_physical_devices( self.fp_v1_0()
self.handle(), .enumerate_physical_devices(self.handle(), &mut num, ptr::null_mut());
&mut num,
ptr::null_mut(),
);
let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize); let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);
let err_code = self.fp_v1_0().enumerate_physical_devices( let err_code = self.fp_v1_0().enumerate_physical_devices(
self.handle(), self.handle(),

View file

@ -1,8 +1,8 @@
extern crate libc;
extern crate shared_library;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
pub use instance::{Instance, DeviceError}; extern crate libc;
extern crate shared_library;
pub use instance::{DeviceError, Instance};
pub use device::Device; pub use device::Device;
pub use entry::{Entry, InstanceError, LoadingError}; pub use entry::{Entry, InstanceError, LoadingError};

View file

@ -36,10 +36,7 @@ impl EntryLoader for EntryFpV1_0 {
} }
unsafe fn load(static_fn: &vk::StaticFn) -> Result<Self, Vec<&'static str>> { unsafe fn load(static_fn: &vk::StaticFn) -> Result<Self, Vec<&'static str>> {
let entry_fn = vk::EntryFnV1_0::load(|name| { let entry_fn = vk::EntryFnV1_0::load(|name| {
mem::transmute(static_fn.get_instance_proc_addr( mem::transmute(static_fn.get_instance_proc_addr(vk::Instance::null(), name.as_ptr()))
vk::Instance::null(),
name.as_ptr(),
))
})?; })?;
Ok(EntryFpV1_0 { entry_fn: entry_fn }) Ok(EntryFpV1_0 { entry_fn: entry_fn })
} }
@ -73,7 +70,9 @@ impl DeviceLoader for DeviceFpV1_0 {
let device_fn = vk::DeviceFnV1_0::load(|name| { let device_fn = vk::DeviceFnV1_0::load(|name| {
mem::transmute(instance_fn.get_device_proc_addr(device, name.as_ptr())) mem::transmute(instance_fn.get_device_proc_addr(device, name.as_ptr()))
})?; })?;
Ok(DeviceFpV1_0 { device_fn: device_fn }) Ok(DeviceFpV1_0 {
device_fn: device_fn,
})
} }
} }
@ -88,7 +87,9 @@ impl InstanceLoader for InstanceFpV1_0 {
let instance_fn = vk::InstanceFnV1_0::load(|name| { let instance_fn = vk::InstanceFnV1_0::load(|name| {
mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr())) mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr()))
})?; })?;
Ok(InstanceFpV1_0 { instance_fn: instance_fn }) Ok(InstanceFpV1_0 {
instance_fn: instance_fn,
})
} }
} }

View file

@ -200,7 +200,7 @@ macro_rules! vk_version_patch {
} }
pub mod types { pub mod types {
#![allow(non_camel_case_types, dead_code)] #![allow(non_camel_case_types, dead_code)]
use std::ops::*; use std::ops::*;
use std::fmt; use std::fmt;
use std::ffi::CStr; use std::ffi::CStr;
@ -1301,10 +1301,9 @@ pub mod types {
impl fmt::Debug for LayerProperties { impl fmt::Debug for LayerProperties {
fn fmt(&self, fmt: &mut fmt::Formatter) -> ::std::result::Result<(), fmt::Error> { fn fmt(&self, fmt: &mut fmt::Formatter) -> ::std::result::Result<(), fmt::Error> {
fmt.debug_struct("LayerProperties") fmt.debug_struct("LayerProperties")
.field( .field("layer_name", &unsafe {
"layer_name", CStr::from_ptr(&self.layer_name[0])
&unsafe { CStr::from_ptr(&self.layer_name[0]) }, })
)
.field("spec_version", &self.spec_version) .field("spec_version", &self.spec_version)
.field("implementation_version", &self.implementation_version) .field("implementation_version", &self.implementation_version)
.field("description", &unsafe { .field("description", &unsafe {
@ -2542,7 +2541,7 @@ pub mod types {
pub s_type: StructureType, pub s_type: StructureType,
pub p_next: *const c_void, pub p_next: *const c_void,
pub p_marker_name: *const c_char, pub p_marker_name: *const c_char,
pub color: [f32; 4] pub color: [f32; 4],
} }
#[repr(C)] #[repr(C)]
@ -2600,12 +2599,12 @@ pub mod types {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub union ClearValue { pub union ClearValue {
pub depth: ClearDepthStencilValue, pub depth: ClearDepthStencilValue,
pub color: ClearColorValue pub color: ClearColorValue,
} }
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub union ClearColorValue{ pub union ClearColorValue {
pub float32: [f32; 4], pub float32: [f32; 4],
pub int32: [i32; 4], pub int32: [i32; 4],
pub uint32: [u32; 4], pub uint32: [u32; 4],
@ -3434,13 +3433,19 @@ pub mod types {
pub const FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT: FormatFeatureFlags = pub const FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT: FormatFeatureFlags =
FormatFeatureFlags { flags: 0b100000000 }; FormatFeatureFlags { flags: 0b100000000 };
pub const FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT: FormatFeatureFlags = pub const FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT: FormatFeatureFlags =
FormatFeatureFlags { flags: 0b1000000000 }; FormatFeatureFlags {
pub const FORMAT_FEATURE_BLIT_SRC_BIT: FormatFeatureFlags = flags: 0b1000000000,
FormatFeatureFlags { flags: 0b10000000000 }; };
pub const FORMAT_FEATURE_BLIT_DST_BIT: FormatFeatureFlags = pub const FORMAT_FEATURE_BLIT_SRC_BIT: FormatFeatureFlags = FormatFeatureFlags {
FormatFeatureFlags { flags: 0b100000000000 }; flags: 0b10000000000,
};
pub const FORMAT_FEATURE_BLIT_DST_BIT: FormatFeatureFlags = FormatFeatureFlags {
flags: 0b100000000000,
};
pub const FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT: FormatFeatureFlags = pub const FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT: FormatFeatureFlags =
FormatFeatureFlags { flags: 0b1000000000000 }; FormatFeatureFlags {
flags: 0b1000000000000,
};
vk_bitflags_wrapped!(FormatFeatureFlags, 0b1111111111111, Flags); vk_bitflags_wrapped!(FormatFeatureFlags, 0b1111111111111, Flags);
pub const IMAGE_USAGE_TRANSFER_SRC_BIT: ImageUsageFlags = ImageUsageFlags { flags: 0b1 }; pub const IMAGE_USAGE_TRANSFER_SRC_BIT: ImageUsageFlags = ImageUsageFlags { flags: 0b1 };
@ -3515,22 +3520,30 @@ pub mod types {
PipelineStageFlags { flags: 0b10000000 }; PipelineStageFlags { flags: 0b10000000 };
pub const PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT: PipelineStageFlags = pub const PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT: PipelineStageFlags =
PipelineStageFlags { flags: 0b100000000 }; PipelineStageFlags { flags: 0b100000000 };
pub const PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT: PipelineStageFlags = pub const PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT: PipelineStageFlags = PipelineStageFlags {
PipelineStageFlags { flags: 0b1000000000 }; flags: 0b1000000000,
pub const PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT: PipelineStageFlags = };
PipelineStageFlags { flags: 0b10000000000 }; pub const PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT: PipelineStageFlags = PipelineStageFlags {
pub const PIPELINE_STAGE_COMPUTE_SHADER_BIT: PipelineStageFlags = flags: 0b10000000000,
PipelineStageFlags { flags: 0b100000000000 }; };
pub const PIPELINE_STAGE_TRANSFER_BIT: PipelineStageFlags = pub const PIPELINE_STAGE_COMPUTE_SHADER_BIT: PipelineStageFlags = PipelineStageFlags {
PipelineStageFlags { flags: 0b1000000000000 }; flags: 0b100000000000,
pub const PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT: PipelineStageFlags = };
PipelineStageFlags { flags: 0b10000000000000 }; pub const PIPELINE_STAGE_TRANSFER_BIT: PipelineStageFlags = PipelineStageFlags {
pub const PIPELINE_STAGE_HOST_BIT: PipelineStageFlags = flags: 0b1000000000000,
PipelineStageFlags { flags: 0b100000000000000 }; };
pub const PIPELINE_STAGE_ALL_GRAPHICS_BIT: PipelineStageFlags = pub const PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT: PipelineStageFlags = PipelineStageFlags {
PipelineStageFlags { flags: 0b1000000000000000 }; flags: 0b10000000000000,
pub const PIPELINE_STAGE_ALL_COMMANDS_BIT: PipelineStageFlags = };
PipelineStageFlags { flags: 0b10000000000000000 }; pub const PIPELINE_STAGE_HOST_BIT: PipelineStageFlags = PipelineStageFlags {
flags: 0b100000000000000,
};
pub const PIPELINE_STAGE_ALL_GRAPHICS_BIT: PipelineStageFlags = PipelineStageFlags {
flags: 0b1000000000000000,
};
pub const PIPELINE_STAGE_ALL_COMMANDS_BIT: PipelineStageFlags = PipelineStageFlags {
flags: 0b10000000000000000,
};
vk_bitflags_wrapped!(PipelineStageFlags, 0b11111111111111111, Flags); vk_bitflags_wrapped!(PipelineStageFlags, 0b11111111111111111, Flags);
pub const IMAGE_ASPECT_COLOR_BIT: ImageAspectFlags = ImageAspectFlags { flags: 0b1 }; pub const IMAGE_ASPECT_COLOR_BIT: ImageAspectFlags = ImageAspectFlags { flags: 0b1 };
@ -3556,18 +3569,30 @@ pub mod types {
pub const QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT: QueryPipelineStatisticFlags = pub const QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT: QueryPipelineStatisticFlags =
QueryPipelineStatisticFlags { flags: 0b1 }; QueryPipelineStatisticFlags { flags: 0b1 };
pub const QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT: QueryPipelineStatisticFlags = QueryPipelineStatisticFlags {flags: 0b10}; pub const QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT: QueryPipelineStatisticFlags =
pub const QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT: QueryPipelineStatisticFlags = QueryPipelineStatisticFlags {flags: 0b100}; QueryPipelineStatisticFlags { flags: 0b10 };
pub const QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT: QueryPipelineStatisticFlags = QueryPipelineStatisticFlags {flags: 0b1000}; pub const QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT: QueryPipelineStatisticFlags =
pub const QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT: QueryPipelineStatisticFlags = QueryPipelineStatisticFlags {flags: 0b10000}; QueryPipelineStatisticFlags { flags: 0b100 };
pub const QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT:
QueryPipelineStatisticFlags = QueryPipelineStatisticFlags { flags: 0b1000 };
pub const QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT: QueryPipelineStatisticFlags =
QueryPipelineStatisticFlags { flags: 0b10000 };
pub const QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT: QueryPipelineStatisticFlags = pub const QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT: QueryPipelineStatisticFlags =
QueryPipelineStatisticFlags { flags: 0b100000 }; QueryPipelineStatisticFlags { flags: 0b100000 };
pub const QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT: QueryPipelineStatisticFlags = pub const QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT: QueryPipelineStatisticFlags =
QueryPipelineStatisticFlags { flags: 0b1000000 }; QueryPipelineStatisticFlags { flags: 0b1000000 };
pub const QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT: QueryPipelineStatisticFlags = QueryPipelineStatisticFlags {flags: 0b10000000}; pub const QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT:
pub const QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT: QueryPipelineStatisticFlags = QueryPipelineStatisticFlags {flags: 0b100000000}; QueryPipelineStatisticFlags = QueryPipelineStatisticFlags { flags: 0b10000000 };
pub const QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT: QueryPipelineStatisticFlags = QueryPipelineStatisticFlags {flags: 0b1000000000}; pub const QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT:
pub const QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT: QueryPipelineStatisticFlags = QueryPipelineStatisticFlags {flags: 0b10000000000}; QueryPipelineStatisticFlags = QueryPipelineStatisticFlags { flags: 0b100000000 };
pub const QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT:
QueryPipelineStatisticFlags = QueryPipelineStatisticFlags {
flags: 0b1000000000,
};
pub const QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT: QueryPipelineStatisticFlags =
QueryPipelineStatisticFlags {
flags: 0b10000000000,
};
vk_bitflags_wrapped!(QueryPipelineStatisticFlags, 0b11111111111, Flags); vk_bitflags_wrapped!(QueryPipelineStatisticFlags, 0b11111111111, Flags);
pub const QUERY_RESULT_64_BIT: QueryResultFlags = QueryResultFlags { flags: 0b1 }; pub const QUERY_RESULT_64_BIT: QueryResultFlags = QueryResultFlags { flags: 0b1 };
@ -3620,8 +3645,9 @@ pub mod types {
pub const SHADER_STAGE_FRAGMENT_BIT: ShaderStageFlags = ShaderStageFlags { flags: 0b10000 }; pub const SHADER_STAGE_FRAGMENT_BIT: ShaderStageFlags = ShaderStageFlags { flags: 0b10000 };
pub const SHADER_STAGE_COMPUTE_BIT: ShaderStageFlags = ShaderStageFlags { flags: 0b100000 }; pub const SHADER_STAGE_COMPUTE_BIT: ShaderStageFlags = ShaderStageFlags { flags: 0b100000 };
pub const SHADER_STAGE_ALL_GRAPHICS: ShaderStageFlags = ShaderStageFlags { flags: 0b11111 }; pub const SHADER_STAGE_ALL_GRAPHICS: ShaderStageFlags = ShaderStageFlags { flags: 0b11111 };
pub const SHADER_STAGE_ALL: ShaderStageFlags = pub const SHADER_STAGE_ALL: ShaderStageFlags = ShaderStageFlags {
ShaderStageFlags { flags: 0b1111111111111111111111111111111 }; flags: 0b1111111111111111111111111111111,
};
vk_bitflags_wrapped!(ShaderStageFlags, 0b1111111111111111111111111111111, Flags); vk_bitflags_wrapped!(ShaderStageFlags, 0b1111111111111111111111111111111, Flags);
pub const CULL_MODE_NONE: CullModeFlags = CullModeFlags { flags: 0b0 }; pub const CULL_MODE_NONE: CullModeFlags = CullModeFlags { flags: 0b0 };
@ -3653,16 +3679,30 @@ pub mod types {
pub const ACCESS_SHADER_WRITE_BIT: AccessFlags = AccessFlags { flags: 0b1000000 }; pub const ACCESS_SHADER_WRITE_BIT: AccessFlags = AccessFlags { flags: 0b1000000 };
pub const ACCESS_COLOR_ATTACHMENT_READ_BIT: AccessFlags = AccessFlags { flags: 0b10000000 }; pub const ACCESS_COLOR_ATTACHMENT_READ_BIT: AccessFlags = AccessFlags { flags: 0b10000000 };
pub const ACCESS_COLOR_ATTACHMENT_WRITE_BIT: AccessFlags = AccessFlags { flags: 0b100000000 }; pub const ACCESS_COLOR_ATTACHMENT_WRITE_BIT: AccessFlags = AccessFlags { flags: 0b100000000 };
pub const ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT: AccessFlags = pub const ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT: AccessFlags = AccessFlags {
AccessFlags { flags: 0b1000000000 }; flags: 0b1000000000,
pub const ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT: AccessFlags = };
AccessFlags { flags: 0b10000000000 }; pub const ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT: AccessFlags = AccessFlags {
pub const ACCESS_TRANSFER_READ_BIT: AccessFlags = AccessFlags { flags: 0b100000000000 }; flags: 0b10000000000,
pub const ACCESS_TRANSFER_WRITE_BIT: AccessFlags = AccessFlags { flags: 0b1000000000000 }; };
pub const ACCESS_HOST_READ_BIT: AccessFlags = AccessFlags { flags: 0b10000000000000 }; pub const ACCESS_TRANSFER_READ_BIT: AccessFlags = AccessFlags {
pub const ACCESS_HOST_WRITE_BIT: AccessFlags = AccessFlags { flags: 0b100000000000000 }; flags: 0b100000000000,
pub const ACCESS_MEMORY_READ_BIT: AccessFlags = AccessFlags { flags: 0b1000000000000000 }; };
pub const ACCESS_MEMORY_WRITE_BIT: AccessFlags = AccessFlags { flags: 0b10000000000000000 }; pub const ACCESS_TRANSFER_WRITE_BIT: AccessFlags = AccessFlags {
flags: 0b1000000000000,
};
pub const ACCESS_HOST_READ_BIT: AccessFlags = AccessFlags {
flags: 0b10000000000000,
};
pub const ACCESS_HOST_WRITE_BIT: AccessFlags = AccessFlags {
flags: 0b100000000000000,
};
pub const ACCESS_MEMORY_READ_BIT: AccessFlags = AccessFlags {
flags: 0b1000000000000000,
};
pub const ACCESS_MEMORY_WRITE_BIT: AccessFlags = AccessFlags {
flags: 0b10000000000000000,
};
vk_bitflags_wrapped!(AccessFlags, 0b11111111111111111, Flags); vk_bitflags_wrapped!(AccessFlags, 0b11111111111111111, Flags);
pub const DEPENDENCY_BY_REGION_BIT: DependencyFlags = DependencyFlags { flags: 0b1 }; pub const DEPENDENCY_BY_REGION_BIT: DependencyFlags = DependencyFlags { flags: 0b1 };
@ -3750,45 +3790,43 @@ pub mod types {
DebugReportFlagsEXT { flags: 0b10000 }; DebugReportFlagsEXT { flags: 0b10000 };
vk_bitflags_wrapped!(DebugReportFlagsEXT, 0b11111, Flags); vk_bitflags_wrapped!(DebugReportFlagsEXT, 0b11111, Flags);
pub type PFN_vkAllocationFunction =
pub type PFN_vkAllocationFunction = unsafe extern "system" fn(*mut c_void, unsafe extern "system" fn(*mut c_void, size_t, size_t, SystemAllocationScope)
size_t,
size_t,
SystemAllocationScope)
-> *mut c_void; -> *mut c_void;
pub type PFN_vkReallocationFunction = unsafe extern "system" fn(*mut c_void, pub type PFN_vkReallocationFunction =
*mut c_void, unsafe extern "system" fn(*mut c_void, *mut c_void, size_t, size_t, SystemAllocationScope)
size_t,
size_t,
SystemAllocationScope)
-> *mut c_void; -> *mut c_void;
pub type PFN_vkFreeFunction = unsafe extern "system" fn(*mut c_void, *mut c_void); pub type PFN_vkFreeFunction = unsafe extern "system" fn(*mut c_void, *mut c_void);
pub type PFN_vkInternalAllocationNotification = pub type PFN_vkInternalAllocationNotification =
unsafe extern "system" fn(*mut c_void, unsafe extern "system" fn(
*mut c_void,
size_t, size_t,
InternalAllocationType, InternalAllocationType,
SystemAllocationScope); SystemAllocationScope,
);
pub type PFN_vkInternalFreeNotification = unsafe extern "system" fn(*mut c_void, pub type PFN_vkInternalFreeNotification = unsafe extern "system" fn(
*mut c_void,
size_t, size_t,
InternalAllocationType, InternalAllocationType,
SystemAllocationScope); SystemAllocationScope,
);
pub type PFN_vkVoidFunction = unsafe extern "system" fn(); pub type PFN_vkVoidFunction = unsafe extern "system" fn();
pub type PFN_vkDebugReportCallbackEXT = unsafe extern "system" fn(DebugReportFlagsEXT, pub type PFN_vkDebugReportCallbackEXT = unsafe extern "system" fn(
DebugReportFlagsEXT,
DebugReportObjectTypeEXT, DebugReportObjectTypeEXT,
uint64_t, uint64_t,
size_t, size_t,
int32_t, int32_t,
*const c_char, *const c_char,
*const c_char, *const c_char,
*mut c_void) *mut c_void,
-> Bool32; ) -> Bool32;
} }
// FIX: Need better error handling for extensions // FIX: Need better error handling for extensions
@ -3853,7 +3891,7 @@ macro_rules! vk_functions {
} }
pub mod cmds { pub mod cmds {
#![allow(dead_code)] #![allow(dead_code)]
use super::*; use super::*;
vk_functions!{ vk_functions!{
@ -3862,7 +3900,7 @@ pub mod cmds {
instance: Instance, instance: Instance,
p_name: *const c_char, p_name: *const c_char,
) -> PFN_vkVoidFunction; ) -> PFN_vkVoidFunction;
} }
vk_functions!{ vk_functions!{
EntryFnV1_0, EntryFnV1_0,
@ -3882,7 +3920,7 @@ pub mod cmds {
p_property_count: *mut uint32_t, p_property_count: *mut uint32_t,
p_properties: *mut LayerProperties, p_properties: *mut LayerProperties,
) -> Result; ) -> Result;
} }
vk_functions!{ vk_functions!{
InstanceFnV1_0, InstanceFnV1_0,
@ -3971,7 +4009,7 @@ pub mod cmds {
p_property_count: *mut uint32_t, p_property_count: *mut uint32_t,
p_properties: *mut SparseImageFormatProperties, p_properties: *mut SparseImageFormatProperties,
) -> (); ) -> ();
} }
vk_functions!{ vk_functions!{
DeviceFnV1_0, DeviceFnV1_0,
@ -4802,7 +4840,7 @@ pub mod cmds {
command_buffer_count: uint32_t, command_buffer_count: uint32_t,
p_command_buffers: *const CommandBuffer, p_command_buffers: *const CommandBuffer,
) -> (); ) -> ();
} }
vk_functions!{ vk_functions!{
DisplaySwapchainFn, DisplaySwapchainFn,
@ -4813,7 +4851,7 @@ pub mod cmds {
p_allocator: *const AllocationCallbacks, p_allocator: *const AllocationCallbacks,
p_swapchains: *mut SwapchainKHR, p_swapchains: *mut SwapchainKHR,
) -> Result; ) -> Result;
} }
vk_functions!{ vk_functions!{
SwapchainFn, SwapchainFn,
@ -4850,7 +4888,7 @@ pub mod cmds {
queue: Queue, queue: Queue,
p_present_info: *const PresentInfoKHR, p_present_info: *const PresentInfoKHR,
) -> Result; ) -> Result;
} }
vk_functions!{ vk_functions!{
SurfaceFn, SurfaceFn,
@ -4886,7 +4924,7 @@ pub mod cmds {
p_present_mode_count: *mut uint32_t, p_present_mode_count: *mut uint32_t,
p_present_modes: *mut PresentModeKHR, p_present_modes: *mut PresentModeKHR,
) -> Result; ) -> Result;
} }
vk_functions!{ vk_functions!{
XlibSurfaceFn, XlibSurfaceFn,
"vkCreateXlibSurfaceKHR", create_xlib_surface_khr( "vkCreateXlibSurfaceKHR", create_xlib_surface_khr(
@ -4902,7 +4940,7 @@ pub mod cmds {
dpy: *mut Display, dpy: *mut Display,
visual_id: VisualID, visual_id: VisualID,
) -> Bool32; ) -> Bool32;
} }
vk_functions!{ vk_functions!{
DebugMarkerFn, DebugMarkerFn,
"vkDebugMarkerSetObjectNameEXT", debug_marker_set_object_name_ext( "vkDebugMarkerSetObjectNameEXT", debug_marker_set_object_name_ext(
@ -4920,7 +4958,7 @@ pub mod cmds {
command_buffer: CommandBuffer, command_buffer: CommandBuffer,
p_marker_info: *const DebugMarkerMarkerInfoEXT, p_marker_info: *const DebugMarkerMarkerInfoEXT,
) -> (); ) -> ();
} }
vk_functions!{ vk_functions!{
DebugReportFn, DebugReportFn,
"vkCreateDebugReportCallbackEXT", create_debug_report_callback_ext( "vkCreateDebugReportCallbackEXT", create_debug_report_callback_ext(
@ -4946,7 +4984,7 @@ pub mod cmds {
p_layer_prefix: *const c_char, p_layer_prefix: *const c_char,
p_message: *const c_char, p_message: *const c_char,
) -> (); ) -> ();
} }
vk_functions!{ vk_functions!{
Win32SurfaceFn, Win32SurfaceFn,
"vkCreateWin32SurfaceKHR", create_win32_surface_khr( "vkCreateWin32SurfaceKHR", create_win32_surface_khr(
@ -4960,7 +4998,7 @@ pub mod cmds {
physical_device: PhysicalDevice, physical_device: PhysicalDevice,
queue_family_index: uint32_t, queue_family_index: uint32_t,
) -> Bool32; ) -> Bool32;
} }
vk_functions!{ vk_functions!{
MirSurfaceFn, MirSurfaceFn,
"vkCreateMirSurfaceKHR", create_mir_surface_khr( "vkCreateMirSurfaceKHR", create_mir_surface_khr(
@ -4975,7 +5013,7 @@ pub mod cmds {
queue_family_index: uint32_t, queue_family_index: uint32_t,
connection: *mut MirConnection, connection: *mut MirConnection,
) -> Bool32; ) -> Bool32;
} }
vk_functions!{ vk_functions!{
XcbSurfaceFn, XcbSurfaceFn,
"vkCreateXcbSurfaceKHR", create_xcb_surface_khr( "vkCreateXcbSurfaceKHR", create_xcb_surface_khr(
@ -4991,7 +5029,7 @@ pub mod cmds {
connection: *mut xcb_connection_t, connection: *mut xcb_connection_t,
visual_id: xcb_visualid_t, visual_id: xcb_visualid_t,
) -> Bool32; ) -> Bool32;
} }
vk_functions!{ vk_functions!{
AndroidSurfaceFn, AndroidSurfaceFn,
"vkCreateAndroidSurfaceKHR", create_android_surface_khr( "vkCreateAndroidSurfaceKHR", create_android_surface_khr(
@ -5000,7 +5038,7 @@ pub mod cmds {
p_allocator: *const AllocationCallbacks, p_allocator: *const AllocationCallbacks,
p_surface: *mut SurfaceKHR, p_surface: *mut SurfaceKHR,
) -> Result; ) -> Result;
} }
vk_functions!{ vk_functions!{
WaylandSurfaceFn, WaylandSurfaceFn,
"vkCreateWaylandSurfaceKHR", create_wayland_surface_khr( "vkCreateWaylandSurfaceKHR", create_wayland_surface_khr(
@ -5015,7 +5053,7 @@ pub mod cmds {
queue_family_index: uint32_t, queue_family_index: uint32_t,
display: *mut wl_display, display: *mut wl_display,
) -> Bool32; ) -> Bool32;
} }
vk_functions!{ vk_functions!{
DisplayFn, DisplayFn,
"vkGetPhysicalDeviceDisplayPropertiesKHR", get_physical_device_display_properties_khr( "vkGetPhysicalDeviceDisplayPropertiesKHR", get_physical_device_display_properties_khr(
@ -5065,7 +5103,7 @@ pub mod cmds {
p_allocator: *const AllocationCallbacks, p_allocator: *const AllocationCallbacks,
p_surface: *mut SurfaceKHR, p_surface: *mut SurfaceKHR,
) -> Result; ) -> Result;
} }
vk_functions!{ vk_functions!{
IOSSurfaceFn, IOSSurfaceFn,
@ -5075,7 +5113,7 @@ pub mod cmds {
p_allocator: *const AllocationCallbacks, p_allocator: *const AllocationCallbacks,
p_surface: *mut SurfaceKHR, p_surface: *mut SurfaceKHR,
) -> Result; ) -> Result;
} }
vk_functions!{ vk_functions!{
MacOSSurfaceFn, MacOSSurfaceFn,
@ -5085,5 +5123,5 @@ pub mod cmds {
p_allocator: *const AllocationCallbacks, p_allocator: *const AllocationCallbacks,
p_surface: *mut SurfaceKHR, p_surface: *mut SurfaceKHR,
) -> Result; ) -> Result;
} }
} }

View file

@ -26,7 +26,7 @@ pub struct Vector3 {
pub x: f32, pub x: f32,
pub y: f32, pub y: f32,
pub z: f32, pub z: f32,
pub _pad: f32 pub _pad: f32,
} }
fn main() { fn main() {
@ -70,8 +70,8 @@ fn main() {
dst_subpass: Default::default(), dst_subpass: Default::default(),
src_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, src_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
src_access_mask: Default::default(), src_access_mask: Default::default(),
dst_access_mask: vk::ACCESS_COLOR_ATTACHMENT_READ_BIT | dst_access_mask: vk::ACCESS_COLOR_ATTACHMENT_READ_BIT
vk::ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | vk::ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
dst_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, dst_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
}; };
let subpass = vk::SubpassDescription { let subpass = vk::SubpassDescription {
@ -198,9 +198,8 @@ fn main() {
let vertex_input_buffer = base.device let vertex_input_buffer = base.device
.create_buffer(&vertex_input_buffer_info, None) .create_buffer(&vertex_input_buffer_info, None)
.unwrap(); .unwrap();
let vertex_input_buffer_memory_req = base.device.get_buffer_memory_requirements( let vertex_input_buffer_memory_req = base.device
vertex_input_buffer, .get_buffer_memory_requirements(vertex_input_buffer);
);
let vertex_input_buffer_memory_index = let vertex_input_buffer_memory_index =
find_memorytype_index( find_memorytype_index(
&vertex_input_buffer_memory_req, &vertex_input_buffer_memory_req,
@ -240,7 +239,7 @@ fn main() {
x: 1.0, x: 1.0,
y: 1.0, y: 1.0,
z: 1.0, z: 1.0,
_pad: 0.0 _pad: 0.0,
}; };
let uniform_color_buffer_info = vk::BufferCreateInfo { let uniform_color_buffer_info = vk::BufferCreateInfo {
s_type: vk::StructureType::BufferCreateInfo, s_type: vk::StructureType::BufferCreateInfo,
@ -255,9 +254,8 @@ fn main() {
let uniform_color_buffer = base.device let uniform_color_buffer = base.device
.create_buffer(&uniform_color_buffer_info, None) .create_buffer(&uniform_color_buffer_info, None)
.unwrap(); .unwrap();
let uniform_color_buffer_memory_req = base.device.get_buffer_memory_requirements( let uniform_color_buffer_memory_req = base.device
uniform_color_buffer, .get_buffer_memory_requirements(uniform_color_buffer);
);
let uniform_color_buffer_memory_index = let uniform_color_buffer_memory_index =
find_memorytype_index( find_memorytype_index(
&uniform_color_buffer_memory_req, &uniform_color_buffer_memory_req,
@ -388,9 +386,8 @@ fn main() {
.bind_image_memory(texture_image, texture_memory, 0) .bind_image_memory(texture_image, texture_memory, 0)
.expect("Unable to bind depth image memory"); .expect("Unable to bind depth image memory");
record_submit_commandbuffer(
&base.device,
record_submit_commandbuffer(&base.device,
base.setup_command_buffer, base.setup_command_buffer,
base.present_queue, base.present_queue,
&[vk::PIPELINE_STAGE_TOP_OF_PIPE_BIT], &[vk::PIPELINE_STAGE_TOP_OF_PIPE_BIT],
@ -415,14 +412,17 @@ fn main() {
layer_count: 1, layer_count: 1,
}, },
}; };
device.cmd_pipeline_barrier(texture_command_buffer, device.cmd_pipeline_barrier(
texture_command_buffer,
vk::PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, vk::PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
vk::PIPELINE_STAGE_TRANSFER_BIT, vk::PIPELINE_STAGE_TRANSFER_BIT,
vk::DependencyFlags::empty(), vk::DependencyFlags::empty(),
&[], &[],
&[], &[],
&[texture_barrier]); &[texture_barrier],
let buffer_copy_regions = [vk::BufferImageCopy { );
let buffer_copy_regions = [
vk::BufferImageCopy {
image_subresource: vk::ImageSubresourceLayers { image_subresource: vk::ImageSubresourceLayers {
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT, aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
mip_level: 0, mip_level: 0,
@ -439,12 +439,15 @@ fn main() {
buffer_image_height: 0, buffer_image_height: 0,
buffer_row_length: 0, buffer_row_length: 0,
image_offset: vk::Offset3D { x: 0, y: 0, z: 0 }, image_offset: vk::Offset3D { x: 0, y: 0, z: 0 },
}]; },
device.cmd_copy_buffer_to_image(texture_command_buffer, ];
device.cmd_copy_buffer_to_image(
texture_command_buffer,
image_buffer, image_buffer,
texture_image, texture_image,
vk::ImageLayout::TransferDstOptimal, vk::ImageLayout::TransferDstOptimal,
&buffer_copy_regions); &buffer_copy_regions,
);
let texture_barrier_end = vk::ImageMemoryBarrier { let texture_barrier_end = vk::ImageMemoryBarrier {
s_type: vk::StructureType::ImageMemoryBarrier, s_type: vk::StructureType::ImageMemoryBarrier,
p_next: ptr::null(), p_next: ptr::null(),
@ -463,14 +466,17 @@ fn main() {
layer_count: 1, layer_count: 1,
}, },
}; };
device.cmd_pipeline_barrier(texture_command_buffer, device.cmd_pipeline_barrier(
texture_command_buffer,
vk::PIPELINE_STAGE_TRANSFER_BIT, vk::PIPELINE_STAGE_TRANSFER_BIT,
vk::PIPELINE_STAGE_FRAGMENT_SHADER_BIT, vk::PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
vk::DependencyFlags::empty(), vk::DependencyFlags::empty(),
&[], &[],
&[], &[],
&[texture_barrier_end]); &[texture_barrier_end],
}); );
},
);
let sampler_info = vk::SamplerCreateInfo { let sampler_info = vk::SamplerCreateInfo {
s_type: vk::StructureType::SamplerCreateInfo, s_type: vk::StructureType::SamplerCreateInfo,
@ -564,7 +570,6 @@ fn main() {
p_bindings: desc_layout_bindings.as_ptr(), p_bindings: desc_layout_bindings.as_ptr(),
}; };
let desc_set_layouts = [ let desc_set_layouts = [
base.device base.device
.create_descriptor_set_layout(&descriptor_info, None) .create_descriptor_set_layout(&descriptor_info, None)
@ -856,13 +861,14 @@ fn main() {
let graphic_pipeline = graphics_pipelines[0]; let graphic_pipeline = graphics_pipelines[0];
base.render_loop(|| { base.render_loop(|| {
let present_index = base.swapchain_loader let present_index = base.swapchain_loader
.acquire_next_image_khr(base.swapchain, .acquire_next_image_khr(
base.swapchain,
std::u64::MAX, std::u64::MAX,
base.present_complete_semaphore, base.present_complete_semaphore,
vk::Fence::null()) vk::Fence::null(),
)
.unwrap(); .unwrap();
let clear_values = [ let clear_values = [
vk::ClearValue { vk::ClearValue {
@ -948,14 +954,10 @@ fn main() {
base.device.destroy_pipeline(pipeline, None); base.device.destroy_pipeline(pipeline, None);
} }
base.device.destroy_pipeline_layout(pipeline_layout, None); base.device.destroy_pipeline_layout(pipeline_layout, None);
base.device.destroy_shader_module( base.device
vertex_shader_module, .destroy_shader_module(vertex_shader_module, None);
None, base.device
); .destroy_shader_module(fragment_shader_module, None);
base.device.destroy_shader_module(
fragment_shader_module,
None,
);
base.device.free_memory(image_buffer_memory, None); base.device.free_memory(image_buffer_memory, None);
base.device.destroy_buffer(image_buffer, None); base.device.destroy_buffer(image_buffer, None);
base.device.free_memory(texture_memory, None); base.device.free_memory(texture_memory, None);
@ -968,10 +970,8 @@ fn main() {
base.device.free_memory(vertex_input_buffer_memory, None); base.device.free_memory(vertex_input_buffer_memory, None);
base.device.destroy_buffer(vertex_input_buffer, None); base.device.destroy_buffer(vertex_input_buffer, None);
for &descriptor_set_layout in desc_set_layouts.iter() { for &descriptor_set_layout in desc_set_layouts.iter() {
base.device.destroy_descriptor_set_layout( base.device
descriptor_set_layout, .destroy_descriptor_set_layout(descriptor_set_layout, None);
None,
);
} }
base.device.destroy_descriptor_pool(descriptor_pool, None); base.device.destroy_descriptor_pool(descriptor_pool, None);
base.device.destroy_sampler(sampler, None); base.device.destroy_sampler(sampler, None);