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 | |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 22 | #include <limits> |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 23 | #include <map> |
| 24 | #include <memory> |
| 25 | #include <unordered_map> |
| 26 | #include <vulkan/vulkan.h> |
| 27 | |
| 28 | #include "synchronization_validation_types.h" |
| 29 | #include "state_tracker.h" |
| 30 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 31 | class SyncValidator; |
| 32 | |
John Zulauf | 2f952d2 | 2020-02-10 11:34:51 -0700 | [diff] [blame] | 33 | enum SyncHazard { |
| 34 | NONE = 0, |
| 35 | READ_AFTER_WRITE, |
| 36 | WRITE_AFTER_READ, |
| 37 | WRITE_AFTER_WRITE, |
| 38 | READ_RACING_WRITE, |
| 39 | WRITE_RACING_WRITE, |
| 40 | WRITE_RACING_READ, |
| 41 | }; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 42 | |
| 43 | // Useful Utilites for manipulating StageAccess parameters, suitable as base class to save typing |
| 44 | struct SyncStageAccess { |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 45 | static inline SyncStageAccessFlagBits FlagBit(SyncStageAccessIndex stage_access) { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 46 | return syncStageAccessInfoByStageAccessIndex[stage_access].stage_access_bit; |
| 47 | } |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 48 | static inline SyncStageAccessFlags Flags(SyncStageAccessIndex stage_access) { |
| 49 | return static_cast<SyncStageAccessFlags>(FlagBit(stage_access)); |
| 50 | } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 51 | |
| 52 | static bool IsRead(SyncStageAccessFlagBits stage_access_bit) { return 0 != (stage_access_bit & syncStageAccessReadMask); } |
| 53 | static bool IsRead(SyncStageAccessIndex stage_access_index) { return IsRead(FlagBit(stage_access_index)); } |
| 54 | |
| 55 | 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] | 56 | 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] | 57 | static bool IsWrite(SyncStageAccessIndex stage_access_index) { return IsWrite(FlagBit(stage_access_index)); } |
| 58 | static VkPipelineStageFlagBits PipelineStageBit(SyncStageAccessIndex stage_access_index) { |
| 59 | return syncStageAccessInfoByStageAccessIndex[stage_access_index].stage_mask; |
| 60 | } |
| 61 | static SyncStageAccessFlags AccessScopeByStage(VkPipelineStageFlags stages); |
| 62 | static SyncStageAccessFlags AccessScopeByAccess(VkAccessFlags access); |
| 63 | static SyncStageAccessFlags AccessScope(VkPipelineStageFlags stages, VkAccessFlags access); |
| 64 | static SyncStageAccessFlags AccessScope(SyncStageAccessFlags stage_scope, VkAccessFlags accesses) { |
| 65 | return stage_scope & AccessScopeByAccess(accesses); |
| 66 | } |
| 67 | }; |
| 68 | |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 69 | struct ResourceUsageTag { |
| 70 | uint64_t index; |
John Zulauf | cc6fecb | 2020-06-17 15:24:54 -0600 | [diff] [blame] | 71 | CMD_TYPE command; |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 72 | const static uint64_t kMaxIndex = std::numeric_limits<uint64_t>::max(); |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 73 | ResourceUsageTag &operator++() { |
| 74 | index++; |
| 75 | return *this; |
| 76 | } |
| 77 | bool IsBefore(const ResourceUsageTag &rhs) const { return index < rhs.index; } |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 78 | bool operator==(const ResourceUsageTag &rhs) const { return (index == rhs.index); } |
| 79 | bool operator!=(const ResourceUsageTag &rhs) const { return !(*this == rhs); } |
John Zulauf | cc6fecb | 2020-06-17 15:24:54 -0600 | [diff] [blame] | 80 | ResourceUsageTag() : index(0), command(CMD_NONE) {} |
| 81 | ResourceUsageTag(uint64_t index_, CMD_TYPE command_) : index(index_), command(command_) {} |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 82 | }; |
| 83 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 84 | struct HazardResult { |
| 85 | SyncHazard hazard = NONE; |
| 86 | ResourceUsageTag tag = ResourceUsageTag(); |
| 87 | void Set(SyncHazard hazard_, const ResourceUsageTag &tag_) { |
| 88 | hazard = hazard_; |
| 89 | tag = tag_; |
| 90 | } |
| 91 | }; |
| 92 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 93 | struct SyncBarrier { |
| 94 | VkPipelineStageFlags src_exec_scope; |
| 95 | SyncStageAccessFlags src_access_scope; |
| 96 | VkPipelineStageFlags dst_exec_scope; |
| 97 | SyncStageAccessFlags dst_access_scope; |
| 98 | SyncBarrier() = default; |
| 99 | SyncBarrier &operator=(const SyncBarrier &) = default; |
| 100 | SyncBarrier(VkQueueFlags gueue_flags, const VkSubpassDependency2 &sub_pass_barrier); |
| 101 | }; |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 102 | |
| 103 | // To represent ordering guarantees such as rasterization and store |
| 104 | struct SyncOrderingBarrier { |
| 105 | VkPipelineStageFlags exec_scope; |
| 106 | SyncStageAccessFlags access_scope; |
| 107 | SyncOrderingBarrier() = default; |
| 108 | SyncOrderingBarrier &operator=(const SyncOrderingBarrier &) = default; |
| 109 | }; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 110 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 111 | class ResourceAccessState : public SyncStageAccess { |
| 112 | protected: |
| 113 | // Mutliple read operations can be simlutaneously (and independently) synchronized, |
| 114 | // given the only the second execution scope creates a dependency chain, we have to track each, |
| 115 | // but only up to one per pipeline stage (as another read from the *same* stage become more recent, |
| 116 | // and applicable one for hazard detection |
| 117 | struct ReadState { |
| 118 | VkPipelineStageFlagBits stage; // The stage of this read |
| 119 | VkPipelineStageFlags barriers; // all applicable barriered stages |
| 120 | ResourceUsageTag tag; |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 121 | bool operator==(const ReadState &rhs) const { |
| 122 | bool same = (stage == rhs.stage) && (barriers == rhs.barriers) && (tag == rhs.tag); |
| 123 | return same; |
| 124 | } |
| 125 | bool operator!=(const ReadState &rhs) const { return !(*this == rhs); } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | public: |
| 129 | HazardResult DetectHazard(SyncStageAccessIndex usage_index) const; |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 130 | HazardResult DetectHazard(SyncStageAccessIndex usage_index, const SyncOrderingBarrier &ordering) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 131 | |
John Zulauf | c920122 | 2020-05-13 15:13:03 -0600 | [diff] [blame] | 132 | HazardResult DetectBarrierHazard(SyncStageAccessIndex usage_index, VkPipelineStageFlags source_exec_scope, |
| 133 | SyncStageAccessFlags source_access_scope) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 134 | HazardResult DetectAsyncHazard(SyncStageAccessIndex usage_index) const; |
| 135 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 136 | void Update(SyncStageAccessIndex usage_index, const ResourceUsageTag &tag); |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 137 | void Resolve(const ResourceAccessState &other); |
| 138 | void ApplyBarrier(const SyncBarrier &barrier); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 139 | void ApplyExecutionBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask); |
| 140 | void ApplyMemoryAccessBarrier(VkPipelineStageFlags src_stage_mask, SyncStageAccessFlags src_scope, |
| 141 | VkPipelineStageFlags dst_stage_mask, SyncStageAccessFlags dst_scope); |
| 142 | |
| 143 | ResourceAccessState() |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 144 | : write_barriers(~SyncStageAccessFlags(0)), |
| 145 | write_dependency_chain(0), |
| 146 | last_read_count(0), |
| 147 | last_read_stages(0), |
| 148 | write_tag(), |
| 149 | last_write(0) {} |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 150 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 151 | bool HasWriteOp() const { return last_write != 0; } |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 152 | bool operator==(const ResourceAccessState &rhs) const { |
| 153 | bool same = (write_barriers == rhs.write_barriers) && (write_dependency_chain == rhs.write_dependency_chain) && |
| 154 | (last_read_count == rhs.last_read_count) && (last_read_stages == rhs.last_read_stages) && |
| 155 | (write_tag == rhs.write_tag); |
| 156 | for (uint32_t i = 0; same && i < last_read_count; i++) { |
| 157 | same |= last_reads[i] == rhs.last_reads[i]; |
| 158 | } |
| 159 | return same; |
| 160 | } |
| 161 | bool operator!=(const ResourceAccessState &rhs) const { return !(*this == rhs); } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 162 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 163 | private: |
| 164 | bool IsWriteHazard(SyncStageAccessFlagBits usage) const { return 0 != (usage & ~write_barriers); } |
| 165 | bool IsReadHazard(VkPipelineStageFlagBits stage, const ReadState &read_access) const { |
| 166 | return 0 != (stage & ~read_access.barriers); |
| 167 | } |
John Zulauf | 0cb5be2 | 2020-01-23 12:18:22 -0700 | [diff] [blame] | 168 | bool IsReadHazard(VkPipelineStageFlags stage_mask, const ReadState &read_access) const { |
| 169 | return stage_mask != (stage_mask & read_access.barriers); |
| 170 | } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 171 | // With reads, each must be "safe" relative to it's prior write, so we need only |
| 172 | // save the most recent write operation (as anything *transitively* unsafe would arleady |
| 173 | // be included |
| 174 | SyncStageAccessFlags write_barriers; // union of applicable barrier masks since last write |
| 175 | VkPipelineStageFlags write_dependency_chain; // intiially zero, but accumulating the dstStages of barriers if they chain. |
| 176 | uint32_t last_read_count; |
| 177 | VkPipelineStageFlags last_read_stages; |
| 178 | |
| 179 | ResourceUsageTag write_tag; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 180 | // TODO: Add a NONE (zero) enum to SyncStageAccessFlagBits |
| 181 | SyncStageAccessFlags last_write; // only the most recent write |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 182 | |
| 183 | std::array<ReadState, 8 * sizeof(VkPipelineStageFlags)> last_reads; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 184 | }; |
| 185 | |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 186 | using ResourceAccessRangeMap = sparse_container::range_map<VkDeviceSize, ResourceAccessState>; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 187 | using ResourceAccessRange = typename ResourceAccessRangeMap::key_type; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 188 | using ResourceRangeMergeIterator = sparse_container::parallel_iterator<ResourceAccessRangeMap, const ResourceAccessRangeMap>; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 189 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 190 | class AccessContext { |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 191 | public: |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 192 | enum AddressType : int { kLinearAddress = 0, kIdealizedAddress = 1, kMaxAddressType = 1 }; |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 193 | enum DetectOptions : uint32_t { |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 194 | kDetectPrevious = 1U << 0, |
| 195 | kDetectAsync = 1U << 1, |
| 196 | kDetectAll = (kDetectPrevious | kDetectAsync) |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 197 | }; |
| 198 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 199 | struct TrackBack { |
| 200 | SyncBarrier barrier; |
John Zulauf | 1a22429 | 2020-06-30 14:52:13 -0600 | [diff] [blame^] | 201 | const AccessContext *context; |
| 202 | TrackBack(const AccessContext *context_, VkQueueFlags queue_flags_, const VkSubpassDependency2 &subpass_barrier_) |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 203 | : barrier(queue_flags_, subpass_barrier_), context(context_) {} |
| 204 | TrackBack &operator=(const TrackBack &) = default; |
| 205 | TrackBack() = default; |
| 206 | }; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 207 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 208 | 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] | 209 | HazardResult DetectHazard(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 210 | const VkImageSubresourceLayers &subresource, const VkOffset3D &offset, |
| 211 | const VkExtent3D &extent) const; |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 212 | template <typename Detector> |
| 213 | HazardResult DetectHazard(Detector &detector, const IMAGE_STATE &image, const VkImageSubresourceRange &subresource_range, |
| 214 | const VkOffset3D &offset, const VkExtent3D &extent, DetectOptions options) const; |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 215 | HazardResult DetectHazard(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
| 216 | const VkImageSubresourceRange &subresource_range, const VkOffset3D &offset, |
| 217 | const VkExtent3D &extent) const; |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 218 | HazardResult DetectHazard(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
| 219 | const VkImageSubresourceRange &subresource_range, const SyncOrderingBarrier &ordering, |
| 220 | const VkOffset3D &offset, const VkExtent3D &extent) const; |
John Zulauf | b027cdb | 2020-05-21 14:25:22 -0600 | [diff] [blame] | 221 | HazardResult DetectHazard(const IMAGE_VIEW_STATE *view, SyncStageAccessIndex current_usage, const SyncOrderingBarrier &ordering, |
| 222 | const VkOffset3D &offset, const VkExtent3D &extent, VkImageAspectFlags aspect_mask = 0U) const; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 223 | HazardResult DetectImageBarrierHazard(const IMAGE_STATE &image, VkPipelineStageFlags src_exec_scope, |
| 224 | SyncStageAccessFlags src_access_scope, const VkImageSubresourceRange &subresource_range, |
| 225 | DetectOptions options) const; |
| 226 | HazardResult DetectImageBarrierHazard(const IMAGE_STATE &image, VkPipelineStageFlags src_exec_scope, |
| 227 | SyncStageAccessFlags src_stage_accesses, const VkImageMemoryBarrier &barrier) const; |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 228 | 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] | 229 | |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 230 | const TrackBack &GetDstExternalTrackBack() const { return dst_external_; } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 231 | void Reset() { |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 232 | prev_.clear(); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 233 | prev_by_subpass_.clear(); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 234 | async_.clear(); |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 235 | src_external_ = TrackBack(); |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 236 | for (auto &map : access_state_maps_) { |
| 237 | map.clear(); |
| 238 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 239 | } |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 240 | // TODO: See if returning the lower_bound would be useful from a performance POV -- look at the lower_bound overhead |
| 241 | // 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] | 242 | void ResolvePreviousAccess(AddressType type, const ResourceAccessRange &range, ResourceAccessRangeMap *descent_map, |
| 243 | const ResourceAccessState *infill_state) const; |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 244 | void ResolvePreviousAccess(const IMAGE_STATE &image_state, const VkImageSubresourceRange &subresource_range, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 245 | AddressType address_type, ResourceAccessRangeMap *descent_map, |
| 246 | const ResourceAccessState *infill_state) const; |
| 247 | void ResolveAccessRange(AddressType type, const ResourceAccessRange &range, const SyncBarrier *barrier, |
| 248 | ResourceAccessRangeMap *resolve_map, const ResourceAccessState *infill_state, |
| 249 | bool recur_to_infill = true) const; |
| 250 | void UpdateAccessState(const BUFFER_STATE &buffer, SyncStageAccessIndex current_usage, const ResourceAccessRange &range, |
| 251 | const ResourceUsageTag &tag); |
| 252 | void UpdateAccessState(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
| 253 | const VkImageSubresourceRange &subresource_range, const VkOffset3D &offset, const VkExtent3D &extent, |
| 254 | const ResourceUsageTag &tag); |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 255 | void UpdateAccessState(const IMAGE_VIEW_STATE *view, SyncStageAccessIndex current_usage, const VkOffset3D &offset, |
| 256 | const VkExtent3D &extent, VkImageAspectFlags aspect_mask, const ResourceUsageTag &tag); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 257 | void UpdateAccessState(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 258 | const VkImageSubresourceLayers &subresource, const VkOffset3D &offset, const VkExtent3D &extent, |
| 259 | const ResourceUsageTag &tag); |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 260 | void UpdateAttachmentResolveAccess(const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, |
| 261 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, uint32_t subpass, |
| 262 | const ResourceUsageTag &tag); |
John Zulauf | aff2066 | 2020-06-01 14:07:58 -0600 | [diff] [blame] | 263 | void UpdateAttachmentStoreAccess(const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, |
| 264 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, uint32_t subpass, |
| 265 | const ResourceUsageTag &tag); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 266 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 267 | void ResolveChildContexts(const std::vector<AccessContext> &contexts); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 268 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 269 | void ApplyImageBarrier(const IMAGE_STATE &image, VkPipelineStageFlags src_exec_scope, SyncStageAccessFlags src_access_scope, |
| 270 | VkPipelineStageFlags dst_exec_scope, SyncStageAccessFlags dst_accesse_scope, |
| 271 | const VkImageSubresourceRange &subresource_range); |
| 272 | |
| 273 | void ApplyImageBarrier(const IMAGE_STATE &image, VkPipelineStageFlags src_exec_scope, SyncStageAccessFlags src_access_scope, |
| 274 | VkPipelineStageFlags dst_exec_scope, SyncStageAccessFlags dst_access_scope, |
| 275 | const VkImageSubresourceRange &subresource_range, bool layout_transition, const ResourceUsageTag &tag); |
| 276 | void ApplyImageBarrier(const IMAGE_STATE &image, const SyncBarrier &barrier, const VkImageSubresourceRange &subresource_range, |
| 277 | bool layout_transition, const ResourceUsageTag &tag); |
| 278 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 279 | template <typename Action> |
| 280 | void UpdateMemoryAccess(const BUFFER_STATE &buffer, const ResourceAccessRange &range, const Action action); |
| 281 | template <typename Action> |
| 282 | void UpdateMemoryAccess(const IMAGE_STATE &image, const VkImageSubresourceRange &subresource_range, const Action action); |
| 283 | |
| 284 | template <typename Action> |
| 285 | void ApplyGlobalBarriers(const Action &barrier_action); |
| 286 | |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 287 | static AddressType ImageAddressType(const IMAGE_STATE &image); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 288 | static VkDeviceSize ResourceBaseAddress(const BINDABLE &bindable); |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 289 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 290 | AccessContext(uint32_t subpass, VkQueueFlags queue_flags, const std::vector<SubpassDependencyGraphNode> &dependencies, |
John Zulauf | 1a22429 | 2020-06-30 14:52:13 -0600 | [diff] [blame^] | 291 | const std::vector<AccessContext> &contexts, const AccessContext *external_context); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 292 | |
| 293 | AccessContext() { Reset(); } |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 294 | AccessContext(const AccessContext ©_from) = default; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 295 | |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 296 | ResourceAccessRangeMap &GetAccessStateMap(AddressType type) { return access_state_maps_[type]; } |
| 297 | const ResourceAccessRangeMap &GetAccessStateMap(AddressType type) const { return access_state_maps_[type]; } |
| 298 | ResourceAccessRangeMap &GetLinearMap() { return GetAccessStateMap(AddressType::kLinearAddress); } |
| 299 | const ResourceAccessRangeMap &GetLinearMap() const { return GetAccessStateMap(AddressType::kLinearAddress); } |
| 300 | ResourceAccessRangeMap &GetIdealizedMap() { return GetAccessStateMap(AddressType::kIdealizedAddress); } |
| 301 | const ResourceAccessRangeMap &GetIdealizedMap() const { return GetAccessStateMap(AddressType::kIdealizedAddress); } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 302 | const TrackBack *GetTrackBackFromSubpass(uint32_t subpass) const { |
| 303 | if (subpass == VK_SUBPASS_EXTERNAL) { |
| 304 | return &src_external_; |
| 305 | } else { |
| 306 | assert(subpass < prev_by_subpass_.size()); |
| 307 | return prev_by_subpass_[subpass]; |
| 308 | } |
| 309 | } |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 310 | |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 311 | bool ValidateLayoutTransitions(const SyncValidator &sync_state, |
| 312 | |
| 313 | const RENDER_PASS_STATE &rp_state, |
| 314 | |
| 315 | const VkRect2D &render_area, |
| 316 | |
| 317 | uint32_t subpass, const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, |
| 318 | const char *func_name) const; |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 319 | bool ValidateLoadOperation(const SyncValidator &sync_state, const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 320 | uint32_t subpass, const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, |
| 321 | const char *func_name) const; |
John Zulauf | aff2066 | 2020-06-01 14:07:58 -0600 | [diff] [blame] | 322 | bool ValidateStoreOperation(const SyncValidator &sync_state, const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, |
| 323 | uint32_t subpass, const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, |
| 324 | const char *func_name) const; |
John Zulauf | b027cdb | 2020-05-21 14:25:22 -0600 | [diff] [blame] | 325 | bool ValidateResolveOperations(const SyncValidator &sync_state, const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, |
| 326 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, const char *func_name, |
| 327 | uint32_t subpass) const; |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 328 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 329 | private: |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 330 | HazardResult DetectHazard(AddressType type, SyncStageAccessIndex usage_index, const ResourceAccessRange &range) const; |
| 331 | HazardResult DetectBarrierHazard(AddressType type, SyncStageAccessIndex current_usage, VkPipelineStageFlags src_exec_scope, |
| 332 | SyncStageAccessFlags src_access_scope, const ResourceAccessRange &range, |
| 333 | DetectOptions options) const; |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 334 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 335 | template <typename Detector> |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 336 | HazardResult DetectHazard(AddressType type, const Detector &detector, const ResourceAccessRange &range, |
| 337 | DetectOptions options) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 338 | template <typename Detector> |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 339 | HazardResult DetectAsyncHazard(AddressType type, const Detector &detector, const ResourceAccessRange &range) const; |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 340 | template <typename Detector> |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 341 | HazardResult DetectPreviousHazard(AddressType type, const Detector &detector, const ResourceAccessRange &range) const; |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 342 | void UpdateAccessState(AddressType type, SyncStageAccessIndex current_usage, const ResourceAccessRange &range, |
| 343 | const ResourceUsageTag &tag); |
| 344 | constexpr static int kAddressTypeCount = AddressType::kMaxAddressType + 1; |
| 345 | static const std::array<AddressType, kAddressTypeCount> kAddressTypes; |
| 346 | std::array<ResourceAccessRangeMap, kAddressTypeCount> access_state_maps_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 347 | std::vector<TrackBack> prev_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 348 | std::vector<TrackBack *> prev_by_subpass_; |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 349 | std::vector<AccessContext *> async_; |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 350 | TrackBack src_external_; |
| 351 | TrackBack dst_external_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 352 | }; |
| 353 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 354 | class RenderPassAccessContext { |
| 355 | public: |
John Zulauf | 1a22429 | 2020-06-30 14:52:13 -0600 | [diff] [blame^] | 356 | RenderPassAccessContext() : rp_state_(nullptr), current_subpass_(0) {} |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 357 | |
locke-lunarg | 61870c2 | 2020-06-09 14:51:50 -0600 | [diff] [blame] | 358 | bool ValidateDrawSubpassAttachment(const SyncValidator &sync_state, const CMD_BUFFER_STATE &cmd, const VkRect2D &render_area, |
| 359 | const char *func_name) const; |
locke-lunarg | 96dc963 | 2020-06-10 17:22:18 -0600 | [diff] [blame] | 360 | void RecordDrawSubpassAttachment(const CMD_BUFFER_STATE &cmd, const VkRect2D &render_area, const ResourceUsageTag &tag); |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 361 | bool ValidateNextSubpass(const SyncValidator &sync_state, const VkRect2D &render_area, const char *command_name) const; |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 362 | bool ValidateEndRenderPass(const SyncValidator &sync_state, const VkRect2D &render_area, const char *func_name) const; |
| 363 | bool ValidateFinalSubpassLayoutTransitions(const SyncValidator &sync_state, const VkRect2D &render_area, |
| 364 | const char *func_name) const; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 365 | |
| 366 | void RecordLayoutTransitions(const ResourceUsageTag &tag); |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 367 | void RecordLoadOperations(const VkRect2D &render_area, const ResourceUsageTag &tag); |
John Zulauf | 1a22429 | 2020-06-30 14:52:13 -0600 | [diff] [blame^] | 368 | void RecordBeginRenderPass(const SyncValidator &state, const CMD_BUFFER_STATE &cb_state, const AccessContext *external_context, |
| 369 | VkQueueFlags queue_flags, const ResourceUsageTag &tag); |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 370 | void RecordNextSubpass(const VkRect2D &render_area, const ResourceUsageTag &tag); |
John Zulauf | 1a22429 | 2020-06-30 14:52:13 -0600 | [diff] [blame^] | 371 | void RecordEndRenderPass(AccessContext *external_context, const VkRect2D &render_area, const ResourceUsageTag &tag); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 372 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 373 | AccessContext &CurrentContext() { return subpass_contexts_[current_subpass_]; } |
| 374 | const AccessContext &CurrentContext() const { return subpass_contexts_[current_subpass_]; } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 375 | const std::vector<AccessContext> &GetContexts() const { return subpass_contexts_; } |
| 376 | uint32_t GetCurrentSubpass() const { return current_subpass_; } |
| 377 | const RENDER_PASS_STATE *GetRenderPassState() const { return rp_state_; } |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 378 | AccessContext *CreateStoreResolveProxy(const VkRect2D &render_area) const; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 379 | |
| 380 | private: |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 381 | const RENDER_PASS_STATE *rp_state_; |
| 382 | uint32_t current_subpass_; |
| 383 | std::vector<AccessContext> subpass_contexts_; |
| 384 | std::vector<const IMAGE_VIEW_STATE *> attachment_views_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 385 | }; |
| 386 | |
| 387 | class CommandBufferAccessContext { |
| 388 | public: |
| 389 | CommandBufferAccessContext() |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 390 | : command_number_(0), |
| 391 | reset_count_(0), |
| 392 | render_pass_contexts_(), |
| 393 | cb_access_context_(), |
| 394 | current_context_(&cb_access_context_), |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 395 | current_renderpass_context_(), |
| 396 | cb_state_(), |
| 397 | queue_flags_() {} |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 398 | 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] | 399 | : CommandBufferAccessContext() { |
| 400 | cb_state_ = cb_state; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 401 | sync_state_ = &sync_validator; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 402 | queue_flags_ = queue_flags; |
| 403 | } |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 404 | |
| 405 | void Reset() { |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 406 | command_number_ = 0; |
| 407 | reset_count_++; |
| 408 | cb_access_context_.Reset(); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 409 | render_pass_contexts_.clear(); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 410 | current_context_ = &cb_access_context_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 411 | current_renderpass_context_ = nullptr; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 412 | } |
| 413 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 414 | AccessContext *GetCurrentAccessContext() { return current_context_; } |
| 415 | const AccessContext *GetCurrentAccessContext() const { return current_context_; } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 416 | void RecordBeginRenderPass(const ResourceUsageTag &tag); |
| 417 | bool ValidateBeginRenderPass(const RENDER_PASS_STATE &render_pass, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 418 | const VkSubpassBeginInfoKHR *pSubpassBeginInfo, const char *func_name) const; |
locke-lunarg | 61870c2 | 2020-06-09 14:51:50 -0600 | [diff] [blame] | 419 | bool ValidateDispatchDrawDescriptorSet(VkPipelineBindPoint pipelineBindPoint, const char *func_name) const; |
| 420 | void RecordDispatchDrawDescriptorSet(VkPipelineBindPoint pipelineBindPoint, const ResourceUsageTag &tag); |
| 421 | bool ValidateDrawVertex(uint32_t vertexCount, uint32_t firstVertex, const char *func_name) const; |
| 422 | void RecordDrawVertex(uint32_t vertexCount, uint32_t firstVertex, const ResourceUsageTag &tag); |
| 423 | bool ValidateDrawVertexIndex(uint32_t indexCount, uint32_t firstIndex, const char *func_name) const; |
| 424 | void RecordDrawVertexIndex(uint32_t indexCount, uint32_t firstIndex, const ResourceUsageTag &tag); |
| 425 | bool ValidateDrawSubpassAttachment(const char *func_name) const; |
| 426 | void RecordDrawSubpassAttachment(const ResourceUsageTag &tag); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 427 | bool ValidateNextSubpass(const char *func_name) const; |
| 428 | bool ValidateEndRenderpass(const char *func_name) const; |
| 429 | void RecordNextSubpass(const RENDER_PASS_STATE &render_pass, const ResourceUsageTag &tag); |
| 430 | void RecordEndRenderPass(const RENDER_PASS_STATE &render_pass, const ResourceUsageTag &tag); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 431 | CMD_BUFFER_STATE *GetCommandBufferState() { return cb_state_.get(); } |
| 432 | const CMD_BUFFER_STATE *GetCommandBufferState() const { return cb_state_.get(); } |
| 433 | VkQueueFlags GetQueueFlags() const { return queue_flags_; } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 434 | inline ResourceUsageTag NextCommandTag(CMD_TYPE command) { |
| 435 | // TODO: add command encoding to ResourceUsageTag. |
| 436 | // What else we what to include. Do we want some sort of "parent" or global sequence number |
| 437 | command_number_++; |
John Zulauf | cc6fecb | 2020-06-17 15:24:54 -0600 | [diff] [blame] | 438 | const auto index = (static_cast<uint64_t>(reset_count_) << 32) | command_number_; |
| 439 | ResourceUsageTag next(index, command); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 440 | return next; |
| 441 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 442 | |
| 443 | private: |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 444 | uint32_t command_number_; |
| 445 | uint32_t reset_count_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 446 | std::vector<RenderPassAccessContext> render_pass_contexts_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 447 | AccessContext cb_access_context_; |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 448 | AccessContext *current_context_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 449 | RenderPassAccessContext *current_renderpass_context_; |
| 450 | std::shared_ptr<CMD_BUFFER_STATE> cb_state_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 451 | SyncValidator *sync_state_; |
| 452 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 453 | VkQueueFlags queue_flags_; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 454 | }; |
| 455 | |
| 456 | class SyncValidator : public ValidationStateTracker, public SyncStageAccess { |
| 457 | public: |
| 458 | SyncValidator() { container_type = LayerObjectTypeSyncValidation; } |
| 459 | using StateTracker = ValidationStateTracker; |
| 460 | |
| 461 | using StateTracker::AccessorTraitsTypes; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 462 | std::unordered_map<VkCommandBuffer, std::unique_ptr<CommandBufferAccessContext>> cb_access_state; |
| 463 | CommandBufferAccessContext *GetAccessContextImpl(VkCommandBuffer command_buffer, bool do_insert) { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 464 | auto found_it = cb_access_state.find(command_buffer); |
| 465 | if (found_it == cb_access_state.end()) { |
| 466 | if (!do_insert) return nullptr; |
| 467 | // If we don't have one, make it. |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 468 | auto cb_state = GetShared<CMD_BUFFER_STATE>(command_buffer); |
| 469 | assert(cb_state.get()); |
| 470 | auto queue_flags = GetQueueFlags(*cb_state); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 471 | std::unique_ptr<CommandBufferAccessContext> context(new CommandBufferAccessContext(*this, cb_state, queue_flags)); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 472 | 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] | 473 | found_it = insert_pair.first; |
| 474 | } |
| 475 | return found_it->second.get(); |
| 476 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 477 | CommandBufferAccessContext *GetAccessContext(VkCommandBuffer command_buffer) { |
| 478 | return GetAccessContextImpl(command_buffer, true); // true -> do_insert on not found |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 479 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 480 | CommandBufferAccessContext *GetAccessContextNoInsert(VkCommandBuffer command_buffer) { |
| 481 | 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] | 482 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 483 | |
| 484 | const CommandBufferAccessContext *GetAccessContext(VkCommandBuffer command_buffer) const { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 485 | const auto found_it = cb_access_state.find(command_buffer); |
| 486 | if (found_it == cb_access_state.end()) { |
| 487 | return nullptr; |
| 488 | } |
| 489 | return found_it->second.get(); |
| 490 | } |
| 491 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 492 | void ApplyGlobalBarriers(AccessContext *context, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 493 | SyncStageAccessFlags src_stage_scope, SyncStageAccessFlags dst_stage_scope, |
| 494 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 495 | void ApplyBufferBarriers(AccessContext *context, VkPipelineStageFlags src_stage_mask, SyncStageAccessFlags src_stage_scope, |
| 496 | VkPipelineStageFlags dst_stage_mask, SyncStageAccessFlags dst_stage_scope, uint32_t barrier_count, |
| 497 | const VkBufferMemoryBarrier *barriers); |
| 498 | void ApplyImageBarriers(AccessContext *context, VkPipelineStageFlags src_stage_mask, SyncStageAccessFlags src_stage_scope, |
| 499 | VkPipelineStageFlags dst_stage_mask, SyncStageAccessFlags dst_stage_scope, uint32_t barrier_count, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 500 | const VkImageMemoryBarrier *barriers, const ResourceUsageTag &tag); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 501 | |
John Zulauf | d1f85d4 | 2020-04-15 12:23:15 -0600 | [diff] [blame] | 502 | void ResetCommandBufferCallback(VkCommandBuffer command_buffer); |
| 503 | void FreeCommandBufferCallback(VkCommandBuffer command_buffer); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 504 | void RecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 505 | const VkSubpassBeginInfo *pSubpassBeginInfo, CMD_TYPE command); |
| 506 | void RecordCmdNextSubpass(VkCommandBuffer commandBuffer, |
| 507 | |
| 508 | const VkSubpassBeginInfo *pSubpassBeginInfo, const VkSubpassEndInfo *pSubpassEndInfo, |
| 509 | CMD_TYPE command); |
| 510 | void RecordCmdEndRenderPass(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo, CMD_TYPE command); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 511 | |
| 512 | void PostCallRecordCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, |
| 513 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result); |
| 514 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 515 | bool ValidateBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 516 | const VkSubpassBeginInfoKHR *pSubpassBeginInfo, const char *func_name) const; |
| 517 | |
| 518 | bool PreCallValidateCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 519 | VkSubpassContents contents) const; |
| 520 | |
| 521 | bool PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 522 | const VkSubpassBeginInfoKHR *pSubpassBeginInfo) const; |
| 523 | |
| 524 | bool PreCallValidateCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 525 | const VkSubpassBeginInfoKHR *pSubpassBeginInfo) const; |
| 526 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 527 | bool PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, |
| 528 | const VkBufferCopy *pRegions) const; |
| 529 | |
| 530 | void PreCallRecordCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, |
| 531 | const VkBufferCopy *pRegions); |
| 532 | |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 533 | bool PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 534 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
| 535 | const VkImageCopy *pRegions) const; |
| 536 | |
| 537 | void PreCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 538 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions); |
| 539 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 540 | bool PreCallValidateCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, |
| 541 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 542 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 543 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 544 | uint32_t imageMemoryBarrierCount, |
| 545 | const VkImageMemoryBarrier *pImageMemoryBarriers) const; |
| 546 | |
| 547 | void PreCallRecordCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, |
| 548 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 549 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 550 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 551 | uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 552 | |
| 553 | void PostCallRecordBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo, |
| 554 | VkResult result); |
| 555 | |
| 556 | void PostCallRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 557 | VkSubpassContents contents); |
| 558 | void PostCallRecordCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 559 | const VkSubpassBeginInfo *pSubpassBeginInfo); |
| 560 | void PostCallRecordCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
| 561 | const VkSubpassBeginInfo *pSubpassBeginInfo); |
| 562 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 563 | bool ValidateCmdNextSubpass(VkCommandBuffer commandBuffer, const VkSubpassBeginInfoKHR *pSubpassBeginInfo, |
| 564 | const VkSubpassEndInfoKHR *pSubpassEndInfo, const char *func_name) const; |
| 565 | bool PreCallValidateCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) const; |
| 566 | bool PreCallValidateCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfoKHR *pSubpassBeginInfo, |
| 567 | const VkSubpassEndInfoKHR *pSubpassEndInfo) const; |
| 568 | bool PreCallValidateCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, const VkSubpassBeginInfoKHR *pSubpassBeginInfo, |
| 569 | const VkSubpassEndInfoKHR *pSubpassEndInfo) const; |
| 570 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 571 | void PostCallRecordCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents); |
| 572 | void PostCallRecordCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 573 | const VkSubpassEndInfo *pSubpassEndInfo); |
| 574 | void PostCallRecordCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 575 | const VkSubpassEndInfo *pSubpassEndInfo); |
| 576 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 577 | bool ValidateCmdEndRenderPass(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR *pSubpassEndInfo, |
| 578 | const char *func_name) const; |
| 579 | bool PreCallValidateCmdEndRenderPass(VkCommandBuffer commandBuffer) const; |
| 580 | bool PreCallValidateCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR *pSubpassEndInfo) const; |
| 581 | bool PreCallValidateCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR *pSubpassEndInfo) const; |
| 582 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 583 | void PostCallRecordCmdEndRenderPass(VkCommandBuffer commandBuffer); |
| 584 | void PostCallRecordCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo); |
| 585 | void PostCallRecordCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo); |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 586 | bool PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
| 587 | VkImageLayout dstImageLayout, uint32_t regionCount, |
| 588 | const VkBufferImageCopy *pRegions) const; |
| 589 | |
| 590 | void PreCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
| 591 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy *pRegions); |
| 592 | |
| 593 | bool PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 594 | VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions) const; |
| 595 | |
| 596 | void PreCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 597 | VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions); |
| 598 | |
| 599 | bool PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 600 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
| 601 | const VkImageBlit *pRegions, VkFilter filter) const; |
| 602 | |
| 603 | void PreCallRecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 604 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, |
| 605 | VkFilter filter); |
locke-lunarg | 36ba259 | 2020-04-03 09:42:04 -0600 | [diff] [blame] | 606 | |
locke-lunarg | 61870c2 | 2020-06-09 14:51:50 -0600 | [diff] [blame] | 607 | bool ValidateIndirectBuffer(const AccessContext &context, VkCommandBuffer commandBuffer, const VkDeviceSize struct_size, |
| 608 | const VkBuffer buffer, const VkDeviceSize offset, const uint32_t drawCount, const uint32_t stride, |
| 609 | const char *function) const; |
| 610 | void RecordIndirectBuffer(AccessContext &context, const ResourceUsageTag &tag, const VkDeviceSize struct_size, |
| 611 | 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] | 612 | |
locke-lunarg | 61870c2 | 2020-06-09 14:51:50 -0600 | [diff] [blame] | 613 | bool ValidateCountBuffer(const AccessContext &context, VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 614 | const char *function) const; |
| 615 | void RecordCountBuffer(AccessContext &context, const ResourceUsageTag &tag, VkBuffer buffer, VkDeviceSize offset); |
locke-lunarg | 93d68af | 2020-05-12 17:18:03 -0600 | [diff] [blame] | 616 | |
locke-lunarg | 36ba259 | 2020-04-03 09:42:04 -0600 | [diff] [blame] | 617 | bool PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) const; |
| 618 | void PreCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z); |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 619 | |
| 620 | bool PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset) const; |
| 621 | void PreCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset); |
| 622 | |
| 623 | bool PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, |
| 624 | uint32_t firstInstance) const; |
| 625 | void PreCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, |
| 626 | uint32_t firstInstance); |
| 627 | |
| 628 | bool PreCallValidateCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, |
| 629 | uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) const; |
| 630 | void PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, |
| 631 | uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance); |
| 632 | |
| 633 | bool PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, |
| 634 | uint32_t stride) const; |
| 635 | void PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, |
| 636 | uint32_t stride); |
| 637 | |
| 638 | bool PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 639 | uint32_t drawCount, uint32_t stride) const; |
| 640 | void PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 641 | uint32_t drawCount, uint32_t stride); |
| 642 | |
locke-lunarg | ff255f9 | 2020-05-13 18:53:52 -0600 | [diff] [blame] | 643 | bool ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, |
| 644 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride, |
| 645 | const char *function) const; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 646 | bool PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 647 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 648 | uint32_t stride) const; |
| 649 | void PreCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 650 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 651 | uint32_t stride); |
| 652 | bool PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 653 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 654 | uint32_t stride) const; |
| 655 | void PreCallRecordCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 656 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 657 | uint32_t stride); |
| 658 | bool PreCallValidateCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 659 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 660 | uint32_t stride) const; |
| 661 | void PreCallRecordCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 662 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 663 | uint32_t stride); |
| 664 | |
locke-lunarg | ff255f9 | 2020-05-13 18:53:52 -0600 | [diff] [blame] | 665 | bool ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 666 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 667 | uint32_t stride, const char *function) const; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 668 | bool PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 669 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 670 | uint32_t stride) const; |
| 671 | void PreCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 672 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 673 | uint32_t stride); |
| 674 | bool PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 675 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 676 | uint32_t stride) const; |
| 677 | void PreCallRecordCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 678 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 679 | uint32_t stride); |
| 680 | bool PreCallValidateCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 681 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 682 | uint32_t stride) const; |
| 683 | void PreCallRecordCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 684 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 685 | uint32_t stride); |
| 686 | |
| 687 | bool PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 688 | const VkClearColorValue *pColor, uint32_t rangeCount, |
| 689 | const VkImageSubresourceRange *pRanges) const; |
| 690 | void PreCallRecordCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 691 | const VkClearColorValue *pColor, uint32_t rangeCount, |
| 692 | const VkImageSubresourceRange *pRanges); |
| 693 | |
| 694 | bool PreCallValidateCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 695 | const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount, |
| 696 | const VkImageSubresourceRange *pRanges) const; |
| 697 | void PreCallRecordCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 698 | const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount, |
| 699 | const VkImageSubresourceRange *pRanges); |
| 700 | |
| 701 | bool PreCallValidateCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, |
| 702 | uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, |
| 703 | VkDeviceSize stride, VkQueryResultFlags flags) const; |
| 704 | void PreCallRecordCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, |
| 705 | uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, |
| 706 | VkQueryResultFlags flags); |
| 707 | |
| 708 | bool PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, |
| 709 | uint32_t data) const; |
| 710 | void PreCallRecordCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, |
| 711 | uint32_t data); |
| 712 | |
| 713 | bool PreCallValidateCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 714 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
| 715 | const VkImageResolve *pRegions) const; |
| 716 | void PreCallRecordCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 717 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
| 718 | const VkImageResolve *pRegions); |
| 719 | |
| 720 | bool PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, |
| 721 | VkDeviceSize dataSize, const void *pData) const; |
| 722 | void PreCallRecordCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, |
| 723 | VkDeviceSize dataSize, const void *pData); |
locke-lunarg | ff255f9 | 2020-05-13 18:53:52 -0600 | [diff] [blame] | 724 | |
| 725 | bool PreCallValidateCmdWriteBufferMarkerAMD(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, |
| 726 | VkBuffer dstBuffer, VkDeviceSize dstOffset, uint32_t marker) const; |
| 727 | void PreCallRecordCmdWriteBufferMarkerAMD(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, |
| 728 | VkBuffer dstBuffer, VkDeviceSize dstOffset, uint32_t marker); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 729 | }; |