reformatted with fmt
This commit is contained in:
parent
2855192145
commit
046989ad75
|
@ -53,7 +53,6 @@ fn main() {
|
|||
},
|
||||
];
|
||||
|
||||
|
||||
let color_attachment_ref = vk::AttachmentReference {
|
||||
attachment: 0,
|
||||
layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
|
||||
|
@ -72,15 +71,12 @@ fn main() {
|
|||
..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])
|
||||
|
@ -384,22 +380,17 @@ fn main() {
|
|||
&[],
|
||||
&[texture_barrier],
|
||||
);
|
||||
let buffer_copy_regions = [
|
||||
vk::BufferImageCopy::builder()
|
||||
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 {
|
||||
.build(),
|
||||
).image_extent(vk::Extent3D {
|
||||
width: image_dimensions.0,
|
||||
height: image_dimensions.1,
|
||||
depth: 1,
|
||||
})
|
||||
.build()
|
||||
];
|
||||
}).build()];
|
||||
device.cmd_copy_buffer_to_image(
|
||||
texture_command_buffer,
|
||||
image_buffer,
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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(
|
||||
|
|
|
@ -54,13 +54,12 @@ 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>
|
||||
where
|
||||
B: Iterator<Item = u8>,
|
||||
{
|
||||
let mut output = vec![];
|
||||
let mut buffer: [u8; 4] = [0, 0, 0, 0];
|
||||
|
@ -70,8 +69,8 @@ where B: Iterator<Item=u8>
|
|||
buffer[3] = b;
|
||||
output.push(u32_from_bytes(&buffer));
|
||||
buffer = [0, 0, 0, 0];
|
||||
},
|
||||
idx => buffer[idx] = b
|
||||
}
|
||||
idx => buffer[idx] = b,
|
||||
}
|
||||
}
|
||||
if buffer != [0, 0, 0, 0] {
|
||||
|
@ -80,7 +79,6 @@ where B: Iterator<Item=u8>
|
|||
output
|
||||
}
|
||||
|
||||
|
||||
pub fn record_submit_commandbuffer<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffer)>(
|
||||
device: &D,
|
||||
command_buffer: vk::CommandBuffer,
|
||||
|
@ -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
|
||||
|
@ -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