vk: use explicit tranisition for hello triangle

This commit is contained in:
chyyran 2023-01-15 17:21:10 -05:00
parent 14f94e8346
commit d9d75d760c
2 changed files with 43 additions and 23 deletions

View file

@ -178,23 +178,42 @@ impl VulkanWindow {
.begin_command_buffer(cmd, &vk::CommandBufferBeginInfo::default())
.expect("failed to begin command buffer");
// util::vulkan_image_layout_transition_levels(
// &vulkan.base.device,
// cmd,
// framebuffer_image,
// 1,
// vk::ImageLayout::UNDEFINED,
// vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
// vk::AccessFlags::empty(),
// vk::AccessFlags::SHADER_READ,
// vk::PipelineStageFlags::ALL_GRAPHICS,
// vk::PipelineStageFlags::VERTEX_SHADER,
// vk::QUEUE_FAMILY_IGNORED,
// vk::QUEUE_FAMILY_IGNORED
// );
util::vulkan_image_layout_transition_levels(
&vulkan.base.device,
cmd,
framebuffer_image,
1,
vk::ImageLayout::UNDEFINED,
vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
vk::AccessFlags::MEMORY_READ
| vk::AccessFlags::MEMORY_WRITE | vk::AccessFlags::HOST_READ | vk::AccessFlags::HOST_WRITE
| vk::AccessFlags::COLOR_ATTACHMENT_READ | vk::AccessFlags::COLOR_ATTACHMENT_WRITE | vk::AccessFlags::SHADER_READ,
vk::AccessFlags::COLOR_ATTACHMENT_WRITE | vk::AccessFlags::COLOR_ATTACHMENT_READ,
vk::PipelineStageFlags::ALL_COMMANDS,
vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
vk::QUEUE_FAMILY_IGNORED,
vk::QUEUE_FAMILY_IGNORED
);
Self::record_command_buffer(vulkan, framebuffer, cmd);
util::vulkan_image_layout_transition_levels(
&vulkan.base.device,
cmd,
framebuffer_image,
1,
vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
vk::AccessFlags::MEMORY_READ
| vk::AccessFlags::MEMORY_WRITE | vk::AccessFlags::HOST_READ | vk::AccessFlags::HOST_WRITE
| vk::AccessFlags::COLOR_ATTACHMENT_READ | vk::AccessFlags::COLOR_ATTACHMENT_WRITE | vk::AccessFlags::SHADER_READ,
vk::AccessFlags::SHADER_READ,
vk::PipelineStageFlags::ALL_COMMANDS,
vk::PipelineStageFlags::FRAGMENT_SHADER,
vk::QUEUE_FAMILY_IGNORED,
vk::QUEUE_FAMILY_IGNORED
);
//
// util::vulkan_image_layout_transition_levels(
// &vulkan.base.device,
// cmd,

View file

@ -250,7 +250,7 @@ impl VulkanPipeline {
samples: vk::SampleCountFlags::TYPE_1,
load_op: vk::AttachmentLoadOp::CLEAR,
store_op: vk::AttachmentStoreOp::STORE,
initial_layout: vk::ImageLayout::UNDEFINED,
initial_layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
final_layout: vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
..Default::default()
}];
@ -259,14 +259,15 @@ impl VulkanPipeline {
layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
}];
let dependencies = [vk::SubpassDependency {
src_subpass: vk::SUBPASS_EXTERNAL,
src_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
dst_access_mask: vk::AccessFlags::COLOR_ATTACHMENT_READ
| vk::AccessFlags::COLOR_ATTACHMENT_WRITE,
dst_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
..Default::default()
}];
// gonna use an explicit transition instead
// let dependencies = [
// vk::SubpassDependency {
// src_subpass: vk::SUBPASS_EXTERNAL,
// src_stage_mask: vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
// dst_access_mask: vk::AccessFlags::COLOR_ATTACHMENT_READ | vk::AccessFlags::COLOR_ATTACHMENT_WRITE,
// dst_stage_mask: vk::PipelineStageFlags::FRAGMENT_SHADER,
// ..Default::default()
// }];
let subpass = vk::SubpassDescription::builder()
.color_attachments(&color_attachment_refs)