Port texture example
This commit is contained in:
parent
7c8ab2a876
commit
c6be07f5f5
|
@ -36,50 +36,50 @@ fn main() {
|
||||||
vk::AttachmentDescription {
|
vk::AttachmentDescription {
|
||||||
format: base.surface_format.format,
|
format: base.surface_format.format,
|
||||||
flags: vk::AttachmentDescriptionFlags::empty(),
|
flags: vk::AttachmentDescriptionFlags::empty(),
|
||||||
samples: vk::SAMPLE_COUNT_1_BIT,
|
samples: vk::SampleCountFlags::TYPE_1,
|
||||||
load_op: vk::AttachmentLoadOp::Clear,
|
load_op: vk::AttachmentLoadOp::CLEAR,
|
||||||
store_op: vk::AttachmentStoreOp::Store,
|
store_op: vk::AttachmentStoreOp::STORE,
|
||||||
stencil_load_op: vk::AttachmentLoadOp::DontCare,
|
stencil_load_op: vk::AttachmentLoadOp::DONT_CARE,
|
||||||
stencil_store_op: vk::AttachmentStoreOp::DontCare,
|
stencil_store_op: vk::AttachmentStoreOp::DONT_CARE,
|
||||||
initial_layout: vk::ImageLayout::Undefined,
|
initial_layout: vk::ImageLayout::UNDEFINED,
|
||||||
final_layout: vk::ImageLayout::PresentSrcKhr,
|
final_layout: vk::ImageLayout::PRESENT_SRC_KHR,
|
||||||
},
|
},
|
||||||
vk::AttachmentDescription {
|
vk::AttachmentDescription {
|
||||||
format: vk::Format::D16Unorm,
|
format: vk::Format::D16_UNORM,
|
||||||
flags: vk::AttachmentDescriptionFlags::empty(),
|
flags: vk::AttachmentDescriptionFlags::empty(),
|
||||||
samples: vk::SAMPLE_COUNT_1_BIT,
|
samples: vk::SampleCountFlags::TYPE_1,
|
||||||
load_op: vk::AttachmentLoadOp::Clear,
|
load_op: vk::AttachmentLoadOp::CLEAR,
|
||||||
store_op: vk::AttachmentStoreOp::DontCare,
|
store_op: vk::AttachmentStoreOp::DONT_CARE,
|
||||||
stencil_load_op: vk::AttachmentLoadOp::DontCare,
|
stencil_load_op: vk::AttachmentLoadOp::DONT_CARE,
|
||||||
stencil_store_op: vk::AttachmentStoreOp::DontCare,
|
stencil_store_op: vk::AttachmentStoreOp::DONT_CARE,
|
||||||
initial_layout: vk::ImageLayout::DepthStencilAttachmentOptimal,
|
initial_layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||||
final_layout: vk::ImageLayout::DepthStencilAttachmentOptimal,
|
final_layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let color_attachment_ref = vk::AttachmentReference {
|
let color_attachment_ref = vk::AttachmentReference {
|
||||||
attachment: 0,
|
attachment: 0,
|
||||||
layout: vk::ImageLayout::ColorAttachmentOptimal,
|
layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
|
||||||
};
|
};
|
||||||
let depth_attachment_ref = vk::AttachmentReference {
|
let depth_attachment_ref = vk::AttachmentReference {
|
||||||
attachment: 1,
|
attachment: 1,
|
||||||
layout: vk::ImageLayout::DepthStencilAttachmentOptimal,
|
layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||||
};
|
};
|
||||||
let dependency = vk::SubpassDependency {
|
let dependency = vk::SubpassDependency {
|
||||||
dependency_flags: Default::default(),
|
dependency_flags: Default::default(),
|
||||||
src_subpass: vk::VK_SUBPASS_EXTERNAL,
|
src_subpass: vk::SUBPASS_EXTERNAL,
|
||||||
dst_subpass: Default::default(),
|
dst_subpass: Default::default(),
|
||||||
src_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
src_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
|
||||||
src_access_mask: Default::default(),
|
src_access_mask: Default::default(),
|
||||||
dst_access_mask: vk::ACCESS_COLOR_ATTACHMENT_READ_BIT
|
dst_access_mask: vk::AccessFlags::COLOR_ATTACHMENT_READ
|
||||||
| vk::ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
| vk::AccessFlags::COLOR_ATTACHMENT_WRITE,
|
||||||
dst_stage_mask: vk::PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
dst_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
|
||||||
};
|
};
|
||||||
let subpass = vk::SubpassDescription {
|
let subpass = vk::SubpassDescription {
|
||||||
color_attachment_count: 1,
|
color_attachment_count: 1,
|
||||||
p_color_attachments: &color_attachment_ref,
|
p_color_attachments: &color_attachment_ref,
|
||||||
p_depth_stencil_attachment: &depth_attachment_ref,
|
p_depth_stencil_attachment: &depth_attachment_ref,
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
pipeline_bind_point: vk::PipelineBindPoint::Graphics,
|
pipeline_bind_point: vk::PipelineBindPoint::GRAPHICS,
|
||||||
input_attachment_count: 0,
|
input_attachment_count: 0,
|
||||||
p_input_attachments: ptr::null(),
|
p_input_attachments: ptr::null(),
|
||||||
p_resolve_attachments: ptr::null(),
|
p_resolve_attachments: ptr::null(),
|
||||||
|
@ -87,7 +87,7 @@ fn main() {
|
||||||
p_preserve_attachments: ptr::null(),
|
p_preserve_attachments: ptr::null(),
|
||||||
};
|
};
|
||||||
let renderpass_create_info = vk::RenderPassCreateInfo {
|
let renderpass_create_info = vk::RenderPassCreateInfo {
|
||||||
s_type: vk::StructureType::RenderPassCreateInfo,
|
s_type: vk::StructureType::RENDER_PASS_CREATE_INFO,
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
attachment_count: renderpass_attachments.len() as u32,
|
attachment_count: renderpass_attachments.len() as u32,
|
||||||
|
@ -105,7 +105,7 @@ fn main() {
|
||||||
.map(|&present_image_view| {
|
.map(|&present_image_view| {
|
||||||
let framebuffer_attachments = [present_image_view, base.depth_image_view];
|
let framebuffer_attachments = [present_image_view, base.depth_image_view];
|
||||||
let frame_buffer_create_info = vk::FramebufferCreateInfo {
|
let frame_buffer_create_info = vk::FramebufferCreateInfo {
|
||||||
s_type: vk::StructureType::FramebufferCreateInfo,
|
s_type: vk::StructureType::FRAMEBUFFER_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
render_pass: renderpass,
|
render_pass: renderpass,
|
||||||
|
@ -122,12 +122,12 @@ fn main() {
|
||||||
.collect();
|
.collect();
|
||||||
let index_buffer_data = [0u32, 1, 2, 2, 3, 0];
|
let index_buffer_data = [0u32, 1, 2, 2, 3, 0];
|
||||||
let index_buffer_info = vk::BufferCreateInfo {
|
let index_buffer_info = vk::BufferCreateInfo {
|
||||||
s_type: vk::StructureType::BufferCreateInfo,
|
s_type: vk::StructureType::BUFFER_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: vk::BufferCreateFlags::empty(),
|
flags: vk::BufferCreateFlags::empty(),
|
||||||
size: std::mem::size_of_val(&index_buffer_data) as u64,
|
size: std::mem::size_of_val(&index_buffer_data) as u64,
|
||||||
usage: vk::BUFFER_USAGE_INDEX_BUFFER_BIT,
|
usage: vk::BufferUsageFlags::INDEX_BUFFER,
|
||||||
sharing_mode: vk::SharingMode::Exclusive,
|
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||||
queue_family_index_count: 0,
|
queue_family_index_count: 0,
|
||||||
p_queue_family_indices: ptr::null(),
|
p_queue_family_indices: ptr::null(),
|
||||||
};
|
};
|
||||||
|
@ -137,10 +137,10 @@ fn main() {
|
||||||
find_memorytype_index(
|
find_memorytype_index(
|
||||||
&index_buffer_memory_req,
|
&index_buffer_memory_req,
|
||||||
&base.device_memory_properties,
|
&base.device_memory_properties,
|
||||||
vk::MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
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 {
|
let index_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MemoryAllocateInfo,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
allocation_size: index_buffer_memory_req.size,
|
allocation_size: index_buffer_memory_req.size,
|
||||||
memory_type_index: index_buffer_memory_index,
|
memory_type_index: index_buffer_memory_index,
|
||||||
|
@ -186,12 +186,12 @@ fn main() {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let vertex_input_buffer_info = vk::BufferCreateInfo {
|
let vertex_input_buffer_info = vk::BufferCreateInfo {
|
||||||
s_type: vk::StructureType::BufferCreateInfo,
|
s_type: vk::StructureType::BUFFER_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: vk::BufferCreateFlags::empty(),
|
flags: vk::BufferCreateFlags::empty(),
|
||||||
size: std::mem::size_of_val(&vertices) as u64,
|
size: std::mem::size_of_val(&vertices) as u64,
|
||||||
usage: vk::BUFFER_USAGE_VERTEX_BUFFER_BIT,
|
usage: vk::BufferUsageFlags::VERTEX_BUFFER,
|
||||||
sharing_mode: vk::SharingMode::Exclusive,
|
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||||
queue_family_index_count: 0,
|
queue_family_index_count: 0,
|
||||||
p_queue_family_indices: ptr::null(),
|
p_queue_family_indices: ptr::null(),
|
||||||
};
|
};
|
||||||
|
@ -204,11 +204,11 @@ fn main() {
|
||||||
find_memorytype_index(
|
find_memorytype_index(
|
||||||
&vertex_input_buffer_memory_req,
|
&vertex_input_buffer_memory_req,
|
||||||
&base.device_memory_properties,
|
&base.device_memory_properties,
|
||||||
vk::MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
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 {
|
let vertex_buffer_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MemoryAllocateInfo,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
allocation_size: vertex_input_buffer_memory_req.size,
|
allocation_size: vertex_input_buffer_memory_req.size,
|
||||||
memory_type_index: vertex_input_buffer_memory_index,
|
memory_type_index: vertex_input_buffer_memory_index,
|
||||||
|
@ -242,12 +242,12 @@ fn main() {
|
||||||
_pad: 0.0,
|
_pad: 0.0,
|
||||||
};
|
};
|
||||||
let uniform_color_buffer_info = vk::BufferCreateInfo {
|
let uniform_color_buffer_info = vk::BufferCreateInfo {
|
||||||
s_type: vk::StructureType::BufferCreateInfo,
|
s_type: vk::StructureType::BUFFER_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: vk::BufferCreateFlags::empty(),
|
flags: vk::BufferCreateFlags::empty(),
|
||||||
size: std::mem::size_of_val(&uniform_color_buffer_data) as u64,
|
size: std::mem::size_of_val(&uniform_color_buffer_data) as u64,
|
||||||
usage: vk::BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
usage: vk::BufferUsageFlags::UNIFORM_BUFFER,
|
||||||
sharing_mode: vk::SharingMode::Exclusive,
|
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||||
queue_family_index_count: 0,
|
queue_family_index_count: 0,
|
||||||
p_queue_family_indices: ptr::null(),
|
p_queue_family_indices: ptr::null(),
|
||||||
};
|
};
|
||||||
|
@ -260,11 +260,11 @@ fn main() {
|
||||||
find_memorytype_index(
|
find_memorytype_index(
|
||||||
&uniform_color_buffer_memory_req,
|
&uniform_color_buffer_memory_req,
|
||||||
&base.device_memory_properties,
|
&base.device_memory_properties,
|
||||||
vk::MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
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 {
|
let uniform_color_buffer_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MemoryAllocateInfo,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
allocation_size: uniform_color_buffer_memory_req.size,
|
allocation_size: uniform_color_buffer_memory_req.size,
|
||||||
memory_type_index: uniform_color_buffer_memory_index,
|
memory_type_index: uniform_color_buffer_memory_index,
|
||||||
|
@ -295,12 +295,12 @@ fn main() {
|
||||||
let image_dimensions = image.dimensions();
|
let image_dimensions = image.dimensions();
|
||||||
let image_data = image.into_raw();
|
let image_data = image.into_raw();
|
||||||
let image_buffer_info = vk::BufferCreateInfo {
|
let image_buffer_info = vk::BufferCreateInfo {
|
||||||
s_type: vk::StructureType::BufferCreateInfo,
|
s_type: vk::StructureType::BUFFER_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: vk::BufferCreateFlags::empty(),
|
flags: vk::BufferCreateFlags::empty(),
|
||||||
size: (std::mem::size_of::<u8>() * image_data.len()) as u64,
|
size: (std::mem::size_of::<u8>() * image_data.len()) as u64,
|
||||||
usage: vk::BUFFER_USAGE_TRANSFER_SRC_BIT,
|
usage: vk::BufferUsageFlags::TRANSFER_SRC,
|
||||||
sharing_mode: vk::SharingMode::Exclusive,
|
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||||
queue_family_index_count: 0,
|
queue_family_index_count: 0,
|
||||||
p_queue_family_indices: ptr::null(),
|
p_queue_family_indices: ptr::null(),
|
||||||
};
|
};
|
||||||
|
@ -310,11 +310,11 @@ fn main() {
|
||||||
find_memorytype_index(
|
find_memorytype_index(
|
||||||
&image_buffer_memory_req,
|
&image_buffer_memory_req,
|
||||||
&base.device_memory_properties,
|
&base.device_memory_properties,
|
||||||
vk::MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
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 {
|
let image_buffer_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MemoryAllocateInfo,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
allocation_size: image_buffer_memory_req.size,
|
allocation_size: image_buffer_memory_req.size,
|
||||||
memory_type_index: image_buffer_memory_index,
|
memory_type_index: image_buffer_memory_index,
|
||||||
|
@ -342,11 +342,11 @@ fn main() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let texture_create_info = vk::ImageCreateInfo {
|
let texture_create_info = vk::ImageCreateInfo {
|
||||||
s_type: vk::StructureType::ImageCreateInfo,
|
s_type: vk::StructureType::IMAGE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
image_type: vk::ImageType::Type2d,
|
image_type: vk::ImageType::TYPE_2D,
|
||||||
format: vk::Format::R8g8b8a8Unorm,
|
format: vk::Format::R8G8B8A8_UNORM,
|
||||||
extent: vk::Extent3D {
|
extent: vk::Extent3D {
|
||||||
width: image_dimensions.0,
|
width: image_dimensions.0,
|
||||||
height: image_dimensions.1,
|
height: image_dimensions.1,
|
||||||
|
@ -354,13 +354,13 @@ fn main() {
|
||||||
},
|
},
|
||||||
mip_levels: 1,
|
mip_levels: 1,
|
||||||
array_layers: 1,
|
array_layers: 1,
|
||||||
samples: vk::SAMPLE_COUNT_1_BIT,
|
samples: vk::SampleCountFlags::TYPE_1,
|
||||||
tiling: vk::ImageTiling::Optimal,
|
tiling: vk::ImageTiling::OPTIMAL,
|
||||||
usage: vk::IMAGE_USAGE_TRANSFER_DST_BIT | vk::IMAGE_USAGE_SAMPLED_BIT,
|
usage: vk::ImageUsageFlags::TRANSFER_DST | vk::ImageUsageFlags::SAMPLED,
|
||||||
sharing_mode: vk::SharingMode::Exclusive,
|
sharing_mode: vk::SharingMode::EXCLUSIVE,
|
||||||
queue_family_index_count: 0,
|
queue_family_index_count: 0,
|
||||||
p_queue_family_indices: ptr::null(),
|
p_queue_family_indices: ptr::null(),
|
||||||
initial_layout: vk::ImageLayout::Undefined,
|
initial_layout: vk::ImageLayout::UNDEFINED,
|
||||||
};
|
};
|
||||||
let texture_image = base.device
|
let texture_image = base.device
|
||||||
.create_image(&texture_create_info, None)
|
.create_image(&texture_create_info, None)
|
||||||
|
@ -370,11 +370,11 @@ fn main() {
|
||||||
find_memorytype_index(
|
find_memorytype_index(
|
||||||
&texture_memory_req,
|
&texture_memory_req,
|
||||||
&base.device_memory_properties,
|
&base.device_memory_properties,
|
||||||
vk::MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
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 {
|
let texture_allocate_info = vk::MemoryAllocateInfo {
|
||||||
s_type: vk::StructureType::MemoryAllocateInfo,
|
s_type: vk::StructureType::MEMORY_ALLOCATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
allocation_size: texture_memory_req.size,
|
allocation_size: texture_memory_req.size,
|
||||||
memory_type_index: texture_memory_index,
|
memory_type_index: texture_memory_index,
|
||||||
|
@ -390,22 +390,22 @@ fn main() {
|
||||||
&base.device,
|
&base.device,
|
||||||
base.setup_command_buffer,
|
base.setup_command_buffer,
|
||||||
base.present_queue,
|
base.present_queue,
|
||||||
&[vk::PIPELINE_STAGE_TOP_OF_PIPE_BIT],
|
&[vk::PipelineStageFlags::TOP_OF_PIPE],
|
||||||
&[],
|
&[],
|
||||||
&[],
|
&[],
|
||||||
|device, texture_command_buffer| {
|
|device, texture_command_buffer| {
|
||||||
let texture_barrier = vk::ImageMemoryBarrier {
|
let texture_barrier = vk::ImageMemoryBarrier {
|
||||||
s_type: vk::StructureType::ImageMemoryBarrier,
|
s_type: vk::StructureType::IMAGE_MEMORY_BARRIER,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
src_access_mask: Default::default(),
|
src_access_mask: Default::default(),
|
||||||
dst_access_mask: vk::ACCESS_TRANSFER_WRITE_BIT,
|
dst_access_mask: vk::AccessFlags::TRANSFER_WRITE,
|
||||||
old_layout: vk::ImageLayout::Undefined,
|
old_layout: vk::ImageLayout::UNDEFINED,
|
||||||
new_layout: vk::ImageLayout::TransferDstOptimal,
|
new_layout: vk::ImageLayout::TRANSFER_DST_OPTIMAL,
|
||||||
src_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
src_queue_family_index: vk::QUEUE_FAMILY_IGNORED,
|
||||||
dst_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
dst_queue_family_index: vk::QUEUE_FAMILY_IGNORED,
|
||||||
image: texture_image,
|
image: texture_image,
|
||||||
subresource_range: vk::ImageSubresourceRange {
|
subresource_range: vk::ImageSubresourceRange {
|
||||||
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
|
aspect_mask: vk::ImageAspectFlags::COLOR,
|
||||||
base_mip_level: 0,
|
base_mip_level: 0,
|
||||||
level_count: 1,
|
level_count: 1,
|
||||||
base_array_layer: 0,
|
base_array_layer: 0,
|
||||||
|
@ -414,8 +414,8 @@ fn main() {
|
||||||
};
|
};
|
||||||
device.cmd_pipeline_barrier(
|
device.cmd_pipeline_barrier(
|
||||||
texture_command_buffer,
|
texture_command_buffer,
|
||||||
vk::PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
vk::PipelineStageFlags::BOTTOM_OF_PIPE,
|
||||||
vk::PIPELINE_STAGE_TRANSFER_BIT,
|
vk::PipelineStageFlags::TRANSFER,
|
||||||
vk::DependencyFlags::empty(),
|
vk::DependencyFlags::empty(),
|
||||||
&[],
|
&[],
|
||||||
&[],
|
&[],
|
||||||
|
@ -424,7 +424,7 @@ fn main() {
|
||||||
let buffer_copy_regions = [
|
let buffer_copy_regions = [
|
||||||
vk::BufferImageCopy {
|
vk::BufferImageCopy {
|
||||||
image_subresource: vk::ImageSubresourceLayers {
|
image_subresource: vk::ImageSubresourceLayers {
|
||||||
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
|
aspect_mask: vk::ImageAspectFlags::COLOR,
|
||||||
mip_level: 0,
|
mip_level: 0,
|
||||||
base_array_layer: 0,
|
base_array_layer: 0,
|
||||||
layer_count: 1,
|
layer_count: 1,
|
||||||
|
@ -445,21 +445,21 @@ fn main() {
|
||||||
texture_command_buffer,
|
texture_command_buffer,
|
||||||
image_buffer,
|
image_buffer,
|
||||||
texture_image,
|
texture_image,
|
||||||
vk::ImageLayout::TransferDstOptimal,
|
vk::ImageLayout::TRANSFER_DST_OPTIMAL,
|
||||||
&buffer_copy_regions,
|
&buffer_copy_regions,
|
||||||
);
|
);
|
||||||
let texture_barrier_end = vk::ImageMemoryBarrier {
|
let texture_barrier_end = vk::ImageMemoryBarrier {
|
||||||
s_type: vk::StructureType::ImageMemoryBarrier,
|
s_type: vk::StructureType::IMAGE_MEMORY_BARRIER,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
src_access_mask: vk::ACCESS_TRANSFER_WRITE_BIT,
|
src_access_mask: vk::AccessFlags::TRANSFER_WRITE,
|
||||||
dst_access_mask: vk::ACCESS_SHADER_READ_BIT,
|
dst_access_mask: vk::AccessFlags::SHADER_READ,
|
||||||
old_layout: vk::ImageLayout::TransferDstOptimal,
|
old_layout: vk::ImageLayout::TRANSFER_DST_OPTIMAL,
|
||||||
new_layout: vk::ImageLayout::ShaderReadOnlyOptimal,
|
new_layout: vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
|
||||||
src_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
src_queue_family_index: vk::QUEUE_FAMILY_IGNORED,
|
||||||
dst_queue_family_index: vk::VK_QUEUE_FAMILY_IGNORED,
|
dst_queue_family_index: vk::QUEUE_FAMILY_IGNORED,
|
||||||
image: texture_image,
|
image: texture_image,
|
||||||
subresource_range: vk::ImageSubresourceRange {
|
subresource_range: vk::ImageSubresourceRange {
|
||||||
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
|
aspect_mask: vk::ImageAspectFlags::COLOR,
|
||||||
base_mip_level: 0,
|
base_mip_level: 0,
|
||||||
level_count: 1,
|
level_count: 1,
|
||||||
base_array_layer: 0,
|
base_array_layer: 0,
|
||||||
|
@ -468,8 +468,8 @@ fn main() {
|
||||||
};
|
};
|
||||||
device.cmd_pipeline_barrier(
|
device.cmd_pipeline_barrier(
|
||||||
texture_command_buffer,
|
texture_command_buffer,
|
||||||
vk::PIPELINE_STAGE_TRANSFER_BIT,
|
vk::PipelineStageFlags::TRANSFER,
|
||||||
vk::PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
vk::PipelineStageFlags::FRAGMENT_SHADER,
|
||||||
vk::DependencyFlags::empty(),
|
vk::DependencyFlags::empty(),
|
||||||
&[],
|
&[],
|
||||||
&[],
|
&[],
|
||||||
|
@ -479,33 +479,33 @@ fn main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let sampler_info = vk::SamplerCreateInfo {
|
let sampler_info = vk::SamplerCreateInfo {
|
||||||
s_type: vk::StructureType::SamplerCreateInfo,
|
s_type: vk::StructureType::SAMPLER_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
mag_filter: vk::Filter::Linear,
|
mag_filter: vk::Filter::LINEAR,
|
||||||
min_filter: vk::Filter::Linear,
|
min_filter: vk::Filter::LINEAR,
|
||||||
mipmap_mode: vk::SamplerMipmapMode::Linear,
|
mipmap_mode: vk::SamplerMipmapMode::LINEAR,
|
||||||
address_mode_u: vk::SamplerAddressMode::MirroredRepeat,
|
address_mode_u: vk::SamplerAddressMode::MIRRORED_REPEAT,
|
||||||
address_mode_v: vk::SamplerAddressMode::MirroredRepeat,
|
address_mode_v: vk::SamplerAddressMode::MIRRORED_REPEAT,
|
||||||
address_mode_w: vk::SamplerAddressMode::MirroredRepeat,
|
address_mode_w: vk::SamplerAddressMode::MIRRORED_REPEAT,
|
||||||
mip_lod_bias: 0.0,
|
mip_lod_bias: 0.0,
|
||||||
min_lod: 0.0,
|
min_lod: 0.0,
|
||||||
max_lod: 0.0,
|
max_lod: 0.0,
|
||||||
anisotropy_enable: 0,
|
anisotropy_enable: 0,
|
||||||
max_anisotropy: 1.0,
|
max_anisotropy: 1.0,
|
||||||
border_color: vk::BorderColor::FloatOpaqueWhite,
|
border_color: vk::BorderColor::FLOAT_OPAQUE_WHITE,
|
||||||
compare_enable: 0,
|
compare_enable: 0,
|
||||||
compare_op: vk::CompareOp::Never,
|
compare_op: vk::CompareOp::NEVER,
|
||||||
unnormalized_coordinates: 0,
|
unnormalized_coordinates: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let sampler = base.device.create_sampler(&sampler_info, None).unwrap();
|
let sampler = base.device.create_sampler(&sampler_info, None).unwrap();
|
||||||
|
|
||||||
let tex_image_view_info = vk::ImageViewCreateInfo {
|
let tex_image_view_info = vk::ImageViewCreateInfo {
|
||||||
s_type: vk::StructureType::ImageViewCreateInfo,
|
s_type: vk::StructureType::IMAGE_VIEW_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
view_type: vk::ImageViewType::Type2d,
|
view_type: vk::ImageViewType::TYPE_2D,
|
||||||
format: texture_create_info.format,
|
format: texture_create_info.format,
|
||||||
components: vk::ComponentMapping {
|
components: vk::ComponentMapping {
|
||||||
r: vk::ComponentSwizzle::R,
|
r: vk::ComponentSwizzle::R,
|
||||||
|
@ -514,7 +514,7 @@ fn main() {
|
||||||
a: vk::ComponentSwizzle::A,
|
a: vk::ComponentSwizzle::A,
|
||||||
},
|
},
|
||||||
subresource_range: vk::ImageSubresourceRange {
|
subresource_range: vk::ImageSubresourceRange {
|
||||||
aspect_mask: vk::IMAGE_ASPECT_COLOR_BIT,
|
aspect_mask: vk::ImageAspectFlags::COLOR,
|
||||||
base_mip_level: 0,
|
base_mip_level: 0,
|
||||||
level_count: 1,
|
level_count: 1,
|
||||||
base_array_layer: 0,
|
base_array_layer: 0,
|
||||||
|
@ -527,16 +527,16 @@ fn main() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let descriptor_sizes = [
|
let descriptor_sizes = [
|
||||||
vk::DescriptorPoolSize {
|
vk::DescriptorPoolSize {
|
||||||
typ: vk::DescriptorType::UniformBuffer,
|
ty: vk::DescriptorType::UNIFORM_BUFFER,
|
||||||
descriptor_count: 1,
|
descriptor_count: 1,
|
||||||
},
|
},
|
||||||
vk::DescriptorPoolSize {
|
vk::DescriptorPoolSize {
|
||||||
typ: vk::DescriptorType::CombinedImageSampler,
|
ty: vk::DescriptorType::COMBINED_IMAGE_SAMPLER,
|
||||||
descriptor_count: 1,
|
descriptor_count: 1,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let descriptor_pool_info = vk::DescriptorPoolCreateInfo {
|
let descriptor_pool_info = vk::DescriptorPoolCreateInfo {
|
||||||
s_type: vk::StructureType::DescriptorPoolCreateInfo,
|
s_type: vk::StructureType::DESCRIPTOR_POOL_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
pool_size_count: descriptor_sizes.len() as u32,
|
pool_size_count: descriptor_sizes.len() as u32,
|
||||||
|
@ -549,21 +549,21 @@ fn main() {
|
||||||
let desc_layout_bindings = [
|
let desc_layout_bindings = [
|
||||||
vk::DescriptorSetLayoutBinding {
|
vk::DescriptorSetLayoutBinding {
|
||||||
binding: 0,
|
binding: 0,
|
||||||
descriptor_type: vk::DescriptorType::UniformBuffer,
|
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
|
||||||
descriptor_count: 1,
|
descriptor_count: 1,
|
||||||
stage_flags: vk::SHADER_STAGE_FRAGMENT_BIT,
|
stage_flags: vk::ShaderStageFlags::FRAGMENT,
|
||||||
p_immutable_samplers: ptr::null(),
|
p_immutable_samplers: ptr::null(),
|
||||||
},
|
},
|
||||||
vk::DescriptorSetLayoutBinding {
|
vk::DescriptorSetLayoutBinding {
|
||||||
binding: 1,
|
binding: 1,
|
||||||
descriptor_type: vk::DescriptorType::CombinedImageSampler,
|
descriptor_type: vk::DescriptorType::COMBINED_IMAGE_SAMPLER,
|
||||||
descriptor_count: 1,
|
descriptor_count: 1,
|
||||||
stage_flags: vk::SHADER_STAGE_FRAGMENT_BIT,
|
stage_flags: vk::ShaderStageFlags::FRAGMENT,
|
||||||
p_immutable_samplers: ptr::null(),
|
p_immutable_samplers: ptr::null(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let descriptor_info = vk::DescriptorSetLayoutCreateInfo {
|
let descriptor_info = vk::DescriptorSetLayoutCreateInfo {
|
||||||
s_type: vk::StructureType::DescriptorSetLayoutCreateInfo,
|
s_type: vk::StructureType::DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
binding_count: desc_layout_bindings.len() as u32,
|
binding_count: desc_layout_bindings.len() as u32,
|
||||||
|
@ -576,7 +576,7 @@ fn main() {
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
];
|
];
|
||||||
let desc_alloc_info = vk::DescriptorSetAllocateInfo {
|
let desc_alloc_info = vk::DescriptorSetAllocateInfo {
|
||||||
s_type: vk::StructureType::DescriptorSetAllocateInfo,
|
s_type: vk::StructureType::DESCRIPTOR_SET_ALLOCATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
descriptor_pool: descriptor_pool,
|
descriptor_pool: descriptor_pool,
|
||||||
descriptor_set_count: desc_set_layouts.len() as u32,
|
descriptor_set_count: desc_set_layouts.len() as u32,
|
||||||
|
@ -593,32 +593,32 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let tex_descriptor = vk::DescriptorImageInfo {
|
let tex_descriptor = vk::DescriptorImageInfo {
|
||||||
image_layout: vk::ImageLayout::General,
|
image_layout: vk::ImageLayout::GENERAL,
|
||||||
image_view: tex_image_view,
|
image_view: tex_image_view,
|
||||||
sampler: sampler,
|
sampler: sampler,
|
||||||
};
|
};
|
||||||
|
|
||||||
let write_desc_sets = [
|
let write_desc_sets = [
|
||||||
vk::WriteDescriptorSet {
|
vk::WriteDescriptorSet {
|
||||||
s_type: vk::StructureType::WriteDescriptorSet,
|
s_type: vk::StructureType::WRITE_DESCRIPTOR_SET,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
dst_set: descriptor_sets[0],
|
dst_set: descriptor_sets[0],
|
||||||
dst_binding: 0,
|
dst_binding: 0,
|
||||||
dst_array_element: 0,
|
dst_array_element: 0,
|
||||||
descriptor_count: 1,
|
descriptor_count: 1,
|
||||||
descriptor_type: vk::DescriptorType::UniformBuffer,
|
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
|
||||||
p_image_info: ptr::null(),
|
p_image_info: ptr::null(),
|
||||||
p_buffer_info: &uniform_color_buffer_descriptor,
|
p_buffer_info: &uniform_color_buffer_descriptor,
|
||||||
p_texel_buffer_view: ptr::null(),
|
p_texel_buffer_view: ptr::null(),
|
||||||
},
|
},
|
||||||
vk::WriteDescriptorSet {
|
vk::WriteDescriptorSet {
|
||||||
s_type: vk::StructureType::WriteDescriptorSet,
|
s_type: vk::StructureType::WRITE_DESCRIPTOR_SET,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
dst_set: descriptor_sets[0],
|
dst_set: descriptor_sets[0],
|
||||||
dst_binding: 1,
|
dst_binding: 1,
|
||||||
dst_array_element: 0,
|
dst_array_element: 0,
|
||||||
descriptor_count: 1,
|
descriptor_count: 1,
|
||||||
descriptor_type: vk::DescriptorType::CombinedImageSampler,
|
descriptor_type: vk::DescriptorType::COMBINED_IMAGE_SAMPLER,
|
||||||
p_image_info: &tex_descriptor,
|
p_image_info: &tex_descriptor,
|
||||||
p_buffer_info: ptr::null(),
|
p_buffer_info: ptr::null(),
|
||||||
p_texel_buffer_view: ptr::null(),
|
p_texel_buffer_view: ptr::null(),
|
||||||
|
@ -636,7 +636,7 @@ fn main() {
|
||||||
.filter_map(|byte| byte.ok())
|
.filter_map(|byte| byte.ok())
|
||||||
.collect();
|
.collect();
|
||||||
let vertex_shader_info = vk::ShaderModuleCreateInfo {
|
let vertex_shader_info = vk::ShaderModuleCreateInfo {
|
||||||
s_type: vk::StructureType::ShaderModuleCreateInfo,
|
s_type: vk::StructureType::SHADER_MODULE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
code_size: vertex_bytes.len(),
|
code_size: vertex_bytes.len(),
|
||||||
|
@ -644,7 +644,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
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_shader_info = vk::ShaderModuleCreateInfo {
|
let frag_shader_info = vk::ShaderModuleCreateInfo {
|
||||||
s_type: vk::StructureType::ShaderModuleCreateInfo,
|
s_type: vk::StructureType::SHADER_MODULE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
code_size: frag_bytes.len(),
|
code_size: frag_bytes.len(),
|
||||||
|
@ -659,7 +659,7 @@ fn main() {
|
||||||
.expect("Fragment shader module error");
|
.expect("Fragment shader module error");
|
||||||
|
|
||||||
let layout_create_info = vk::PipelineLayoutCreateInfo {
|
let layout_create_info = vk::PipelineLayoutCreateInfo {
|
||||||
s_type: vk::StructureType::PipelineLayoutCreateInfo,
|
s_type: vk::StructureType::PIPELINE_LAYOUT_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
set_layout_count: desc_set_layouts.len() as u32,
|
set_layout_count: desc_set_layouts.len() as u32,
|
||||||
|
@ -675,47 +675,47 @@ fn main() {
|
||||||
let shader_entry_name = CString::new("main").unwrap();
|
let shader_entry_name = CString::new("main").unwrap();
|
||||||
let shader_stage_create_infos = [
|
let shader_stage_create_infos = [
|
||||||
vk::PipelineShaderStageCreateInfo {
|
vk::PipelineShaderStageCreateInfo {
|
||||||
s_type: vk::StructureType::PipelineShaderStageCreateInfo,
|
s_type: vk::StructureType::PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
module: vertex_shader_module,
|
module: vertex_shader_module,
|
||||||
p_name: shader_entry_name.as_ptr(),
|
p_name: shader_entry_name.as_ptr(),
|
||||||
p_specialization_info: ptr::null(),
|
p_specialization_info: ptr::null(),
|
||||||
stage: vk::SHADER_STAGE_VERTEX_BIT,
|
stage: vk::ShaderStageFlags::VERTEX,
|
||||||
},
|
},
|
||||||
vk::PipelineShaderStageCreateInfo {
|
vk::PipelineShaderStageCreateInfo {
|
||||||
s_type: vk::StructureType::PipelineShaderStageCreateInfo,
|
s_type: vk::StructureType::PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
module: fragment_shader_module,
|
module: fragment_shader_module,
|
||||||
p_name: shader_entry_name.as_ptr(),
|
p_name: shader_entry_name.as_ptr(),
|
||||||
p_specialization_info: ptr::null(),
|
p_specialization_info: ptr::null(),
|
||||||
stage: vk::SHADER_STAGE_FRAGMENT_BIT,
|
stage: vk::ShaderStageFlags::FRAGMENT,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let vertex_input_binding_descriptions = [
|
let vertex_input_binding_descriptions = [
|
||||||
vk::VertexInputBindingDescription {
|
vk::VertexInputBindingDescription {
|
||||||
binding: 0,
|
binding: 0,
|
||||||
stride: mem::size_of::<Vertex>() as u32,
|
stride: mem::size_of::<Vertex>() as u32,
|
||||||
input_rate: vk::VertexInputRate::Vertex,
|
input_rate: vk::VertexInputRate::VERTEX,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let vertex_input_attribute_descriptions = [
|
let vertex_input_attribute_descriptions = [
|
||||||
vk::VertexInputAttributeDescription {
|
vk::VertexInputAttributeDescription {
|
||||||
location: 0,
|
location: 0,
|
||||||
binding: 0,
|
binding: 0,
|
||||||
format: vk::Format::R32g32b32a32Sfloat,
|
format: vk::Format::R32G32B32A32_SFLOAT,
|
||||||
offset: offset_of!(Vertex, pos) as u32,
|
offset: offset_of!(Vertex, pos) as u32,
|
||||||
},
|
},
|
||||||
vk::VertexInputAttributeDescription {
|
vk::VertexInputAttributeDescription {
|
||||||
location: 1,
|
location: 1,
|
||||||
binding: 0,
|
binding: 0,
|
||||||
format: vk::Format::R32g32Sfloat,
|
format: vk::Format::R32G32_SFLOAT,
|
||||||
offset: offset_of!(Vertex, uv) as u32,
|
offset: offset_of!(Vertex, uv) as u32,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let vertex_input_state_info = vk::PipelineVertexInputStateCreateInfo {
|
let vertex_input_state_info = vk::PipelineVertexInputStateCreateInfo {
|
||||||
s_type: vk::StructureType::PipelineVertexInputStateCreateInfo,
|
s_type: vk::StructureType::PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
vertex_attribute_description_count: vertex_input_attribute_descriptions.len() as u32,
|
vertex_attribute_description_count: vertex_input_attribute_descriptions.len() as u32,
|
||||||
|
@ -724,11 +724,11 @@ fn main() {
|
||||||
p_vertex_binding_descriptions: vertex_input_binding_descriptions.as_ptr(),
|
p_vertex_binding_descriptions: vertex_input_binding_descriptions.as_ptr(),
|
||||||
};
|
};
|
||||||
let vertex_input_assembly_state_info = vk::PipelineInputAssemblyStateCreateInfo {
|
let vertex_input_assembly_state_info = vk::PipelineInputAssemblyStateCreateInfo {
|
||||||
s_type: vk::StructureType::PipelineInputAssemblyStateCreateInfo,
|
s_type: vk::StructureType::PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
primitive_restart_enable: 0,
|
primitive_restart_enable: 0,
|
||||||
topology: vk::PrimitiveTopology::TriangleList,
|
topology: vk::PrimitiveTopology::TRIANGLE_LIST,
|
||||||
};
|
};
|
||||||
let viewports = [
|
let viewports = [
|
||||||
vk::Viewport {
|
vk::Viewport {
|
||||||
|
@ -747,7 +747,7 @@ fn main() {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let viewport_state_info = vk::PipelineViewportStateCreateInfo {
|
let viewport_state_info = vk::PipelineViewportStateCreateInfo {
|
||||||
s_type: vk::StructureType::PipelineViewportStateCreateInfo,
|
s_type: vk::StructureType::PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
scissor_count: scissors.len() as u32,
|
scissor_count: scissors.len() as u32,
|
||||||
|
@ -756,25 +756,25 @@ fn main() {
|
||||||
p_viewports: viewports.as_ptr(),
|
p_viewports: viewports.as_ptr(),
|
||||||
};
|
};
|
||||||
let rasterization_info = vk::PipelineRasterizationStateCreateInfo {
|
let rasterization_info = vk::PipelineRasterizationStateCreateInfo {
|
||||||
s_type: vk::StructureType::PipelineRasterizationStateCreateInfo,
|
s_type: vk::StructureType::PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
cull_mode: vk::CULL_MODE_NONE,
|
cull_mode: vk::CullModeFlags::NONE,
|
||||||
depth_bias_clamp: 0.0,
|
depth_bias_clamp: 0.0,
|
||||||
depth_bias_constant_factor: 0.0,
|
depth_bias_constant_factor: 0.0,
|
||||||
depth_bias_enable: 0,
|
depth_bias_enable: 0,
|
||||||
depth_bias_slope_factor: 0.0,
|
depth_bias_slope_factor: 0.0,
|
||||||
depth_clamp_enable: 0,
|
depth_clamp_enable: 0,
|
||||||
front_face: vk::FrontFace::CounterClockwise,
|
front_face: vk::FrontFace::COUNTER_CLOCKWISE,
|
||||||
line_width: 1.0,
|
line_width: 1.0,
|
||||||
polygon_mode: vk::PolygonMode::Fill,
|
polygon_mode: vk::PolygonMode::FILL,
|
||||||
rasterizer_discard_enable: 0,
|
rasterizer_discard_enable: 0,
|
||||||
};
|
};
|
||||||
let multisample_state_info = vk::PipelineMultisampleStateCreateInfo {
|
let multisample_state_info = vk::PipelineMultisampleStateCreateInfo {
|
||||||
s_type: vk::StructureType::PipelineMultisampleStateCreateInfo,
|
s_type: vk::StructureType::PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
rasterization_samples: vk::SAMPLE_COUNT_1_BIT,
|
rasterization_samples: vk::SampleCountFlags::TYPE_1,
|
||||||
sample_shading_enable: 0,
|
sample_shading_enable: 0,
|
||||||
min_sample_shading: 0.0,
|
min_sample_shading: 0.0,
|
||||||
p_sample_mask: ptr::null(),
|
p_sample_mask: ptr::null(),
|
||||||
|
@ -782,21 +782,21 @@ fn main() {
|
||||||
alpha_to_coverage_enable: 0,
|
alpha_to_coverage_enable: 0,
|
||||||
};
|
};
|
||||||
let noop_stencil_state = vk::StencilOpState {
|
let noop_stencil_state = vk::StencilOpState {
|
||||||
fail_op: vk::StencilOp::Keep,
|
fail_op: vk::StencilOp::KEEP,
|
||||||
pass_op: vk::StencilOp::Keep,
|
pass_op: vk::StencilOp::KEEP,
|
||||||
depth_fail_op: vk::StencilOp::Keep,
|
depth_fail_op: vk::StencilOp::KEEP,
|
||||||
compare_op: vk::CompareOp::Always,
|
compare_op: vk::CompareOp::ALWAYS,
|
||||||
compare_mask: 0,
|
compare_mask: 0,
|
||||||
write_mask: 0,
|
write_mask: 0,
|
||||||
reference: 0,
|
reference: 0,
|
||||||
};
|
};
|
||||||
let depth_state_info = vk::PipelineDepthStencilStateCreateInfo {
|
let depth_state_info = vk::PipelineDepthStencilStateCreateInfo {
|
||||||
s_type: vk::StructureType::PipelineDepthStencilStateCreateInfo,
|
s_type: vk::StructureType::PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
depth_test_enable: 1,
|
depth_test_enable: 1,
|
||||||
depth_write_enable: 1,
|
depth_write_enable: 1,
|
||||||
depth_compare_op: vk::CompareOp::LessOrEqual,
|
depth_compare_op: vk::CompareOp::LESS_OR_EQUAL,
|
||||||
depth_bounds_test_enable: 0,
|
depth_bounds_test_enable: 0,
|
||||||
stencil_test_enable: 0,
|
stencil_test_enable: 0,
|
||||||
front: noop_stencil_state.clone(),
|
front: noop_stencil_state.clone(),
|
||||||
|
@ -807,35 +807,35 @@ fn main() {
|
||||||
let color_blend_attachment_states = [
|
let color_blend_attachment_states = [
|
||||||
vk::PipelineColorBlendAttachmentState {
|
vk::PipelineColorBlendAttachmentState {
|
||||||
blend_enable: 0,
|
blend_enable: 0,
|
||||||
src_color_blend_factor: vk::BlendFactor::SrcColor,
|
src_color_blend_factor: vk::BlendFactor::SRC_COLOR,
|
||||||
dst_color_blend_factor: vk::BlendFactor::OneMinusDstColor,
|
dst_color_blend_factor: vk::BlendFactor::ONE_MINUS_DST_COLOR,
|
||||||
color_blend_op: vk::BlendOp::Add,
|
color_blend_op: vk::BlendOp::ADD,
|
||||||
src_alpha_blend_factor: vk::BlendFactor::Zero,
|
src_alpha_blend_factor: vk::BlendFactor::ZERO,
|
||||||
dst_alpha_blend_factor: vk::BlendFactor::Zero,
|
dst_alpha_blend_factor: vk::BlendFactor::ZERO,
|
||||||
alpha_blend_op: vk::BlendOp::Add,
|
alpha_blend_op: vk::BlendOp::ADD,
|
||||||
color_write_mask: vk::ColorComponentFlags::all(),
|
color_write_mask: vk::ColorComponentFlags::all(),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let color_blend_state = vk::PipelineColorBlendStateCreateInfo {
|
let color_blend_state = vk::PipelineColorBlendStateCreateInfo {
|
||||||
s_type: vk::StructureType::PipelineColorBlendStateCreateInfo,
|
s_type: vk::StructureType::PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
logic_op_enable: 0,
|
logic_op_enable: 0,
|
||||||
logic_op: vk::LogicOp::Clear,
|
logic_op: vk::LogicOp::CLEAR,
|
||||||
attachment_count: color_blend_attachment_states.len() as u32,
|
attachment_count: color_blend_attachment_states.len() as u32,
|
||||||
p_attachments: color_blend_attachment_states.as_ptr(),
|
p_attachments: color_blend_attachment_states.as_ptr(),
|
||||||
blend_constants: [0.0, 0.0, 0.0, 0.0],
|
blend_constants: [0.0, 0.0, 0.0, 0.0],
|
||||||
};
|
};
|
||||||
let dynamic_state = [vk::DynamicState::Viewport, vk::DynamicState::Scissor];
|
let dynamic_state = [vk::DynamicState::VIEWPORT, vk::DynamicState::SCISSOR];
|
||||||
let dynamic_state_info = vk::PipelineDynamicStateCreateInfo {
|
let dynamic_state_info = vk::PipelineDynamicStateCreateInfo {
|
||||||
s_type: vk::StructureType::PipelineDynamicStateCreateInfo,
|
s_type: vk::StructureType::PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: Default::default(),
|
flags: Default::default(),
|
||||||
dynamic_state_count: dynamic_state.len() as u32,
|
dynamic_state_count: dynamic_state.len() as u32,
|
||||||
p_dynamic_states: dynamic_state.as_ptr(),
|
p_dynamic_states: dynamic_state.as_ptr(),
|
||||||
};
|
};
|
||||||
let graphic_pipeline_info = vk::GraphicsPipelineCreateInfo {
|
let graphic_pipeline_info = vk::GraphicsPipelineCreateInfo {
|
||||||
s_type: vk::StructureType::GraphicsPipelineCreateInfo,
|
s_type: vk::StructureType::GRAPHICS_PIPELINE_CREATE_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
flags: vk::PipelineCreateFlags::empty(),
|
flags: vk::PipelineCreateFlags::empty(),
|
||||||
stage_count: shader_stage_create_infos.len() as u32,
|
stage_count: shader_stage_create_infos.len() as u32,
|
||||||
|
@ -877,7 +877,7 @@ fn main() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
vk::ClearValue {
|
vk::ClearValue {
|
||||||
depth: vk::ClearDepthStencilValue {
|
depth_stencil: vk::ClearDepthStencilValue {
|
||||||
depth: 1.0,
|
depth: 1.0,
|
||||||
stencil: 0,
|
stencil: 0,
|
||||||
},
|
},
|
||||||
|
@ -885,7 +885,7 @@ fn main() {
|
||||||
];
|
];
|
||||||
|
|
||||||
let render_pass_begin_info = vk::RenderPassBeginInfo {
|
let render_pass_begin_info = vk::RenderPassBeginInfo {
|
||||||
s_type: vk::StructureType::RenderPassBeginInfo,
|
s_type: vk::StructureType::RENDER_PASS_BEGIN_INFO,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
render_pass: renderpass,
|
render_pass: renderpass,
|
||||||
framebuffer: framebuffers[present_index as usize],
|
framebuffer: framebuffers[present_index as usize],
|
||||||
|
@ -899,21 +899,21 @@ fn main() {
|
||||||
record_submit_commandbuffer(&base.device,
|
record_submit_commandbuffer(&base.device,
|
||||||
base.draw_command_buffer,
|
base.draw_command_buffer,
|
||||||
base.present_queue,
|
base.present_queue,
|
||||||
&[vk::PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT],
|
&[vk::PipelineStageFlags::BOTTOM_OF_PIPE],
|
||||||
&[base.present_complete_semaphore],
|
&[base.present_complete_semaphore],
|
||||||
&[base.rendering_complete_semaphore],
|
&[base.rendering_complete_semaphore],
|
||||||
|device, draw_command_buffer| {
|
|device, draw_command_buffer| {
|
||||||
device.cmd_begin_render_pass(draw_command_buffer,
|
device.cmd_begin_render_pass(draw_command_buffer,
|
||||||
&render_pass_begin_info,
|
&render_pass_begin_info,
|
||||||
vk::SubpassContents::Inline);
|
vk::SubpassContents::INLINE);
|
||||||
device.cmd_bind_descriptor_sets(draw_command_buffer,
|
device.cmd_bind_descriptor_sets(draw_command_buffer,
|
||||||
vk::PipelineBindPoint::Graphics,
|
vk::PipelineBindPoint::GRAPHICS,
|
||||||
pipeline_layout,
|
pipeline_layout,
|
||||||
0,
|
0,
|
||||||
&descriptor_sets[..],
|
&descriptor_sets[..],
|
||||||
&[]);
|
&[]);
|
||||||
device.cmd_bind_pipeline(draw_command_buffer,
|
device.cmd_bind_pipeline(draw_command_buffer,
|
||||||
vk::PipelineBindPoint::Graphics,
|
vk::PipelineBindPoint::GRAPHICS,
|
||||||
graphic_pipeline);
|
graphic_pipeline);
|
||||||
device.cmd_set_viewport(draw_command_buffer, 0, &viewports);
|
device.cmd_set_viewport(draw_command_buffer, 0, &viewports);
|
||||||
device.cmd_set_scissor(draw_command_buffer, 0, &scissors);
|
device.cmd_set_scissor(draw_command_buffer, 0, &scissors);
|
||||||
|
@ -922,7 +922,7 @@ fn main() {
|
||||||
device.cmd_bind_index_buffer(draw_command_buffer,
|
device.cmd_bind_index_buffer(draw_command_buffer,
|
||||||
index_buffer,
|
index_buffer,
|
||||||
0,
|
0,
|
||||||
vk::IndexType::Uint32);
|
vk::IndexType::UINT32);
|
||||||
device.cmd_draw_indexed(draw_command_buffer,
|
device.cmd_draw_indexed(draw_command_buffer,
|
||||||
index_buffer_data.len() as u32,
|
index_buffer_data.len() as u32,
|
||||||
1,
|
1,
|
||||||
|
@ -935,7 +935,7 @@ fn main() {
|
||||||
});
|
});
|
||||||
//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::PRESENT_INFO_KHR,
|
||||||
p_next: ptr::null(),
|
p_next: ptr::null(),
|
||||||
wait_semaphore_count: 1,
|
wait_semaphore_count: 1,
|
||||||
p_wait_semaphores: &base.rendering_complete_semaphore,
|
p_wait_semaphores: &base.rendering_complete_semaphore,
|
||||||
|
|
Loading…
Reference in a new issue