John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1 | /* |
John Zulauf | ab7756b | 2020-12-29 16:10:16 -0700 | [diff] [blame] | 2 | * Copyright (c) 2019-2021 Valve Corporation |
| 3 | * Copyright (c) 2019-2021 LunarG, Inc. |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | * Author: John Zulauf <jzulauf@lunarg.com> |
John Zulauf | ab7756b | 2020-12-29 16:10:16 -0700 | [diff] [blame] | 18 | * Author: Locke Lin <locke@lunarg.com> |
| 19 | * Author: Jeremy Gebben <jeremyg@lunarg.com> |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #pragma once |
| 23 | |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 24 | #include <limits> |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 25 | #include <map> |
| 26 | #include <memory> |
| 27 | #include <unordered_map> |
| 28 | #include <vulkan/vulkan.h> |
| 29 | |
| 30 | #include "synchronization_validation_types.h" |
| 31 | #include "state_tracker.h" |
| 32 | |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 33 | class AccessContext; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 34 | class CommandBufferAccessContext; |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 35 | using CommandBufferAccessContextShared = std::shared_ptr<CommandBufferAccessContext>; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 36 | class CommandExecutionContext; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 37 | class ResourceAccessState; |
| 38 | class SyncValidator; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 39 | |
John Zulauf | 2f952d2 | 2020-02-10 11:34:51 -0700 | [diff] [blame] | 40 | enum SyncHazard { |
| 41 | NONE = 0, |
| 42 | READ_AFTER_WRITE, |
| 43 | WRITE_AFTER_READ, |
| 44 | WRITE_AFTER_WRITE, |
| 45 | READ_RACING_WRITE, |
| 46 | WRITE_RACING_WRITE, |
| 47 | WRITE_RACING_READ, |
| 48 | }; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 49 | |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 50 | enum class SyncOrdering : uint8_t { |
| 51 | kNonAttachment = 0, |
| 52 | kColorAttachment = 1, |
| 53 | kDepthStencilAttachment = 2, |
| 54 | kRaster = 3, |
| 55 | kNumOrderings = 4, |
| 56 | }; |
| 57 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 58 | // Useful Utilites for manipulating StageAccess parameters, suitable as base class to save typing |
| 59 | struct SyncStageAccess { |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 60 | static inline SyncStageAccessFlags FlagBit(SyncStageAccessIndex stage_access) { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 61 | return syncStageAccessInfoByStageAccessIndex[stage_access].stage_access_bit; |
| 62 | } |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 63 | static inline SyncStageAccessFlags Flags(SyncStageAccessIndex stage_access) { |
| 64 | return static_cast<SyncStageAccessFlags>(FlagBit(stage_access)); |
| 65 | } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 66 | |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 67 | static bool IsRead(const SyncStageAccessFlags &stage_access_bit) { return (stage_access_bit & syncStageAccessReadMask).any(); } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 68 | static bool IsRead(SyncStageAccessIndex stage_access_index) { return IsRead(FlagBit(stage_access_index)); } |
| 69 | |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 70 | static bool IsWrite(const SyncStageAccessFlags &stage_access_bit) { |
| 71 | return (stage_access_bit & syncStageAccessWriteMask).any(); |
| 72 | } |
| 73 | static bool HasWrite(const SyncStageAccessFlags &stage_access_mask) { |
| 74 | return (stage_access_mask & syncStageAccessWriteMask).any(); |
| 75 | } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 76 | static bool IsWrite(SyncStageAccessIndex stage_access_index) { return IsWrite(FlagBit(stage_access_index)); } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 77 | static VkPipelineStageFlags2KHR PipelineStageBit(SyncStageAccessIndex stage_access_index) { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 78 | return syncStageAccessInfoByStageAccessIndex[stage_access_index].stage_mask; |
| 79 | } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 80 | static SyncStageAccessFlags AccessScopeByStage(VkPipelineStageFlags2KHR stages); |
| 81 | static SyncStageAccessFlags AccessScopeByAccess(VkAccessFlags2KHR access); |
| 82 | static SyncStageAccessFlags AccessScope(VkPipelineStageFlags2KHR stages, VkAccessFlags2KHR access); |
| 83 | static SyncStageAccessFlags AccessScope(const SyncStageAccessFlags &stage_scope, VkAccessFlags2KHR accesses) { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 84 | return stage_scope & AccessScopeByAccess(accesses); |
| 85 | } |
| 86 | }; |
| 87 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 88 | // The resource tag is relative to the command buffer or queue in which it's found |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 89 | struct ResourceUsageTag { |
John Zulauf | f4aecca | 2021-01-05 16:21:58 -0700 | [diff] [blame] | 90 | using TagIndex = uint64_t; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 91 | using Count = uint32_t; |
John Zulauf | f4aecca | 2021-01-05 16:21:58 -0700 | [diff] [blame] | 92 | constexpr static TagIndex kMaxIndex = std::numeric_limits<TagIndex>::max(); |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 93 | constexpr static uint32_t kMaxCount = std::numeric_limits<Count>::max(); |
Jeremy Gebben | 4bb7350 | 2020-12-14 11:17:50 -0700 | [diff] [blame] | 94 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 95 | TagIndex index = 0U; // the index of the command within the command buffer itself (primary or secondary) |
| 96 | CMD_TYPE command = CMD_NONE; |
| 97 | Count seq_num = 0U; |
| 98 | Count sub_command = 0U; |
Jeremy Gebben | 4bb7350 | 2020-12-14 11:17:50 -0700 | [diff] [blame] | 99 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 100 | bool operator<(const ResourceUsageTag &rhs) const { return index < rhs.index; } |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 101 | bool IsBefore(const ResourceUsageTag &rhs) const { return index < rhs.index; } |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 102 | bool operator==(const ResourceUsageTag &rhs) const { return (index == rhs.index); } |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 103 | bool operator!=(const ResourceUsageTag &rhs) const { return !(*this == rhs); } |
Jeremy Gebben | 4bb7350 | 2020-12-14 11:17:50 -0700 | [diff] [blame] | 104 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 105 | ResourceUsageTag() = default; |
| 106 | ResourceUsageTag(TagIndex index_, Count seq_num_, Count sub_command_, CMD_TYPE command_) |
| 107 | : index(index_), command(command_), seq_num(seq_num_), sub_command(sub_command_) {} |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 108 | }; |
| 109 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 110 | struct HazardResult { |
John Zulauf | 59e2507 | 2020-07-17 10:55:21 -0600 | [diff] [blame] | 111 | std::unique_ptr<const ResourceAccessState> access_state; |
| 112 | SyncStageAccessIndex usage_index = std::numeric_limits<SyncStageAccessIndex>::max(); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 113 | SyncHazard hazard = NONE; |
John Zulauf | 37ceaed | 2020-07-03 16:18:15 -0600 | [diff] [blame] | 114 | SyncStageAccessFlags prior_access = 0U; // TODO -- change to a NONE enum in ...Bits |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 115 | ResourceUsageTag tag = ResourceUsageTag(); |
John Zulauf | 59e2507 | 2020-07-17 10:55:21 -0600 | [diff] [blame] | 116 | void Set(const ResourceAccessState *access_state_, SyncStageAccessIndex usage_index_, SyncHazard hazard_, |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 117 | const SyncStageAccessFlags &prior_, const ResourceUsageTag &tag_); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 118 | }; |
| 119 | |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 120 | struct SyncExecScope { |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 121 | VkPipelineStageFlags2KHR mask_param; // the xxxStageMask parameter passed by the caller |
| 122 | VkPipelineStageFlags2KHR |
| 123 | expanded_mask; // all stage bits covered by any 'catch all bits' in the parameter (eg. ALL_GRAPHICS_BIT). |
| 124 | VkPipelineStageFlags2KHR exec_scope; // all earlier or later stages that would be affected by a barrier using this scope. |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 125 | SyncStageAccessFlags valid_accesses; // all valid accesses that can be used with this scope. |
| 126 | |
| 127 | SyncExecScope() : mask_param(0), expanded_mask(0), exec_scope(0), valid_accesses(0) {} |
| 128 | |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 129 | static SyncExecScope MakeSrc(VkQueueFlags queue_flags, VkPipelineStageFlags2KHR src_stage_mask); |
| 130 | static SyncExecScope MakeDst(VkQueueFlags queue_flags, VkPipelineStageFlags2KHR src_stage_mask); |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 131 | }; |
| 132 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 133 | struct SyncBarrier { |
John Zulauf | c523bf6 | 2021-02-16 08:20:34 -0700 | [diff] [blame^] | 134 | SyncExecScope src_exec_scope; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 135 | SyncStageAccessFlags src_access_scope; |
John Zulauf | c523bf6 | 2021-02-16 08:20:34 -0700 | [diff] [blame^] | 136 | SyncExecScope dst_exec_scope; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 137 | SyncStageAccessFlags dst_access_scope; |
| 138 | SyncBarrier() = default; |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 139 | SyncBarrier(const SyncBarrier &other) = default; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 140 | SyncBarrier &operator=(const SyncBarrier &) = default; |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 141 | |
| 142 | SyncBarrier(const SyncExecScope &src, const SyncExecScope &dst); |
| 143 | |
| 144 | template <typename Barrier> |
| 145 | SyncBarrier(const Barrier &barrier, const SyncExecScope &src, const SyncExecScope &dst); |
| 146 | |
| 147 | SyncBarrier(VkQueueFlags queue_flags, const VkSubpassDependency2 &barrier); |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 148 | // template constructor for sync2 barriers |
| 149 | template <typename Barrier> |
| 150 | SyncBarrier(VkQueueFlags queue_flags, const Barrier &barrier); |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 151 | |
John Zulauf | a0a9829 | 2020-09-18 09:30:10 -0600 | [diff] [blame] | 152 | void Merge(const SyncBarrier &other) { |
John Zulauf | c523bf6 | 2021-02-16 08:20:34 -0700 | [diff] [blame^] | 153 | // Note that after merge, only the exec_scope and access_scope fields are fully valid |
| 154 | // TODO: Do we need to update any of the other fields? Merging has limited application. |
| 155 | src_exec_scope.exec_scope |= other.src_exec_scope.exec_scope; |
John Zulauf | a0a9829 | 2020-09-18 09:30:10 -0600 | [diff] [blame] | 156 | src_access_scope |= other.src_access_scope; |
John Zulauf | c523bf6 | 2021-02-16 08:20:34 -0700 | [diff] [blame^] | 157 | dst_exec_scope.exec_scope |= other.dst_exec_scope.exec_scope; |
John Zulauf | a0a9829 | 2020-09-18 09:30:10 -0600 | [diff] [blame] | 158 | dst_access_scope |= other.dst_access_scope; |
| 159 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 160 | }; |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 161 | |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 162 | enum class AccessAddressType : uint32_t { kLinear = 0, kIdealized = 1, kMaxType = 1, kTypeCount = kMaxType + 1 }; |
| 163 | |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 164 | struct SyncEventState { |
| 165 | enum IgnoreReason { NotIgnored = 0, ResetWaitRace, SetRace, MissingStageBits }; |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 166 | using EventPointer = std::shared_ptr<const EVENT_STATE>; |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 167 | using ScopeMap = sparse_container::range_map<VkDeviceSize, bool>; |
| 168 | EventPointer event; |
| 169 | CMD_TYPE last_command; // Only Event commands are valid here. |
| 170 | CMD_TYPE unsynchronized_set; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 171 | VkPipelineStageFlags2KHR barriers; |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 172 | SyncExecScope scope; |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 173 | ResourceUsageTag first_scope_tag; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 174 | bool destroyed; |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 175 | std::array<ScopeMap, static_cast<size_t>(AccessAddressType::kTypeCount)> first_scope; |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 176 | template <typename EventPointerType> |
| 177 | SyncEventState(EventPointerType &&event_state) |
| 178 | : event(std::forward<EventPointerType>(event_state)), |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 179 | last_command(CMD_NONE), |
| 180 | unsynchronized_set(CMD_NONE), |
| 181 | barriers(0U), |
| 182 | scope(), |
| 183 | first_scope_tag(), |
| 184 | destroyed((event_state.get() == nullptr) || event_state->destroyed) {} |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 185 | SyncEventState() : SyncEventState(EventPointer()) {} |
| 186 | void ResetFirstScope(); |
| 187 | const ScopeMap &FirstScope(AccessAddressType address_type) const { return first_scope[static_cast<size_t>(address_type)]; } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 188 | IgnoreReason IsIgnoredByWait(VkPipelineStageFlags2KHR srcStageMask) const; |
| 189 | bool HasBarrier(VkPipelineStageFlags2KHR stageMask, VkPipelineStageFlags2KHR exec_scope) const; |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 190 | }; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 191 | using SyncEventStateShared = std::shared_ptr<SyncEventState>; |
| 192 | using SyncEventStateConstShared = std::shared_ptr<const SyncEventState>; |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 193 | class SyncEventsContext { |
| 194 | public: |
| 195 | using Map = std::unordered_map<const EVENT_STATE *, SyncEventStateShared>; |
| 196 | using iterator = Map::iterator; |
| 197 | using const_iterator = Map::const_iterator; |
| 198 | |
| 199 | SyncEventState *GetFromShared(const SyncEventState::EventPointer &event_state) { |
| 200 | const auto find_it = map_.find(event_state.get()); |
| 201 | if (find_it == map_.end()) { |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 202 | if (!event_state.get()) return nullptr; |
| 203 | |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 204 | const auto *event_plain_ptr = event_state.get(); |
| 205 | auto sync_state = SyncEventStateShared(new SyncEventState(event_state)); |
| 206 | auto insert_pair = map_.insert(std::make_pair(event_plain_ptr, std::move(sync_state))); |
| 207 | return insert_pair.first->second.get(); |
| 208 | } |
| 209 | return find_it->second.get(); |
| 210 | } |
| 211 | |
| 212 | const SyncEventState *Get(const EVENT_STATE *event_state) const { |
| 213 | const auto find_it = map_.find(event_state); |
| 214 | if (find_it == map_.end()) { |
| 215 | return nullptr; |
| 216 | } |
| 217 | return find_it->second.get(); |
| 218 | } |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 219 | const SyncEventState *Get(const SyncEventState::EventPointer &event_state) const { return Get(event_state.get()); } |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 220 | |
| 221 | // stl style naming for range-for support |
| 222 | inline iterator begin() { return map_.begin(); } |
| 223 | inline const_iterator begin() const { return map_.begin(); } |
| 224 | inline iterator end() { return map_.end(); } |
| 225 | inline const_iterator end() const { return map_.end(); } |
| 226 | |
| 227 | void Destroy(const EVENT_STATE *event_state) { |
| 228 | auto sync_it = map_.find(event_state); |
| 229 | if (sync_it != map_.end()) { |
| 230 | sync_it->second->destroyed = true; |
| 231 | map_.erase(sync_it); |
| 232 | } |
| 233 | } |
| 234 | void Clear() { map_.clear(); } |
| 235 | |
| 236 | private: |
| 237 | Map map_; |
| 238 | }; |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 239 | |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 240 | // To represent ordering guarantees such as rasterization and store |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 241 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 242 | class ResourceAccessState : public SyncStageAccess { |
| 243 | protected: |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 244 | struct OrderingBarrier { |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 245 | VkPipelineStageFlags2KHR exec_scope; |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 246 | SyncStageAccessFlags access_scope; |
| 247 | OrderingBarrier() = default; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 248 | OrderingBarrier(VkPipelineStageFlags2KHR es, SyncStageAccessFlags as) : exec_scope(es), access_scope(as) {} |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 249 | OrderingBarrier &operator=(const OrderingBarrier &) = default; |
| 250 | }; |
| 251 | using OrderingBarriers = std::array<OrderingBarrier, static_cast<size_t>(SyncOrdering::kNumOrderings)>; |
| 252 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 253 | struct FirstAccess { |
| 254 | ResourceUsageTag tag; |
| 255 | SyncStageAccessIndex usage_index; |
| 256 | SyncOrdering ordering_rule; |
| 257 | FirstAccess(const ResourceUsageTag &tag_, SyncStageAccessIndex usage_index_, SyncOrdering ordering_rule_) |
| 258 | : tag(tag_), usage_index(usage_index_), ordering_rule(ordering_rule_){}; |
| 259 | FirstAccess(const FirstAccess &other) = default; |
| 260 | FirstAccess(FirstAccess &&other) = default; |
| 261 | FirstAccess &operator=(const FirstAccess &rhs) = default; |
| 262 | FirstAccess &operator=(FirstAccess &&rhs) = default; |
| 263 | |
| 264 | bool operator==(const FirstAccess &rhs) const { |
| 265 | return (tag == rhs.tag) && (usage_index == rhs.usage_index) && (ordering_rule == rhs.ordering_rule); |
| 266 | } |
| 267 | }; |
| 268 | using FirstAccesses = small_vector<FirstAccess, 3>; |
| 269 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 270 | // Mutliple read operations can be simlutaneously (and independently) synchronized, |
| 271 | // given the only the second execution scope creates a dependency chain, we have to track each, |
| 272 | // but only up to one per pipeline stage (as another read from the *same* stage become more recent, |
| 273 | // and applicable one for hazard detection |
| 274 | struct ReadState { |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 275 | VkPipelineStageFlags2KHR stage; // The stage of this read |
John Zulauf | 37ceaed | 2020-07-03 16:18:15 -0600 | [diff] [blame] | 276 | SyncStageAccessFlags access; // TODO: Change to FlagBits when we have a None bit enum |
John Zulauf | f51fbb6 | 2020-10-02 14:43:24 -0600 | [diff] [blame] | 277 | // TODO: Revisit whether this needs to support multiple reads per stage |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 278 | VkPipelineStageFlags2KHR barriers; // all applicable barriered stages |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 279 | ResourceUsageTag tag; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 280 | VkPipelineStageFlags2KHR pending_dep_chain; // Should be zero except during barrier application |
| 281 | // Excluded from comparison |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 282 | ReadState() = default; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 283 | ReadState(VkPipelineStageFlags2KHR stage_, SyncStageAccessFlags access_, VkPipelineStageFlags2KHR barriers_, |
John Zulauf | ab7756b | 2020-12-29 16:10:16 -0700 | [diff] [blame] | 284 | const ResourceUsageTag &tag_) |
| 285 | : stage(stage_), access(access_), barriers(barriers_), tag(tag_), pending_dep_chain(0) {} |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 286 | bool operator==(const ReadState &rhs) const { |
John Zulauf | 37ceaed | 2020-07-03 16:18:15 -0600 | [diff] [blame] | 287 | bool same = (stage == rhs.stage) && (access == rhs.access) && (barriers == rhs.barriers) && (tag == rhs.tag); |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 288 | return same; |
| 289 | } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 290 | bool IsReadBarrierHazard(VkPipelineStageFlags2KHR src_exec_scope) const { |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 291 | // If the read stage is not in the src sync scope |
| 292 | // *AND* not execution chained with an existing sync barrier (that's the or) |
| 293 | // then the barrier access is unsafe (R/W after R) |
| 294 | return (src_exec_scope & (stage | barriers)) == 0; |
| 295 | } |
| 296 | |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 297 | bool operator!=(const ReadState &rhs) const { return !(*this == rhs); } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 298 | inline void Set(VkPipelineStageFlags2KHR stage_, const SyncStageAccessFlags &access_, VkPipelineStageFlags2KHR barriers_, |
John Zulauf | 4285ee9 | 2020-09-23 10:20:52 -0600 | [diff] [blame] | 299 | const ResourceUsageTag &tag_) { |
| 300 | stage = stage_; |
| 301 | access = access_; |
| 302 | barriers = barriers_; |
| 303 | tag = tag_; |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 304 | pending_dep_chain = 0; // If this is a new read, we aren't applying a barrier set. |
John Zulauf | 4285ee9 | 2020-09-23 10:20:52 -0600 | [diff] [blame] | 305 | } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 306 | }; |
| 307 | |
| 308 | public: |
| 309 | HazardResult DetectHazard(SyncStageAccessIndex usage_index) const; |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 310 | HazardResult DetectHazard(SyncStageAccessIndex usage_index, const SyncOrdering &ordering_rule) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 311 | |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 312 | HazardResult DetectBarrierHazard(SyncStageAccessIndex usage_index, VkPipelineStageFlags2KHR source_exec_scope, |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 313 | const SyncStageAccessFlags &source_access_scope) const; |
Jeremy Gebben | c4b78c5 | 2020-12-11 09:39:47 -0700 | [diff] [blame] | 314 | HazardResult DetectAsyncHazard(SyncStageAccessIndex usage_index, const ResourceUsageTag &start_tag) const; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 315 | HazardResult DetectBarrierHazard(SyncStageAccessIndex usage_index, VkPipelineStageFlags2KHR source_exec_scope, |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 316 | const SyncStageAccessFlags &source_access_scope, const ResourceUsageTag &event_tag) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 317 | |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 318 | void Update(SyncStageAccessIndex usage_index, SyncOrdering ordering_rule, const ResourceUsageTag &tag); |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 319 | void SetWrite(const SyncStageAccessFlags &usage_bit, const ResourceUsageTag &tag); |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 320 | void Resolve(const ResourceAccessState &other); |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 321 | void ApplyBarriers(const std::vector<SyncBarrier> &barriers, bool layout_transition); |
| 322 | void ApplyBarriers(const std::vector<SyncBarrier> &barriers, const ResourceUsageTag &tag); |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 323 | void ApplyBarrier(const SyncBarrier &barrier, bool layout_transition); |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 324 | void ApplyBarrier(const ResourceUsageTag &scope_tag, const SyncBarrier &barrier, bool layout_transition); |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 325 | void ApplyPendingBarriers(const ResourceUsageTag &tag); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 326 | |
| 327 | ResourceAccessState() |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 328 | : write_barriers(~SyncStageAccessFlags(0)), |
| 329 | write_dependency_chain(0), |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 330 | write_tag(), |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 331 | last_write(0), |
John Zulauf | f51fbb6 | 2020-10-02 14:43:24 -0600 | [diff] [blame] | 332 | input_attachment_read(false), |
John Zulauf | 361fb53 | 2020-07-22 10:45:39 -0600 | [diff] [blame] | 333 | last_read_stages(0), |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 334 | read_execution_barriers(0), |
| 335 | pending_write_dep_chain(0), |
| 336 | pending_layout_transition(false), |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 337 | pending_write_barriers(0), |
| 338 | first_accesses_(), |
| 339 | first_read_stages_(0U) {} |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 340 | |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 341 | bool HasPendingState() const { |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 342 | return (0 != pending_layout_transition) || pending_write_barriers.any() || (0 != pending_write_dep_chain); |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 343 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 344 | bool HasWriteOp() const { return last_write != 0; } |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 345 | bool operator==(const ResourceAccessState &rhs) const { |
| 346 | bool same = (write_barriers == rhs.write_barriers) && (write_dependency_chain == rhs.write_dependency_chain) && |
John Zulauf | ab7756b | 2020-12-29 16:10:16 -0700 | [diff] [blame] | 347 | (last_reads == rhs.last_reads) && (last_read_stages == rhs.last_read_stages) && (write_tag == rhs.write_tag) && |
| 348 | (input_attachment_read == rhs.input_attachment_read) && |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 349 | (read_execution_barriers == rhs.read_execution_barriers) && (first_accesses_ == rhs.first_accesses_); |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 350 | return same; |
| 351 | } |
| 352 | bool operator!=(const ResourceAccessState &rhs) const { return !(*this == rhs); } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 353 | VkPipelineStageFlags2KHR GetReadBarriers(const SyncStageAccessFlags &usage) const; |
John Zulauf | 59e2507 | 2020-07-17 10:55:21 -0600 | [diff] [blame] | 354 | SyncStageAccessFlags GetWriteBarriers() const { return write_barriers; } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 355 | bool InSourceScopeOrChain(VkPipelineStageFlags2KHR src_exec_scope, SyncStageAccessFlags src_access_scope) const { |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 356 | return ReadInSourceScopeOrChain(src_exec_scope) || WriteInSourceScopeOrChain(src_exec_scope, src_access_scope); |
| 357 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 358 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 359 | private: |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 360 | static constexpr VkPipelineStageFlags2KHR kInvalidAttachmentStage = ~VkPipelineStageFlags2KHR(0); |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 361 | bool IsWriteHazard(SyncStageAccessFlags usage) const { return (usage & ~write_barriers).any(); } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 362 | bool IsRAWHazard(VkPipelineStageFlags2KHR usage_stage, const SyncStageAccessFlags &usage) const; |
| 363 | bool IsWriteBarrierHazard(VkPipelineStageFlags2KHR src_exec_scope, const SyncStageAccessFlags &src_access_scope) const { |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 364 | // If the previous write is *not* in the 1st access scope |
| 365 | // *AND* the current barrier is not in the dependency chain |
| 366 | // *AND* the there is no prior memory barrier for the previous write in the dependency chain |
| 367 | // then the barrier access is unsafe (R/W after W) |
| 368 | return ((last_write & src_access_scope) == 0) && ((src_exec_scope & write_dependency_chain) == 0) && (write_barriers == 0); |
| 369 | } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 370 | bool ReadInSourceScopeOrChain(VkPipelineStageFlags2KHR src_exec_scope) const { |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 371 | return (0 != (src_exec_scope & (last_read_stages | read_execution_barriers))); |
| 372 | } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 373 | bool WriteInSourceScopeOrChain(VkPipelineStageFlags2KHR src_exec_scope, SyncStageAccessFlags src_access_scope) const { |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 374 | return (src_access_scope & last_write).any() || (write_dependency_chain & src_exec_scope); |
John Zulauf | a0a9829 | 2020-09-18 09:30:10 -0600 | [diff] [blame] | 375 | } |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 376 | |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 377 | static bool IsReadHazard(VkPipelineStageFlags2KHR stage_mask, const VkPipelineStageFlags2KHR barriers) { |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 378 | return stage_mask != (stage_mask & barriers); |
| 379 | } |
| 380 | |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 381 | bool IsReadHazard(VkPipelineStageFlags2KHR stage_mask, const ReadState &read_access) const { |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 382 | return IsReadHazard(stage_mask, read_access.barriers); |
John Zulauf | 0cb5be2 | 2020-01-23 12:18:22 -0700 | [diff] [blame] | 383 | } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 384 | VkPipelineStageFlags2KHR GetOrderedStages(const OrderingBarrier &ordering) const; |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 385 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 386 | void UpdateFirst(const ResourceUsageTag &tag, SyncStageAccessIndex usage_index, SyncOrdering ordering_rule); |
| 387 | |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 388 | static const OrderingBarrier &GetOrderingRules(SyncOrdering ordering_enum) { |
| 389 | return kOrderingRules[static_cast<size_t>(ordering_enum)]; |
| 390 | } |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 391 | |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 392 | // TODO: Add a NONE (zero) enum to SyncStageAccessFlags for input_attachment_read and last_write |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 393 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 394 | // With reads, each must be "safe" relative to it's prior write, so we need only |
| 395 | // save the most recent write operation (as anything *transitively* unsafe would arleady |
| 396 | // be included |
| 397 | SyncStageAccessFlags write_barriers; // union of applicable barrier masks since last write |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 398 | VkPipelineStageFlags2KHR write_dependency_chain; // intiially zero, but accumulating the dstStages of barriers if they chain. |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 399 | ResourceUsageTag write_tag; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 400 | SyncStageAccessFlags last_write; // only the most recent write |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 401 | |
John Zulauf | f51fbb6 | 2020-10-02 14:43:24 -0600 | [diff] [blame] | 402 | // TODO Input Attachment cleanup for multiple reads in a given stage |
| 403 | // Tracks whether the fragment shader read is input attachment read |
| 404 | bool input_attachment_read; |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 405 | |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 406 | VkPipelineStageFlags2KHR last_read_stages; |
| 407 | VkPipelineStageFlags2KHR read_execution_barriers; |
John Zulauf | ab7756b | 2020-12-29 16:10:16 -0700 | [diff] [blame] | 408 | small_vector<ReadState, 3> last_reads; |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 409 | |
| 410 | // Pending execution state to support independent parallel barriers |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 411 | VkPipelineStageFlags2KHR pending_write_dep_chain; |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 412 | bool pending_layout_transition; |
| 413 | SyncStageAccessFlags pending_write_barriers; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 414 | FirstAccesses first_accesses_; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 415 | VkPipelineStageFlags2KHR first_read_stages_; |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 416 | |
| 417 | static OrderingBarriers kOrderingRules; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 418 | }; |
| 419 | |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 420 | using ResourceAccessRangeMap = sparse_container::range_map<VkDeviceSize, ResourceAccessState>; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 421 | using ResourceAccessRange = typename ResourceAccessRangeMap::key_type; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 422 | using ResourceRangeMergeIterator = sparse_container::parallel_iterator<ResourceAccessRangeMap, const ResourceAccessRangeMap>; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 423 | |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 424 | using SyncMemoryBarrier = SyncBarrier; |
| 425 | struct SyncBufferMemoryBarrier { |
| 426 | using Buffer = std::shared_ptr<const BUFFER_STATE>; |
| 427 | Buffer buffer; |
| 428 | SyncBarrier barrier; |
| 429 | ResourceAccessRange range; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 430 | bool IsLayoutTransition() const { return false; } |
| 431 | const ResourceAccessRange &Range() const { return range; }; |
| 432 | const BUFFER_STATE *GetState() const { return buffer.get(); } |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 433 | SyncBufferMemoryBarrier(const Buffer &buffer_, const SyncBarrier &barrier_, const ResourceAccessRange &range_) |
| 434 | : buffer(buffer_), barrier(barrier_), range(range_) {} |
| 435 | SyncBufferMemoryBarrier() = default; |
| 436 | }; |
| 437 | |
| 438 | struct SyncImageMemoryBarrier { |
| 439 | using Image = std::shared_ptr<const IMAGE_STATE>; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 440 | struct SubImageRange { |
| 441 | VkImageSubresourceRange subresource_range; |
| 442 | VkOffset3D offset; |
| 443 | VkExtent3D extent; |
| 444 | }; |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 445 | Image image; |
| 446 | uint32_t index; |
| 447 | SyncBarrier barrier; |
| 448 | VkImageLayout old_layout; |
| 449 | VkImageLayout new_layout; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 450 | SubImageRange range; |
| 451 | |
| 452 | bool IsLayoutTransition() const { return old_layout != new_layout; } |
| 453 | const SubImageRange &Range() const { return range; }; |
| 454 | const IMAGE_STATE *GetState() const { return image.get(); } |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 455 | SyncImageMemoryBarrier(const Image &image_, uint32_t index_, const SyncBarrier &barrier_, VkImageLayout old_layout_, |
| 456 | VkImageLayout new_layout_, const VkImageSubresourceRange &subresource_range_) |
| 457 | : image(image_), |
| 458 | index(index_), |
| 459 | barrier(barrier_), |
| 460 | old_layout(old_layout_), |
| 461 | new_layout(new_layout_), |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 462 | range({subresource_range_, VkOffset3D{0, 0, 0}, image->createInfo.extent}) {} |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 463 | SyncImageMemoryBarrier() = default; |
| 464 | }; |
| 465 | |
| 466 | class SyncOpBase { |
| 467 | public: |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 468 | SyncOpBase() : cmd_(CMD_NONE), name_override_(nullptr) {} |
| 469 | SyncOpBase(CMD_TYPE cmd, const char *name_override = nullptr) : cmd_(cmd), name_override_(name_override) {} |
| 470 | const char *CmdName() const { return name_override_ ? name_override_ : CommandTypeString(cmd_); } |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 471 | virtual bool Validate(const CommandBufferAccessContext &cb_context) const = 0; |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 472 | virtual void Record(CommandBufferAccessContext *cb_context) const = 0; |
| 473 | |
| 474 | protected: |
| 475 | CMD_TYPE cmd_; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 476 | // Some promoted commands alias CMD_TYPE for KHR and non-KHR versions, also callers to preserve the cmd name as needed |
| 477 | const char *name_override_; |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 478 | }; |
| 479 | |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 480 | class SyncOpBarriers : public SyncOpBase { |
| 481 | protected: |
| 482 | template <typename Barriers, typename FunctorFactory> |
| 483 | static void ApplyBarriers(const Barriers &barriers, const FunctorFactory &factory, const ResourceUsageTag &tag, |
| 484 | AccessContext *context); |
| 485 | template <typename Barriers, typename FunctorFactory> |
| 486 | static void ApplyGlobalBarriers(const Barriers &barriers, const FunctorFactory &factory, const ResourceUsageTag &tag, |
| 487 | AccessContext *access_context); |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 488 | |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 489 | SyncOpBarriers(CMD_TYPE cmd, const SyncValidator &sync_state, VkQueueFlags queue_flags, VkPipelineStageFlags srcStageMask, |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 490 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, |
| 491 | const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, |
| 492 | const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, |
| 493 | const VkImageMemoryBarrier *pImageMemoryBarriers); |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 494 | SyncOpBarriers(CMD_TYPE cmd, const SyncValidator &sync_state, VkQueueFlags queue_flags, |
| 495 | const VkDependencyInfoKHR &pDependencyInfo); |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 496 | |
| 497 | protected: |
| 498 | void MakeMemoryBarriers(const SyncExecScope &src, const SyncExecScope &dst, VkDependencyFlags dependencyFlags, |
| 499 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers); |
| 500 | void MakeBufferMemoryBarriers(const SyncValidator &sync_state, const SyncExecScope &src, const SyncExecScope &dst, |
| 501 | VkDependencyFlags dependencyFlags, uint32_t bufferMemoryBarrierCount, |
| 502 | const VkBufferMemoryBarrier *pBufferMemoryBarriers); |
| 503 | void MakeImageMemoryBarriers(const SyncValidator &sync_state, const SyncExecScope &src, const SyncExecScope &dst, |
| 504 | VkDependencyFlags dependencyFlags, uint32_t imageMemoryBarrierCount, |
| 505 | const VkImageMemoryBarrier *pImageMemoryBarriers); |
| 506 | |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 507 | void MakeMemoryBarriers(VkQueueFlags queue_flags, VkDependencyFlags dependency_flags, uint32_t barrier_count, |
| 508 | const VkMemoryBarrier2KHR *barriers); |
| 509 | void MakeBufferMemoryBarriers(const SyncValidator &sync_state, VkQueueFlags queue_flags, VkDependencyFlags dependency_flags, |
| 510 | uint32_t barrier_count, const VkBufferMemoryBarrier2KHR *barriers); |
| 511 | void MakeImageMemoryBarriers(const SyncValidator &sync_state, VkQueueFlags queue_flags, VkDependencyFlags dependency_flags, |
| 512 | uint32_t barrier_count, const VkImageMemoryBarrier2KHR *barriers); |
| 513 | |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 514 | VkDependencyFlags dependency_flags_; |
| 515 | SyncExecScope src_exec_scope_; |
| 516 | SyncExecScope dst_exec_scope_; |
| 517 | std::vector<SyncMemoryBarrier> memory_barriers_; |
| 518 | std::vector<SyncBufferMemoryBarrier> buffer_memory_barriers_; |
| 519 | std::vector<SyncImageMemoryBarrier> image_memory_barriers_; |
| 520 | }; |
| 521 | |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 522 | class SyncOpPipelineBarrier : public SyncOpBarriers { |
| 523 | public: |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 524 | SyncOpPipelineBarrier(CMD_TYPE cmd, const SyncValidator &sync_state, VkQueueFlags queue_flags, |
| 525 | VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 526 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 527 | const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, |
| 528 | const VkImageMemoryBarrier *pImageMemoryBarriers); |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 529 | SyncOpPipelineBarrier(CMD_TYPE cmd, const SyncValidator &sync_state, VkQueueFlags queue_flags, |
| 530 | const VkDependencyInfoKHR &pDependencyInfo); |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 531 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 532 | void Record(CommandBufferAccessContext *cb_context) const override; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 533 | }; |
| 534 | |
| 535 | class SyncOpWaitEvents : public SyncOpBarriers { |
| 536 | public: |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 537 | SyncOpWaitEvents(CMD_TYPE cmd, const SyncValidator &sync_state, VkQueueFlags queue_flags, uint32_t eventCount, |
| 538 | const VkEvent *pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, |
| 539 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 540 | const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, |
| 541 | const VkImageMemoryBarrier *pImageMemoryBarriers); |
| 542 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 543 | void Record(CommandBufferAccessContext *cb_context) const override; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 544 | |
| 545 | protected: |
| 546 | // TODO PHASE2 This is the wrong thing to use for "replay".. as the event state will have moved on since the record |
| 547 | // TODO PHASE2 May need to capture by value w.r.t. "first use" or build up in calling/enqueue context through replay. |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 548 | std::vector<std::shared_ptr<const EVENT_STATE>> events_; |
| 549 | void MakeEventsList(const SyncValidator &sync_state, uint32_t event_count, const VkEvent *events); |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 550 | }; |
| 551 | |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 552 | class SyncOpResetEvent : public SyncOpBase { |
| 553 | public: |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 554 | SyncOpResetEvent(CMD_TYPE cmd, const SyncValidator &sync_state, VkQueueFlags queue_flags, VkEvent event, |
| 555 | VkPipelineStageFlags stageMask); |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 556 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 557 | void Record(CommandBufferAccessContext *cb_context) const override; |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 558 | |
| 559 | private: |
| 560 | std::shared_ptr<const EVENT_STATE> event_; |
| 561 | SyncExecScope exec_scope_; |
| 562 | }; |
| 563 | |
| 564 | class SyncOpSetEvent : public SyncOpBase { |
| 565 | public: |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 566 | SyncOpSetEvent(CMD_TYPE cmd, const SyncValidator &sync_state, VkQueueFlags queue_flags, VkEvent event, |
| 567 | VkPipelineStageFlags stageMask); |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 568 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 569 | void Record(CommandBufferAccessContext *cb_context) const override; |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 570 | |
| 571 | private: |
| 572 | std::shared_ptr<const EVENT_STATE> event_; |
| 573 | SyncExecScope src_exec_scope_; |
| 574 | }; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 575 | |
| 576 | class SyncOpBeginRenderPass : public SyncOpBase { |
| 577 | public: |
| 578 | SyncOpBeginRenderPass(CMD_TYPE cmd, const SyncValidator &sync_state, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 579 | const VkSubpassBeginInfo *pSubpassBeginInfo, const char *command_name = nullptr); |
| 580 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
| 581 | void Record(CommandBufferAccessContext *cb_context) const override; |
| 582 | |
| 583 | protected: |
| 584 | safe_VkRenderPassBeginInfo renderpass_begin_info_; |
| 585 | safe_VkSubpassBeginInfo subpass_begin_info_; |
| 586 | std::vector<std::shared_ptr<const IMAGE_VIEW_STATE>> shared_attachments_; |
| 587 | std::vector<const IMAGE_VIEW_STATE *> attachments_; |
| 588 | std::shared_ptr<const RENDER_PASS_STATE> rp_state_; |
| 589 | }; |
| 590 | |
| 591 | class SyncOpNextSubpass : public SyncOpBase { |
| 592 | public: |
| 593 | SyncOpNextSubpass(CMD_TYPE cmd, const SyncValidator &sync_state, const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 594 | const VkSubpassEndInfo *pSubpassEndInfo, const char *name_override = nullptr); |
| 595 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
| 596 | void Record(CommandBufferAccessContext *cb_context) const override; |
| 597 | |
| 598 | protected: |
| 599 | safe_VkSubpassBeginInfo subpass_begin_info_; |
| 600 | safe_VkSubpassEndInfo subpass_end_info_; |
| 601 | }; |
| 602 | |
| 603 | class SyncOpEndRenderPass : public SyncOpBase { |
| 604 | public: |
| 605 | SyncOpEndRenderPass(CMD_TYPE cmd, const SyncValidator &sync_state, const VkSubpassEndInfo *pSubpassEndInfo, |
| 606 | const char *name_override = nullptr); |
| 607 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
| 608 | void Record(CommandBufferAccessContext *cb_context) const override; |
| 609 | |
| 610 | protected: |
| 611 | safe_VkSubpassEndInfo subpass_end_info_; |
| 612 | }; |
| 613 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 614 | class AccessContext { |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 615 | public: |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 616 | enum DetectOptions : uint32_t { |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 617 | kDetectPrevious = 1U << 0, |
| 618 | kDetectAsync = 1U << 1, |
| 619 | kDetectAll = (kDetectPrevious | kDetectAsync) |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 620 | }; |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 621 | using MapArray = std::array<ResourceAccessRangeMap, static_cast<size_t>(AccessAddressType::kTypeCount)>; |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 622 | |
John Zulauf | baea94f | 2020-09-15 17:55:16 -0600 | [diff] [blame] | 623 | // WIP TODO WIP Multi-dep -- change track back to support barrier vector, not just last. |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 624 | struct TrackBack { |
John Zulauf | a0a9829 | 2020-09-18 09:30:10 -0600 | [diff] [blame] | 625 | std::vector<SyncBarrier> barriers; |
John Zulauf | 1a22429 | 2020-06-30 14:52:13 -0600 | [diff] [blame] | 626 | const AccessContext *context; |
John Zulauf | baea94f | 2020-09-15 17:55:16 -0600 | [diff] [blame] | 627 | TrackBack(const AccessContext *context_, VkQueueFlags queue_flags_, |
John Zulauf | a0a9829 | 2020-09-18 09:30:10 -0600 | [diff] [blame] | 628 | const std::vector<const VkSubpassDependency2 *> &subpass_dependencies_) |
| 629 | : barriers(), context(context_) { |
| 630 | barriers.reserve(subpass_dependencies_.size()); |
| 631 | for (const VkSubpassDependency2 *dependency : subpass_dependencies_) { |
| 632 | assert(dependency); |
| 633 | barriers.emplace_back(queue_flags_, *dependency); |
| 634 | } |
| 635 | } |
| 636 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 637 | TrackBack &operator=(const TrackBack &) = default; |
| 638 | TrackBack() = default; |
| 639 | }; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 640 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 641 | HazardResult DetectHazard(const BUFFER_STATE &buffer, SyncStageAccessIndex usage_index, const ResourceAccessRange &range) const; |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 642 | HazardResult DetectHazard(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 643 | const VkImageSubresourceLayers &subresource, const VkOffset3D &offset, |
| 644 | const VkExtent3D &extent) const; |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 645 | template <typename Detector> |
| 646 | HazardResult DetectHazard(Detector &detector, const IMAGE_STATE &image, const VkImageSubresourceRange &subresource_range, |
| 647 | const VkOffset3D &offset, const VkExtent3D &extent, DetectOptions options) const; |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 648 | HazardResult DetectHazard(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
| 649 | const VkImageSubresourceRange &subresource_range, const VkOffset3D &offset, |
| 650 | const VkExtent3D &extent) const; |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 651 | HazardResult DetectHazard(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 652 | const VkImageSubresourceRange &subresource_range, SyncOrdering ordering_rule, |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 653 | const VkOffset3D &offset, const VkExtent3D &extent) const; |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 654 | HazardResult DetectHazard(const IMAGE_VIEW_STATE *view, SyncStageAccessIndex current_usage, SyncOrdering ordering_rule, |
John Zulauf | b027cdb | 2020-05-21 14:25:22 -0600 | [diff] [blame] | 655 | const VkOffset3D &offset, const VkExtent3D &extent, VkImageAspectFlags aspect_mask = 0U) const; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 656 | HazardResult DetectImageBarrierHazard(const IMAGE_STATE &image, VkPipelineStageFlags2KHR src_exec_scope, |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 657 | const SyncStageAccessFlags &src_access_scope, |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 658 | const VkImageSubresourceRange &subresource_range, const SyncEventState &sync_event, |
| 659 | DetectOptions options) const; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 660 | HazardResult DetectImageBarrierHazard(const IMAGE_STATE &image, VkPipelineStageFlags2KHR src_exec_scope, |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 661 | const SyncStageAccessFlags &src_access_scope, |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 662 | const VkImageSubresourceRange &subresource_range, DetectOptions options) const; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 663 | HazardResult DetectImageBarrierHazard(const IMAGE_STATE &image, VkPipelineStageFlags2KHR src_exec_scope, |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 664 | const SyncStageAccessFlags &src_stage_accesses, |
| 665 | const VkImageMemoryBarrier &barrier) const; |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 666 | HazardResult DetectImageBarrierHazard(const SyncImageMemoryBarrier &image_barrier) const; |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 667 | HazardResult DetectSubpassTransitionHazard(const TrackBack &track_back, const IMAGE_VIEW_STATE *attach_view) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 668 | |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 669 | void RecordLayoutTransitions(const RENDER_PASS_STATE &rp_state, uint32_t subpass, |
| 670 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, const ResourceUsageTag &tag); |
| 671 | |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 672 | const TrackBack &GetDstExternalTrackBack() const { return dst_external_; } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 673 | void Reset() { |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 674 | prev_.clear(); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 675 | prev_by_subpass_.clear(); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 676 | async_.clear(); |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 677 | src_external_ = TrackBack(); |
John Zulauf | a0a9829 | 2020-09-18 09:30:10 -0600 | [diff] [blame] | 678 | dst_external_ = TrackBack(); |
Jeremy Gebben | c4b78c5 | 2020-12-11 09:39:47 -0700 | [diff] [blame] | 679 | start_tag_ = ResourceUsageTag(); |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 680 | for (auto &map : access_state_maps_) { |
| 681 | map.clear(); |
| 682 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 683 | } |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 684 | |
| 685 | // Follow the context previous to access the access state, supporting "lazy" import into the context. Not intended for |
| 686 | // subpass layout transition, as the pending state handling is more complex |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 687 | // TODO: See if returning the lower_bound would be useful from a performance POV -- look at the lower_bound overhead |
| 688 | // Would need to add a "hint" overload to parallel_iterator::invalidate_[AB] call, if so. |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 689 | void ResolvePreviousAccess(AccessAddressType type, const ResourceAccessRange &range, ResourceAccessRangeMap *descent_map, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 690 | const ResourceAccessState *infill_state) const; |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 691 | void ResolvePreviousAccesses(); |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 692 | template <typename BarrierAction> |
| 693 | void ResolveAccessRange(const IMAGE_STATE &image_state, const VkImageSubresourceRange &subresource_range, |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 694 | BarrierAction &barrier_action, AccessAddressType address_type, ResourceAccessRangeMap *descent_map, |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 695 | const ResourceAccessState *infill_state) const; |
| 696 | template <typename BarrierAction> |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 697 | void ResolveAccessRange(AccessAddressType type, const ResourceAccessRange &range, BarrierAction &barrier_action, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 698 | ResourceAccessRangeMap *resolve_map, const ResourceAccessState *infill_state, |
| 699 | bool recur_to_infill = true) const; |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 700 | |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 701 | void UpdateAccessState(const BUFFER_STATE &buffer, SyncStageAccessIndex current_usage, SyncOrdering ordering_rule, |
| 702 | const ResourceAccessRange &range, const ResourceUsageTag &tag); |
| 703 | void UpdateAccessState(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, SyncOrdering ordering_rule, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 704 | const VkImageSubresourceRange &subresource_range, const VkOffset3D &offset, const VkExtent3D &extent, |
| 705 | const ResourceUsageTag &tag); |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 706 | void UpdateAccessState(const IMAGE_VIEW_STATE *view, SyncStageAccessIndex current_usage, SyncOrdering ordering_rule, |
| 707 | const VkOffset3D &offset, const VkExtent3D &extent, VkImageAspectFlags aspect_mask, |
| 708 | const ResourceUsageTag &tag); |
| 709 | void UpdateAccessState(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, SyncOrdering ordering_rule, |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 710 | const VkImageSubresourceLayers &subresource, const VkOffset3D &offset, const VkExtent3D &extent, |
| 711 | const ResourceUsageTag &tag); |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 712 | void UpdateAttachmentResolveAccess(const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, |
| 713 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, uint32_t subpass, |
| 714 | const ResourceUsageTag &tag); |
John Zulauf | aff2066 | 2020-06-01 14:07:58 -0600 | [diff] [blame] | 715 | void UpdateAttachmentStoreAccess(const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, |
| 716 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, uint32_t subpass, |
| 717 | const ResourceUsageTag &tag); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 718 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 719 | void ResolveChildContexts(const std::vector<AccessContext> &contexts); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 720 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 721 | template <typename Action> |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 722 | void UpdateResourceAccess(const BUFFER_STATE &buffer, const ResourceAccessRange &range, const Action action); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 723 | template <typename Action> |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 724 | void UpdateResourceAccess(const IMAGE_STATE &image, const VkImageSubresourceRange &subresource_range, const Action action); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 725 | |
| 726 | template <typename Action> |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 727 | void ApplyToContext(const Action &barrier_action); |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 728 | static AccessAddressType ImageAddressType(const IMAGE_STATE &image); |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 729 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 730 | AccessContext(uint32_t subpass, VkQueueFlags queue_flags, const std::vector<SubpassDependencyGraphNode> &dependencies, |
John Zulauf | 1a22429 | 2020-06-30 14:52:13 -0600 | [diff] [blame] | 731 | const std::vector<AccessContext> &contexts, const AccessContext *external_context); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 732 | |
| 733 | AccessContext() { Reset(); } |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 734 | AccessContext(const AccessContext ©_from) = default; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 735 | |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 736 | ResourceAccessRangeMap &GetAccessStateMap(AccessAddressType type) { return access_state_maps_[static_cast<size_t>(type)]; } |
| 737 | const ResourceAccessRangeMap &GetAccessStateMap(AccessAddressType type) const { |
| 738 | return access_state_maps_[static_cast<size_t>(type)]; |
| 739 | } |
| 740 | ResourceAccessRangeMap &GetLinearMap() { return GetAccessStateMap(AccessAddressType::kLinear); } |
| 741 | const ResourceAccessRangeMap &GetLinearMap() const { return GetAccessStateMap(AccessAddressType::kLinear); } |
| 742 | ResourceAccessRangeMap &GetIdealizedMap() { return GetAccessStateMap(AccessAddressType::kIdealized); } |
| 743 | const ResourceAccessRangeMap &GetIdealizedMap() const { return GetAccessStateMap(AccessAddressType::kIdealized); } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 744 | const TrackBack *GetTrackBackFromSubpass(uint32_t subpass) const { |
| 745 | if (subpass == VK_SUBPASS_EXTERNAL) { |
| 746 | return &src_external_; |
| 747 | } else { |
| 748 | assert(subpass < prev_by_subpass_.size()); |
| 749 | return prev_by_subpass_[subpass]; |
| 750 | } |
| 751 | } |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 752 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 753 | bool ValidateLayoutTransitions(const CommandExecutionContext &ex_context, const RENDER_PASS_STATE &rp_state, |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 754 | const VkRect2D &render_area, uint32_t subpass, |
| 755 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, const char *func_name) const; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 756 | bool ValidateLoadOperation(const CommandExecutionContext &ex_context, const RENDER_PASS_STATE &rp_state, |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 757 | const VkRect2D &render_area, uint32_t subpass, |
| 758 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, const char *func_name) const; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 759 | bool ValidateStoreOperation(const CommandExecutionContext &ex_context, const RENDER_PASS_STATE &rp_state, |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 760 | const VkRect2D &render_area, uint32_t subpass, |
| 761 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, const char *func_name) const; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 762 | bool ValidateResolveOperations(const CommandExecutionContext &ex_context, const RENDER_PASS_STATE &rp_state, |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 763 | const VkRect2D &render_area, const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, |
| 764 | const char *func_name, uint32_t subpass) const; |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 765 | |
Jeremy Gebben | c4b78c5 | 2020-12-11 09:39:47 -0700 | [diff] [blame] | 766 | void SetStartTag(const ResourceUsageTag &tag) { start_tag_ = tag; } |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 767 | template <typename Action> |
| 768 | void ForAll(Action &&action); |
Jeremy Gebben | c4b78c5 | 2020-12-11 09:39:47 -0700 | [diff] [blame] | 769 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 770 | private: |
| 771 | template <typename Detector> |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 772 | HazardResult DetectHazard(AccessAddressType type, const Detector &detector, const ResourceAccessRange &range, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 773 | DetectOptions options) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 774 | template <typename Detector> |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 775 | HazardResult DetectAsyncHazard(AccessAddressType type, const Detector &detector, const ResourceAccessRange &range) const; |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 776 | template <typename Detector> |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 777 | HazardResult DetectPreviousHazard(AccessAddressType type, const Detector &detector, const ResourceAccessRange &range) const; |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 778 | void UpdateAccessState(AccessAddressType type, SyncStageAccessIndex current_usage, SyncOrdering ordering_rule, |
| 779 | const ResourceAccessRange &range, const ResourceUsageTag &tag); |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 780 | |
| 781 | MapArray access_state_maps_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 782 | std::vector<TrackBack> prev_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 783 | std::vector<TrackBack *> prev_by_subpass_; |
Jeremy Gebben | c4b78c5 | 2020-12-11 09:39:47 -0700 | [diff] [blame] | 784 | std::vector<const AccessContext *> async_; |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 785 | TrackBack src_external_; |
| 786 | TrackBack dst_external_; |
Jeremy Gebben | c4b78c5 | 2020-12-11 09:39:47 -0700 | [diff] [blame] | 787 | ResourceUsageTag start_tag_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 788 | }; |
| 789 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 790 | class RenderPassAccessContext { |
| 791 | public: |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 792 | RenderPassAccessContext() : rp_state_(nullptr), render_area_(VkRect2D()), current_subpass_(0) {} |
| 793 | RenderPassAccessContext(const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, VkQueueFlags queue_flags, |
| 794 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, const AccessContext *external_context); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 795 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 796 | bool ValidateDrawSubpassAttachment(const CommandExecutionContext &ex_context, const CMD_BUFFER_STATE &cmd, |
| 797 | const char *func_name) const; |
| 798 | void RecordDrawSubpassAttachment(const CMD_BUFFER_STATE &cmd, const ResourceUsageTag &tag); |
| 799 | bool ValidateNextSubpass(const CommandExecutionContext &ex_context, const char *command_name) const; |
| 800 | bool ValidateEndRenderPass(const CommandExecutionContext &ex_context, const char *func_name) const; |
| 801 | bool ValidateFinalSubpassLayoutTransitions(const CommandExecutionContext &ex_context, const char *func_name) const; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 802 | |
| 803 | void RecordLayoutTransitions(const ResourceUsageTag &tag); |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 804 | void RecordLoadOperations(const ResourceUsageTag &tag); |
| 805 | void RecordBeginRenderPass(const ResourceUsageTag &tag); |
| 806 | void RecordNextSubpass(const ResourceUsageTag &prev_subpass_tag, const ResourceUsageTag &next_subpass_tag); |
| 807 | void RecordEndRenderPass(AccessContext *external_context, const ResourceUsageTag &tag); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 808 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 809 | AccessContext &CurrentContext() { return subpass_contexts_[current_subpass_]; } |
| 810 | const AccessContext &CurrentContext() const { return subpass_contexts_[current_subpass_]; } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 811 | const std::vector<AccessContext> &GetContexts() const { return subpass_contexts_; } |
| 812 | uint32_t GetCurrentSubpass() const { return current_subpass_; } |
| 813 | const RENDER_PASS_STATE *GetRenderPassState() const { return rp_state_; } |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 814 | AccessContext *CreateStoreResolveProxy() const; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 815 | |
| 816 | private: |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 817 | const RENDER_PASS_STATE *rp_state_; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 818 | const VkRect2D render_area_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 819 | uint32_t current_subpass_; |
| 820 | std::vector<AccessContext> subpass_contexts_; |
| 821 | std::vector<const IMAGE_VIEW_STATE *> attachment_views_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 822 | }; |
| 823 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 824 | // Command execution context is the base class for command buffer and queue contexts |
| 825 | // Preventing unintented leakage of subclass specific state, storing enough information |
| 826 | // for message logging. |
| 827 | // TODO: determine where to draw the design split for tag tracking (is there anything command to Queues and CB's) |
| 828 | class CommandExecutionContext { |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 829 | public: |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 830 | CommandExecutionContext() : sync_state_(nullptr) {} |
| 831 | CommandExecutionContext(SyncValidator *sync_validator) : sync_state_(sync_validator) {} |
| 832 | virtual ~CommandExecutionContext() = default; |
| 833 | const SyncValidator &GetSyncState() const { |
| 834 | assert(sync_state_); |
| 835 | return *sync_state_; |
| 836 | } |
| 837 | SyncValidator &GetSyncState() { |
| 838 | assert(sync_state_); |
| 839 | return *sync_state_; |
| 840 | } |
| 841 | virtual std::string FormatUsage(const HazardResult &hazard) const = 0; |
| 842 | |
| 843 | protected: |
| 844 | SyncValidator *sync_state_; |
| 845 | }; |
| 846 | |
| 847 | class CommandBufferAccessContext : public CommandExecutionContext { |
| 848 | public: |
| 849 | CommandBufferAccessContext(SyncValidator *sync_validator = nullptr) |
| 850 | : CommandExecutionContext(sync_validator), |
| 851 | access_index_(0), |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 852 | command_number_(0), |
| 853 | subcommand_number_(0), |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 854 | reset_count_(0), |
| 855 | render_pass_contexts_(), |
| 856 | cb_access_context_(), |
| 857 | current_context_(&cb_access_context_), |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 858 | current_renderpass_context_(), |
| 859 | cb_state_(), |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 860 | queue_flags_(), |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 861 | events_context_(), |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 862 | destroyed_(false) {} |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 863 | CommandBufferAccessContext(SyncValidator &sync_validator, std::shared_ptr<CMD_BUFFER_STATE> &cb_state, VkQueueFlags queue_flags) |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 864 | : CommandBufferAccessContext(&sync_validator) { |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 865 | cb_state_ = cb_state; |
| 866 | queue_flags_ = queue_flags; |
| 867 | } |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 868 | ~CommandBufferAccessContext() override = default; |
| 869 | CommandExecutionContext &GetExecutionContext() { return *this; } |
| 870 | const CommandExecutionContext &GetExecutionContext() const { return *this; } |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 871 | |
| 872 | void Reset() { |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 873 | access_index_ = 0; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 874 | command_number_ = 0; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 875 | subcommand_number_ = 0; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 876 | reset_count_++; |
| 877 | cb_access_context_.Reset(); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 878 | render_pass_contexts_.clear(); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 879 | current_context_ = &cb_access_context_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 880 | current_renderpass_context_ = nullptr; |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 881 | events_context_.Clear(); |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 882 | } |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 883 | void MarkDestroyed() { destroyed_ = true; } |
| 884 | bool IsDestroyed() const { return destroyed_; } |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 885 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 886 | std::string FormatUsage(const HazardResult &hazard) const override; |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 887 | AccessContext *GetCurrentAccessContext() { return current_context_; } |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 888 | SyncEventsContext *GetCurrentEventsContext() { return &events_context_; } |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 889 | RenderPassAccessContext *GetCurrentRenderPassContext() { return current_renderpass_context_; } |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 890 | const AccessContext *GetCurrentAccessContext() const { return current_context_; } |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 891 | const SyncEventsContext *GetCurrentEventsContext() const { return &events_context_; } |
| 892 | const RenderPassAccessContext *GetCurrentRenderPassContext() const { return current_renderpass_context_; } |
| 893 | void RecordBeginRenderPass(const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, |
| 894 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, const ResourceUsageTag &tag); |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 895 | void ApplyGlobalBarriersToEvents(const SyncExecScope &src, const SyncExecScope &dst); |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 896 | |
locke-lunarg | 61870c2 | 2020-06-09 14:51:50 -0600 | [diff] [blame] | 897 | bool ValidateDispatchDrawDescriptorSet(VkPipelineBindPoint pipelineBindPoint, const char *func_name) const; |
| 898 | void RecordDispatchDrawDescriptorSet(VkPipelineBindPoint pipelineBindPoint, const ResourceUsageTag &tag); |
| 899 | bool ValidateDrawVertex(uint32_t vertexCount, uint32_t firstVertex, const char *func_name) const; |
| 900 | void RecordDrawVertex(uint32_t vertexCount, uint32_t firstVertex, const ResourceUsageTag &tag); |
| 901 | bool ValidateDrawVertexIndex(uint32_t indexCount, uint32_t firstIndex, const char *func_name) const; |
| 902 | void RecordDrawVertexIndex(uint32_t indexCount, uint32_t firstIndex, const ResourceUsageTag &tag); |
| 903 | bool ValidateDrawSubpassAttachment(const char *func_name) const; |
| 904 | void RecordDrawSubpassAttachment(const ResourceUsageTag &tag); |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 905 | void RecordNextSubpass(CMD_TYPE command); |
| 906 | void RecordEndRenderPass(CMD_TYPE command); |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 907 | void RecordDestroyEvent(VkEvent event); |
John Zulauf | 49beb11 | 2020-11-04 16:06:31 -0700 | [diff] [blame] | 908 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 909 | const CMD_BUFFER_STATE *GetCommandBufferState() const { return cb_state_.get(); } |
| 910 | VkQueueFlags GetQueueFlags() const { return queue_flags_; } |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 911 | inline ResourceUsageTag::TagIndex NextAccessIndex() { return access_index_++; } |
| 912 | |
| 913 | inline ResourceUsageTag NextSubcommandTag(CMD_TYPE command) { |
| 914 | ResourceUsageTag next(NextAccessIndex(), command_number_, subcommand_number_++, command); |
| 915 | return next; |
| 916 | } |
| 917 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 918 | inline ResourceUsageTag NextCommandTag(CMD_TYPE command) { |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 919 | command_number_++; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 920 | subcommand_number_ = 0; |
Jeremy Gebben | 6ea9d9e | 2020-12-11 09:41:01 -0700 | [diff] [blame] | 921 | // The lowest bit is a sub-command number used to separate operations at the end of the previous renderpass |
| 922 | // from the start of the new one in VkCmdNextRenderpass(). |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 923 | ResourceUsageTag next(NextAccessIndex(), command_number_, subcommand_number_, command); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 924 | return next; |
| 925 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 926 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 927 | const CMD_BUFFER_STATE &GetCBState() const { |
| 928 | assert(cb_state_); |
| 929 | return *(cb_state_.get()); |
| 930 | } |
| 931 | CMD_BUFFER_STATE &GetCBState() { |
| 932 | assert(cb_state_); |
| 933 | return *(cb_state_.get()); |
| 934 | } |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 935 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 936 | private: |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 937 | ResourceUsageTag::TagIndex access_index_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 938 | uint32_t command_number_; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 939 | uint32_t subcommand_number_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 940 | uint32_t reset_count_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 941 | std::vector<RenderPassAccessContext> render_pass_contexts_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 942 | AccessContext cb_access_context_; |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 943 | AccessContext *current_context_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 944 | RenderPassAccessContext *current_renderpass_context_; |
| 945 | std::shared_ptr<CMD_BUFFER_STATE> cb_state_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 946 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 947 | VkQueueFlags queue_flags_; |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 948 | SyncEventsContext events_context_; |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 949 | bool destroyed_; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 950 | }; |
| 951 | |
| 952 | class SyncValidator : public ValidationStateTracker, public SyncStageAccess { |
| 953 | public: |
| 954 | SyncValidator() { container_type = LayerObjectTypeSyncValidation; } |
| 955 | using StateTracker = ValidationStateTracker; |
| 956 | |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 957 | std::unordered_map<VkCommandBuffer, CommandBufferAccessContextShared> cb_access_state; |
| 958 | |
| 959 | CommandBufferAccessContextShared GetAccessContextImpl(VkCommandBuffer command_buffer, bool do_insert) { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 960 | auto found_it = cb_access_state.find(command_buffer); |
| 961 | if (found_it == cb_access_state.end()) { |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 962 | if (!do_insert) return CommandBufferAccessContextShared(); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 963 | // If we don't have one, make it. |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 964 | auto cb_state = GetShared<CMD_BUFFER_STATE>(command_buffer); |
| 965 | assert(cb_state.get()); |
| 966 | auto queue_flags = GetQueueFlags(*cb_state); |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 967 | std::shared_ptr<CommandBufferAccessContext> context(new CommandBufferAccessContext(*this, cb_state, queue_flags)); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 968 | auto insert_pair = cb_access_state.insert(std::make_pair(command_buffer, std::move(context))); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 969 | found_it = insert_pair.first; |
| 970 | } |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 971 | return found_it->second; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 972 | } |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 973 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 974 | CommandBufferAccessContext *GetAccessContext(VkCommandBuffer command_buffer) { |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 975 | return GetAccessContextImpl(command_buffer, true).get(); // true -> do_insert on not found |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 976 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 977 | CommandBufferAccessContext *GetAccessContextNoInsert(VkCommandBuffer command_buffer) { |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 978 | return GetAccessContextImpl(command_buffer, false).get(); // false -> don't do_insert on not found |
| 979 | } |
| 980 | |
| 981 | CommandBufferAccessContextShared GetAccessContextShared(VkCommandBuffer command_buffer) { |
| 982 | return GetAccessContextImpl(command_buffer, true); // true -> do_insert on not found |
| 983 | } |
| 984 | CommandBufferAccessContextShared GetAccessContextSharedNoInsert(VkCommandBuffer command_buffer) { |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 985 | return GetAccessContextImpl(command_buffer, false); // false -> don't do_insert on not found |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 986 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 987 | |
| 988 | const CommandBufferAccessContext *GetAccessContext(VkCommandBuffer command_buffer) const { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 989 | const auto found_it = cb_access_state.find(command_buffer); |
| 990 | if (found_it == cb_access_state.end()) { |
| 991 | return nullptr; |
| 992 | } |
| 993 | return found_it->second.get(); |
| 994 | } |
| 995 | |
John Zulauf | d1f85d4 | 2020-04-15 12:23:15 -0600 | [diff] [blame] | 996 | void ResetCommandBufferCallback(VkCommandBuffer command_buffer); |
| 997 | void FreeCommandBufferCallback(VkCommandBuffer command_buffer); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 998 | void RecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 999 | const VkSubpassBeginInfo *pSubpassBeginInfo, CMD_TYPE cmd, const char *cmd_name = nullptr); |
| 1000 | void RecordCmdNextSubpass(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 1001 | const VkSubpassEndInfo *pSubpassEndInfo, CMD_TYPE command, const char *command_name = nullptr); |
| 1002 | void RecordCmdEndRenderPass(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo, CMD_TYPE cmd, |
| 1003 | const char *cmd_name = nullptr); |
John Zulauf | 33fc1d5 | 2020-07-17 11:01:10 -0600 | [diff] [blame] | 1004 | bool SupressedBoundDescriptorWAW(const HazardResult &hazard) const; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1005 | |
| 1006 | void PostCallRecordCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1007 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) override; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1008 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1009 | bool ValidateBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1010 | const VkSubpassBeginInfo *pSubpassBeginInfo, CMD_TYPE cmd, const char *cmd_name = nullptr) const; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1011 | |
| 1012 | bool PreCallValidateCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1013 | VkSubpassContents contents) const override; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1014 | |
| 1015 | bool PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1016 | const VkSubpassBeginInfo *pSubpassBeginInfo) const override; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1017 | |
| 1018 | bool PreCallValidateCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1019 | const VkSubpassBeginInfo *pSubpassBeginInfo) const override; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1020 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1021 | bool PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1022 | const VkBufferCopy *pRegions) const override; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1023 | |
| 1024 | void PreCallRecordCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1025 | const VkBufferCopy *pRegions) override; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1026 | |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 1027 | void PreCallRecordDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks *pAllocator) override; |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1028 | bool PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2KHR *pCopyBufferInfos) const override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1029 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1030 | void PreCallRecordCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2KHR *pCopyBufferInfos) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1031 | |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 1032 | bool PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 1033 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1034 | const VkImageCopy *pRegions) const override; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 1035 | |
| 1036 | void PreCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1037 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions) override; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 1038 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1039 | bool PreCallValidateCmdCopyImage2KHR(VkCommandBuffer commandBuffer, const VkCopyImageInfo2KHR *pCopyImageInfo) const override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1040 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1041 | void PreCallRecordCmdCopyImage2KHR(VkCommandBuffer commandBuffer, const VkCopyImageInfo2KHR *pCopyImageInfo) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1042 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1043 | bool PreCallValidateCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, |
| 1044 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 1045 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 1046 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 1047 | uint32_t imageMemoryBarrierCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1048 | const VkImageMemoryBarrier *pImageMemoryBarriers) const override; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1049 | |
| 1050 | void PreCallRecordCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, |
| 1051 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 1052 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 1053 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1054 | uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1055 | |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 1056 | bool PreCallValidateCmdPipelineBarrier2KHR(VkCommandBuffer commandBuffer, |
| 1057 | const VkDependencyInfoKHR *pDependencyInfo) const override; |
| 1058 | void PreCallRecordCmdPipelineBarrier2KHR(VkCommandBuffer commandBuffer, const VkDependencyInfoKHR *pDependencyInfo) override; |
| 1059 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1060 | void PostCallRecordBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1061 | VkResult result) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1062 | |
| 1063 | void PostCallRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1064 | VkSubpassContents contents) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1065 | void PostCallRecordCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1066 | const VkSubpassBeginInfo *pSubpassBeginInfo) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1067 | void PostCallRecordCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1068 | const VkSubpassBeginInfo *pSubpassBeginInfo) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1069 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1070 | bool ValidateCmdNextSubpass(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1071 | const VkSubpassEndInfo *pSubpassEndInfo, CMD_TYPE cmd, const char *cmd_name = nullptr) const; |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1072 | bool PreCallValidateCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) const override; |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1073 | bool PreCallValidateCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 1074 | const VkSubpassEndInfo *pSubpassEndInfo) const override; |
| 1075 | bool PreCallValidateCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 1076 | const VkSubpassEndInfo *pSubpassEndInfo) const override; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1077 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1078 | void PostCallRecordCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1079 | void PostCallRecordCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1080 | const VkSubpassEndInfo *pSubpassEndInfo) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1081 | void PostCallRecordCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1082 | const VkSubpassEndInfo *pSubpassEndInfo) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1083 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1084 | bool ValidateCmdEndRenderPass(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo, CMD_TYPE cmd, |
| 1085 | const char *cmd_name = nullptr) const; |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1086 | bool PreCallValidateCmdEndRenderPass(VkCommandBuffer commandBuffer) const override; |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1087 | bool PreCallValidateCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo) const override; |
| 1088 | bool PreCallValidateCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo) const override; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1089 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1090 | void PostCallRecordCmdEndRenderPass(VkCommandBuffer commandBuffer) override; |
| 1091 | void PostCallRecordCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo) override; |
| 1092 | void PostCallRecordCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1093 | |
| 1094 | template <typename BufferImageCopyRegionType> |
| 1095 | bool ValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
| 1096 | VkImageLayout dstImageLayout, uint32_t regionCount, const BufferImageCopyRegionType *pRegions, |
| 1097 | CopyCommandVersion version) const; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1098 | bool PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
| 1099 | VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1100 | const VkBufferImageCopy *pRegions) const override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1101 | bool PreCallValidateCmdCopyBufferToImage2KHR(VkCommandBuffer commandBuffer, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1102 | const VkCopyBufferToImageInfo2KHR *pCopyBufferToImageInfo) const override; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1103 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1104 | template <typename BufferImageCopyRegionType> |
| 1105 | void RecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
| 1106 | VkImageLayout dstImageLayout, uint32_t regionCount, const BufferImageCopyRegionType *pRegions, |
| 1107 | CopyCommandVersion version); |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1108 | void PreCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1109 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy *pRegions) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1110 | void PreCallRecordCmdCopyBufferToImage2KHR(VkCommandBuffer commandBuffer, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1111 | const VkCopyBufferToImageInfo2KHR *pCopyBufferToImageInfo) override; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1112 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1113 | template <typename BufferImageCopyRegionType> |
| 1114 | bool ValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 1115 | VkBuffer dstBuffer, uint32_t regionCount, const BufferImageCopyRegionType *pRegions, |
| 1116 | CopyCommandVersion version) const; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1117 | bool PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1118 | VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions) const override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1119 | bool PreCallValidateCmdCopyImageToBuffer2KHR(VkCommandBuffer commandBuffer, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1120 | const VkCopyImageToBufferInfo2KHR *pCopyImageToBufferInfo) const override; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1121 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1122 | template <typename BufferImageCopyRegionType> |
| 1123 | void RecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 1124 | VkBuffer dstBuffer, uint32_t regionCount, const BufferImageCopyRegionType *pRegions, |
| 1125 | CopyCommandVersion version); |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1126 | void PreCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1127 | VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1128 | void PreCallRecordCmdCopyImageToBuffer2KHR(VkCommandBuffer commandBuffer, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1129 | const VkCopyImageToBufferInfo2KHR *pCopyImageToBufferInfo) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1130 | |
| 1131 | template <typename RegionType> |
| 1132 | bool ValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 1133 | VkImageLayout dstImageLayout, uint32_t regionCount, const RegionType *pRegions, VkFilter filter, |
| 1134 | const char *apiName) const; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1135 | |
| 1136 | bool PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 1137 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1138 | const VkImageBlit *pRegions, VkFilter filter) const override; |
| 1139 | bool PreCallValidateCmdBlitImage2KHR(VkCommandBuffer commandBuffer, const VkBlitImageInfo2KHR *pBlitImageInfo) const override; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1140 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1141 | template <typename RegionType> |
| 1142 | void RecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 1143 | VkImageLayout dstImageLayout, uint32_t regionCount, const RegionType *pRegions, VkFilter filter, |
| 1144 | ResourceUsageTag tag); |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1145 | void PreCallRecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 1146 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1147 | VkFilter filter) override; |
| 1148 | void PreCallRecordCmdBlitImage2KHR(VkCommandBuffer commandBuffer, const VkBlitImageInfo2KHR *pBlitImageInfo) override; |
locke-lunarg | 36ba259 | 2020-04-03 09:42:04 -0600 | [diff] [blame] | 1149 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 1150 | bool ValidateIndirectBuffer(const CommandBufferAccessContext &cb_context, const AccessContext &context, |
| 1151 | VkCommandBuffer commandBuffer, const VkDeviceSize struct_size, const VkBuffer buffer, |
| 1152 | const VkDeviceSize offset, const uint32_t drawCount, const uint32_t stride, |
locke-lunarg | 61870c2 | 2020-06-09 14:51:50 -0600 | [diff] [blame] | 1153 | const char *function) const; |
| 1154 | void RecordIndirectBuffer(AccessContext &context, const ResourceUsageTag &tag, const VkDeviceSize struct_size, |
| 1155 | const VkBuffer buffer, const VkDeviceSize offset, const uint32_t drawCount, uint32_t stride); |
locke-lunarg | 36ba259 | 2020-04-03 09:42:04 -0600 | [diff] [blame] | 1156 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 1157 | bool ValidateCountBuffer(const CommandBufferAccessContext &cb_context, const AccessContext &context, |
| 1158 | VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, const char *function) const; |
locke-lunarg | 61870c2 | 2020-06-09 14:51:50 -0600 | [diff] [blame] | 1159 | void RecordCountBuffer(AccessContext &context, const ResourceUsageTag &tag, VkBuffer buffer, VkDeviceSize offset); |
locke-lunarg | 93d68af | 2020-05-12 17:18:03 -0600 | [diff] [blame] | 1160 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1161 | bool PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) const override; |
| 1162 | void PreCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1163 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1164 | bool PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset) const override; |
| 1165 | void PreCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1166 | |
| 1167 | bool PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1168 | uint32_t firstInstance) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1169 | void PreCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1170 | uint32_t firstInstance) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1171 | |
| 1172 | bool PreCallValidateCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1173 | uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1174 | void PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1175 | uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1176 | |
| 1177 | bool PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1178 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1179 | void PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1180 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1181 | |
| 1182 | bool PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1183 | uint32_t drawCount, uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1184 | void PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1185 | uint32_t drawCount, uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1186 | |
locke-lunarg | ff255f9 | 2020-05-13 18:53:52 -0600 | [diff] [blame] | 1187 | bool ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, |
| 1188 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride, |
| 1189 | const char *function) const; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1190 | bool PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1191 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1192 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1193 | void PreCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1194 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1195 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1196 | bool PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1197 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1198 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1199 | void PreCallRecordCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1200 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1201 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1202 | bool PreCallValidateCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1203 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1204 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1205 | void PreCallRecordCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1206 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1207 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1208 | |
locke-lunarg | ff255f9 | 2020-05-13 18:53:52 -0600 | [diff] [blame] | 1209 | bool ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1210 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 1211 | uint32_t stride, const char *function) const; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1212 | bool PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1213 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1214 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1215 | void PreCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1216 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1217 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1218 | bool PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1219 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1220 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1221 | void PreCallRecordCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1222 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1223 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1224 | bool PreCallValidateCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1225 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1226 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1227 | void PreCallRecordCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1228 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1229 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1230 | |
| 1231 | bool PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 1232 | const VkClearColorValue *pColor, uint32_t rangeCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1233 | const VkImageSubresourceRange *pRanges) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1234 | void PreCallRecordCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 1235 | const VkClearColorValue *pColor, uint32_t rangeCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1236 | const VkImageSubresourceRange *pRanges) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1237 | |
| 1238 | bool PreCallValidateCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 1239 | const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1240 | const VkImageSubresourceRange *pRanges) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1241 | void PreCallRecordCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 1242 | const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1243 | const VkImageSubresourceRange *pRanges) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1244 | |
| 1245 | bool PreCallValidateCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, |
| 1246 | uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1247 | VkDeviceSize stride, VkQueryResultFlags flags) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1248 | void PreCallRecordCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, |
| 1249 | uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1250 | VkQueryResultFlags flags) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1251 | |
| 1252 | bool PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1253 | uint32_t data) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1254 | void PreCallRecordCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1255 | uint32_t data) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1256 | |
| 1257 | bool PreCallValidateCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 1258 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1259 | const VkImageResolve *pRegions) const override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1260 | |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1261 | void PreCallRecordCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 1262 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1263 | const VkImageResolve *pRegions) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1264 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1265 | bool PreCallValidateCmdResolveImage2KHR(VkCommandBuffer commandBuffer, const VkResolveImageInfo2KHR *pResolveImageInfo) const override; |
| 1266 | void PreCallRecordCmdResolveImage2KHR(VkCommandBuffer commandBuffer, const VkResolveImageInfo2KHR *pResolveImageInfo) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1267 | |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1268 | bool PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1269 | VkDeviceSize dataSize, const void *pData) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1270 | void PreCallRecordCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1271 | VkDeviceSize dataSize, const void *pData) override; |
locke-lunarg | ff255f9 | 2020-05-13 18:53:52 -0600 | [diff] [blame] | 1272 | |
| 1273 | bool PreCallValidateCmdWriteBufferMarkerAMD(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1274 | VkBuffer dstBuffer, VkDeviceSize dstOffset, uint32_t marker) const override; |
locke-lunarg | ff255f9 | 2020-05-13 18:53:52 -0600 | [diff] [blame] | 1275 | void PreCallRecordCmdWriteBufferMarkerAMD(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1276 | VkBuffer dstBuffer, VkDeviceSize dstOffset, uint32_t marker) override; |
John Zulauf | 49beb11 | 2020-11-04 16:06:31 -0700 | [diff] [blame] | 1277 | |
| 1278 | bool PreCallValidateCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) const override; |
| 1279 | void PostCallRecordCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) override; |
| 1280 | |
| 1281 | bool PreCallValidateCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) const override; |
| 1282 | void PostCallRecordCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) override; |
| 1283 | |
| 1284 | bool PreCallValidateCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, |
| 1285 | VkPipelineStageFlags sourceStageMask, VkPipelineStageFlags dstStageMask, |
| 1286 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 1287 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 1288 | uint32_t imageMemoryBarrierCount, |
| 1289 | const VkImageMemoryBarrier *pImageMemoryBarriers) const override; |
| 1290 | void PostCallRecordCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, |
| 1291 | VkPipelineStageFlags sourceStageMask, VkPipelineStageFlags dstStageMask, |
| 1292 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 1293 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 1294 | uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers) override; |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 1295 | bool PreCallValidateCmdWriteBufferMarker2AMD(VkCommandBuffer commandBuffer, VkPipelineStageFlags2KHR stage, VkBuffer dstBuffer, |
| 1296 | VkDeviceSize dstOffset, uint32_t marker) const override; |
| 1297 | void PreCallRecordCmdWriteBufferMarker2AMD(VkCommandBuffer commandBuffer, VkPipelineStageFlags2KHR stage, VkBuffer dstBuffer, |
| 1298 | VkDeviceSize dstOffset, uint32_t marker) override; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1299 | }; |