reformatting via rust fmt
This commit is contained in:
parent
5dfd07098c
commit
962f1ba830
3 changed files with 170 additions and 148 deletions
|
@ -100,7 +100,8 @@ 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 {
|
||||
size: std::mem::size_of_val(&index_buffer_data) as u64,
|
||||
|
@ -114,7 +115,8 @@ fn main() {
|
|||
&index_buffer_memory_req,
|
||||
&base.device_memory_properties,
|
||||
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 {
|
||||
allocation_size: index_buffer_memory_req.size,
|
||||
memory_type_index: index_buffer_memory_index,
|
||||
|
@ -131,7 +133,8 @@ 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,7 +181,8 @@ fn main() {
|
|||
&vertex_input_buffer_memory_req,
|
||||
&base.device_memory_properties,
|
||||
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 {
|
||||
allocation_size: vertex_input_buffer_memory_req.size,
|
||||
|
@ -197,7 +201,8 @@ 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,
|
||||
|
@ -232,7 +237,8 @@ fn main() {
|
|||
&uniform_color_buffer_memory_req,
|
||||
&base.device_memory_properties,
|
||||
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 {
|
||||
allocation_size: uniform_color_buffer_memory_req.size,
|
||||
|
@ -250,7 +256,8 @@ 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,
|
||||
|
@ -277,7 +284,8 @@ fn main() {
|
|||
&image_buffer_memory_req,
|
||||
&base.device_memory_properties,
|
||||
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 {
|
||||
allocation_size: image_buffer_memory_req.size,
|
||||
|
@ -295,7 +303,8 @@ 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,
|
||||
|
@ -332,7 +341,8 @@ fn main() {
|
|||
&texture_memory_req,
|
||||
&base.device_memory_properties,
|
||||
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 {
|
||||
allocation_size: texture_memory_req.size,
|
||||
|
@ -492,8 +502,8 @@ fn main() {
|
|||
..Default::default()
|
||||
},
|
||||
];
|
||||
let descriptor_info = vk::DescriptorSetLayoutCreateInfo::builder()
|
||||
.bindings(&desc_layout_bindings);
|
||||
let descriptor_info =
|
||||
vk::DescriptorSetLayoutCreateInfo::builder().bindings(&desc_layout_bindings);
|
||||
|
||||
let desc_set_layouts = [base
|
||||
.device
|
||||
|
@ -565,8 +575,8 @@ fn main() {
|
|||
.create_shader_module(&frag_shader_info, None)
|
||||
.expect("Fragment shader module error");
|
||||
|
||||
let layout_create_info = vk::PipelineLayoutCreateInfo::builder()
|
||||
.set_layouts(&desc_set_layouts);
|
||||
let layout_create_info =
|
||||
vk::PipelineLayoutCreateInfo::builder().set_layouts(&desc_set_layouts);
|
||||
|
||||
let pipeline_layout = base
|
||||
.device
|
||||
|
@ -678,8 +688,8 @@ fn main() {
|
|||
.attachments(&color_blend_attachment_states);
|
||||
|
||||
let dynamic_state = [vk::DynamicState::VIEWPORT, vk::DynamicState::SCISSOR];
|
||||
let dynamic_state_info = vk::PipelineDynamicStateCreateInfo::builder()
|
||||
.dynamic_states(&dynamic_state);
|
||||
let dynamic_state_info =
|
||||
vk::PipelineDynamicStateCreateInfo::builder().dynamic_states(&dynamic_state);
|
||||
|
||||
let graphic_pipeline_info = vk::GraphicsPipelineCreateInfo::builder()
|
||||
.stages(&shader_stage_create_infos)
|
||||
|
@ -710,7 +720,8 @@ fn main() {
|
|||
std::u64::MAX,
|
||||
base.present_complete_semaphore,
|
||||
vk::Fence::null(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
let clear_values = [
|
||||
vk::ClearValue {
|
||||
color: vk::ClearColorValue {
|
||||
|
|
|
@ -88,7 +88,8 @@ 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::builder()
|
||||
|
@ -102,7 +103,8 @@ fn main() {
|
|||
&index_buffer_memory_req,
|
||||
&base.device_memory_properties,
|
||||
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 {
|
||||
allocation_size: index_buffer_memory_req.size,
|
||||
|
@ -120,7 +122,8 @@ 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,
|
||||
|
@ -152,7 +155,8 @@ fn main() {
|
|||
&vertex_input_buffer_memory_req,
|
||||
&base.device_memory_properties,
|
||||
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 {
|
||||
allocation_size: vertex_input_buffer_memory_req.size,
|
||||
|
@ -187,7 +191,8 @@ fn main() {
|
|||
0,
|
||||
vertex_input_buffer_memory_req.size,
|
||||
vk::MemoryMapFlags::empty(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut vert_align = Align::new(
|
||||
vert_ptr,
|
||||
|
@ -279,7 +284,6 @@ fn main() {
|
|||
let vertex_input_assembly_state_info = vk::PipelineInputAssemblyStateCreateInfo {
|
||||
topology: vk::PrimitiveTopology::TRIANGLE_LIST,
|
||||
..Default::default()
|
||||
|
||||
};
|
||||
let viewports = [vk::Viewport {
|
||||
x: 0.0,
|
||||
|
@ -338,9 +342,8 @@ fn main() {
|
|||
.attachments(&color_blend_attachment_states);
|
||||
|
||||
let dynamic_state = [vk::DynamicState::VIEWPORT, vk::DynamicState::SCISSOR];
|
||||
let dynamic_state_info = vk::PipelineDynamicStateCreateInfo::builder()
|
||||
.dynamic_states(&dynamic_state);
|
||||
|
||||
let dynamic_state_info =
|
||||
vk::PipelineDynamicStateCreateInfo::builder().dynamic_states(&dynamic_state);
|
||||
|
||||
let graphic_pipeline_info = vk::GraphicsPipelineCreateInfo::builder()
|
||||
.stages(&shader_stage_create_infos)
|
||||
|
@ -356,7 +359,6 @@ fn main() {
|
|||
.render_pass(renderpass)
|
||||
.build();
|
||||
|
||||
|
||||
let graphics_pipelines = base
|
||||
.device
|
||||
.create_graphics_pipelines(vk::PipelineCache::null(), &[graphic_pipeline_info], None)
|
||||
|
@ -372,7 +374,8 @@ fn main() {
|
|||
std::u64::MAX,
|
||||
base.present_complete_semaphore,
|
||||
vk::Fence::null(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
let clear_values = [
|
||||
vk::ClearValue {
|
||||
color: vk::ClearColorValue {
|
||||
|
|
|
@ -36,7 +36,7 @@ use ash::extensions::khr::Win32Surface;
|
|||
use ash::extensions::mvk::MacOSSurface;
|
||||
pub use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0};
|
||||
use ash::{vk, Device, Entry, Instance};
|
||||
use byteorder::{LittleEndian, BigEndian, ReadBytesExt};
|
||||
use byteorder::{BigEndian, LittleEndian, ReadBytesExt};
|
||||
use std::cell::RefCell;
|
||||
use std::default::Default;
|
||||
use std::ffi::{CStr, CString};
|
||||
|
@ -45,7 +45,6 @@ use std::ops::Drop;
|
|||
use std::os::raw::{c_char, c_void};
|
||||
use std::ptr;
|
||||
|
||||
|
||||
const MAGIC_NUMBER: u32 = 0x07230203;
|
||||
|
||||
fn spirv_is_little_endian(bytes: &[u8]) -> bool {
|
||||
|
@ -131,7 +130,8 @@ pub fn record_submit_commandbuffer<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffe
|
|||
.reset_command_buffer(
|
||||
command_buffer,
|
||||
vk::CommandBufferResetFlags::RELEASE_RESOURCES,
|
||||
).expect("Reset command buffer failed.");
|
||||
)
|
||||
.expect("Reset command buffer failed.");
|
||||
let command_buffer_begin_info = vk::CommandBufferBeginInfo::builder()
|
||||
.flags(vk::CommandBufferUsageFlags::ONE_TIME_SUBMIT);
|
||||
|
||||
|
@ -384,7 +384,8 @@ impl ExampleBase {
|
|||
.with_dimensions(winit::dpi::LogicalSize::new(
|
||||
window_width as f64,
|
||||
window_height as f64,
|
||||
)).build(&events_loop)
|
||||
))
|
||||
.build(&events_loop)
|
||||
.unwrap();
|
||||
let entry = Entry::new().unwrap();
|
||||
let app_name = CString::new("VulkanTriangle").unwrap();
|
||||
|
@ -419,7 +420,8 @@ impl ExampleBase {
|
|||
.flags(
|
||||
vk::DebugReportFlagsEXT::ERROR
|
||||
| vk::DebugReportFlagsEXT::WARNING
|
||||
| vk::DebugReportFlagsEXT::PERFORMANCE_WARNING)
|
||||
| vk::DebugReportFlagsEXT::PERFORMANCE_WARNING,
|
||||
)
|
||||
.pfn_callback(Some(vulkan_debug_callback));
|
||||
|
||||
let debug_report_loader = DebugReport::new(&entry, &instance);
|
||||
|
@ -450,8 +452,10 @@ impl ExampleBase {
|
|||
true => Some((*pdevice, index)),
|
||||
_ => None,
|
||||
}
|
||||
}).nth(0)
|
||||
}).filter_map(|v| v)
|
||||
})
|
||||
.nth(0)
|
||||
})
|
||||
.filter_map(|v| v)
|
||||
.nth(0)
|
||||
.expect("Couldn't find suitable device.");
|
||||
let queue_family_index = queue_family_index as u32;
|
||||
|
@ -488,7 +492,8 @@ impl ExampleBase {
|
|||
color_space: sfmt.color_space,
|
||||
},
|
||||
_ => sfmt.clone(),
|
||||
}).nth(0)
|
||||
})
|
||||
.nth(0)
|
||||
.expect("Unable to find suitable surface format.");
|
||||
let surface_capabilities = surface_loader
|
||||
.get_physical_device_surface_capabilities(pdevice, surface)
|
||||
|
@ -581,7 +586,8 @@ impl ExampleBase {
|
|||
})
|
||||
.image(image);
|
||||
device.create_image_view(&create_view_info, None).unwrap()
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
let device_memory_properties = instance.get_physical_device_memory_properties(pdevice);
|
||||
let depth_image_create_info = vk::ImageCreateInfo::builder()
|
||||
.image_type(vk::ImageType::TYPE_2D)
|
||||
|
@ -604,7 +610,8 @@ impl ExampleBase {
|
|||
&depth_image_memory_req,
|
||||
&device_memory_properties,
|
||||
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::builder()
|
||||
.allocation_size(depth_image_memory_req.size)
|
||||
|
@ -624,6 +631,7 @@ impl ExampleBase {
|
|||
setup_command_buffer,
|
||||
present_queue,
|
||||
&[],
|
||||
// &[vk::PipelineStageFlags::BOTTOM_OF_PIPE],
|
||||
&[],
|
||||
&[],
|
||||
|device, setup_command_buffer| {
|
||||
|
|
Loading…
Add table
Reference in a new issue