diff --git a/librashader-runtime-vk/src/hello_triangle/mod.rs b/librashader-runtime-vk/src/hello_triangle/mod.rs index c1ab28f..479ed33 100644 --- a/librashader-runtime-vk/src/hello_triangle/mod.rs +++ b/librashader-runtime-vk/src/hello_triangle/mod.rs @@ -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, diff --git a/librashader-runtime-vk/src/hello_triangle/pipeline.rs b/librashader-runtime-vk/src/hello_triangle/pipeline.rs index 5895a7e..7a1bd4f 100644 --- a/librashader-runtime-vk/src/hello_triangle/pipeline.rs +++ b/librashader-runtime-vk/src/hello_triangle/pipeline.rs @@ -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)