commit
65040ecbea
|
@ -5,7 +5,7 @@ os:
|
||||||
language: rust
|
language: rust
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- rustup component add rustfmt-preview
|
- rustup component add rustfmt
|
||||||
|
|
||||||
rust:
|
rust:
|
||||||
- stable
|
- stable
|
||||||
|
|
|
@ -17,11 +17,7 @@ const LIB_PATH: &'static str = "vulkan-1.dll";
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
unix,
|
unix,
|
||||||
not(any(
|
not(any(target_os = "macos", target_os = "ios", target_os = "android"))
|
||||||
target_os = "macos",
|
|
||||||
target_os = "ios",
|
|
||||||
target_os = "android"
|
|
||||||
))
|
|
||||||
))]
|
))]
|
||||||
const LIB_PATH: &'static str = "libvulkan.so.1";
|
const LIB_PATH: &'static str = "libvulkan.so.1";
|
||||||
|
|
||||||
|
|
1353
ash/src/vk.rs
1353
ash/src/vk.rs
File diff suppressed because it is too large
Load diff
|
@ -121,7 +121,8 @@ 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,
|
||||||
|
@ -139,7 +140,8 @@ fn main() {
|
||||||
&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(),
|
||||||
|
@ -157,7 +159,8 @@ 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,
|
||||||
|
@ -208,7 +211,8 @@ fn main() {
|
||||||
&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,
|
||||||
|
@ -227,7 +231,8 @@ 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,
|
||||||
|
@ -266,7 +271,8 @@ fn main() {
|
||||||
&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,
|
||||||
|
@ -285,7 +291,8 @@ 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,
|
||||||
|
@ -316,7 +323,8 @@ fn main() {
|
||||||
&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,
|
||||||
|
@ -335,7 +343,8 @@ 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,
|
||||||
|
@ -377,7 +386,8 @@ fn main() {
|
||||||
&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,
|
||||||
|
@ -872,7 +882,8 @@ 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,7 +110,8 @@ 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,
|
||||||
|
@ -128,7 +129,8 @@ fn main() {
|
||||||
&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(),
|
||||||
|
@ -146,7 +148,8 @@ 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,
|
||||||
|
@ -179,7 +182,8 @@ fn main() {
|
||||||
&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,
|
||||||
|
@ -212,7 +216,8 @@ 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,
|
||||||
|
@ -462,7 +467,8 @@ 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 {
|
||||||
|
|
|
@ -67,7 +67,8 @@ pub fn record_submit_commandbuffer<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffe
|
||||||
.reset_command_buffer(
|
.reset_command_buffer(
|
||||||
command_buffer,
|
command_buffer,
|
||||||
vk::CommandBufferResetFlags::RELEASE_RESOURCES,
|
vk::CommandBufferResetFlags::RELEASE_RESOURCES,
|
||||||
).expect("Reset command buffer failed.");
|
)
|
||||||
|
.expect("Reset command buffer failed.");
|
||||||
let command_buffer_begin_info = vk::CommandBufferBeginInfo {
|
let command_buffer_begin_info = vk::CommandBufferBeginInfo {
|
||||||
s_type: vk::StructureType::COMMAND_BUFFER_BEGIN_INFO,
|
s_type: vk::StructureType::COMMAND_BUFFER_BEGIN_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
|
@ -330,7 +331,8 @@ impl ExampleBase {
|
||||||
.with_dimensions(winit::dpi::LogicalSize::new(
|
.with_dimensions(winit::dpi::LogicalSize::new(
|
||||||
window_width as f64,
|
window_width as f64,
|
||||||
window_height as f64,
|
window_height as f64,
|
||||||
)).build(&events_loop)
|
))
|
||||||
|
.build(&events_loop)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let entry = Entry::new().unwrap();
|
let entry = Entry::new().unwrap();
|
||||||
let app_name = CString::new("VulkanTriangle").unwrap();
|
let app_name = CString::new("VulkanTriangle").unwrap();
|
||||||
|
@ -402,8 +404,10 @@ impl ExampleBase {
|
||||||
true => Some((*pdevice, index)),
|
true => Some((*pdevice, index)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}).nth(0)
|
})
|
||||||
}).filter_map(|v| v)
|
.nth(0)
|
||||||
|
})
|
||||||
|
.filter_map(|v| v)
|
||||||
.nth(0)
|
.nth(0)
|
||||||
.expect("Couldn't find suitable device.");
|
.expect("Couldn't find suitable device.");
|
||||||
let queue_family_index = queue_family_index as u32;
|
let queue_family_index = queue_family_index as u32;
|
||||||
|
@ -449,7 +453,8 @@ impl ExampleBase {
|
||||||
color_space: sfmt.color_space,
|
color_space: sfmt.color_space,
|
||||||
},
|
},
|
||||||
_ => sfmt.clone(),
|
_ => sfmt.clone(),
|
||||||
}).nth(0)
|
})
|
||||||
|
.nth(0)
|
||||||
.expect("Unable to find suitable surface format.");
|
.expect("Unable to find suitable surface format.");
|
||||||
let surface_capabilities = surface_loader
|
let surface_capabilities = surface_loader
|
||||||
.get_physical_device_surface_capabilities(pdevice, surface)
|
.get_physical_device_surface_capabilities(pdevice, surface)
|
||||||
|
@ -553,7 +558,8 @@ impl ExampleBase {
|
||||||
image: image,
|
image: image,
|
||||||
};
|
};
|
||||||
device.create_image_view(&create_view_info, None).unwrap()
|
device.create_image_view(&create_view_info, None).unwrap()
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
let device_memory_properties = instance.get_physical_device_memory_properties(pdevice);
|
let device_memory_properties = instance.get_physical_device_memory_properties(pdevice);
|
||||||
let depth_image_create_info = vk::ImageCreateInfo {
|
let depth_image_create_info = vk::ImageCreateInfo {
|
||||||
s_type: vk::StructureType::IMAGE_CREATE_INFO,
|
s_type: vk::StructureType::IMAGE_CREATE_INFO,
|
||||||
|
@ -582,7 +588,8 @@ impl ExampleBase {
|
||||||
&depth_image_memory_req,
|
&depth_image_memory_req,
|
||||||
&device_memory_properties,
|
&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 depth_image_allocate_info = vk::MemoryAllocateInfo {
|
let depth_image_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
|
|
|
@ -539,7 +539,8 @@ impl CommandExt for vkxml::Command {
|
||||||
.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"
|
||||||
|
@ -704,7 +705,8 @@ 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()
|
||||||
|
@ -716,9 +718,11 @@ fn generate_function_pointers<'a>(
|
||||||
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()
|
||||||
|
@ -727,7 +731,8 @@ 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()
|
||||||
|
@ -738,7 +743,8 @@ 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,7 +755,8 @@ 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
|
||||||
|
@ -774,9 +781,11 @@ fn generate_function_pointers<'a>(
|
||||||
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
|
||||||
|
@ -867,7 +876,8 @@ pub fn generate_extension_constants<'a>(
|
||||||
.filter_map(|item| match item {
|
.filter_map(|item| match item {
|
||||||
vk_parse::ExtensionChild::Require { items, .. } => Some(items.iter()),
|
vk_parse::ExtensionChild::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;
|
||||||
|
@ -937,7 +947,8 @@ 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..]);
|
||||||
|
@ -1051,7 +1062,8 @@ 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| {
|
||||||
|
@ -1093,7 +1105,8 @@ 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());
|
||||||
|
@ -1202,7 +1215,8 @@ 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);
|
||||||
|
@ -1369,11 +1383,13 @@ pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
|
||||||
.clone()
|
.clone()
|
||||||
.find(|field| field.param_ident().to_string() == "p_next")
|
.find(|field| field.param_ident().to_string() == "p_next")
|
||||||
{
|
{
|
||||||
Some(p_next) => if p_next.type_tokens().to_string().starts_with("*const") {
|
Some(p_next) => {
|
||||||
|
if p_next.type_tokens().to_string().starts_with("*const") {
|
||||||
(true, true)
|
(true, true)
|
||||||
} else {
|
} else {
|
||||||
(true, false)
|
(true, false)
|
||||||
},
|
}
|
||||||
|
}
|
||||||
None => (false, false),
|
None => (false, false),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1390,7 +1406,8 @@ 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") && !nofilter_count_members
|
if !array_size.starts_with("latexmath")
|
||||||
|
&& !nofilter_count_members
|
||||||
.iter()
|
.iter()
|
||||||
.any(|n| *n == &(_struct.name.clone() + "." + field_name))
|
.any(|n| *n == &(_struct.name.clone() + "." + field_name))
|
||||||
{
|
{
|
||||||
|
@ -1405,7 +1422,8 @@ 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();
|
||||||
|
@ -1770,11 +1788,13 @@ 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| {
|
||||||
|
@ -1939,7 +1959,8 @@ pub fn generate_aliases_of_types<'a>(
|
||||||
.filter_map(|child| match child {
|
.filter_map(|child| match child {
|
||||||
vk_parse::TypesChild::Type(ty) => Some((ty.name.as_ref()?, ty.alias.as_ref()?)),
|
vk_parse::TypesChild::Type(ty) => Some((ty.name.as_ref()?, ty.alias.as_ref()?)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}).filter_map(|(name, alias)| {
|
})
|
||||||
|
.filter_map(|(name, alias)| {
|
||||||
let name_ident = name_to_tokens(name);
|
let name_ident = name_to_tokens(name);
|
||||||
if ty_cache.contains(&name_ident) {
|
if ty_cache.contains(&name_ident) {
|
||||||
return None;
|
return None;
|
||||||
|
@ -1965,7 +1986,8 @@ pub fn write_source_code(path: &Path) {
|
||||||
.filter_map(|item| match item {
|
.filter_map(|item| match item {
|
||||||
vk_parse::RegistryChild::Extensions(ref ext) => Some(&ext.children),
|
vk_parse::RegistryChild::Extensions(ref ext) => Some(&ext.children),
|
||||||
_ => None,
|
_ => None,
|
||||||
}).nth(0)
|
})
|
||||||
|
.nth(0)
|
||||||
.expect("extension");
|
.expect("extension");
|
||||||
let mut ty_cache = HashSet::new();
|
let mut ty_cache = HashSet::new();
|
||||||
let aliases: Vec<_> = spec2
|
let aliases: Vec<_> = spec2
|
||||||
|
@ -1976,7 +1998,8 @@ pub fn write_source_code(path: &Path) {
|
||||||
Some(generate_aliases_of_types(ty, &mut ty_cache))
|
Some(generate_aliases_of_types(ty, &mut ty_cache))
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
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
|
let commands: HashMap<vkxml::Identifier, &vkxml::Command> = spec
|
||||||
|
@ -1985,7 +2008,8 @@ pub fn write_source_code(path: &Path) {
|
||||||
.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
|
let features: Vec<&vkxml::Feature> = spec
|
||||||
|
@ -1994,7 +2018,8 @@ pub fn write_source_code(path: &Path) {
|
||||||
.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
|
let definitions: Vec<&vkxml::DefinitionsElement> = spec
|
||||||
|
@ -2003,7 +2028,8 @@ pub fn write_source_code(path: &Path) {
|
||||||
.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
|
let enums: Vec<&vkxml::Enumeration> = spec
|
||||||
|
@ -2012,12 +2038,14 @@ pub fn write_source_code(path: &Path) {
|
||||||
.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
|
let constants: Vec<&vkxml::Constant> = spec
|
||||||
.elements
|
.elements
|
||||||
|
@ -2025,7 +2053,8 @@ pub fn write_source_code(path: &Path) {
|
||||||
.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();
|
||||||
|
@ -2059,14 +2088,16 @@ 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()
|
||||||
|
|
Loading…
Reference in a new issue