Initial support for rustfmt
This commit is contained in:
parent
515f52fab9
commit
b71dc58efb
|
@ -1,12 +1,17 @@
|
||||||
os:
|
os:
|
||||||
- linux
|
- linux
|
||||||
- osx
|
- osx
|
||||||
|
|
||||||
language: rust
|
language: rust
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- rustup component add rustfmt-preview
|
||||||
|
|
||||||
rust:
|
rust:
|
||||||
- stable
|
- stable
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
- cargo fmt --all -- --check
|
||||||
- cargo build --manifest-path ash/Cargo.toml
|
- cargo build --manifest-path ash/Cargo.toml
|
||||||
- cargo build --manifest-path examples/Cargo.toml
|
- cargo build --manifest-path examples/Cargo.toml
|
||||||
- cargo build --manifest-path generator/Cargo.toml
|
- cargo build --manifest-path generator/Cargo.toml
|
||||||
|
|
|
@ -51,11 +51,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
|
||||||
peer_memory_features
|
peer_memory_features
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn cmd_set_device_mask(
|
unsafe fn cmd_set_device_mask(&self, command_buffer: vk::CommandBuffer, device_mask: u32) {
|
||||||
&self,
|
|
||||||
command_buffer: vk::CommandBuffer,
|
|
||||||
device_mask: u32,
|
|
||||||
) {
|
|
||||||
self.fp_v1_1()
|
self.fp_v1_1()
|
||||||
.cmd_set_device_mask(command_buffer, device_mask);
|
.cmd_set_device_mask(command_buffer, device_mask);
|
||||||
}
|
}
|
||||||
|
@ -86,11 +82,8 @@ pub trait DeviceV1_1: DeviceV1_0 {
|
||||||
info: &vk::ImageMemoryRequirementsInfo2,
|
info: &vk::ImageMemoryRequirementsInfo2,
|
||||||
out: &mut vk::MemoryRequirements2,
|
out: &mut vk::MemoryRequirements2,
|
||||||
) {
|
) {
|
||||||
self.fp_v1_1().get_image_memory_requirements2(
|
self.fp_v1_1()
|
||||||
self.handle(),
|
.get_image_memory_requirements2(self.handle(), info, out);
|
||||||
info,
|
|
||||||
out,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn get_buffer_memory_requirements2(
|
unsafe fn get_buffer_memory_requirements2(
|
||||||
|
@ -98,11 +91,8 @@ pub trait DeviceV1_1: DeviceV1_0 {
|
||||||
info: &vk::BufferMemoryRequirementsInfo2,
|
info: &vk::BufferMemoryRequirementsInfo2,
|
||||||
out: &mut vk::MemoryRequirements2,
|
out: &mut vk::MemoryRequirements2,
|
||||||
) {
|
) {
|
||||||
self.fp_v1_1().get_buffer_memory_requirements2(
|
self.fp_v1_1()
|
||||||
self.handle(),
|
.get_buffer_memory_requirements2(self.handle(), info, out);
|
||||||
info,
|
|
||||||
out,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn get_image_sparse_memory_requirements2_len(
|
unsafe fn get_image_sparse_memory_requirements2_len(
|
||||||
|
@ -221,11 +211,8 @@ pub trait DeviceV1_1: DeviceV1_0 {
|
||||||
create_info: &vk::DescriptorSetLayoutCreateInfo,
|
create_info: &vk::DescriptorSetLayoutCreateInfo,
|
||||||
out: &mut vk::DescriptorSetLayoutSupport,
|
out: &mut vk::DescriptorSetLayoutSupport,
|
||||||
) {
|
) {
|
||||||
self.fp_v1_1().get_descriptor_set_layout_support(
|
self.fp_v1_1()
|
||||||
self.handle(),
|
.get_descriptor_set_layout_support(self.handle(), create_info, out);
|
||||||
create_info,
|
|
||||||
out,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -721,11 +708,9 @@ pub trait DeviceV1_0 {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> {
|
unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_0().reset_fences(
|
let err_code =
|
||||||
self.handle(),
|
self.fp_v1_0()
|
||||||
fences.len() as u32,
|
.reset_fences(self.handle(), fences.len() as u32, fences.as_ptr());
|
||||||
fences.as_ptr(),
|
|
||||||
);
|
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::SUCCESS => Ok(()),
|
vk::Result::SUCCESS => Ok(()),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
|
@ -1357,11 +1342,7 @@ pub trait DeviceV1_0 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn get_device_queue(
|
unsafe fn get_device_queue(&self, queue_family_index: u32, queue_index: u32) -> vk::Queue {
|
||||||
&self,
|
|
||||||
queue_family_index: u32,
|
|
||||||
queue_index: u32,
|
|
||||||
) -> vk::Queue {
|
|
||||||
let mut queue = mem::uninitialized();
|
let mut queue = mem::uninitialized();
|
||||||
self.fp_v1_0()
|
self.fp_v1_0()
|
||||||
.get_device_queue(self.handle(), queue_family_index, queue_index, &mut queue);
|
.get_device_queue(self.handle(), queue_family_index, queue_index, &mut queue);
|
||||||
|
@ -1473,12 +1454,9 @@ pub trait DeviceV1_0 {
|
||||||
submits: &[vk::SubmitInfo],
|
submits: &[vk::SubmitInfo],
|
||||||
fence: vk::Fence,
|
fence: vk::Fence,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_0().queue_submit(
|
let err_code =
|
||||||
queue,
|
self.fp_v1_0()
|
||||||
submits.len() as u32,
|
.queue_submit(queue, submits.len() as u32, submits.as_ptr(), fence);
|
||||||
submits.as_ptr(),
|
|
||||||
fence,
|
|
||||||
);
|
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::SUCCESS => Ok(()),
|
vk::Result::SUCCESS => Ok(()),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
|
@ -1725,10 +1703,7 @@ pub struct Device {
|
||||||
device_fn_1_1: vk::DeviceFnV1_1,
|
device_fn_1_1: vk::DeviceFnV1_1,
|
||||||
}
|
}
|
||||||
impl Device {
|
impl Device {
|
||||||
pub unsafe fn load(
|
pub unsafe fn load(instance_fn: &vk::InstanceFnV1_0, device: vk::Device) -> Self {
|
||||||
instance_fn: &vk::InstanceFnV1_0,
|
|
||||||
device: vk::Device,
|
|
||||||
) -> Self {
|
|
||||||
let device_fn_1_0 = vk::DeviceFnV1_0::load(|name| {
|
let device_fn_1_0 = 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()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,18 +15,14 @@ use RawPtr;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
const LIB_PATH: &'static str = "vulkan-1.dll";
|
const LIB_PATH: &'static str = "vulkan-1.dll";
|
||||||
|
|
||||||
#[cfg(
|
#[cfg(all(
|
||||||
all(
|
unix,
|
||||||
unix,
|
not(any(
|
||||||
not(
|
target_os = "macos",
|
||||||
any(
|
target_os = "ios",
|
||||||
target_os = "macos",
|
target_os = "android"
|
||||||
target_os = "ios",
|
))
|
||||||
target_os = "android"
|
))]
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)]
|
|
||||||
const LIB_PATH: &'static str = "libvulkan.so.1";
|
const LIB_PATH: &'static str = "libvulkan.so.1";
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
|
|
|
@ -13,10 +13,7 @@ pub struct AndroidSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AndroidSurface {
|
impl AndroidSurface {
|
||||||
pub fn new<E: EntryV1_0, I: InstanceV1_0>(
|
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> AndroidSurface {
|
||||||
entry: &E,
|
|
||||||
instance: &I,
|
|
||||||
) -> AndroidSurface {
|
|
||||||
let surface_fn = vk::KhrAndroidSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::KhrAndroidSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,10 +11,7 @@ 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, device: &D) -> DebugMarker {
|
||||||
instance: &I,
|
|
||||||
device: &D,
|
|
||||||
) -> DebugMarker {
|
|
||||||
let debug_marker_fn = vk::ExtDebugMarkerFn::load(|name| unsafe {
|
let debug_marker_fn = vk::ExtDebugMarkerFn::load(|name| unsafe {
|
||||||
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
|
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,10 +13,7 @@ pub struct DebugReport {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DebugReport {
|
impl DebugReport {
|
||||||
pub fn new<E: EntryV1_0, I: InstanceV1_0>(
|
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> DebugReport {
|
||||||
entry: &E,
|
|
||||||
instance: &I,
|
|
||||||
) -> DebugReport {
|
|
||||||
let debug_report_fn = vk::ExtDebugReportFn::load(|name| unsafe {
|
let debug_report_fn = vk::ExtDebugReportFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,10 +12,7 @@ pub struct DebugUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DebugUtils {
|
impl DebugUtils {
|
||||||
pub fn new<E: EntryV1_0, I: InstanceV1_0>(
|
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> DebugUtils {
|
||||||
entry: &E,
|
|
||||||
instance: &I,
|
|
||||||
) -> DebugUtils {
|
|
||||||
let debug_utils_fn = vk::ExtDebugUtilsFn::load(|name| unsafe {
|
let debug_utils_fn = vk::ExtDebugUtilsFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
@ -34,7 +31,9 @@ impl DebugUtils {
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
name_info: &vk::DebugUtilsObjectNameInfoEXT,
|
name_info: &vk::DebugUtilsObjectNameInfoEXT,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self.debug_utils_fn.set_debug_utils_object_name_ext(device, name_info);
|
let err_code = self
|
||||||
|
.debug_utils_fn
|
||||||
|
.set_debug_utils_object_name_ext(device, name_info);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::SUCCESS => Ok(()),
|
vk::Result::SUCCESS => Ok(()),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
|
@ -46,7 +45,9 @@ impl DebugUtils {
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
tag_info: &vk::DebugUtilsObjectTagInfoEXT,
|
tag_info: &vk::DebugUtilsObjectTagInfoEXT,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self.debug_utils_fn.set_debug_utils_object_tag_ext(device, tag_info);
|
let err_code = self
|
||||||
|
.debug_utils_fn
|
||||||
|
.set_debug_utils_object_tag_ext(device, tag_info);
|
||||||
match err_code {
|
match err_code {
|
||||||
vk::Result::SUCCESS => Ok(()),
|
vk::Result::SUCCESS => Ok(()),
|
||||||
_ => Err(err_code),
|
_ => Err(err_code),
|
||||||
|
|
|
@ -13,10 +13,7 @@ pub struct DisplaySwapchain {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DisplaySwapchain {
|
impl DisplaySwapchain {
|
||||||
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(
|
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> DisplaySwapchain {
|
||||||
instance: &I,
|
|
||||||
device: &D,
|
|
||||||
) -> DisplaySwapchain {
|
|
||||||
let swapchain_fn = vk::KhrDisplaySwapchainFn::load(|name| unsafe {
|
let swapchain_fn = vk::KhrDisplaySwapchainFn::load(|name| unsafe {
|
||||||
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
|
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,10 +13,7 @@ pub struct IOSSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IOSSurface {
|
impl IOSSurface {
|
||||||
pub fn new<E: EntryV1_0, I: InstanceV1_0>(
|
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> IOSSurface {
|
||||||
entry: &E,
|
|
||||||
instance: &I,
|
|
||||||
) -> IOSSurface{
|
|
||||||
let surface_fn = vk::MvkIosSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::MvkIosSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,10 +13,7 @@ pub struct MacOSSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MacOSSurface {
|
impl MacOSSurface {
|
||||||
pub fn new<E: EntryV1_0, I: InstanceV1_0>(
|
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> MacOSSurface {
|
||||||
entry: &E,
|
|
||||||
instance: &I,
|
|
||||||
) -> MacOSSurface {
|
|
||||||
let surface_fn = vk::MvkMacosSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::MvkMacosSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,10 +14,7 @@ pub struct Surface {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Surface {
|
impl Surface {
|
||||||
pub fn new<E: EntryV1_0, I: InstanceV1_0>(
|
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> Surface {
|
||||||
entry: &E,
|
|
||||||
instance: &I,
|
|
||||||
) -> Surface {
|
|
||||||
let surface_fn = vk::KhrSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::KhrSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,10 +14,7 @@ pub struct Swapchain {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Swapchain {
|
impl Swapchain {
|
||||||
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(
|
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> Swapchain {
|
||||||
instance: &I,
|
|
||||||
device: &D,
|
|
||||||
) -> Swapchain {
|
|
||||||
let swapchain_fn = vk::KhrSwapchainFn::load(|name| unsafe {
|
let swapchain_fn = vk::KhrSwapchainFn::load(|name| unsafe {
|
||||||
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
|
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,10 +13,7 @@ pub struct WaylandSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaylandSurface {
|
impl WaylandSurface {
|
||||||
pub fn new<E: EntryV1_0, I: InstanceV1_0>(
|
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> WaylandSurface {
|
||||||
entry: &E,
|
|
||||||
instance: &I,
|
|
||||||
) -> WaylandSurface {
|
|
||||||
let surface_fn = vk::KhrWaylandSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::KhrWaylandSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,10 +13,7 @@ pub struct Win32Surface {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Win32Surface {
|
impl Win32Surface {
|
||||||
pub fn new<E: EntryV1_0, I: InstanceV1_0>(
|
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> Win32Surface {
|
||||||
entry: &E,
|
|
||||||
instance: &I,
|
|
||||||
) -> Win32Surface {
|
|
||||||
let surface_fn = vk::KhrWin32SurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::KhrWin32SurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,10 +13,7 @@ pub struct XcbSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XcbSurface {
|
impl XcbSurface {
|
||||||
pub fn new<E: EntryV1_0, I: InstanceV1_0>(
|
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> XcbSurface {
|
||||||
entry: &E,
|
|
||||||
instance: &I,
|
|
||||||
) -> XcbSurface {
|
|
||||||
let surface_fn = vk::KhrXcbSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::KhrXcbSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,10 +13,7 @@ pub struct XlibSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XlibSurface {
|
impl XlibSurface {
|
||||||
pub fn new<E: EntryV1_0, I: InstanceV1_0>(
|
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> XlibSurface {
|
||||||
entry: &E,
|
|
||||||
instance: &I,
|
|
||||||
) -> XlibSurface {
|
|
||||||
let surface_fn = vk::KhrXlibSurfaceFn::load(|name| unsafe {
|
let surface_fn = vk::KhrXlibSurfaceFn::load(|name| unsafe {
|
||||||
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,11 +46,7 @@ fn calc_padding(adr: vk::DeviceSize, align: vk::DeviceSize) -> vk::DeviceSize {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Align<T> {
|
impl<T> Align<T> {
|
||||||
pub unsafe fn new(
|
pub unsafe fn new(ptr: *mut c_void, alignment: vk::DeviceSize, size: vk::DeviceSize) -> Self {
|
||||||
ptr: *mut c_void,
|
|
||||||
alignment: vk::DeviceSize,
|
|
||||||
size: vk::DeviceSize,
|
|
||||||
) -> Self {
|
|
||||||
let padding = calc_padding(size_of::<T>() as vk::DeviceSize, alignment);
|
let padding = calc_padding(size_of::<T>() as vk::DeviceSize, alignment);
|
||||||
let elem_size = size_of::<T>() as vk::DeviceSize + padding;
|
let elem_size = size_of::<T>() as vk::DeviceSize + padding;
|
||||||
assert!(calc_padding(size, alignment) == 0, "size must be aligned");
|
assert!(calc_padding(size, alignment) == 0, "size must be aligned");
|
||||||
|
|
|
@ -3,7 +3,11 @@ use ash::vk;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn display_flags() {
|
fn display_flags() {
|
||||||
assert_eq!((vk::AccessFlags::INDIRECT_COMMAND_READ | vk::AccessFlags::VERTEX_ATTRIBUTE_READ).to_string(), "INDIRECT_COMMAND_READ | VERTEX_ATTRIBUTE_READ");
|
assert_eq!(
|
||||||
|
(vk::AccessFlags::INDIRECT_COMMAND_READ | vk::AccessFlags::VERTEX_ATTRIBUTE_READ)
|
||||||
|
.to_string(),
|
||||||
|
"INDIRECT_COMMAND_READ | VERTEX_ATTRIBUTE_READ"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -121,8 +121,7 @@ fn main() {
|
||||||
base.device
|
base.device
|
||||||
.create_framebuffer(&frame_buffer_create_info, None)
|
.create_framebuffer(&frame_buffer_create_info, None)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
let index_buffer_data = [0u32, 1, 2, 2, 3, 0];
|
let index_buffer_data = [0u32, 1, 2, 2, 3, 0];
|
||||||
let index_buffer_info = vk::BufferCreateInfo {
|
let index_buffer_info = vk::BufferCreateInfo {
|
||||||
s_type: vk::StructureType::BUFFER_CREATE_INFO,
|
s_type: vk::StructureType::BUFFER_CREATE_INFO,
|
||||||
|
@ -136,12 +135,11 @@ fn main() {
|
||||||
};
|
};
|
||||||
let index_buffer = base.device.create_buffer(&index_buffer_info, None).unwrap();
|
let index_buffer = base.device.create_buffer(&index_buffer_info, None).unwrap();
|
||||||
let index_buffer_memory_req = base.device.get_buffer_memory_requirements(index_buffer);
|
let index_buffer_memory_req = base.device.get_buffer_memory_requirements(index_buffer);
|
||||||
let index_buffer_memory_index =
|
let index_buffer_memory_index = find_memorytype_index(
|
||||||
find_memorytype_index(
|
&index_buffer_memory_req,
|
||||||
&index_buffer_memory_req,
|
&base.device_memory_properties,
|
||||||
&base.device_memory_properties,
|
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
||||||
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
).expect("Unable to find suitable memorytype for the index buffer.");
|
||||||
).expect("Unable to find suitable memorytype for the index buffer.");
|
|
||||||
let index_allocate_info = vk::MemoryAllocateInfo {
|
let index_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
|
@ -159,8 +157,7 @@ fn main() {
|
||||||
0,
|
0,
|
||||||
index_buffer_memory_req.size,
|
index_buffer_memory_req.size,
|
||||||
vk::MemoryMapFlags::empty(),
|
vk::MemoryMapFlags::empty(),
|
||||||
)
|
).unwrap();
|
||||||
.unwrap();
|
|
||||||
let mut index_slice = Align::new(
|
let mut index_slice = Align::new(
|
||||||
index_ptr,
|
index_ptr,
|
||||||
align_of::<u32>() as u64,
|
align_of::<u32>() as u64,
|
||||||
|
@ -207,12 +204,11 @@ fn main() {
|
||||||
let vertex_input_buffer_memory_req = base
|
let vertex_input_buffer_memory_req = base
|
||||||
.device
|
.device
|
||||||
.get_buffer_memory_requirements(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,
|
&base.device_memory_properties,
|
||||||
&base.device_memory_properties,
|
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
||||||
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
).expect("Unable to find suitable memorytype for the vertex buffer.");
|
||||||
).expect("Unable to find suitable memorytype for the vertex buffer.");
|
|
||||||
|
|
||||||
let vertex_buffer_allocate_info = vk::MemoryAllocateInfo {
|
let vertex_buffer_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
|
@ -231,8 +227,7 @@ fn main() {
|
||||||
0,
|
0,
|
||||||
vertex_input_buffer_memory_req.size,
|
vertex_input_buffer_memory_req.size,
|
||||||
vk::MemoryMapFlags::empty(),
|
vk::MemoryMapFlags::empty(),
|
||||||
)
|
).unwrap();
|
||||||
.unwrap();
|
|
||||||
let mut slice = Align::new(
|
let mut slice = Align::new(
|
||||||
vert_ptr,
|
vert_ptr,
|
||||||
align_of::<Vertex>() as u64,
|
align_of::<Vertex>() as u64,
|
||||||
|
@ -267,12 +262,11 @@ fn main() {
|
||||||
let uniform_color_buffer_memory_req = base
|
let uniform_color_buffer_memory_req = base
|
||||||
.device
|
.device
|
||||||
.get_buffer_memory_requirements(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,
|
&base.device_memory_properties,
|
||||||
&base.device_memory_properties,
|
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
||||||
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
).expect("Unable to find suitable memorytype for the vertex buffer.");
|
||||||
).expect("Unable to find suitable memorytype for the vertex buffer.");
|
|
||||||
|
|
||||||
let uniform_color_buffer_allocate_info = vk::MemoryAllocateInfo {
|
let uniform_color_buffer_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
|
@ -291,8 +285,7 @@ fn main() {
|
||||||
0,
|
0,
|
||||||
uniform_color_buffer_memory_req.size,
|
uniform_color_buffer_memory_req.size,
|
||||||
vk::MemoryMapFlags::empty(),
|
vk::MemoryMapFlags::empty(),
|
||||||
)
|
).unwrap();
|
||||||
.unwrap();
|
|
||||||
let mut uniform_aligned_slice = Align::new(
|
let mut uniform_aligned_slice = Align::new(
|
||||||
uniform_ptr,
|
uniform_ptr,
|
||||||
align_of::<Vector3>() as u64,
|
align_of::<Vector3>() as u64,
|
||||||
|
@ -319,12 +312,11 @@ fn main() {
|
||||||
};
|
};
|
||||||
let image_buffer = base.device.create_buffer(&image_buffer_info, None).unwrap();
|
let image_buffer = base.device.create_buffer(&image_buffer_info, None).unwrap();
|
||||||
let image_buffer_memory_req = base.device.get_buffer_memory_requirements(image_buffer);
|
let image_buffer_memory_req = base.device.get_buffer_memory_requirements(image_buffer);
|
||||||
let image_buffer_memory_index =
|
let image_buffer_memory_index = find_memorytype_index(
|
||||||
find_memorytype_index(
|
&image_buffer_memory_req,
|
||||||
&image_buffer_memory_req,
|
&base.device_memory_properties,
|
||||||
&base.device_memory_properties,
|
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
||||||
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
).expect("Unable to find suitable memorytype for the vertex buffer.");
|
||||||
).expect("Unable to find suitable memorytype for the vertex buffer.");
|
|
||||||
|
|
||||||
let image_buffer_allocate_info = vk::MemoryAllocateInfo {
|
let image_buffer_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
|
@ -343,8 +335,7 @@ fn main() {
|
||||||
0,
|
0,
|
||||||
image_buffer_memory_req.size,
|
image_buffer_memory_req.size,
|
||||||
vk::MemoryMapFlags::empty(),
|
vk::MemoryMapFlags::empty(),
|
||||||
)
|
).unwrap();
|
||||||
.unwrap();
|
|
||||||
let mut image_slice = Align::new(
|
let mut image_slice = Align::new(
|
||||||
image_ptr,
|
image_ptr,
|
||||||
std::mem::align_of::<u8>() as u64,
|
std::mem::align_of::<u8>() as u64,
|
||||||
|
@ -382,12 +373,11 @@ fn main() {
|
||||||
.create_image(&texture_create_info, None)
|
.create_image(&texture_create_info, None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let texture_memory_req = base.device.get_image_memory_requirements(texture_image);
|
let texture_memory_req = base.device.get_image_memory_requirements(texture_image);
|
||||||
let texture_memory_index =
|
let texture_memory_index = find_memorytype_index(
|
||||||
find_memorytype_index(
|
&texture_memory_req,
|
||||||
&texture_memory_req,
|
&base.device_memory_properties,
|
||||||
&base.device_memory_properties,
|
vk::MemoryPropertyFlags::DEVICE_LOCAL,
|
||||||
vk::MemoryPropertyFlags::DEVICE_LOCAL,
|
).expect("Unable to find suitable memory index for depth image.");
|
||||||
).expect("Unable to find suitable memory index for depth image.");
|
|
||||||
|
|
||||||
let texture_allocate_info = vk::MemoryAllocateInfo {
|
let texture_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
|
@ -882,8 +872,7 @@ fn main() {
|
||||||
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 {
|
||||||
color: vk::ClearColorValue {
|
color: vk::ClearColorValue {
|
||||||
|
|
|
@ -110,8 +110,7 @@ fn main() {
|
||||||
base.device
|
base.device
|
||||||
.create_framebuffer(&frame_buffer_create_info, None)
|
.create_framebuffer(&frame_buffer_create_info, None)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
let index_buffer_data = [0u32, 1, 2];
|
let index_buffer_data = [0u32, 1, 2];
|
||||||
let index_buffer_info = vk::BufferCreateInfo {
|
let index_buffer_info = vk::BufferCreateInfo {
|
||||||
s_type: vk::StructureType::BUFFER_CREATE_INFO,
|
s_type: vk::StructureType::BUFFER_CREATE_INFO,
|
||||||
|
@ -125,12 +124,11 @@ fn main() {
|
||||||
};
|
};
|
||||||
let index_buffer = base.device.create_buffer(&index_buffer_info, None).unwrap();
|
let index_buffer = base.device.create_buffer(&index_buffer_info, None).unwrap();
|
||||||
let index_buffer_memory_req = base.device.get_buffer_memory_requirements(index_buffer);
|
let index_buffer_memory_req = base.device.get_buffer_memory_requirements(index_buffer);
|
||||||
let index_buffer_memory_index =
|
let index_buffer_memory_index = find_memorytype_index(
|
||||||
find_memorytype_index(
|
&index_buffer_memory_req,
|
||||||
&index_buffer_memory_req,
|
&base.device_memory_properties,
|
||||||
&base.device_memory_properties,
|
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
||||||
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
).expect("Unable to find suitable memorytype for the index buffer.");
|
||||||
).expect("Unable to find suitable memorytype for the index buffer.");
|
|
||||||
let index_allocate_info = vk::MemoryAllocateInfo {
|
let index_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
|
@ -148,8 +146,7 @@ fn main() {
|
||||||
0,
|
0,
|
||||||
index_buffer_memory_req.size,
|
index_buffer_memory_req.size,
|
||||||
vk::MemoryMapFlags::empty(),
|
vk::MemoryMapFlags::empty(),
|
||||||
)
|
).unwrap();
|
||||||
.unwrap();
|
|
||||||
let mut index_slice = Align::new(
|
let mut index_slice = Align::new(
|
||||||
index_ptr,
|
index_ptr,
|
||||||
align_of::<u32>() as u64,
|
align_of::<u32>() as u64,
|
||||||
|
@ -178,12 +175,11 @@ fn main() {
|
||||||
let vertex_input_buffer_memory_req = base
|
let vertex_input_buffer_memory_req = base
|
||||||
.device
|
.device
|
||||||
.get_buffer_memory_requirements(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,
|
&base.device_memory_properties,
|
||||||
&base.device_memory_properties,
|
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
||||||
vk::MemoryPropertyFlags::HOST_VISIBLE,
|
).expect("Unable to find suitable memorytype for the vertex buffer.");
|
||||||
).expect("Unable to find suitable memorytype for the vertex buffer.");
|
|
||||||
|
|
||||||
let vertex_buffer_allocate_info = vk::MemoryAllocateInfo {
|
let vertex_buffer_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
|
@ -216,8 +212,7 @@ fn main() {
|
||||||
0,
|
0,
|
||||||
vertex_input_buffer_memory_req.size,
|
vertex_input_buffer_memory_req.size,
|
||||||
vk::MemoryMapFlags::empty(),
|
vk::MemoryMapFlags::empty(),
|
||||||
)
|
).unwrap();
|
||||||
.unwrap();
|
|
||||||
let mut vert_align = Align::new(
|
let mut vert_align = Align::new(
|
||||||
vert_ptr,
|
vert_ptr,
|
||||||
align_of::<Vertex>() as u64,
|
align_of::<Vertex>() as u64,
|
||||||
|
@ -467,8 +462,7 @@ fn main() {
|
||||||
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 {
|
||||||
color: vk::ClearColorValue {
|
color: vk::ClearColorValue {
|
||||||
|
|
|
@ -4,13 +4,13 @@ extern crate ash;
|
||||||
extern crate winapi;
|
extern crate winapi;
|
||||||
extern crate winit;
|
extern crate winit;
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
extern crate objc;
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
extern crate cocoa;
|
extern crate cocoa;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
extern crate metal_rs as metal;
|
extern crate metal_rs as metal;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
extern crate objc;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
use cocoa::appkit::{NSView, NSWindow};
|
use cocoa::appkit::{NSView, NSWindow};
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use cocoa::base::id as cocoa_id;
|
use cocoa::base::id as cocoa_id;
|
||||||
|
@ -21,18 +21,18 @@ use objc::runtime::YES;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use ash::vk;
|
#[cfg(target_os = "macos")]
|
||||||
use ash::Device;
|
use ash::extensions::MacOSSurface;
|
||||||
use ash::Entry;
|
|
||||||
use ash::Instance;
|
|
||||||
pub use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0};
|
|
||||||
use ash::extensions::{DebugReport, Surface, Swapchain};
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use ash::extensions::Win32Surface;
|
use ash::extensions::Win32Surface;
|
||||||
#[cfg(all(unix, not(target_os = "android"), not(target_os = "macos")))]
|
#[cfg(all(unix, not(target_os = "android"), not(target_os = "macos")))]
|
||||||
use ash::extensions::XlibSurface;
|
use ash::extensions::XlibSurface;
|
||||||
#[cfg(target_os = "macos")]
|
use ash::extensions::{DebugReport, Surface, Swapchain};
|
||||||
use ash::extensions::MacOSSurface;
|
pub use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0};
|
||||||
|
use ash::vk;
|
||||||
|
use ash::Device;
|
||||||
|
use ash::Entry;
|
||||||
|
use ash::Instance;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
|
@ -125,8 +125,7 @@ unsafe fn create_surface<E: EntryV1_0, I: InstanceV1_0>(
|
||||||
window: x11_window as vk::Window,
|
window: x11_window as vk::Window,
|
||||||
dpy: x11_display as *mut vk::Display,
|
dpy: x11_display as *mut vk::Display,
|
||||||
};
|
};
|
||||||
let xlib_surface_loader =
|
let xlib_surface_loader = XlibSurface::new(entry, instance);
|
||||||
XlibSurface::new(entry, instance);
|
|
||||||
xlib_surface_loader.create_xlib_surface_khr(&x11_create_info, None)
|
xlib_surface_loader.create_xlib_surface_khr(&x11_create_info, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,11 +155,10 @@ unsafe fn create_surface<E: EntryV1_0, I: InstanceV1_0>(
|
||||||
s_type: vk::StructureType::MACOS_SURFACE_CREATE_INFO_M,
|
s_type: vk::StructureType::MACOS_SURFACE_CREATE_INFO_M,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
p_view: window.get_nsview() as *const c_void
|
p_view: window.get_nsview() as *const c_void,
|
||||||
};
|
};
|
||||||
|
|
||||||
let macos_surface_loader =
|
let macos_surface_loader = MacOSSurface::new(entry, instance);
|
||||||
MacOSSurface::new(entry, instance);
|
|
||||||
macos_surface_loader.create_mac_os_surface_mvk(&create_info, None)
|
macos_surface_loader.create_mac_os_surface_mvk(&create_info, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,8 +181,7 @@ unsafe fn create_surface<E: EntryV1_0, I: InstanceV1_0>(
|
||||||
hinstance: hinstance,
|
hinstance: hinstance,
|
||||||
hwnd: hwnd as *const c_void,
|
hwnd: hwnd as *const c_void,
|
||||||
};
|
};
|
||||||
let win32_surface_loader =
|
let win32_surface_loader = Win32Surface::new(entry, instance);
|
||||||
Win32Surface::new(entry, instance);
|
|
||||||
win32_surface_loader.create_win32_surface_khr(&win32_create_info, None)
|
win32_surface_loader.create_win32_surface_khr(&win32_create_info, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,8 +373,7 @@ impl ExampleBase {
|
||||||
pfn_callback: Some(vulkan_debug_callback),
|
pfn_callback: Some(vulkan_debug_callback),
|
||||||
p_user_data: ptr::null_mut(),
|
p_user_data: ptr::null_mut(),
|
||||||
};
|
};
|
||||||
let debug_report_loader =
|
let debug_report_loader = DebugReport::new(&entry, &instance);
|
||||||
DebugReport::new(&entry, &instance);
|
|
||||||
let debug_call_back = debug_report_loader
|
let debug_call_back = debug_report_loader
|
||||||
.create_debug_report_callback_ext(&debug_info, None)
|
.create_debug_report_callback_ext(&debug_info, None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -385,8 +381,7 @@ impl ExampleBase {
|
||||||
let pdevices = instance
|
let pdevices = instance
|
||||||
.enumerate_physical_devices()
|
.enumerate_physical_devices()
|
||||||
.expect("Physical device error");
|
.expect("Physical device error");
|
||||||
let surface_loader =
|
let surface_loader = Surface::new(&entry, &instance);
|
||||||
Surface::new(&entry, &instance);
|
|
||||||
let (pdevice, queue_family_index) = pdevices
|
let (pdevice, queue_family_index) = pdevices
|
||||||
.iter()
|
.iter()
|
||||||
.map(|pdevice| {
|
.map(|pdevice| {
|
||||||
|
@ -396,8 +391,8 @@ impl ExampleBase {
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(index, ref info)| {
|
.filter_map(|(index, ref info)| {
|
||||||
let supports_graphic_and_surface =
|
let supports_graphic_and_surface =
|
||||||
info.queue_flags.contains(vk::QueueFlags::GRAPHICS) && surface_loader
|
info.queue_flags.contains(vk::QueueFlags::GRAPHICS)
|
||||||
.get_physical_device_surface_support_khr(
|
&& surface_loader.get_physical_device_surface_support_khr(
|
||||||
*pdevice,
|
*pdevice,
|
||||||
index as u32,
|
index as u32,
|
||||||
surface,
|
surface,
|
||||||
|
@ -487,8 +482,7 @@ impl ExampleBase {
|
||||||
.cloned()
|
.cloned()
|
||||||
.find(|&mode| mode == vk::PresentModeKHR::MAILBOX)
|
.find(|&mode| mode == vk::PresentModeKHR::MAILBOX)
|
||||||
.unwrap_or(vk::PresentModeKHR::FIFO);
|
.unwrap_or(vk::PresentModeKHR::FIFO);
|
||||||
let swapchain_loader =
|
let swapchain_loader = Swapchain::new(&instance, &device);
|
||||||
Swapchain::new(&instance, &device);
|
|
||||||
let swapchain_create_info = vk::SwapchainCreateInfoKHR {
|
let swapchain_create_info = vk::SwapchainCreateInfoKHR {
|
||||||
s_type: vk::StructureType::SWAPCHAIN_CREATE_INFO_KHR,
|
s_type: vk::StructureType::SWAPCHAIN_CREATE_INFO_KHR,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
|
|
|
@ -531,13 +531,13 @@ impl CommandExt for vkxml::Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn function_type(&self) -> FunctionType {
|
fn function_type(&self) -> FunctionType {
|
||||||
let is_first_param_device = self.param
|
let is_first_param_device = self
|
||||||
|
.param
|
||||||
.get(0)
|
.get(0)
|
||||||
.map(|field| match field.basetype.as_str() {
|
.map(|field| match field.basetype.as_str() {
|
||||||
"VkDevice" | "VkCommandBuffer" | "VkQueue" => true,
|
"VkDevice" | "VkCommandBuffer" | "VkQueue" => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
}).unwrap_or(false);
|
||||||
.unwrap_or(false);
|
|
||||||
match self.name.as_str() {
|
match self.name.as_str() {
|
||||||
"vkGetInstanceProcAddr" => FunctionType::Static,
|
"vkGetInstanceProcAddr" => FunctionType::Static,
|
||||||
"vkCreateInstance"
|
"vkCreateInstance"
|
||||||
|
@ -643,7 +643,8 @@ impl FieldExt for vkxml::Field {
|
||||||
|
|
||||||
fn type_tokens(&self) -> Tokens {
|
fn type_tokens(&self) -> Tokens {
|
||||||
let ty = name_to_tokens(&self.basetype);
|
let ty = name_to_tokens(&self.basetype);
|
||||||
let pointer = self.reference
|
let pointer = self
|
||||||
|
.reference
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|r| r.to_tokens(self.is_const))
|
.map(|r| r.to_tokens(self.is_const))
|
||||||
.unwrap_or(quote!{});
|
.unwrap_or(quote!{});
|
||||||
|
@ -652,7 +653,8 @@ impl FieldExt for vkxml::Field {
|
||||||
};
|
};
|
||||||
let array = self.array.as_ref().and_then(|arraytype| match arraytype {
|
let array = self.array.as_ref().and_then(|arraytype| match arraytype {
|
||||||
vkxml::ArrayType::Static => {
|
vkxml::ArrayType::Static => {
|
||||||
let size = self.size
|
let size = self
|
||||||
|
.size
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.or_else(|| self.size_enumref.as_ref())
|
.or_else(|| self.size_enumref.as_ref())
|
||||||
.expect("Should have size");
|
.expect("Should have size");
|
||||||
|
@ -700,23 +702,21 @@ fn generate_function_pointers<'a>(
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
|
|
||||||
let params: Vec<Vec<(Ident, Tokens)>> = commands
|
let params: Vec<Vec<(Ident, Tokens)>> = commands
|
||||||
.iter()
|
.iter()
|
||||||
.map(|cmd| {
|
.map(|cmd| {
|
||||||
let params: Vec<_> = cmd.param
|
let params: Vec<_> = cmd
|
||||||
|
.param
|
||||||
.iter()
|
.iter()
|
||||||
.map(|field| {
|
.map(|field| {
|
||||||
let name = field.param_ident();
|
let name = field.param_ident();
|
||||||
let ty = field.type_tokens();
|
let ty = field.type_tokens();
|
||||||
(name, ty)
|
(name, ty)
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
params
|
params
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
|
|
||||||
let params_names: Vec<Vec<_>> = params
|
let params_names: Vec<Vec<_>> = params
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -725,8 +725,7 @@ fn generate_function_pointers<'a>(
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&(param_name, _)| param_name)
|
.map(|&(param_name, _)| param_name)
|
||||||
.collect()
|
.collect()
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
let param_names_ref = ¶ms_names;
|
let param_names_ref = ¶ms_names;
|
||||||
let expanded_params: Vec<_> = params
|
let expanded_params: Vec<_> = params
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -737,8 +736,7 @@ fn generate_function_pointers<'a>(
|
||||||
quote!{
|
quote!{
|
||||||
#(#inner_params_iter,)*
|
#(#inner_params_iter,)*
|
||||||
}
|
}
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
let expanded_params_unused: Vec<_> = params
|
let expanded_params_unused: Vec<_> = params
|
||||||
.iter()
|
.iter()
|
||||||
.map(|inner_params| {
|
.map(|inner_params| {
|
||||||
|
@ -749,8 +747,7 @@ fn generate_function_pointers<'a>(
|
||||||
quote!{
|
quote!{
|
||||||
#(#inner_params_iter,)*
|
#(#inner_params_iter,)*
|
||||||
}
|
}
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
let expanded_params_ref = &expanded_params;
|
let expanded_params_ref = &expanded_params;
|
||||||
|
|
||||||
let return_types: Vec<_> = commands
|
let return_types: Vec<_> = commands
|
||||||
|
@ -768,17 +765,16 @@ fn generate_function_pointers<'a>(
|
||||||
let signature_params: Vec<Vec<_>> = pfn_commands
|
let signature_params: Vec<Vec<_>> = pfn_commands
|
||||||
.iter()
|
.iter()
|
||||||
.map(|cmd| {
|
.map(|cmd| {
|
||||||
let params: Vec<_> = cmd.param
|
let params: Vec<_> = cmd
|
||||||
|
.param
|
||||||
.iter()
|
.iter()
|
||||||
.map(|field| {
|
.map(|field| {
|
||||||
let name = field.param_ident();
|
let name = field.param_ident();
|
||||||
let ty = field.type_tokens();
|
let ty = field.type_tokens();
|
||||||
quote! { #name: #ty }
|
quote! { #name: #ty }
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
params
|
params
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
let signature_params_ref = &signature_params;
|
let signature_params_ref = &signature_params;
|
||||||
|
|
||||||
let pfn_return_types: Vec<_> = pfn_commands
|
let pfn_return_types: Vec<_> = pfn_commands
|
||||||
|
@ -869,8 +865,7 @@ pub fn generate_extension_constants<'a>(
|
||||||
.filter_map(|item| match item {
|
.filter_map(|item| match item {
|
||||||
vk_parse::ExtensionItem::Require { items, .. } => Some(items.iter()),
|
vk_parse::ExtensionItem::Require { items, .. } => Some(items.iter()),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
}).flat_map(|iter| iter);
|
||||||
.flat_map(|iter| iter);
|
|
||||||
let enum_tokens = items.filter_map(|item| match item {
|
let enum_tokens = items.filter_map(|item| match item {
|
||||||
vk_parse::InterfaceItem::Enum(_enum) => {
|
vk_parse::InterfaceItem::Enum(_enum) => {
|
||||||
use vk_parse::EnumSpec;
|
use vk_parse::EnumSpec;
|
||||||
|
@ -940,8 +935,7 @@ pub fn generate_extension_commands<'a>(
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
}).flat_map(|iter| iter)
|
||||||
.flat_map(|iter| iter)
|
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
let name = format!("{}Fn", extension_name.to_camel_case());
|
let name = format!("{}Fn", extension_name.to_camel_case());
|
||||||
let ident = Ident::from(&name[2..]);
|
let ident = Ident::from(&name[2..]);
|
||||||
|
@ -1048,8 +1042,7 @@ pub fn bitflags_impl_block(
|
||||||
let variant_ident = constant.variant_ident(enum_name);
|
let variant_ident = constant.variant_ident(enum_name);
|
||||||
let tokens = constant.to_tokens();
|
let tokens = constant.to_tokens();
|
||||||
(variant_ident, tokens)
|
(variant_ident, tokens)
|
||||||
})
|
}).collect_vec();
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
let notations = constants.iter().map(|constant| {
|
let notations = constants.iter().map(|constant| {
|
||||||
constant.notation().map(|n| {
|
constant.notation().map(|n| {
|
||||||
|
@ -1059,14 +1052,16 @@ pub fn bitflags_impl_block(
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let variants = variants.iter().zip(notations.clone()).map(
|
let variants =
|
||||||
|((variant_ident, value), ref notation)| {
|
variants
|
||||||
quote!{
|
.iter()
|
||||||
#notation
|
.zip(notations.clone())
|
||||||
pub const #variant_ident: Self = #ident(#value);
|
.map(|((variant_ident, value), ref notation)| {
|
||||||
}
|
quote!{
|
||||||
},
|
#notation
|
||||||
);
|
pub const #variant_ident: Self = #ident(#value);
|
||||||
|
}
|
||||||
|
});
|
||||||
quote!{
|
quote!{
|
||||||
impl #ident {
|
impl #ident {
|
||||||
#(#variants)*
|
#(#variants)*
|
||||||
|
@ -1088,8 +1083,7 @@ pub fn generate_enum<'a>(
|
||||||
.filter_map(|elem| match *elem {
|
.filter_map(|elem| match *elem {
|
||||||
vkxml::EnumerationElement::Enum(ref constant) => Some(constant),
|
vkxml::EnumerationElement::Enum(ref constant) => Some(constant),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
}).collect_vec();
|
||||||
.collect_vec();
|
|
||||||
let values = const_values.entry(ident.clone()).or_insert_with(Vec::new);
|
let values = const_values.entry(ident.clone()).or_insert_with(Vec::new);
|
||||||
for constant in &constants {
|
for constant in &constants {
|
||||||
const_cache.insert(constant.name.as_str());
|
const_cache.insert(constant.name.as_str());
|
||||||
|
@ -1193,8 +1187,7 @@ fn is_static_array(field: &vkxml::Field) -> bool {
|
||||||
.map(|ty| match ty {
|
.map(|ty| match ty {
|
||||||
vkxml::ArrayType::Static => true,
|
vkxml::ArrayType::Static => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
}).unwrap_or(false)
|
||||||
.unwrap_or(false)
|
|
||||||
}
|
}
|
||||||
pub fn derive_default(_struct: &vkxml::Struct) -> Option<Tokens> {
|
pub fn derive_default(_struct: &vkxml::Struct) -> Option<Tokens> {
|
||||||
let name = name_to_tokens(&_struct.name);
|
let name = name_to_tokens(&_struct.name);
|
||||||
|
@ -1366,10 +1359,9 @@ pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
|
||||||
// Associated _count members
|
// Associated _count members
|
||||||
if field.array.is_some() {
|
if field.array.is_some() {
|
||||||
if let Some(ref array_size) = field.size {
|
if let Some(ref array_size) = field.size {
|
||||||
if !array_size.starts_with("latexmath")
|
if !array_size.starts_with("latexmath") && !nofilter_count_members
|
||||||
&& !nofilter_count_members
|
.iter()
|
||||||
.iter()
|
.any(|n| *n == &(_struct.name.clone() + "." + field_name))
|
||||||
.any(|n| *n == &(_struct.name.clone() + "." + field_name))
|
|
||||||
{
|
{
|
||||||
return Some((*array_size).clone());
|
return Some((*array_size).clone());
|
||||||
}
|
}
|
||||||
|
@ -1382,8 +1374,7 @@ pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
|
|
||||||
let setters = members.clone().filter_map(|field| {
|
let setters = members.clone().filter_map(|field| {
|
||||||
let param_ident = field.param_ident();
|
let param_ident = field.param_ident();
|
||||||
|
@ -1704,13 +1695,11 @@ pub fn generate_feature<'a>(
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
}).collect()
|
||||||
.collect()
|
|
||||||
} else {
|
} else {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
})
|
}).filter_map(|cmd_ref| commands.get(&cmd_ref.name))
|
||||||
.filter_map(|cmd_ref| commands.get(&cmd_ref.name))
|
|
||||||
.fold(
|
.fold(
|
||||||
(Vec::new(), Vec::new(), Vec::new(), Vec::new()),
|
(Vec::new(), Vec::new(), Vec::new(), Vec::new()),
|
||||||
|mut acc, &cmd_ref| {
|
|mut acc, &cmd_ref| {
|
||||||
|
@ -1873,59 +1862,57 @@ pub fn write_source_code(path: &Path) {
|
||||||
.filter_map(|item| match item {
|
.filter_map(|item| match item {
|
||||||
vk_parse::RegistryItem::Extensions { items: ext, .. } => Some(ext),
|
vk_parse::RegistryItem::Extensions { items: ext, .. } => Some(ext),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
}).nth(0)
|
||||||
.nth(0)
|
|
||||||
.expect("extension");
|
.expect("extension");
|
||||||
|
|
||||||
let spec = vk_parse::parse_file_as_vkxml(path);
|
let spec = vk_parse::parse_file_as_vkxml(path);
|
||||||
let commands: HashMap<vkxml::Identifier, &vkxml::Command> = spec.elements
|
let commands: HashMap<vkxml::Identifier, &vkxml::Command> = spec
|
||||||
|
.elements
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|elem| match elem {
|
.filter_map(|elem| match elem {
|
||||||
vkxml::RegistryElement::Commands(ref cmds) => Some(cmds),
|
vkxml::RegistryElement::Commands(ref cmds) => Some(cmds),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
}).flat_map(|cmds| cmds.elements.iter().map(|cmd| (cmd.name.clone(), cmd)))
|
||||||
.flat_map(|cmds| cmds.elements.iter().map(|cmd| (cmd.name.clone(), cmd)))
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let features: Vec<&vkxml::Feature> = spec.elements
|
let features: Vec<&vkxml::Feature> = spec
|
||||||
|
.elements
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|elem| match elem {
|
.filter_map(|elem| match elem {
|
||||||
vkxml::RegistryElement::Features(ref features) => Some(features),
|
vkxml::RegistryElement::Features(ref features) => Some(features),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
}).flat_map(|features| features.elements.iter())
|
||||||
.flat_map(|features| features.elements.iter())
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let definitions: Vec<&vkxml::DefinitionsElement> = spec.elements
|
let definitions: Vec<&vkxml::DefinitionsElement> = spec
|
||||||
|
.elements
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|elem| match elem {
|
.filter_map(|elem| match elem {
|
||||||
vkxml::RegistryElement::Definitions(ref definitions) => Some(definitions),
|
vkxml::RegistryElement::Definitions(ref definitions) => Some(definitions),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
}).flat_map(|definitions| definitions.elements.iter())
|
||||||
.flat_map(|definitions| definitions.elements.iter())
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let enums: Vec<&vkxml::Enumeration> = spec.elements
|
let enums: Vec<&vkxml::Enumeration> = spec
|
||||||
|
.elements
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|elem| match elem {
|
.filter_map(|elem| match elem {
|
||||||
vkxml::RegistryElement::Enums(ref enums) => Some(enums),
|
vkxml::RegistryElement::Enums(ref enums) => Some(enums),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
}).flat_map(|enums| {
|
||||||
.flat_map(|enums| {
|
|
||||||
enums.elements.iter().filter_map(|_enum| match *_enum {
|
enums.elements.iter().filter_map(|_enum| match *_enum {
|
||||||
vkxml::EnumsElement::Enumeration(ref e) => Some(e),
|
vkxml::EnumsElement::Enumeration(ref e) => Some(e),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
})
|
}).collect();
|
||||||
.collect();
|
|
||||||
|
|
||||||
let constants: Vec<&vkxml::Constant> = spec.elements
|
let constants: Vec<&vkxml::Constant> = spec
|
||||||
|
.elements
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|elem| match elem {
|
.filter_map(|elem| match elem {
|
||||||
vkxml::RegistryElement::Constants(ref constants) => Some(constants),
|
vkxml::RegistryElement::Constants(ref constants) => Some(constants),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
}).flat_map(|constants| constants.elements.iter())
|
||||||
.flat_map(|constants| constants.elements.iter())
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut fn_cache = HashSet::new();
|
let mut fn_cache = HashSet::new();
|
||||||
|
@ -1958,16 +1945,14 @@ pub fn write_source_code(path: &Path) {
|
||||||
&mut const_values,
|
&mut const_values,
|
||||||
&mut fn_cache,
|
&mut fn_cache,
|
||||||
)
|
)
|
||||||
})
|
}).collect_vec();
|
||||||
.collect_vec();
|
|
||||||
|
|
||||||
let union_types = definitions
|
let union_types = definitions
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|def| match def {
|
.filter_map(|def| match def {
|
||||||
vkxml::DefinitionsElement::Union(ref union) => Some(union.name.as_str()),
|
vkxml::DefinitionsElement::Union(ref union) => Some(union.name.as_str()),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
}).collect::<HashSet<&str>>();
|
||||||
.collect::<HashSet<&str>>();
|
|
||||||
|
|
||||||
let definition_code: Vec<_> = definitions
|
let definition_code: Vec<_> = definitions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
max_width = 100
|
max_width = 100
|
||||||
error_on_line_overflow = false
|
|
Loading…
Reference in a new issue