Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions backends/vulkan/runtime/api/containers/Tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,11 +810,22 @@ void vTensorStorage::transition(
dst_stage = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
}

VkAccessFlags dst_access = vkapi::vk_access(cur_stage, cur_access);

// WAR hazard: the read-only source access mask yields an execution-only
// dependency that some drivers may drop, so widen it to a full memory
// barrier to keep the write from racing the prior read.
const bool prev_read = (prev_access & vkapi::MemoryAccessType::READ) != 0;
if (prev_read && !prev_written && cur_written) {
src_stage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
dst_stage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
src_access = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
dst_access = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
}

pipeline_barrier.stage.src |= src_stage;
pipeline_barrier.stage.dst |= dst_stage;

VkAccessFlags dst_access = vkapi::vk_access(cur_stage, cur_access);

if (image_) {
pipeline_barrier.images.emplace_back(
src_access, dst_access, cur_layout, new_layout, image_);
Expand Down
Loading