Update example with the new ClearValue union
This commit is contained in:
parent
1b612cb1bf
commit
0a8f335206
|
@ -864,12 +864,19 @@ fn main() {
|
||||||
base.present_complete_semaphore,
|
base.present_complete_semaphore,
|
||||||
vk::Fence::null())
|
vk::Fence::null())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let clear_values =
|
let clear_values = [
|
||||||
[vk::ClearValue::new_color(vk::ClearColorValue::new_float32([0.0, 0.0, 0.0, 0.0])),
|
vk::ClearValue {
|
||||||
vk::ClearValue::new_depth_stencil(vk::ClearDepthStencilValue {
|
color: vk::ClearColorValue {
|
||||||
depth: 1.0,
|
float32: [0.0, 0.0, 0.0, 0.0],
|
||||||
stencil: 0,
|
},
|
||||||
})];
|
},
|
||||||
|
vk::ClearValue {
|
||||||
|
depth: vk::ClearDepthStencilValue {
|
||||||
|
depth: 1.0,
|
||||||
|
stencil: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
let render_pass_begin_info = vk::RenderPassBeginInfo {
|
let render_pass_begin_info = vk::RenderPassBeginInfo {
|
||||||
s_type: vk::StructureType::RenderPassBeginInfo,
|
s_type: vk::StructureType::RenderPassBeginInfo,
|
||||||
|
|
|
@ -61,8 +61,8 @@ fn main() {
|
||||||
dst_subpass: Default::default(),
|
dst_subpass: Default::default(),
|
||||||
src_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
src_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
src_access_mask: Default::default(),
|
src_access_mask: Default::default(),
|
||||||
dst_access_mask: vk::ACCESS_COLOR_ATTACHMENT_READ_BIT |
|
dst_access_mask: vk::ACCESS_COLOR_ATTACHMENT_READ_BIT
|
||||||
vk::ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
| vk::ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
dst_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
dst_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
};
|
};
|
||||||
let subpass = vk::SubpassDescription {
|
let subpass = vk::SubpassDescription {
|
||||||
|
@ -171,9 +171,8 @@ fn main() {
|
||||||
let vertex_input_buffer = base.device
|
let vertex_input_buffer = base.device
|
||||||
.create_buffer(&vertex_input_buffer_info, None)
|
.create_buffer(&vertex_input_buffer_info, None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let vertex_input_buffer_memory_req = base.device.get_buffer_memory_requirements(
|
let vertex_input_buffer_memory_req = base.device
|
||||||
vertex_input_buffer,
|
.get_buffer_memory_requirements(vertex_input_buffer);
|
||||||
);
|
|
||||||
let vertex_input_buffer_memory_index =
|
let vertex_input_buffer_memory_index =
|
||||||
find_memorytype_index(
|
find_memorytype_index(
|
||||||
&vertex_input_buffer_memory_req,
|
&vertex_input_buffer_memory_req,
|
||||||
|
@ -457,20 +456,28 @@ fn main() {
|
||||||
|
|
||||||
let graphic_pipeline = graphics_pipelines[0];
|
let graphic_pipeline = graphics_pipelines[0];
|
||||||
|
|
||||||
|
|
||||||
base.render_loop(|| {
|
base.render_loop(|| {
|
||||||
let present_index = base.swapchain_loader
|
let present_index = base.swapchain_loader
|
||||||
.acquire_next_image_khr(base.swapchain,
|
.acquire_next_image_khr(
|
||||||
std::u64::MAX,
|
base.swapchain,
|
||||||
base.present_complete_semaphore,
|
std::u64::MAX,
|
||||||
vk::Fence::null())
|
base.present_complete_semaphore,
|
||||||
|
vk::Fence::null(),
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let clear_values =
|
let clear_values = [
|
||||||
[vk::ClearValue::new_color(vk::ClearColorValue::new_float32([0.0, 0.0, 0.0, 0.0])),
|
vk::ClearValue {
|
||||||
vk::ClearValue::new_depth_stencil(vk::ClearDepthStencilValue {
|
color: vk::ClearColorValue {
|
||||||
depth: 1.0,
|
float32: [0.0, 0.0, 0.0, 0.0],
|
||||||
stencil: 0,
|
},
|
||||||
})];
|
},
|
||||||
|
vk::ClearValue {
|
||||||
|
depth: vk::ClearDepthStencilValue {
|
||||||
|
depth: 1.0,
|
||||||
|
stencil: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
let render_pass_begin_info = vk::RenderPassBeginInfo {
|
let render_pass_begin_info = vk::RenderPassBeginInfo {
|
||||||
s_type: vk::StructureType::RenderPassBeginInfo,
|
s_type: vk::StructureType::RenderPassBeginInfo,
|
||||||
|
@ -484,37 +491,51 @@ fn main() {
|
||||||
clear_value_count: clear_values.len() as u32,
|
clear_value_count: clear_values.len() as u32,
|
||||||
p_clear_values: clear_values.as_ptr(),
|
p_clear_values: clear_values.as_ptr(),
|
||||||
};
|
};
|
||||||
record_submit_commandbuffer(&base.device,
|
record_submit_commandbuffer(
|
||||||
base.draw_command_buffer,
|
&base.device,
|
||||||
base.present_queue,
|
base.draw_command_buffer,
|
||||||
&[vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT],
|
base.present_queue,
|
||||||
&[base.present_complete_semaphore],
|
&[vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT],
|
||||||
&[base.rendering_complete_semaphore],
|
&[base.present_complete_semaphore],
|
||||||
|device, draw_command_buffer| {
|
&[base.rendering_complete_semaphore],
|
||||||
device.cmd_begin_render_pass(draw_command_buffer,
|
|device, draw_command_buffer| {
|
||||||
&render_pass_begin_info,
|
device.cmd_begin_render_pass(
|
||||||
vk::SubpassContents::Inline);
|
draw_command_buffer,
|
||||||
device.cmd_bind_pipeline(draw_command_buffer,
|
&render_pass_begin_info,
|
||||||
vk::PipelineBindPoint::Graphics,
|
vk::SubpassContents::Inline,
|
||||||
graphic_pipeline);
|
);
|
||||||
device.cmd_set_viewport(draw_command_buffer, 0, &viewports);
|
device.cmd_bind_pipeline(
|
||||||
device.cmd_set_scissor(draw_command_buffer, &scissors);
|
draw_command_buffer,
|
||||||
device
|
vk::PipelineBindPoint::Graphics,
|
||||||
.cmd_bind_vertex_buffers(draw_command_buffer, 0, &[vertex_input_buffer], &[0]);
|
graphic_pipeline,
|
||||||
device.cmd_bind_index_buffer(draw_command_buffer,
|
);
|
||||||
index_buffer,
|
device.cmd_set_viewport(draw_command_buffer, 0, &viewports);
|
||||||
0,
|
device.cmd_set_scissor(draw_command_buffer, &scissors);
|
||||||
vk::IndexType::Uint32);
|
device.cmd_bind_vertex_buffers(
|
||||||
device.cmd_draw_indexed(draw_command_buffer,
|
draw_command_buffer,
|
||||||
index_buffer_data.len() as u32,
|
0,
|
||||||
1,
|
&[vertex_input_buffer],
|
||||||
0,
|
&[0],
|
||||||
0,
|
);
|
||||||
1);
|
device.cmd_bind_index_buffer(
|
||||||
// Or draw without the index buffer
|
draw_command_buffer,
|
||||||
// device.cmd_draw(draw_command_buffer, 3, 1, 0, 0);
|
index_buffer,
|
||||||
device.cmd_end_render_pass(draw_command_buffer);
|
0,
|
||||||
});
|
vk::IndexType::Uint32,
|
||||||
|
);
|
||||||
|
device.cmd_draw_indexed(
|
||||||
|
draw_command_buffer,
|
||||||
|
index_buffer_data.len() as u32,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
// Or draw without the index buffer
|
||||||
|
// device.cmd_draw(draw_command_buffer, 3, 1, 0, 0);
|
||||||
|
device.cmd_end_render_pass(draw_command_buffer);
|
||||||
|
},
|
||||||
|
);
|
||||||
//let mut present_info_err = mem::uninitialized();
|
//let mut present_info_err = mem::uninitialized();
|
||||||
let present_info = vk::PresentInfoKHR {
|
let present_info = vk::PresentInfoKHR {
|
||||||
s_type: vk::StructureType::PresentInfoKhr,
|
s_type: vk::StructureType::PresentInfoKhr,
|
||||||
|
@ -536,14 +557,10 @@ fn main() {
|
||||||
base.device.destroy_pipeline(pipeline, None);
|
base.device.destroy_pipeline(pipeline, None);
|
||||||
}
|
}
|
||||||
base.device.destroy_pipeline_layout(pipeline_layout, None);
|
base.device.destroy_pipeline_layout(pipeline_layout, None);
|
||||||
base.device.destroy_shader_module(
|
base.device
|
||||||
vertex_shader_module,
|
.destroy_shader_module(vertex_shader_module, None);
|
||||||
None,
|
base.device
|
||||||
);
|
.destroy_shader_module(fragment_shader_module, None);
|
||||||
base.device.destroy_shader_module(
|
|
||||||
fragment_shader_module,
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
base.device.free_memory(index_buffer_memory, None);
|
base.device.free_memory(index_buffer_memory, None);
|
||||||
base.device.destroy_buffer(index_buffer, None);
|
base.device.destroy_buffer(index_buffer, None);
|
||||||
base.device.free_memory(vertex_input_buffer_memory, None);
|
base.device.free_memory(vertex_input_buffer_memory, None);
|
||||||
|
|
Loading…
Reference in a new issue