| 628 | } |
| 629 | |
| 630 | bool AccessState::ApplyBarrier(const BarrierScope& barrier_scope, const SyncBarrier& barrier, bool layout_transition, |
| 631 | uint32_t layout_transition_handle_index, ResourceUsageTag layout_transition_tag) { |
| 632 | // Dedicated layout transition barrier logic |
| 633 | if (layout_transition) { |
| 634 | const SyncAccessInfo& layout_transition_access_info = GetAccessInfo(SYNC_IMAGE_LAYOUT_TRANSITION); |
| 635 | const ResourceUsageTagEx tag_ex = ResourceUsageTagEx{layout_transition_tag, layout_transition_handle_index}; |
| 636 | const OrderingBarrier layout_ordering{barrier.src_exec_scope.exec_scope, barrier.src_access_scope}; |
| 637 | |
| 638 | // Register write access that models layout transition writes |
| 639 | SetWrite(SYNC_IMAGE_LAYOUT_TRANSITION, AttachmentAccess::NonAttachment(), tag_ex); |
| 640 | UpdateFirst(tag_ex, layout_transition_access_info, AttachmentAccess::NonAttachment()); |
| 641 | TouchupFirstForLayoutTransition(layout_transition_tag, layout_ordering); |
| 642 | |
| 643 | last_write->barriers |= barrier.dst_access_scope; |
| 644 | last_write->dependency_chain |= barrier.dst_exec_scope.exec_scope; |
| 645 | return true; |
| 646 | } |
| 647 | |
| 648 | bool barrier_applied = false; |
| 649 | |
| 650 | // Apply barriers over write access |
| 651 | if (last_write.has_value() && last_write->InBarrierSourceScope(barrier_scope)) { |
| 652 | last_write->barriers |= barrier.dst_access_scope; |
| 653 | last_write->dependency_chain |= barrier.dst_exec_scope.exec_scope; |
| 654 | barrier_applied = true; |
| 655 | } |
| 656 | // Apply barriers over read accesses |
| 657 | VkPipelineStageFlags2 stages_in_scope = VK_PIPELINE_STAGE_2_NONE; |
| 658 | for (ReadState& read_access : GetReads()) { |
| 659 | // The | implements the "dependency chain" logic for this access, |
| 660 | // as the barriers field stores the second sync scope |
| 661 | if (read_access.InBarrierSourceScope(barrier_scope)) { |
| 662 | // We will apply the barrier in the next loop to have this in one place |
| 663 | stages_in_scope |= read_access.stage; |
| 664 | } |
| 665 | } |
| 666 | for (ReadState& read_access : GetReads()) { |
| 667 | if ((read_access.stage | read_access.sync_stages) & stages_in_scope) { |
| 668 | // If this stage, or any stage known to be synchronized after it are in scope, apply the barrier to this read. |
| 669 | // NOTE: Forwarding barriers to known prior stages changes the sync_stages from shallow to deep, because the |
| 670 | // barriers used to determine sync_stages have been propagated to all known earlier stages |
| 671 | read_access.barriers |= barrier.dst_exec_scope.exec_scope; |
| 672 | read_execution_barriers |= barrier.dst_exec_scope.exec_scope; |
| 673 | barrier_applied = true; |
| 674 | } |
| 675 | } |
| 676 | return barrier_applied; |
| 677 | } |
| 678 | |
| 679 | void AccessState::CollectPendingBarriers(const BarrierScope& barrier_scope, const SyncBarrier& barrier, bool layout_transition, |
| 680 | uint32_t layout_transition_handle_index, PendingBarriers& pending_barriers) { |
no test coverage detected