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