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