reformatted with fmt
This commit is contained in:
parent
2855192145
commit
046989ad75
|
@ -53,7 +53,6 @@ fn main() {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
let color_attachment_ref = vk::AttachmentReference {
|
let color_attachment_ref = vk::AttachmentReference {
|
||||||
attachment: 0,
|
attachment: 0,
|
||||||
layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
|
layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
|
||||||
|
@ -72,15 +71,12 @@ fn main() {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let subpass = vk::SubpassDescription::builder()
|
let subpass = vk::SubpassDescription::builder()
|
||||||
.color_attachments(&[color_attachment_ref])
|
.color_attachments(&[color_attachment_ref])
|
||||||
.depth_stencil_attachment(&depth_attachment_ref)
|
.depth_stencil_attachment(&depth_attachment_ref)
|
||||||
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS)
|
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
let renderpass_create_info = vk::RenderPassCreateInfo::builder()
|
let renderpass_create_info = vk::RenderPassCreateInfo::builder()
|
||||||
.attachments(&renderpass_attachments)
|
.attachments(&renderpass_attachments)
|
||||||
.subpasses(&[subpass])
|
.subpasses(&[subpass])
|
||||||
|
@ -384,22 +380,17 @@ fn main() {
|
||||||
&[],
|
&[],
|
||||||
&[texture_barrier],
|
&[texture_barrier],
|
||||||
);
|
);
|
||||||
let buffer_copy_regions = [
|
let buffer_copy_regions = [vk::BufferImageCopy::builder()
|
||||||
vk::BufferImageCopy::builder()
|
|
||||||
.image_subresource(
|
.image_subresource(
|
||||||
vk::ImageSubresourceLayers::builder()
|
vk::ImageSubresourceLayers::builder()
|
||||||
.aspect_mask(vk::ImageAspectFlags::COLOR)
|
.aspect_mask(vk::ImageAspectFlags::COLOR)
|
||||||
.layer_count(1)
|
.layer_count(1)
|
||||||
.build()
|
.build(),
|
||||||
)
|
).image_extent(vk::Extent3D {
|
||||||
.image_extent(
|
|
||||||
vk::Extent3D {
|
|
||||||
width: image_dimensions.0,
|
width: image_dimensions.0,
|
||||||
height: image_dimensions.1,
|
height: image_dimensions.1,
|
||||||
depth: 1,
|
depth: 1,
|
||||||
})
|
}).build()];
|
||||||
.build()
|
|
||||||
];
|
|
||||||
device.cmd_copy_buffer_to_image(
|
device.cmd_copy_buffer_to_image(
|
||||||
texture_command_buffer,
|
texture_command_buffer,
|
||||||
image_buffer,
|
image_buffer,
|
||||||
|
@ -564,9 +555,7 @@ fn main() {
|
||||||
.code(&vertex_bytes)
|
.code(&vertex_bytes)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let frag_bytes: Vec<u8> = frag_spv_file.bytes()
|
let frag_bytes: Vec<u8> = frag_spv_file.bytes().filter_map(|byte| byte.ok()).collect();
|
||||||
.filter_map(|byte| byte.ok())
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let frag_bytes = examples::bytes_to_u32_vec(frag_bytes.iter().cloned());
|
let frag_bytes = examples::bytes_to_u32_vec(frag_bytes.iter().cloned());
|
||||||
|
|
||||||
|
@ -752,8 +741,7 @@ fn main() {
|
||||||
.render_area(vk::Rect2D {
|
.render_area(vk::Rect2D {
|
||||||
offset: vk::Offset2D { x: 0, y: 0 },
|
offset: vk::Offset2D { x: 0, y: 0 },
|
||||||
extent: base.surface_resolution.clone(),
|
extent: base.surface_resolution.clone(),
|
||||||
})
|
}).clear_values(&clear_values)
|
||||||
.clear_values(&clear_values)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
record_submit_commandbuffer(
|
record_submit_commandbuffer(
|
||||||
|
|
|
@ -54,13 +54,12 @@ macro_rules! offset_of {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn u32_from_bytes(bytes: &[u8; 4]) -> u32 {
|
fn u32_from_bytes(bytes: &[u8; 4]) -> u32 {
|
||||||
unsafe {
|
unsafe { std::mem::transmute(*bytes) }
|
||||||
std::mem::transmute(*bytes)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bytes_to_u32_vec<B>(bytes: B) -> Vec<u32>
|
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 output = vec![];
|
||||||
let mut buffer: [u8; 4] = [0, 0, 0, 0];
|
let mut buffer: [u8; 4] = [0, 0, 0, 0];
|
||||||
|
@ -70,8 +69,8 @@ where B: Iterator<Item=u8>
|
||||||
buffer[3] = b;
|
buffer[3] = b;
|
||||||
output.push(u32_from_bytes(&buffer));
|
output.push(u32_from_bytes(&buffer));
|
||||||
buffer = [0, 0, 0, 0];
|
buffer = [0, 0, 0, 0];
|
||||||
},
|
}
|
||||||
idx => buffer[idx] = b
|
idx => buffer[idx] = b,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if buffer != [0, 0, 0, 0] {
|
if buffer != [0, 0, 0, 0] {
|
||||||
|
@ -80,7 +79,6 @@ where B: Iterator<Item=u8>
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn record_submit_commandbuffer<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffer)>(
|
pub fn record_submit_commandbuffer<D: DeviceV1_0, F: FnOnce(&D, vk::CommandBuffer)>(
|
||||||
device: &D,
|
device: &D,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
|
@ -383,9 +381,8 @@ impl ExampleBase {
|
||||||
.flags(
|
.flags(
|
||||||
vk::DebugReportFlagsEXT::ERROR
|
vk::DebugReportFlagsEXT::ERROR
|
||||||
| vk::DebugReportFlagsEXT::WARNING
|
| vk::DebugReportFlagsEXT::WARNING
|
||||||
| vk::DebugReportFlagsEXT::PERFORMANCE_WARNING
|
| vk::DebugReportFlagsEXT::PERFORMANCE_WARNING,
|
||||||
)
|
).build();
|
||||||
.build();
|
|
||||||
|
|
||||||
let debug_report_loader = DebugReport::new(&entry, &instance);
|
let debug_report_loader = DebugReport::new(&entry, &instance);
|
||||||
let debug_call_back = debug_report_loader
|
let debug_call_back = debug_report_loader
|
||||||
|
@ -512,7 +509,6 @@ impl ExampleBase {
|
||||||
.flags(vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER)
|
.flags(vk::CommandPoolCreateFlags::RESET_COMMAND_BUFFER)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
let pool = device.create_command_pool(&pool_create_info, None).unwrap();
|
let pool = device.create_command_pool(&pool_create_info, None).unwrap();
|
||||||
|
|
||||||
let command_buffer_allocate_info = vk::CommandBufferAllocateInfo::builder()
|
let command_buffer_allocate_info = vk::CommandBufferAllocateInfo::builder()
|
||||||
|
@ -539,9 +535,8 @@ impl ExampleBase {
|
||||||
.aspect_mask(vk::ImageAspectFlags::COLOR)
|
.aspect_mask(vk::ImageAspectFlags::COLOR)
|
||||||
.level_count(1)
|
.level_count(1)
|
||||||
.layer_count(1)
|
.layer_count(1)
|
||||||
.build()
|
.build(),
|
||||||
)
|
).image(image)
|
||||||
.image(image)
|
|
||||||
.format(surface_format.format)
|
.format(surface_format.format)
|
||||||
.view_type(vk::ImageViewType::TYPE_2D)
|
.view_type(vk::ImageViewType::TYPE_2D)
|
||||||
.build();
|
.build();
|
||||||
|
@ -556,9 +551,8 @@ impl ExampleBase {
|
||||||
.extent(vk::Extent3D {
|
.extent(vk::Extent3D {
|
||||||
width: surface_resolution.width,
|
width: surface_resolution.width,
|
||||||
height: surface_resolution.height,
|
height: surface_resolution.height,
|
||||||
depth: 1
|
depth: 1,
|
||||||
})
|
}).mip_levels(1)
|
||||||
.mip_levels(1)
|
|
||||||
.array_layers(1)
|
.array_layers(1)
|
||||||
.samples(vk::SampleCountFlags::TYPE_1)
|
.samples(vk::SampleCountFlags::TYPE_1)
|
||||||
.usage(vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT)
|
.usage(vk::ImageUsageFlags::DEPTH_STENCIL_ATTACHMENT)
|
||||||
|
@ -572,7 +566,6 @@ impl ExampleBase {
|
||||||
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::builder()
|
let depth_image_allocate_info = vk::MemoryAllocateInfo::builder()
|
||||||
.allocation_size(depth_image_memory_req.size)
|
.allocation_size(depth_image_memory_req.size)
|
||||||
.memory_type_index(depth_image_memory_index)
|
.memory_type_index(depth_image_memory_index)
|
||||||
|
@ -598,18 +591,16 @@ impl ExampleBase {
|
||||||
.image(depth_image)
|
.image(depth_image)
|
||||||
.dst_access_mask(
|
.dst_access_mask(
|
||||||
vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ
|
vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_READ
|
||||||
| vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE
|
| vk::AccessFlags::DEPTH_STENCIL_ATTACHMENT_WRITE,
|
||||||
)
|
).new_layout(vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL)
|
||||||
.new_layout(vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL)
|
|
||||||
.old_layout(vk::ImageLayout::UNDEFINED)
|
.old_layout(vk::ImageLayout::UNDEFINED)
|
||||||
.subresource_range(
|
.subresource_range(
|
||||||
vk::ImageSubresourceRange::builder()
|
vk::ImageSubresourceRange::builder()
|
||||||
.aspect_mask(vk::ImageAspectFlags::DEPTH)
|
.aspect_mask(vk::ImageAspectFlags::DEPTH)
|
||||||
.layer_count(1)
|
.layer_count(1)
|
||||||
.level_count(1)
|
.level_count(1)
|
||||||
.build()
|
.build(),
|
||||||
)
|
).build();
|
||||||
.build();
|
|
||||||
|
|
||||||
device.cmd_pipeline_barrier(
|
device.cmd_pipeline_barrier(
|
||||||
setup_command_buffer,
|
setup_command_buffer,
|
||||||
|
@ -629,9 +620,8 @@ impl ExampleBase {
|
||||||
.aspect_mask(vk::ImageAspectFlags::DEPTH)
|
.aspect_mask(vk::ImageAspectFlags::DEPTH)
|
||||||
.level_count(1)
|
.level_count(1)
|
||||||
.layer_count(1)
|
.layer_count(1)
|
||||||
.build()
|
.build(),
|
||||||
)
|
).image(depth_image)
|
||||||
.image(depth_image)
|
|
||||||
.format(depth_image_create_info.format)
|
.format(depth_image_create_info.format)
|
||||||
.view_type(vk::ImageViewType::TYPE_2D)
|
.view_type(vk::ImageViewType::TYPE_2D)
|
||||||
.build();
|
.build();
|
||||||
|
@ -640,7 +630,6 @@ impl ExampleBase {
|
||||||
.create_image_view(&depth_image_view_info, None)
|
.create_image_view(&depth_image_view_info, None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
||||||
let semaphore_create_info = vk::SemaphoreCreateInfo::default();
|
let semaphore_create_info = vk::SemaphoreCreateInfo::default();
|
||||||
|
|
||||||
let present_complete_semaphore = device
|
let present_complete_semaphore = device
|
||||||
|
|
Loading…
Reference in a new issue