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()) .begin_command_buffer(cmd, &vk::CommandBufferBeginInfo::default())
.expect("failed to begin command buffer"); .expect("failed to begin command buffer");
// util::vulkan_image_layout_transition_levels( util::vulkan_image_layout_transition_levels(
// &vulkan.base.device, &vulkan.base.device,
// cmd, cmd,
// framebuffer_image, framebuffer_image,
// 1, 1,
// vk::ImageLayout::UNDEFINED, vk::ImageLayout::UNDEFINED,
// vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL, vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
// vk::AccessFlags::empty(), vk::AccessFlags::MEMORY_READ
// vk::AccessFlags::SHADER_READ, | vk::AccessFlags::MEMORY_WRITE | vk::AccessFlags::HOST_READ | vk::AccessFlags::HOST_WRITE
// vk::PipelineStageFlags::ALL_GRAPHICS, | vk::AccessFlags::COLOR_ATTACHMENT_READ | vk::AccessFlags::COLOR_ATTACHMENT_WRITE | vk::AccessFlags::SHADER_READ,
// vk::PipelineStageFlags::VERTEX_SHADER, vk::AccessFlags::COLOR_ATTACHMENT_WRITE | vk::AccessFlags::COLOR_ATTACHMENT_READ,
// vk::QUEUE_FAMILY_IGNORED, vk::PipelineStageFlags::ALL_COMMANDS,
// vk::QUEUE_FAMILY_IGNORED vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
// ); vk::QUEUE_FAMILY_IGNORED,
vk::QUEUE_FAMILY_IGNORED
);
Self::record_command_buffer(vulkan, framebuffer, cmd); 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( // util::vulkan_image_layout_transition_levels(
// &vulkan.base.device, // &vulkan.base.device,
// cmd, // cmd,

View file

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