Cleanup implementation

This commit is contained in:
msiglreith 2018-01-09 23:00:35 +01:00
parent b9118e60a5
commit 1a1f1f856e
2 changed files with 25 additions and 23 deletions

View file

@ -179,17 +179,18 @@ pub fn map_image_kind(
}
pub fn map_image_layout(layout: VkImageLayout) -> image::ImageLayout {
use hal::image::ImageLayout::*;
match layout {
VkImageLayout::VK_IMAGE_LAYOUT_UNDEFINED => image::ImageLayout::Undefined,
VkImageLayout::VK_IMAGE_LAYOUT_GENERAL => image::ImageLayout::General,
VkImageLayout::VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL => image::ImageLayout::ColorAttachmentOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL => image::ImageLayout::DepthStencilAttachmentOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL => image::ImageLayout::DepthStencilReadOnlyOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL => image::ImageLayout::ShaderReadOnlyOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL => image::ImageLayout::TransferSrcOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL => image::ImageLayout::TransferDstOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_PREINITIALIZED => image::ImageLayout::Preinitialized,
VkImageLayout::VK_IMAGE_LAYOUT_PRESENT_SRC_KHR => image::ImageLayout::Present,
VkImageLayout::VK_IMAGE_LAYOUT_UNDEFINED => Undefined,
VkImageLayout::VK_IMAGE_LAYOUT_GENERAL => General,
VkImageLayout::VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL => ColorAttachmentOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL => DepthStencilAttachmentOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL => DepthStencilReadOnlyOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL => ShaderReadOnlyOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL => TransferSrcOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL => TransferDstOptimal,
VkImageLayout::VK_IMAGE_LAYOUT_PREINITIALIZED => Preinitialized,
VkImageLayout::VK_IMAGE_LAYOUT_PRESENT_SRC_KHR => Present,
_ => panic!("Unexpected image layout: {:?}", layout),
}
}

View file

@ -235,7 +235,7 @@ pub extern "C" fn gfxCreateDevice(
let group = gpu.queues.take_raw(id).unwrap();
let queues = group
.into_iter()
.map(|queue| Handle::new(queue))
.map(Handle::new)
.collect();
(info.queueFamilyIndex, queues)
@ -1297,11 +1297,13 @@ pub extern "C" fn gfxCreateRenderPass(
}
*/
};
let depth_stencil = if subpass.pDepthStencilAttachment.is_null() {
None
} else {
Some(unsafe { map_attachment_ref(&*subpass.pDepthStencilAttachment) })
let depth_stencil = unsafe {
subpass
.pDepthStencilAttachment
.as_ref()
.map(|attachment| map_attachment_ref(attachment))
};
let preserve = unsafe {
slice::from_raw_parts(subpass.pPreserveAttachments, subpass.preserveAttachmentCount as _)
.into_iter()
@ -1318,15 +1320,14 @@ pub extern "C" fn gfxCreateRenderPass(
});
}
let subpasses = subpasses
.into_iter()
.enumerate()
.map(|(i, _)| {
let subpasses = attachment_refs
.iter()
.map(|attachment_ref| {
pass::SubpassDesc {
colors: &attachment_refs[i].color,
depth_stencil: attachment_refs[i].depth_stencil.as_ref(),
inputs: &attachment_refs[i].input,
preserves: &attachment_refs[i].preserve,
colors: &attachment_ref.color,
depth_stencil: attachment_ref.depth_stencil.as_ref(),
inputs: &attachment_ref.input,
preserves: &attachment_ref.preserve,
}
})
.collect::<Vec<_>>();