reformatted with fmt
This commit is contained in:
parent
2855192145
commit
046989ad75
|
@ -41,7 +41,7 @@ fn main() {
|
|||
load_op: vk::AttachmentLoadOp::CLEAR,
|
||||
store_op: vk::AttachmentStoreOp::STORE,
|
||||
final_layout: vk::ImageLayout::PRESENT_SRC_KHR,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
vk::AttachmentDescription {
|
||||
format: vk::Format::D16_UNORM,
|
||||
|
@ -49,11 +49,10 @@ fn main() {
|
|||
load_op: vk::AttachmentLoadOp::CLEAR,
|
||||
initial_layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||
final_layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
let color_attachment_ref = vk::AttachmentReference {
|
||||
attachment: 0,
|
||||
layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
|
||||
|
@ -69,21 +68,18 @@ fn main() {
|
|||
dst_access_mask: vk::AccessFlags::COLOR_ATTACHMENT_READ
|
||||
| vk::AccessFlags::COLOR_ATTACHMENT_WRITE,
|
||||
dst_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
|
||||
let subpass = vk::SubpassDescription::builder()
|
||||
.color_attachments(&[color_attachment_ref])
|
||||
.depth_stencil_attachment(&depth_attachment_ref)
|
||||
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS)
|
||||
.build();
|
||||
|
||||
|
||||
let renderpass_create_info = vk::RenderPassCreateInfo::builder()
|
||||
.attachments(&renderpass_attachments)
|
||||
.subpasses( &[subpass])
|
||||
.subpasses(&[subpass])
|
||||
.dependencies(&[dependency])
|
||||
.build();
|
||||
|
||||
|
@ -100,9 +96,9 @@ fn main() {
|
|||
let frame_buffer_create_info = vk::FramebufferCreateInfo::builder()
|
||||
.render_pass(renderpass)
|
||||
.attachments(&framebuffer_attachments)
|
||||
.width( base.surface_resolution.width)
|
||||
.height( base.surface_resolution.height)
|
||||
.layers( 1)
|
||||
.width(base.surface_resolution.width)
|
||||
.height(base.surface_resolution.height)
|
||||
.layers(1)
|
||||
.build();
|
||||
|
||||
base.device
|
||||
|
@ -114,7 +110,7 @@ fn main() {
|
|||
size: std::mem::size_of_val(&index_buffer_data) as u64,
|
||||
usage: vk::BufferUsageFlags::INDEX_BUFFER,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
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);
|
||||
|
@ -126,7 +122,7 @@ fn main() {
|
|||
let index_allocate_info = vk::MemoryAllocateInfo {
|
||||
allocation_size: index_buffer_memory_req.size,
|
||||
memory_type_index: index_buffer_memory_index,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let index_buffer_memory = base
|
||||
.device
|
||||
|
@ -173,7 +169,7 @@ fn main() {
|
|||
size: std::mem::size_of_val(&vertices) as u64,
|
||||
usage: vk::BufferUsageFlags::VERTEX_BUFFER,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let vertex_input_buffer = base
|
||||
.device
|
||||
|
@ -191,7 +187,7 @@ fn main() {
|
|||
let vertex_buffer_allocate_info = vk::MemoryAllocateInfo {
|
||||
allocation_size: vertex_input_buffer_memory_req.size,
|
||||
memory_type_index: vertex_input_buffer_memory_index,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let vertex_input_buffer_memory = base
|
||||
.device
|
||||
|
@ -227,7 +223,7 @@ fn main() {
|
|||
size: std::mem::size_of_val(&uniform_color_buffer_data) as u64,
|
||||
usage: vk::BufferUsageFlags::UNIFORM_BUFFER,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let uniform_color_buffer = base
|
||||
.device
|
||||
|
@ -245,7 +241,7 @@ fn main() {
|
|||
let uniform_color_buffer_allocate_info = vk::MemoryAllocateInfo {
|
||||
allocation_size: uniform_color_buffer_memory_req.size,
|
||||
memory_type_index: uniform_color_buffer_memory_index,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let uniform_color_buffer_memory = base
|
||||
.device
|
||||
|
@ -277,7 +273,7 @@ fn main() {
|
|||
size: (std::mem::size_of::<u8>() * image_data.len()) as u64,
|
||||
usage: vk::BufferUsageFlags::TRANSFER_SRC,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
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);
|
||||
|
@ -290,7 +286,7 @@ fn main() {
|
|||
let image_buffer_allocate_info = vk::MemoryAllocateInfo {
|
||||
allocation_size: image_buffer_memory_req.size,
|
||||
memory_type_index: image_buffer_memory_index,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let image_buffer_memory = base
|
||||
.device
|
||||
|
@ -329,7 +325,7 @@ fn main() {
|
|||
tiling: vk::ImageTiling::OPTIMAL,
|
||||
usage: vk::ImageUsageFlags::TRANSFER_DST | vk::ImageUsageFlags::SAMPLED,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let texture_image = base
|
||||
.device
|
||||
|
@ -345,7 +341,7 @@ fn main() {
|
|||
let texture_allocate_info = vk::MemoryAllocateInfo {
|
||||
allocation_size: texture_memory_req.size,
|
||||
memory_type_index: texture_memory_index,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let texture_memory = base
|
||||
.device
|
||||
|
@ -371,9 +367,9 @@ fn main() {
|
|||
aspect_mask: vk::ImageAspectFlags::COLOR,
|
||||
level_count: 1,
|
||||
layer_count: 1,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
device.cmd_pipeline_barrier(
|
||||
texture_command_buffer,
|
||||
|
@ -384,22 +380,17 @@ fn main() {
|
|||
&[],
|
||||
&[texture_barrier],
|
||||
);
|
||||
let buffer_copy_regions = [
|
||||
vk::BufferImageCopy::builder()
|
||||
.image_subresource(
|
||||
vk::ImageSubresourceLayers::builder()
|
||||
.aspect_mask( vk::ImageAspectFlags::COLOR)
|
||||
.layer_count(1)
|
||||
.build()
|
||||
)
|
||||
.image_extent(
|
||||
vk::Extent3D {
|
||||
width: image_dimensions.0,
|
||||
height: image_dimensions.1,
|
||||
depth: 1,
|
||||
})
|
||||
.build()
|
||||
];
|
||||
let buffer_copy_regions = [vk::BufferImageCopy::builder()
|
||||
.image_subresource(
|
||||
vk::ImageSubresourceLayers::builder()
|
||||
.aspect_mask(vk::ImageAspectFlags::COLOR)
|
||||
.layer_count(1)
|
||||
.build(),
|
||||
).image_extent(vk::Extent3D {
|
||||
width: image_dimensions.0,
|
||||
height: image_dimensions.1,
|
||||
depth: 1,
|
||||
}).build()];
|
||||
device.cmd_copy_buffer_to_image(
|
||||
texture_command_buffer,
|
||||
image_buffer,
|
||||
|
@ -417,9 +408,9 @@ fn main() {
|
|||
aspect_mask: vk::ImageAspectFlags::COLOR,
|
||||
level_count: 1,
|
||||
layer_count: 1,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
device.cmd_pipeline_barrier(
|
||||
texture_command_buffer,
|
||||
|
@ -441,7 +432,7 @@ fn main() {
|
|||
address_mode_v: vk::SamplerAddressMode::MIRRORED_REPEAT,
|
||||
address_mode_w: vk::SamplerAddressMode::MIRRORED_REPEAT,
|
||||
max_anisotropy: 1.0,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let sampler = base.device.create_sampler(&sampler_info, None).unwrap();
|
||||
|
@ -459,10 +450,10 @@ fn main() {
|
|||
aspect_mask: vk::ImageAspectFlags::COLOR,
|
||||
level_count: 1,
|
||||
layer_count: 1,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
image: texture_image,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let tex_image_view = base
|
||||
.device
|
||||
|
@ -491,14 +482,14 @@ fn main() {
|
|||
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
|
||||
descriptor_count: 1,
|
||||
stage_flags: vk::ShaderStageFlags::FRAGMENT,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
vk::DescriptorSetLayoutBinding {
|
||||
binding: 1,
|
||||
descriptor_type: vk::DescriptorType::COMBINED_IMAGE_SAMPLER,
|
||||
descriptor_count: 1,
|
||||
stage_flags: vk::ShaderStageFlags::FRAGMENT,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
let descriptor_info = vk::DescriptorSetLayoutCreateInfo::builder()
|
||||
|
@ -536,7 +527,7 @@ fn main() {
|
|||
descriptor_count: 1,
|
||||
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
|
||||
p_buffer_info: &uniform_color_buffer_descriptor,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
vk::WriteDescriptorSet {
|
||||
dst_set: descriptor_sets[0],
|
||||
|
@ -544,7 +535,7 @@ fn main() {
|
|||
descriptor_count: 1,
|
||||
descriptor_type: vk::DescriptorType::COMBINED_IMAGE_SAMPLER,
|
||||
p_image_info: &tex_descriptor,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
base.device.update_descriptor_sets(&write_desc_sets, &[]);
|
||||
|
@ -564,9 +555,7 @@ fn main() {
|
|||
.code(&vertex_bytes)
|
||||
.build();
|
||||
|
||||
let frag_bytes: Vec<u8> = frag_spv_file.bytes()
|
||||
.filter_map(|byte| byte.ok())
|
||||
.collect();
|
||||
let frag_bytes: Vec<u8> = frag_spv_file.bytes().filter_map(|byte| byte.ok()).collect();
|
||||
|
||||
let frag_bytes = examples::bytes_to_u32_vec(frag_bytes.iter().cloned());
|
||||
|
||||
|
@ -599,13 +588,13 @@ fn main() {
|
|||
module: vertex_shader_module,
|
||||
p_name: shader_entry_name.as_ptr(),
|
||||
stage: vk::ShaderStageFlags::VERTEX,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
vk::PipelineShaderStageCreateInfo {
|
||||
module: fragment_shader_module,
|
||||
p_name: shader_entry_name.as_ptr(),
|
||||
stage: vk::ShaderStageFlags::FRAGMENT,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
let vertex_input_binding_descriptions = [vk::VertexInputBindingDescription {
|
||||
|
@ -658,11 +647,11 @@ fn main() {
|
|||
front_face: vk::FrontFace::COUNTER_CLOCKWISE,
|
||||
line_width: 1.0,
|
||||
polygon_mode: vk::PolygonMode::FILL,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let multisample_state_info = vk::PipelineMultisampleStateCreateInfo::builder()
|
||||
.rasterization_samples( vk::SampleCountFlags::TYPE_1)
|
||||
.rasterization_samples(vk::SampleCountFlags::TYPE_1)
|
||||
.build();
|
||||
|
||||
let noop_stencil_state = vk::StencilOpState {
|
||||
|
@ -670,7 +659,7 @@ fn main() {
|
|||
pass_op: vk::StencilOp::KEEP,
|
||||
depth_fail_op: vk::StencilOp::KEEP,
|
||||
compare_op: vk::CompareOp::ALWAYS,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let depth_state_info = vk::PipelineDepthStencilStateCreateInfo {
|
||||
depth_test_enable: 1,
|
||||
|
@ -679,7 +668,7 @@ fn main() {
|
|||
front: noop_stencil_state.clone(),
|
||||
back: noop_stencil_state.clone(),
|
||||
max_depth_bounds: 1.0,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let color_blend_attachment_states = [vk::PipelineColorBlendAttachmentState {
|
||||
|
@ -752,8 +741,7 @@ fn main() {
|
|||
.render_area(vk::Rect2D {
|
||||
offset: vk::Offset2D { x: 0, y: 0 },
|
||||
extent: base.surface_resolution.clone(),
|
||||
})
|
||||
.clear_values(&clear_values)
|
||||
}).clear_values(&clear_values)
|
||||
.build();
|
||||
|
||||
record_submit_commandbuffer(
|
||||
|
@ -813,8 +801,8 @@ fn main() {
|
|||
|
||||
let present_info = vk::PresentInfoKHR::builder()
|
||||
.wait_semaphores(&[base.rendering_complete_semaphore])
|
||||
.swapchains( &[base.swapchain])
|
||||
.image_indices( &[present_index])
|
||||
.swapchains(&[base.swapchain])
|
||||
.image_indices(&[present_index])
|
||||
.build();
|
||||
|
||||
base.swapchain_loader
|
||||
|
|
|
@ -29,14 +29,14 @@ fn main() {
|
|||
load_op: vk::AttachmentLoadOp::CLEAR,
|
||||
store_op: vk::AttachmentStoreOp::STORE,
|
||||
final_layout: vk::ImageLayout::PRESENT_SRC_KHR,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
vk::AttachmentDescription {
|
||||
format: vk::Format::D16_UNORM,
|
||||
samples: vk::SampleCountFlags::TYPE_1,
|
||||
load_op: vk::AttachmentLoadOp::CLEAR,
|
||||
final_layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
let color_attachment_ref = vk::AttachmentReference {
|
||||
|
@ -53,11 +53,11 @@ fn main() {
|
|||
dst_access_mask: vk::AccessFlags::COLOR_ATTACHMENT_READ
|
||||
| vk::AccessFlags::COLOR_ATTACHMENT_WRITE,
|
||||
dst_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let subpass = vk::SubpassDescription::builder()
|
||||
.color_attachments( &[color_attachment_ref])
|
||||
.depth_stencil_attachment( &depth_attachment_ref)
|
||||
.color_attachments(&[color_attachment_ref])
|
||||
.depth_stencil_attachment(&depth_attachment_ref)
|
||||
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS)
|
||||
.build();
|
||||
|
||||
|
@ -78,9 +78,9 @@ fn main() {
|
|||
let frame_buffer_create_info = vk::FramebufferCreateInfo::builder()
|
||||
.render_pass(renderpass)
|
||||
.attachments(&framebuffer_attachments)
|
||||
.width( base.surface_resolution.width)
|
||||
.height( base.surface_resolution.height)
|
||||
.layers( 1)
|
||||
.width(base.surface_resolution.width)
|
||||
.height(base.surface_resolution.height)
|
||||
.layers(1)
|
||||
.build();
|
||||
base.device
|
||||
.create_framebuffer(&frame_buffer_create_info, None)
|
||||
|
@ -91,7 +91,7 @@ fn main() {
|
|||
size: std::mem::size_of_val(&index_buffer_data) as u64,
|
||||
usage: vk::BufferUsageFlags::INDEX_BUFFER,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
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);
|
||||
|
@ -103,7 +103,7 @@ fn main() {
|
|||
let index_allocate_info = vk::MemoryAllocateInfo {
|
||||
allocation_size: index_buffer_memory_req.size,
|
||||
memory_type_index: index_buffer_memory_index,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let index_buffer_memory = base
|
||||
.device
|
||||
|
@ -132,7 +132,7 @@ fn main() {
|
|||
size: 3 * std::mem::size_of::<Vertex>() as u64,
|
||||
usage: vk::BufferUsageFlags::VERTEX_BUFFER,
|
||||
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let vertex_input_buffer = base
|
||||
.device
|
||||
|
@ -150,7 +150,7 @@ fn main() {
|
|||
let vertex_buffer_allocate_info = vk::MemoryAllocateInfo {
|
||||
allocation_size: vertex_input_buffer_memory_req.size,
|
||||
memory_type_index: vertex_input_buffer_memory_index,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let vertex_input_buffer_memory = base
|
||||
.device
|
||||
|
@ -232,13 +232,13 @@ fn main() {
|
|||
module: vertex_shader_module,
|
||||
p_name: shader_entry_name.as_ptr(),
|
||||
stage: vk::ShaderStageFlags::VERTEX,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
vk::PipelineShaderStageCreateInfo {
|
||||
module: fragment_shader_module,
|
||||
p_name: shader_entry_name.as_ptr(),
|
||||
stage: vk::ShaderStageFlags::FRAGMENT,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
let vertex_input_binding_descriptions = [vk::VertexInputBindingDescription {
|
||||
|
@ -267,7 +267,7 @@ fn main() {
|
|||
|
||||
let vertex_input_assembly_state_info = vk::PipelineInputAssemblyStateCreateInfo {
|
||||
topology: vk::PrimitiveTopology::TRIANGLE_LIST,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let viewports = [vk::Viewport {
|
||||
x: 0.0,
|
||||
|
@ -289,18 +289,18 @@ fn main() {
|
|||
front_face: vk::FrontFace::COUNTER_CLOCKWISE,
|
||||
line_width: 1.0,
|
||||
polygon_mode: vk::PolygonMode::FILL,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let multisample_state_info = vk::PipelineMultisampleStateCreateInfo {
|
||||
rasterization_samples: vk::SampleCountFlags::TYPE_1,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let noop_stencil_state = vk::StencilOpState {
|
||||
fail_op: vk::StencilOp::KEEP,
|
||||
pass_op: vk::StencilOp::KEEP,
|
||||
depth_fail_op: vk::StencilOp::KEEP,
|
||||
compare_op: vk::CompareOp::ALWAYS,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let depth_state_info = vk::PipelineDepthStencilStateCreateInfo {
|
||||
depth_test_enable: 1,
|
||||
|
@ -309,7 +309,7 @@ fn main() {
|
|||
front: noop_stencil_state.clone(),
|
||||
back: noop_stencil_state.clone(),
|
||||
max_depth_bounds: 1.0,
|
||||
.. Default::default()
|
||||
..Default::default()
|
||||
};
|
||||
let color_blend_attachment_states = [vk::PipelineColorBlendAttachmentState {
|
||||
blend_enable: 0,
|
||||
|
@ -322,7 +322,7 @@ fn main() {
|
|||
color_write_mask: vk::ColorComponentFlags::all(),
|
||||
}];
|
||||
let color_blend_state = vk::PipelineColorBlendStateCreateInfo::builder()
|
||||
.logic_op( vk::LogicOp::CLEAR)
|
||||
.logic_op(vk::LogicOp::CLEAR)
|
||||
.attachments(&color_blend_attachment_states)
|
||||
.build();
|
||||
|
||||
|
@ -333,16 +333,16 @@ fn main() {
|
|||
|
||||
let graphic_pipeline_info = vk::GraphicsPipelineCreateInfo::builder()
|
||||
.stages(&shader_stage_create_infos)
|
||||
.vertex_input_state( &vertex_input_state_info)
|
||||
.input_assembly_state( &vertex_input_assembly_state_info)
|
||||
.viewport_state( &viewport_state_info)
|
||||
.rasterization_state( &rasterization_info)
|
||||
.multisample_state( &multisample_state_info)
|
||||
.depth_stencil_state( &depth_state_info)
|
||||
.color_blend_state( &color_blend_state)
|
||||
.dynamic_state( &dynamic_state_info)
|
||||
.layout( pipeline_layout)
|
||||
.render_pass( renderpass)
|
||||
.vertex_input_state(&vertex_input_state_info)
|
||||
.input_assembly_state(&vertex_input_assembly_state_info)
|
||||
.viewport_state(&viewport_state_info)
|
||||
.rasterization_state(&rasterization_info)
|
||||
.multisample_state(&multisample_state_info)
|
||||
.depth_stencil_state(&depth_state_info)
|
||||
.color_blend_state(&color_blend_state)
|
||||
.dynamic_state(&dynamic_state_info)
|
||||
.layout(pipeline_layout)
|
||||
.render_pass(renderpass)
|
||||
.build();
|
||||
let graphics_pipelines = base
|
||||
.device
|
||||
|
@ -433,9 +433,9 @@ fn main() {
|
|||
);
|
||||
//let mut present_info_err = mem::uninitialized();
|
||||
let present_info = vk::PresentInfoKHR::builder()
|
||||
.wait_semaphores( &[base.rendering_complete_semaphore])
|
||||
.swapchains( &[base.swapchain])
|
||||
.image_indices( &[present_index])
|
||||
.wait_semaphores(&[base.rendering_complete_semaphore])
|
||||
.swapchains(&[base.swapchain])
|
||||
.image_indices(&[present_index])
|
||||
.build();
|
||||
base.swapchain_loader
|
||||
.queue_present_khr(base.present_queue, &present_info)
|
||||
|
|
|
@ -54,33 +54,31 @@ macro_rules! offset_of {
|
|||
}
|
||||
|
||||
fn u32_from_bytes(bytes: &[u8; 4]) -> u32 {
|
||||
unsafe {
|
||||
std::mem::transmute(*bytes)
|
||||
}
|
||||
unsafe { std::mem::transmute(*bytes) }
|
||||
}
|
||||
|
||||
pub fn bytes_to_u32_vec<B>(bytes:B) -> Vec<u32>
|
||||
where B: Iterator<Item=u8>
|
||||
pub fn bytes_to_u32_vec<B>(bytes: B) -> Vec<u32>
|
||||
where
|
||||
B: Iterator<Item = u8>,
|
||||
{
|
||||
let mut output = vec![];
|
||||
let mut buffer: [u8;4] = [0,0,0,0];
|
||||
for (i,b) in bytes.enumerate() {
|
||||
let mut buffer: [u8; 4] = [0, 0, 0, 0];
|
||||
for (i, b) in bytes.enumerate() {
|
||||
match i % 4 {
|
||||
3 => {
|
||||
buffer[3] = b;
|
||||
output.push(u32_from_bytes(&buffer));
|
||||
buffer = [0,0,0,0];
|
||||
},
|
||||
idx => buffer[idx] = b
|
||||
buffer = [0, 0, 0, 0];
|
||||
}
|
||||
idx => buffer[idx] = b,
|
||||
}
|
||||
}
|
||||
if buffer != [0,0,0,0] {
|
||||
if buffer != [0, 0, 0, 0] {
|
||||
output.push(u32_from_bytes(&buffer));
|
||||
}
|
||||
output
|
||||
}
|
||||
|
||||
|
||||
pub fn record_submit_commandbuffer<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffer)>(
|
||||
device: &D,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
|
@ -361,17 +359,17 @@ impl ExampleBase {
|
|||
let extension_names_raw = extension_names();
|
||||
|
||||
let appinfo = vk::ApplicationInfo::builder()
|
||||
.application_name(&app_name )
|
||||
.application_name(&app_name)
|
||||
.application_version(0)
|
||||
.engine_name(&app_name)
|
||||
.engine_version(0)
|
||||
.api_version(vk_make_version!(1,0,36))
|
||||
.api_version(vk_make_version!(1, 0, 36))
|
||||
.build();
|
||||
|
||||
let create_info = vk::InstanceCreateInfo::builder()
|
||||
.application_info(&appinfo)
|
||||
.enabled_layer_names(&layers_names_raw)
|
||||
.enabled_extension_names(&extension_names_raw )
|
||||
.enabled_extension_names(&extension_names_raw)
|
||||
.build();
|
||||
|
||||
let instance: Instance = entry
|
||||
|
@ -383,9 +381,8 @@ impl ExampleBase {
|
|||
.flags(
|
||||
vk::DebugReportFlagsEXT::ERROR
|
||||
| vk::DebugReportFlagsEXT::WARNING
|
||||
| vk::DebugReportFlagsEXT::PERFORMANCE_WARNING
|
||||
)
|
||||
.build();
|
||||
| vk::DebugReportFlagsEXT::PERFORMANCE_WARNING,
|
||||
).build();
|
||||
|
||||
let debug_report_loader = DebugReport::new(&entry, &instance);
|
||||
let debug_call_back = debug_report_loader
|
||||
|
@ -428,7 +425,7 @@ impl ExampleBase {
|
|||
let priorities = [1.0];
|
||||
|
||||
let queue_info = vk::DeviceQueueCreateInfo::builder()
|
||||
.queue_family_index(queue_family_index as u32 )
|
||||
.queue_family_index(queue_family_index as u32)
|
||||
.queue_priorities(&priorities)
|
||||
.build();
|
||||
|
||||
|
@ -500,7 +497,7 @@ impl ExampleBase {
|
|||
.pre_transform(pre_transform)
|
||||
.composite_alpha(vk::CompositeAlphaFlagsKHR::OPAQUE)
|
||||
.present_mode(present_mode)
|
||||
// .clipped(true)
|
||||
// .clipped(true)
|
||||
.image_array_layers(1)
|
||||
.build();
|
||||
let swapchain = swapchain_loader
|
||||
|
@ -512,7 +509,6 @@ impl ExampleBase {
|
|||
.flags(vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER)
|
||||
.build();
|
||||
|
||||
|
||||
let pool = device.create_command_pool(&pool_create_info, None).unwrap();
|
||||
|
||||
let command_buffer_allocate_info = vk::CommandBufferAllocateInfo::builder()
|
||||
|
@ -539,9 +535,8 @@ impl ExampleBase {
|
|||
.aspect_mask(vk::ImageAspectFlags::COLOR)
|
||||
.level_count(1)
|
||||
.layer_count(1)
|
||||
.build()
|
||||
)
|
||||
.image(image)
|
||||
.build(),
|
||||
).image(image)
|
||||
.format(surface_format.format)
|
||||
.view_type(vk::ImageViewType::TYPE_2D)
|
||||
.build();
|
||||
|
@ -556,9 +551,8 @@ impl ExampleBase {
|
|||
.extent(vk::Extent3D {
|
||||
width: surface_resolution.width,
|
||||
height: surface_resolution.height,
|
||||
depth: 1
|
||||
})
|
||||
.mip_levels(1)
|
||||
depth: 1,
|
||||
}).mip_levels(1)
|
||||
.array_layers(1)
|
||||
.samples(vk::SampleCountFlags::TYPE_1)
|
||||
.usage(vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT)
|
||||
|
@ -572,7 +566,6 @@ impl ExampleBase {
|
|||
vk::MemoryPropertyFlags::DEVICE_LOCAL,
|
||||
).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)
|
||||
.memory_type_index(depth_image_memory_index)
|
||||
|
@ -598,18 +591,16 @@ impl ExampleBase {
|
|||
.image(depth_image)
|
||||
.dst_access_mask(
|
||||
vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ
|
||||
| vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE
|
||||
)
|
||||
.new_layout(vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL)
|
||||
| vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE,
|
||||
).new_layout(vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL)
|
||||
.old_layout(vk::ImageLayout::UNDEFINED)
|
||||
.subresource_range(
|
||||
vk::ImageSubresourceRange::builder()
|
||||
.aspect_mask(vk::ImageAspectFlags::DEPTH)
|
||||
.layer_count(1)
|
||||
.level_count(1)
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
.build(),
|
||||
).build();
|
||||
|
||||
device.cmd_pipeline_barrier(
|
||||
setup_command_buffer,
|
||||
|
@ -629,9 +620,8 @@ impl ExampleBase {
|
|||
.aspect_mask(vk::ImageAspectFlags::DEPTH)
|
||||
.level_count(1)
|
||||
.layer_count(1)
|
||||
.build()
|
||||
)
|
||||
.image(depth_image)
|
||||
.build(),
|
||||
).image(depth_image)
|
||||
.format(depth_image_create_info.format)
|
||||
.view_type(vk::ImageViewType::TYPE_2D)
|
||||
.build();
|
||||
|
@ -640,7 +630,6 @@ impl ExampleBase {
|
|||
.create_image_view(&depth_image_view_info, None)
|
||||
.unwrap();
|
||||
|
||||
|
||||
let semaphore_create_info = vk::SemaphoreCreateInfo::default();
|
||||
|
||||
let present_complete_semaphore = device
|
||||
|
|
Loading…
Reference in a new issue