John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019-2020 Valve Corporation |
| 3 | * Copyright (c) 2019-2020 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> |
| 18 | */ |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include <map> |
| 23 | #include <memory> |
| 24 | #include <unordered_map> |
| 25 | #include <vulkan/vulkan.h> |
| 26 | |
| 27 | #include "synchronization_validation_types.h" |
| 28 | #include "state_tracker.h" |
| 29 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 30 | class SyncValidator; |
| 31 | |
John Zulauf | 2f952d2 | 2020-02-10 11:34:51 -0700 | [diff] [blame] | 32 | enum SyncHazard { |
| 33 | NONE = 0, |
| 34 | READ_AFTER_WRITE, |
| 35 | WRITE_AFTER_READ, |
| 36 | WRITE_AFTER_WRITE, |
| 37 | READ_RACING_WRITE, |
| 38 | WRITE_RACING_WRITE, |
| 39 | WRITE_RACING_READ, |
| 40 | }; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 41 | |
| 42 | // Useful Utilites for manipulating StageAccess parameters, suitable as base class to save typing |
| 43 | struct SyncStageAccess { |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame^] | 44 | static inline SyncStageAccessFlagBits FlagBit(SyncStageAccessIndex stage_access) { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 45 | return syncStageAccessInfoByStageAccessIndex[stage_access].stage_access_bit; |
| 46 | } |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame^] | 47 | static inline SyncStageAccessFlags Flags(SyncStageAccessIndex stage_access) { |
| 48 | return static_cast<SyncStageAccessFlags>(FlagBit(stage_access)); |
| 49 | } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 50 | |
| 51 | static bool IsRead(SyncStageAccessFlagBits stage_access_bit) { return 0 != (stage_access_bit & syncStageAccessReadMask); } |
| 52 | static bool IsRead(SyncStageAccessIndex stage_access_index) { return IsRead(FlagBit(stage_access_index)); } |
| 53 | |
| 54 | static bool IsWrite(SyncStageAccessFlagBits stage_access_bit) { return 0 != (stage_access_bit & syncStageAccessWriteMask); } |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame^] | 55 | static bool HasWrite(SyncStageAccessFlags stage_access_mask) { return 0 != (stage_access_mask & syncStageAccessWriteMask); } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 56 | static bool IsWrite(SyncStageAccessIndex stage_access_index) { return IsWrite(FlagBit(stage_access_index)); } |
| 57 | static VkPipelineStageFlagBits PipelineStageBit(SyncStageAccessIndex stage_access_index) { |
| 58 | return syncStageAccessInfoByStageAccessIndex[stage_access_index].stage_mask; |
| 59 | } |
| 60 | static SyncStageAccessFlags AccessScopeByStage(VkPipelineStageFlags stages); |
| 61 | static SyncStageAccessFlags AccessScopeByAccess(VkAccessFlags access); |
| 62 | static SyncStageAccessFlags AccessScope(VkPipelineStageFlags stages, VkAccessFlags access); |
| 63 | static SyncStageAccessFlags AccessScope(SyncStageAccessFlags stage_scope, VkAccessFlags accesses) { |
| 64 | return stage_scope & AccessScopeByAccess(accesses); |
| 65 | } |
| 66 | }; |
| 67 | |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 68 | struct ResourceUsageTag { |
| 69 | uint64_t index; |
| 70 | ResourceUsageTag &operator++() { |
| 71 | index++; |
| 72 | return *this; |
| 73 | } |
| 74 | bool IsBefore(const ResourceUsageTag &rhs) const { return index < rhs.index; } |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 75 | bool operator==(const ResourceUsageTag &rhs) const { return (index == rhs.index); } |
| 76 | bool operator!=(const ResourceUsageTag &rhs) const { return !(*this == rhs); } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 77 | ResourceUsageTag() : index(0) {} |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 78 | }; |
| 79 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 80 | struct HazardResult { |
| 81 | SyncHazard hazard = NONE; |
| 82 | ResourceUsageTag tag = ResourceUsageTag(); |
| 83 | void Set(SyncHazard hazard_, const ResourceUsageTag &tag_) { |
| 84 | hazard = hazard_; |
| 85 | tag = tag_; |
| 86 | } |
| 87 | }; |
| 88 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 89 | struct SyncBarrier { |
| 90 | VkPipelineStageFlags src_exec_scope; |
| 91 | SyncStageAccessFlags src_access_scope; |
| 92 | VkPipelineStageFlags dst_exec_scope; |
| 93 | SyncStageAccessFlags dst_access_scope; |
| 94 | SyncBarrier() = default; |
| 95 | SyncBarrier &operator=(const SyncBarrier &) = default; |
| 96 | SyncBarrier(VkQueueFlags gueue_flags, const VkSubpassDependency2 &sub_pass_barrier); |
| 97 | }; |
| 98 | using SyncBarrierStack = std::vector<const SyncBarrier *>; |
| 99 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 100 | class ResourceAccessState : public SyncStageAccess { |
| 101 | protected: |
| 102 | // Mutliple read operations can be simlutaneously (and independently) synchronized, |
| 103 | // given the only the second execution scope creates a dependency chain, we have to track each, |
| 104 | // but only up to one per pipeline stage (as another read from the *same* stage become more recent, |
| 105 | // and applicable one for hazard detection |
| 106 | struct ReadState { |
| 107 | VkPipelineStageFlagBits stage; // The stage of this read |
| 108 | VkPipelineStageFlags barriers; // all applicable barriered stages |
| 109 | ResourceUsageTag tag; |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 110 | bool operator==(const ReadState &rhs) const { |
| 111 | bool same = (stage == rhs.stage) && (barriers == rhs.barriers) && (tag == rhs.tag); |
| 112 | return same; |
| 113 | } |
| 114 | bool operator!=(const ReadState &rhs) const { return !(*this == rhs); } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | public: |
| 118 | HazardResult DetectHazard(SyncStageAccessIndex usage_index) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 119 | |
John Zulauf | c920122 | 2020-05-13 15:13:03 -0600 | [diff] [blame] | 120 | HazardResult DetectBarrierHazard(SyncStageAccessIndex usage_index, VkPipelineStageFlags source_exec_scope, |
| 121 | SyncStageAccessFlags source_access_scope) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 122 | HazardResult DetectAsyncHazard(SyncStageAccessIndex usage_index) const; |
| 123 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 124 | void Update(SyncStageAccessIndex usage_index, const ResourceUsageTag &tag); |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 125 | void Resolve(const ResourceAccessState &other); |
| 126 | void ApplyBarrier(const SyncBarrier &barrier); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 127 | void ApplyExecutionBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask); |
| 128 | void ApplyMemoryAccessBarrier(VkPipelineStageFlags src_stage_mask, SyncStageAccessFlags src_scope, |
| 129 | VkPipelineStageFlags dst_stage_mask, SyncStageAccessFlags dst_scope); |
| 130 | |
| 131 | ResourceAccessState() |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 132 | : write_barriers(~SyncStageAccessFlags(0)), |
| 133 | write_dependency_chain(0), |
| 134 | last_read_count(0), |
| 135 | last_read_stages(0), |
| 136 | write_tag(), |
| 137 | last_write(0) {} |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 138 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 139 | bool HasWriteOp() const { return last_write != 0; } |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 140 | bool operator==(const ResourceAccessState &rhs) const { |
| 141 | bool same = (write_barriers == rhs.write_barriers) && (write_dependency_chain == rhs.write_dependency_chain) && |
| 142 | (last_read_count == rhs.last_read_count) && (last_read_stages == rhs.last_read_stages) && |
| 143 | (write_tag == rhs.write_tag); |
| 144 | for (uint32_t i = 0; same && i < last_read_count; i++) { |
| 145 | same |= last_reads[i] == rhs.last_reads[i]; |
| 146 | } |
| 147 | return same; |
| 148 | } |
| 149 | bool operator!=(const ResourceAccessState &rhs) const { return !(*this == rhs); } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 150 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 151 | private: |
| 152 | bool IsWriteHazard(SyncStageAccessFlagBits usage) const { return 0 != (usage & ~write_barriers); } |
| 153 | bool IsReadHazard(VkPipelineStageFlagBits stage, const ReadState &read_access) const { |
| 154 | return 0 != (stage & ~read_access.barriers); |
| 155 | } |
John Zulauf | 0cb5be2 | 2020-01-23 12:18:22 -0700 | [diff] [blame] | 156 | bool IsReadHazard(VkPipelineStageFlags stage_mask, const ReadState &read_access) const { |
| 157 | return stage_mask != (stage_mask & read_access.barriers); |
| 158 | } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 159 | // With reads, each must be "safe" relative to it's prior write, so we need only |
| 160 | // save the most recent write operation (as anything *transitively* unsafe would arleady |
| 161 | // be included |
| 162 | SyncStageAccessFlags write_barriers; // union of applicable barrier masks since last write |
| 163 | VkPipelineStageFlags write_dependency_chain; // intiially zero, but accumulating the dstStages of barriers if they chain. |
| 164 | uint32_t last_read_count; |
| 165 | VkPipelineStageFlags last_read_stages; |
| 166 | |
| 167 | ResourceUsageTag write_tag; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 168 | // TODO: Add a NONE (zero) enum to SyncStageAccessFlagBits |
| 169 | SyncStageAccessFlags last_write; // only the most recent write |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 170 | |
| 171 | std::array<ReadState, 8 * sizeof(VkPipelineStageFlags)> last_reads; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 172 | }; |
| 173 | |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 174 | using ResourceAccessRangeMap = sparse_container::range_map<VkDeviceSize, ResourceAccessState>; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 175 | using ResourceAccessRange = typename ResourceAccessRangeMap::key_type; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 176 | using ResourceRangeMergeIterator = sparse_container::parallel_iterator<ResourceAccessRangeMap, const ResourceAccessRangeMap>; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 177 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 178 | class AccessContext { |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 179 | public: |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 180 | enum AddressType : int { kLinearAddress = 0, kIdealizedAddress = 1, kMaxAddressType = 1 }; |
| 181 | enum DetectOptions : unsigned int { |
| 182 | kDetectPrevious = 1U << 0, |
| 183 | kDetectAsync = 1U << 1, |
| 184 | kDetectAll = (kDetectPrevious | kDetectAsync) |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 185 | }; |
| 186 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 187 | struct TrackBack { |
| 188 | SyncBarrier barrier; |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 189 | AccessContext *context; |
| 190 | TrackBack(AccessContext *context_, VkQueueFlags queue_flags_, const VkSubpassDependency2 &subpass_barrier_) |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 191 | : barrier(queue_flags_, subpass_barrier_), context(context_) {} |
| 192 | TrackBack &operator=(const TrackBack &) = default; |
| 193 | TrackBack() = default; |
| 194 | }; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 195 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 196 | 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] | 197 | HazardResult DetectHazard(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 198 | const VkImageSubresourceLayers &subresource, const VkOffset3D &offset, |
| 199 | const VkExtent3D &extent) const; |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame^] | 200 | HazardResult DetectHazard(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
| 201 | const VkImageSubresourceRange &subresource_range, const VkOffset3D &offset, |
| 202 | const VkExtent3D &extent) const; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 203 | HazardResult DetectImageBarrierHazard(const IMAGE_STATE &image, VkPipelineStageFlags src_exec_scope, |
| 204 | SyncStageAccessFlags src_access_scope, const VkImageSubresourceRange &subresource_range, |
| 205 | DetectOptions options) const; |
| 206 | HazardResult DetectImageBarrierHazard(const IMAGE_STATE &image, VkPipelineStageFlags src_exec_scope, |
| 207 | SyncStageAccessFlags src_stage_accesses, const VkImageMemoryBarrier &barrier) const; |
| 208 | HazardResult DetectSubpassTransitionHazard(const RENDER_PASS_STATE::AttachmentTransition &transitions, |
| 209 | const std::vector<const IMAGE_VIEW_STATE *> &attachments) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 210 | |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 211 | const TrackBack &GetDstExternalTrackBack() const { return dst_external_; } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 212 | void Reset() { |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 213 | prev_.clear(); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 214 | prev_by_subpass_.clear(); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 215 | async_.clear(); |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 216 | src_external_ = TrackBack(); |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 217 | for (auto &map : access_state_maps_) { |
| 218 | map.clear(); |
| 219 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 220 | } |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 221 | // TODO: See if returning the lower_bound would be useful from a performance POV -- look at the lower_bound overhead |
| 222 | // Would need to add a "hint" overload to parallel_iterator::invalidate_[AB] call, if so. |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 223 | void ResolvePreviousAccess(AddressType type, const ResourceAccessRange &range, ResourceAccessRangeMap *descent_map, |
| 224 | const ResourceAccessState *infill_state) const; |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 225 | void ResolvePreviousAccess(const IMAGE_STATE &image_state, const VkImageSubresourceRange &subresource_range, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 226 | AddressType address_type, ResourceAccessRangeMap *descent_map, |
| 227 | const ResourceAccessState *infill_state) const; |
| 228 | void ResolveAccessRange(AddressType type, const ResourceAccessRange &range, const SyncBarrier *barrier, |
| 229 | ResourceAccessRangeMap *resolve_map, const ResourceAccessState *infill_state, |
| 230 | bool recur_to_infill = true) const; |
| 231 | void UpdateAccessState(const BUFFER_STATE &buffer, SyncStageAccessIndex current_usage, const ResourceAccessRange &range, |
| 232 | const ResourceUsageTag &tag); |
| 233 | void UpdateAccessState(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
| 234 | const VkImageSubresourceRange &subresource_range, const VkOffset3D &offset, const VkExtent3D &extent, |
| 235 | const ResourceUsageTag &tag); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 236 | void UpdateAccessState(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 237 | const VkImageSubresourceLayers &subresource, const VkOffset3D &offset, const VkExtent3D &extent, |
| 238 | const ResourceUsageTag &tag); |
| 239 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 240 | void ResolveChildContexts(const std::vector<AccessContext> &contexts); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 241 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 242 | void ApplyImageBarrier(const IMAGE_STATE &image, VkPipelineStageFlags src_exec_scope, SyncStageAccessFlags src_access_scope, |
| 243 | VkPipelineStageFlags dst_exec_scope, SyncStageAccessFlags dst_accesse_scope, |
| 244 | const VkImageSubresourceRange &subresource_range); |
| 245 | |
| 246 | void ApplyImageBarrier(const IMAGE_STATE &image, VkPipelineStageFlags src_exec_scope, SyncStageAccessFlags src_access_scope, |
| 247 | VkPipelineStageFlags dst_exec_scope, SyncStageAccessFlags dst_access_scope, |
| 248 | const VkImageSubresourceRange &subresource_range, bool layout_transition, const ResourceUsageTag &tag); |
| 249 | void ApplyImageBarrier(const IMAGE_STATE &image, const SyncBarrier &barrier, const VkImageSubresourceRange &subresource_range, |
| 250 | bool layout_transition, const ResourceUsageTag &tag); |
| 251 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 252 | template <typename Action> |
| 253 | void UpdateMemoryAccess(const BUFFER_STATE &buffer, const ResourceAccessRange &range, const Action action); |
| 254 | template <typename Action> |
| 255 | void UpdateMemoryAccess(const IMAGE_STATE &image, const VkImageSubresourceRange &subresource_range, const Action action); |
| 256 | |
| 257 | template <typename Action> |
| 258 | void ApplyGlobalBarriers(const Action &barrier_action); |
| 259 | |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 260 | static AddressType ImageAddressType(const IMAGE_STATE &image); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 261 | static VkDeviceSize ResourceBaseAddress(const BINDABLE &bindable); |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 262 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 263 | AccessContext(uint32_t subpass, VkQueueFlags queue_flags, const std::vector<SubpassDependencyGraphNode> &dependencies, |
| 264 | const std::vector<AccessContext> &contexts, AccessContext *external_context); |
| 265 | |
| 266 | AccessContext() { Reset(); } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 267 | |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 268 | ResourceAccessRangeMap &GetAccessStateMap(AddressType type) { return access_state_maps_[type]; } |
| 269 | const ResourceAccessRangeMap &GetAccessStateMap(AddressType type) const { return access_state_maps_[type]; } |
| 270 | ResourceAccessRangeMap &GetLinearMap() { return GetAccessStateMap(AddressType::kLinearAddress); } |
| 271 | const ResourceAccessRangeMap &GetLinearMap() const { return GetAccessStateMap(AddressType::kLinearAddress); } |
| 272 | ResourceAccessRangeMap &GetIdealizedMap() { return GetAccessStateMap(AddressType::kIdealizedAddress); } |
| 273 | const ResourceAccessRangeMap &GetIdealizedMap() const { return GetAccessStateMap(AddressType::kIdealizedAddress); } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 274 | const TrackBack *GetTrackBackFromSubpass(uint32_t subpass) const { |
| 275 | if (subpass == VK_SUBPASS_EXTERNAL) { |
| 276 | return &src_external_; |
| 277 | } else { |
| 278 | assert(subpass < prev_by_subpass_.size()); |
| 279 | return prev_by_subpass_[subpass]; |
| 280 | } |
| 281 | } |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 282 | |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame^] | 283 | bool ValidateLayoutTransitions(const SyncValidator &sync_state, const RENDER_PASS_STATE &rp_state, |
| 284 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, const char *func_name, |
| 285 | uint32_t subpass) const; |
| 286 | bool ValidateLoadOperation(const SyncValidator &sync_state, const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, |
| 287 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, const char *func_name, |
| 288 | uint32_t subpass) const; |
| 289 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 290 | private: |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 291 | HazardResult DetectHazard(AddressType type, SyncStageAccessIndex usage_index, const ResourceAccessRange &range) const; |
| 292 | HazardResult DetectBarrierHazard(AddressType type, SyncStageAccessIndex current_usage, VkPipelineStageFlags src_exec_scope, |
| 293 | SyncStageAccessFlags src_access_scope, const ResourceAccessRange &range, |
| 294 | DetectOptions options) const; |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 295 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 296 | template <typename Detector> |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 297 | HazardResult DetectHazard(AddressType type, const Detector &detector, const ResourceAccessRange &range, |
| 298 | DetectOptions options) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 299 | template <typename Detector> |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 300 | HazardResult DetectAsyncHazard(AddressType type, const Detector &detector, const ResourceAccessRange &range) const; |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 301 | template <typename Detector> |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 302 | HazardResult DetectPreviousHazard(AddressType type, const Detector &detector, const ResourceAccessRange &range) const; |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 303 | void UpdateAccessState(AddressType type, SyncStageAccessIndex current_usage, const ResourceAccessRange &range, |
| 304 | const ResourceUsageTag &tag); |
| 305 | constexpr static int kAddressTypeCount = AddressType::kMaxAddressType + 1; |
| 306 | static const std::array<AddressType, kAddressTypeCount> kAddressTypes; |
| 307 | std::array<ResourceAccessRangeMap, kAddressTypeCount> access_state_maps_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 308 | std::vector<TrackBack> prev_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 309 | std::vector<TrackBack *> prev_by_subpass_; |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 310 | std::vector<AccessContext *> async_; |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 311 | TrackBack src_external_; |
| 312 | TrackBack dst_external_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 313 | }; |
| 314 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 315 | class RenderPassAccessContext { |
| 316 | public: |
| 317 | RenderPassAccessContext(AccessContext *external_context) |
| 318 | : external_context_(external_context), rp_state_(nullptr), current_subpass_(0) {} |
| 319 | |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame^] | 320 | bool ValidateNextSubpass(const SyncValidator &sync_state, const VkRect2D &render_area, const char *command_name) const; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 321 | bool ValidateFinalSubpassLayoutTransitions(const SyncValidator &sync_state, const char *func_name) const; |
| 322 | |
| 323 | void RecordLayoutTransitions(const ResourceUsageTag &tag); |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame^] | 324 | void RecordLoadOperations(const VkRect2D &render_area, const ResourceUsageTag &tag); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 325 | void RecordBeginRenderPass(const SyncValidator &state, const CMD_BUFFER_STATE &cb_state, VkQueueFlags queue_flags, |
| 326 | const ResourceUsageTag &tag); |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame^] | 327 | void RecordNextSubpass(const VkRect2D &render_area, const ResourceUsageTag &tag); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 328 | void RecordEndRenderPass(const ResourceUsageTag &tag); |
| 329 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 330 | AccessContext &CurrentContext() { return subpass_contexts_[current_subpass_]; } |
| 331 | const AccessContext &CurrentContext() const { return subpass_contexts_[current_subpass_]; } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 332 | const std::vector<AccessContext> &GetContexts() const { return subpass_contexts_; } |
| 333 | uint32_t GetCurrentSubpass() const { return current_subpass_; } |
| 334 | const RENDER_PASS_STATE *GetRenderPassState() const { return rp_state_; } |
| 335 | |
| 336 | private: |
| 337 | AccessContext *external_context_; |
| 338 | const RENDER_PASS_STATE *rp_state_; |
| 339 | uint32_t current_subpass_; |
| 340 | std::vector<AccessContext> subpass_contexts_; |
| 341 | std::vector<const IMAGE_VIEW_STATE *> attachment_views_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 342 | }; |
| 343 | |
| 344 | class CommandBufferAccessContext { |
| 345 | public: |
| 346 | CommandBufferAccessContext() |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 347 | : command_number_(0), |
| 348 | reset_count_(0), |
| 349 | render_pass_contexts_(), |
| 350 | cb_access_context_(), |
| 351 | current_context_(&cb_access_context_), |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 352 | current_renderpass_context_(), |
| 353 | cb_state_(), |
| 354 | queue_flags_() {} |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 355 | CommandBufferAccessContext(SyncValidator &sync_validator, std::shared_ptr<CMD_BUFFER_STATE> &cb_state, VkQueueFlags queue_flags) |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 356 | : CommandBufferAccessContext() { |
| 357 | cb_state_ = cb_state; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 358 | sync_state_ = &sync_validator; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 359 | queue_flags_ = queue_flags; |
| 360 | } |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 361 | |
| 362 | void Reset() { |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 363 | command_number_ = 0; |
| 364 | reset_count_++; |
| 365 | cb_access_context_.Reset(); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 366 | render_pass_contexts_.clear(); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 367 | current_context_ = &cb_access_context_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 368 | current_renderpass_context_ = nullptr; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 369 | } |
| 370 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 371 | AccessContext *GetCurrentAccessContext() { return current_context_; } |
| 372 | const AccessContext *GetCurrentAccessContext() const { return current_context_; } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 373 | void RecordBeginRenderPass(const ResourceUsageTag &tag); |
| 374 | bool ValidateBeginRenderPass(const RENDER_PASS_STATE &render_pass, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 375 | const VkSubpassBeginInfoKHR *pSubpassBeginInfo, const char *func_name) const; |
| 376 | bool ValidateNextSubpass(const char *func_name) const; |
| 377 | bool ValidateEndRenderpass(const char *func_name) const; |
| 378 | void RecordNextSubpass(const RENDER_PASS_STATE &render_pass, const ResourceUsageTag &tag); |
| 379 | void RecordEndRenderPass(const RENDER_PASS_STATE &render_pass, const ResourceUsageTag &tag); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 380 | CMD_BUFFER_STATE *GetCommandBufferState() { return cb_state_.get(); } |
| 381 | const CMD_BUFFER_STATE *GetCommandBufferState() const { return cb_state_.get(); } |
| 382 | VkQueueFlags GetQueueFlags() const { return queue_flags_; } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 383 | inline ResourceUsageTag NextCommandTag(CMD_TYPE command) { |
| 384 | // TODO: add command encoding to ResourceUsageTag. |
| 385 | // What else we what to include. Do we want some sort of "parent" or global sequence number |
| 386 | command_number_++; |
| 387 | ResourceUsageTag next; |
| 388 | next.index = (static_cast<uint64_t>(reset_count_) << 32) | command_number_; |
| 389 | return next; |
| 390 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 391 | |
| 392 | private: |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 393 | uint32_t command_number_; |
| 394 | uint32_t reset_count_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 395 | std::vector<RenderPassAccessContext> render_pass_contexts_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 396 | AccessContext cb_access_context_; |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 397 | AccessContext *current_context_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 398 | RenderPassAccessContext *current_renderpass_context_; |
| 399 | std::shared_ptr<CMD_BUFFER_STATE> cb_state_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 400 | SyncValidator *sync_state_; |
| 401 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 402 | VkQueueFlags queue_flags_; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 403 | }; |
| 404 | |
| 405 | class SyncValidator : public ValidationStateTracker, public SyncStageAccess { |
| 406 | public: |
| 407 | SyncValidator() { container_type = LayerObjectTypeSyncValidation; } |
| 408 | using StateTracker = ValidationStateTracker; |
| 409 | |
| 410 | using StateTracker::AccessorTraitsTypes; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 411 | std::unordered_map<VkCommandBuffer, std::unique_ptr<CommandBufferAccessContext>> cb_access_state; |
| 412 | CommandBufferAccessContext *GetAccessContextImpl(VkCommandBuffer command_buffer, bool do_insert) { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 413 | auto found_it = cb_access_state.find(command_buffer); |
| 414 | if (found_it == cb_access_state.end()) { |
| 415 | if (!do_insert) return nullptr; |
| 416 | // If we don't have one, make it. |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 417 | auto cb_state = GetShared<CMD_BUFFER_STATE>(command_buffer); |
| 418 | assert(cb_state.get()); |
| 419 | auto queue_flags = GetQueueFlags(*cb_state); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 420 | std::unique_ptr<CommandBufferAccessContext> context(new CommandBufferAccessContext(*this, cb_state, queue_flags)); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 421 | 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] | 422 | found_it = insert_pair.first; |
| 423 | } |
| 424 | return found_it->second.get(); |
| 425 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 426 | CommandBufferAccessContext *GetAccessContext(VkCommandBuffer command_buffer) { |
| 427 | return GetAccessContextImpl(command_buffer, true); // true -> do_insert on not found |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 428 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 429 | CommandBufferAccessContext *GetAccessContextNoInsert(VkCommandBuffer command_buffer) { |
| 430 | 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] | 431 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 432 | |
| 433 | const CommandBufferAccessContext *GetAccessContext(VkCommandBuffer command_buffer) const { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 434 | const auto found_it = cb_access_state.find(command_buffer); |
| 435 | if (found_it == cb_access_state.end()) { |
| 436 | return nullptr; |
| 437 | } |
| 438 | return found_it->second.get(); |
| 439 | } |
| 440 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 441 | void ApplyGlobalBarriers(AccessContext *context, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 442 | SyncStageAccessFlags src_stage_scope, SyncStageAccessFlags dst_stage_scope, |
| 443 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 444 | void ApplyBufferBarriers(AccessContext *context, VkPipelineStageFlags src_stage_mask, SyncStageAccessFlags src_stage_scope, |
| 445 | VkPipelineStageFlags dst_stage_mask, SyncStageAccessFlags dst_stage_scope, uint32_t barrier_count, |
| 446 | const VkBufferMemoryBarrier *barriers); |
| 447 | void ApplyImageBarriers(AccessContext *context, VkPipelineStageFlags src_stage_mask, SyncStageAccessFlags src_stage_scope, |
| 448 | VkPipelineStageFlags dst_stage_mask, SyncStageAccessFlags dst_stage_scope, uint32_t barrier_count, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 449 | const VkImageMemoryBarrier *barriers, const ResourceUsageTag &tag); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 450 | |
John Zulauf | d1f85d4 | 2020-04-15 12:23:15 -0600 | [diff] [blame] | 451 | void ResetCommandBufferCallback(VkCommandBuffer command_buffer); |
| 452 | void FreeCommandBufferCallback(VkCommandBuffer command_buffer); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 453 | void RecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 454 | const VkSubpassBeginInfo *pSubpassBeginInfo, CMD_TYPE command); |
| 455 | void RecordCmdNextSubpass(VkCommandBuffer commandBuffer, |
| 456 | |
| 457 | const VkSubpassBeginInfo *pSubpassBeginInfo, const VkSubpassEndInfo *pSubpassEndInfo, |
| 458 | CMD_TYPE command); |
| 459 | void RecordCmdEndRenderPass(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo, CMD_TYPE command); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 460 | |
| 461 | void PostCallRecordCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, |
| 462 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result); |
| 463 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 464 | bool ValidateBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 465 | const VkSubpassBeginInfoKHR *pSubpassBeginInfo, const char *func_name) const; |
| 466 | |
| 467 | bool PreCallValidateCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 468 | VkSubpassContents contents) const; |
| 469 | |
| 470 | bool PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 471 | const VkSubpassBeginInfoKHR *pSubpassBeginInfo) const; |
| 472 | |
| 473 | bool PreCallValidateCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 474 | const VkSubpassBeginInfoKHR *pSubpassBeginInfo) const; |
| 475 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 476 | bool PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, |
| 477 | const VkBufferCopy *pRegions) const; |
| 478 | |
| 479 | void PreCallRecordCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, |
| 480 | const VkBufferCopy *pRegions); |
| 481 | |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 482 | bool PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 483 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
| 484 | const VkImageCopy *pRegions) const; |
| 485 | |
| 486 | void PreCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 487 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions); |
| 488 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 489 | bool PreCallValidateCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, |
| 490 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 491 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 492 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 493 | uint32_t imageMemoryBarrierCount, |
| 494 | const VkImageMemoryBarrier *pImageMemoryBarriers) const; |
| 495 | |
| 496 | void PreCallRecordCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, |
| 497 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 498 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 499 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 500 | uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 501 | |
| 502 | void PostCallRecordBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo, |
| 503 | VkResult result); |
| 504 | |
| 505 | void PostCallRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 506 | VkSubpassContents contents); |
| 507 | void PostCallRecordCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 508 | const VkSubpassBeginInfo *pSubpassBeginInfo); |
| 509 | void PostCallRecordCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 510 | const VkSubpassBeginInfo *pSubpassBeginInfo); |
| 511 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 512 | bool ValidateCmdNextSubpass(VkCommandBuffer commandBuffer, const VkSubpassBeginInfoKHR *pSubpassBeginInfo, |
| 513 | const VkSubpassEndInfoKHR *pSubpassEndInfo, const char *func_name) const; |
| 514 | bool PreCallValidateCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) const; |
| 515 | bool PreCallValidateCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfoKHR *pSubpassBeginInfo, |
| 516 | const VkSubpassEndInfoKHR *pSubpassEndInfo) const; |
| 517 | bool PreCallValidateCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, const VkSubpassBeginInfoKHR *pSubpassBeginInfo, |
| 518 | const VkSubpassEndInfoKHR *pSubpassEndInfo) const; |
| 519 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 520 | void PostCallRecordCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents); |
| 521 | void PostCallRecordCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 522 | const VkSubpassEndInfo *pSubpassEndInfo); |
| 523 | void PostCallRecordCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 524 | const VkSubpassEndInfo *pSubpassEndInfo); |
| 525 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 526 | bool ValidateCmdEndRenderPass(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR *pSubpassEndInfo, |
| 527 | const char *func_name) const; |
| 528 | bool PreCallValidateCmdEndRenderPass(VkCommandBuffer commandBuffer) const; |
| 529 | bool PreCallValidateCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR *pSubpassEndInfo) const; |
| 530 | bool PreCallValidateCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR *pSubpassEndInfo) const; |
| 531 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 532 | void PostCallRecordCmdEndRenderPass(VkCommandBuffer commandBuffer); |
| 533 | void PostCallRecordCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo); |
| 534 | void PostCallRecordCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo); |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 535 | bool PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
| 536 | VkImageLayout dstImageLayout, uint32_t regionCount, |
| 537 | const VkBufferImageCopy *pRegions) const; |
| 538 | |
| 539 | void PreCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
| 540 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy *pRegions); |
| 541 | |
| 542 | bool PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 543 | VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions) const; |
| 544 | |
| 545 | void PreCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 546 | VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions); |
| 547 | |
| 548 | bool PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 549 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
| 550 | const VkImageBlit *pRegions, VkFilter filter) const; |
| 551 | |
| 552 | void PreCallRecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 553 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, |
| 554 | VkFilter filter); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 555 | }; |