John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1 | /* |
Tony-LunarG | 4c25337 | 2022-01-18 13:51:07 -0700 | [diff] [blame] | 2 | * Copyright (c) 2019-2022 Valve Corporation |
| 3 | * Copyright (c) 2019-2022 LunarG, Inc. |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | * Author: John Zulauf <jzulauf@lunarg.com> |
John Zulauf | ab7756b | 2020-12-29 16:10:16 -0700 | [diff] [blame] | 18 | * Author: Locke Lin <locke@lunarg.com> |
| 19 | * Author: Jeremy Gebben <jeremyg@lunarg.com> |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #pragma once |
| 23 | |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 24 | #include <limits> |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 25 | #include <memory> |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 26 | #include <vulkan/vulkan.h> |
| 27 | |
| 28 | #include "synchronization_validation_types.h" |
| 29 | #include "state_tracker.h" |
Jeremy Gebben | 159b3cc | 2021-06-03 09:09:03 -0600 | [diff] [blame] | 30 | #include "cmd_buffer_state.h" |
| 31 | #include "render_pass_state.h" |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 32 | |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 33 | class AccessContext; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 34 | class CommandBufferAccessContext; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 35 | class CommandExecutionContext; |
John Zulauf | ecf4ac5 | 2022-06-06 10:08:42 -0600 | [diff] [blame] | 36 | class QueueBatchContext; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 37 | class ResourceAccessState; |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 38 | struct ResourceFirstAccess; |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 39 | class SyncEventsContext; |
| 40 | struct SyncEventState; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 41 | class SyncValidator; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 42 | |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 43 | using ImageRangeEncoder = subresource_adapter::ImageRangeEncoder; |
| 44 | using ImageRangeGen = subresource_adapter::ImageRangeGenerator; |
| 45 | |
John Zulauf | ecf4ac5 | 2022-06-06 10:08:42 -0600 | [diff] [blame] | 46 | using QueueId = uint32_t; |
| 47 | |
John Zulauf | 2f952d2 | 2020-02-10 11:34:51 -0700 | [diff] [blame] | 48 | enum SyncHazard { |
| 49 | NONE = 0, |
| 50 | READ_AFTER_WRITE, |
| 51 | WRITE_AFTER_READ, |
| 52 | WRITE_AFTER_WRITE, |
| 53 | READ_RACING_WRITE, |
| 54 | WRITE_RACING_WRITE, |
| 55 | WRITE_RACING_READ, |
| 56 | }; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 57 | |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 58 | enum class SyncOrdering : uint8_t { |
| 59 | kNonAttachment = 0, |
| 60 | kColorAttachment = 1, |
| 61 | kDepthStencilAttachment = 2, |
| 62 | kRaster = 3, |
| 63 | kNumOrderings = 4, |
| 64 | }; |
| 65 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 66 | // Useful Utilites for manipulating StageAccess parameters, suitable as base class to save typing |
| 67 | struct SyncStageAccess { |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 68 | static inline SyncStageAccessFlags FlagBit(SyncStageAccessIndex stage_access) { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 69 | return syncStageAccessInfoByStageAccessIndex[stage_access].stage_access_bit; |
| 70 | } |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 71 | static inline SyncStageAccessFlags Flags(SyncStageAccessIndex stage_access) { |
| 72 | return static_cast<SyncStageAccessFlags>(FlagBit(stage_access)); |
| 73 | } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 74 | |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 75 | static bool IsRead(const SyncStageAccessFlags &stage_access_bit) { return (stage_access_bit & syncStageAccessReadMask).any(); } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 76 | static bool IsRead(SyncStageAccessIndex stage_access_index) { return IsRead(FlagBit(stage_access_index)); } |
| 77 | |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 78 | static bool IsWrite(const SyncStageAccessFlags &stage_access_bit) { |
| 79 | return (stage_access_bit & syncStageAccessWriteMask).any(); |
| 80 | } |
| 81 | static bool HasWrite(const SyncStageAccessFlags &stage_access_mask) { |
| 82 | return (stage_access_mask & syncStageAccessWriteMask).any(); |
| 83 | } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 84 | static bool IsWrite(SyncStageAccessIndex stage_access_index) { return IsWrite(FlagBit(stage_access_index)); } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 85 | static VkPipelineStageFlags2KHR PipelineStageBit(SyncStageAccessIndex stage_access_index) { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 86 | return syncStageAccessInfoByStageAccessIndex[stage_access_index].stage_mask; |
| 87 | } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 88 | static SyncStageAccessFlags AccessScopeByStage(VkPipelineStageFlags2KHR stages); |
| 89 | static SyncStageAccessFlags AccessScopeByAccess(VkAccessFlags2KHR access); |
| 90 | static SyncStageAccessFlags AccessScope(VkPipelineStageFlags2KHR stages, VkAccessFlags2KHR access); |
| 91 | static SyncStageAccessFlags AccessScope(const SyncStageAccessFlags &stage_scope, VkAccessFlags2KHR accesses) { |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 92 | return stage_scope & AccessScopeByAccess(accesses); |
| 93 | } |
| 94 | }; |
| 95 | |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 96 | struct ResourceUsageRecord { |
John Zulauf | 41a9c7c | 2021-12-07 15:59:53 -0700 | [diff] [blame] | 97 | enum class SubcommandType { kNone, kSubpassTransition, kLoadOp, kStoreOp, kResolveOp, kIndex }; |
| 98 | |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 99 | using TagIndex = size_t; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 100 | using Count = uint32_t; |
John Zulauf | f4aecca | 2021-01-05 16:21:58 -0700 | [diff] [blame] | 101 | constexpr static TagIndex kMaxIndex = std::numeric_limits<TagIndex>::max(); |
John Zulauf | 3c2a0b3 | 2021-07-14 11:14:52 -0600 | [diff] [blame] | 102 | constexpr static Count kMaxCount = std::numeric_limits<Count>::max(); |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 103 | CMD_TYPE command = CMD_NONE; |
| 104 | Count seq_num = 0U; |
John Zulauf | 41a9c7c | 2021-12-07 15:59:53 -0700 | [diff] [blame] | 105 | SubcommandType sub_command_type = SubcommandType::kNone; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 106 | Count sub_command = 0U; |
John Zulauf | 3c2a0b3 | 2021-07-14 11:14:52 -0600 | [diff] [blame] | 107 | |
| 108 | // This is somewhat repetitive, but it prevents the need for Exec/Submit time touchup, after which usage records can be |
| 109 | // from different command buffers and resets. |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 110 | const CMD_BUFFER_STATE *cb_state = nullptr; // plain pointer as a shared pointer is held by the context storing this record |
John Zulauf | 3c2a0b3 | 2021-07-14 11:14:52 -0600 | [diff] [blame] | 111 | Count reset_count; |
Jeremy Gebben | 4bb7350 | 2020-12-14 11:17:50 -0700 | [diff] [blame] | 112 | |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 113 | ResourceUsageRecord() = default; |
John Zulauf | 41a9c7c | 2021-12-07 15:59:53 -0700 | [diff] [blame] | 114 | ResourceUsageRecord(CMD_TYPE command_, Count seq_num_, SubcommandType sub_type_, Count sub_command_, |
| 115 | const CMD_BUFFER_STATE *cb_state_, Count reset_count_) |
| 116 | : command(command_), |
| 117 | seq_num(seq_num_), |
| 118 | sub_command_type(sub_type_), |
| 119 | sub_command(sub_command_), |
| 120 | cb_state(cb_state_), |
| 121 | reset_count(reset_count_) {} |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 122 | }; |
| 123 | |
John Zulauf | 3c2a0b3 | 2021-07-14 11:14:52 -0600 | [diff] [blame] | 124 | // The resource tag index is relative to the command buffer or queue in which it's found |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 125 | using ResourceUsageTag = ResourceUsageRecord::TagIndex; |
John Zulauf | ae84200 | 2021-04-15 18:20:55 -0600 | [diff] [blame] | 126 | using ResourceUsageRange = sparse_container::range<ResourceUsageTag>; |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 127 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 128 | struct HazardResult { |
John Zulauf | 59e2507 | 2020-07-17 10:55:21 -0600 | [diff] [blame] | 129 | std::unique_ptr<const ResourceAccessState> access_state; |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 130 | std::unique_ptr<const ResourceFirstAccess> recorded_access; |
John Zulauf | 59e2507 | 2020-07-17 10:55:21 -0600 | [diff] [blame] | 131 | SyncStageAccessIndex usage_index = std::numeric_limits<SyncStageAccessIndex>::max(); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 132 | SyncHazard hazard = NONE; |
John Zulauf | 37ceaed | 2020-07-03 16:18:15 -0600 | [diff] [blame] | 133 | SyncStageAccessFlags prior_access = 0U; // TODO -- change to a NONE enum in ...Bits |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 134 | ResourceUsageTag tag = ResourceUsageTag(); |
John Zulauf | 59e2507 | 2020-07-17 10:55:21 -0600 | [diff] [blame] | 135 | void Set(const ResourceAccessState *access_state_, SyncStageAccessIndex usage_index_, SyncHazard hazard_, |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 136 | const SyncStageAccessFlags &prior_, ResourceUsageTag tag_); |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 137 | void AddRecordedAccess(const ResourceFirstAccess &first_access); |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 138 | bool IsHazard() const { return NONE != hazard; } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 139 | }; |
| 140 | |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 141 | struct SyncExecScope { |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 142 | VkPipelineStageFlags2KHR mask_param; // the xxxStageMask parameter passed by the caller |
| 143 | VkPipelineStageFlags2KHR |
| 144 | expanded_mask; // all stage bits covered by any 'catch all bits' in the parameter (eg. ALL_GRAPHICS_BIT). |
| 145 | VkPipelineStageFlags2KHR exec_scope; // all earlier or later stages that would be affected by a barrier using this scope. |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 146 | SyncStageAccessFlags valid_accesses; // all valid accesses that can be used with this scope. |
| 147 | |
| 148 | SyncExecScope() : mask_param(0), expanded_mask(0), exec_scope(0), valid_accesses(0) {} |
| 149 | |
John Zulauf | 06f6f1e | 2022-04-19 15:28:11 -0600 | [diff] [blame] | 150 | static SyncExecScope MakeSrc(VkQueueFlags queue_flags, VkPipelineStageFlags2KHR src_stage_mask, |
| 151 | const VkPipelineStageFlags2KHR disabled_feature_mask = 0); |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 152 | static SyncExecScope MakeDst(VkQueueFlags queue_flags, VkPipelineStageFlags2KHR src_stage_mask); |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 153 | }; |
| 154 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 155 | struct SyncBarrier { |
John Zulauf | ecf4ac5 | 2022-06-06 10:08:42 -0600 | [diff] [blame] | 156 | struct AllAccess {}; |
John Zulauf | c523bf6 | 2021-02-16 08:20:34 -0700 | [diff] [blame] | 157 | SyncExecScope src_exec_scope; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 158 | SyncStageAccessFlags src_access_scope; |
John Zulauf | c523bf6 | 2021-02-16 08:20:34 -0700 | [diff] [blame] | 159 | SyncExecScope dst_exec_scope; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 160 | SyncStageAccessFlags dst_access_scope; |
| 161 | SyncBarrier() = default; |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 162 | SyncBarrier(const SyncBarrier &other) = default; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 163 | SyncBarrier &operator=(const SyncBarrier &) = default; |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 164 | |
| 165 | SyncBarrier(const SyncExecScope &src, const SyncExecScope &dst); |
John Zulauf | ecf4ac5 | 2022-06-06 10:08:42 -0600 | [diff] [blame] | 166 | SyncBarrier(const SyncExecScope &src, const SyncExecScope &dst, const AllAccess &); |
John Zulauf | 06f6f1e | 2022-04-19 15:28:11 -0600 | [diff] [blame] | 167 | SyncBarrier(const SyncExecScope &src_exec, const SyncStageAccessFlags &src_access, const SyncExecScope &dst_exec, |
| 168 | const SyncStageAccessFlags &dst_access) |
| 169 | : src_exec_scope(src_exec), src_access_scope(src_access), dst_exec_scope(dst_exec), dst_access_scope(dst_access) {} |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 170 | |
| 171 | template <typename Barrier> |
| 172 | SyncBarrier(const Barrier &barrier, const SyncExecScope &src, const SyncExecScope &dst); |
| 173 | |
| 174 | SyncBarrier(VkQueueFlags queue_flags, const VkSubpassDependency2 &barrier); |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 175 | // template constructor for sync2 barriers |
| 176 | template <typename Barrier> |
| 177 | SyncBarrier(VkQueueFlags queue_flags, const Barrier &barrier); |
Jeremy Gebben | 9893daf | 2021-01-04 10:40:50 -0700 | [diff] [blame] | 178 | |
John Zulauf | a0a9829 | 2020-09-18 09:30:10 -0600 | [diff] [blame] | 179 | void Merge(const SyncBarrier &other) { |
John Zulauf | c523bf6 | 2021-02-16 08:20:34 -0700 | [diff] [blame] | 180 | // Note that after merge, only the exec_scope and access_scope fields are fully valid |
| 181 | // TODO: Do we need to update any of the other fields? Merging has limited application. |
| 182 | src_exec_scope.exec_scope |= other.src_exec_scope.exec_scope; |
John Zulauf | a0a9829 | 2020-09-18 09:30:10 -0600 | [diff] [blame] | 183 | src_access_scope |= other.src_access_scope; |
John Zulauf | c523bf6 | 2021-02-16 08:20:34 -0700 | [diff] [blame] | 184 | dst_exec_scope.exec_scope |= other.dst_exec_scope.exec_scope; |
John Zulauf | a0a9829 | 2020-09-18 09:30:10 -0600 | [diff] [blame] | 185 | dst_access_scope |= other.dst_access_scope; |
| 186 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 187 | }; |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 188 | |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 189 | enum class AccessAddressType : uint32_t { kLinear = 0, kIdealized = 1, kMaxType = 1, kTypeCount = kMaxType + 1 }; |
| 190 | |
John Zulauf | ecf4ac5 | 2022-06-06 10:08:42 -0600 | [diff] [blame] | 191 | struct SemaphoreScope : SyncExecScope { |
| 192 | SemaphoreScope(QueueId qid, const SyncExecScope &exec_scope) : SyncExecScope(exec_scope), queue(qid) {} |
| 193 | SemaphoreScope() = default; |
| 194 | QueueId queue; |
| 195 | }; |
| 196 | |
| 197 | class SignaledSemaphores { |
| 198 | public: |
| 199 | // Is the record of a signaled semaphore, deleted when unsignaled |
| 200 | struct Signal { |
| 201 | Signal() = delete; |
| 202 | Signal(const Signal &other) = default; |
| 203 | Signal(Signal &&other) = default; |
| 204 | Signal &operator=(const Signal &other) = default; |
| 205 | Signal &operator=(Signal &&other) = default; |
| 206 | Signal(const std::shared_ptr<const SEMAPHORE_STATE> &sem_state_, const std::shared_ptr<QueueBatchContext> &batch_, |
| 207 | const SyncExecScope &exec_scope_); |
| 208 | |
| 209 | std::shared_ptr<const SEMAPHORE_STATE> sem_state; |
| 210 | std::shared_ptr<QueueBatchContext> batch; |
| 211 | // Use the SyncExecScope::valid_accesses for first access scope |
| 212 | SemaphoreScope first_scope; |
| 213 | // TODO add timeline semaphore support. |
| 214 | }; |
| 215 | using SignalMap = layer_data::unordered_map<VkSemaphore, std::shared_ptr<Signal>>; |
| 216 | using iterator = SignalMap::iterator; |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 217 | using const_iterator = SignalMap::const_iterator; |
| 218 | using mapped_type = SignalMap::mapped_type; |
John Zulauf | ecf4ac5 | 2022-06-06 10:08:42 -0600 | [diff] [blame] | 219 | iterator begin() { return signaled_.begin(); } |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 220 | const_iterator begin() const { return signaled_.begin(); } |
John Zulauf | ecf4ac5 | 2022-06-06 10:08:42 -0600 | [diff] [blame] | 221 | iterator end() { return signaled_.end(); } |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 222 | const_iterator end() const { return signaled_.end(); } |
John Zulauf | ecf4ac5 | 2022-06-06 10:08:42 -0600 | [diff] [blame] | 223 | |
| 224 | bool SignalSemaphore(const std::shared_ptr<const SEMAPHORE_STATE> &sem_state, const std::shared_ptr<QueueBatchContext> &batch, |
| 225 | const VkSemaphoreSubmitInfo &signal_info); |
| 226 | std::shared_ptr<const Signal> Unsignal(VkSemaphore); |
| 227 | void Import(VkSemaphore sem, std::shared_ptr<Signal> &&move_from); |
| 228 | void Reset(); |
| 229 | SignaledSemaphores() : prev_(nullptr) {} |
| 230 | SignaledSemaphores(const SignaledSemaphores &prev) : prev_(&prev) {} |
| 231 | |
| 232 | private: |
| 233 | std::shared_ptr<const Signal> GetPrev(VkSemaphore sem) const; |
| 234 | layer_data::unordered_map<VkSemaphore, std::shared_ptr<Signal>> signaled_; |
| 235 | const SignaledSemaphores *prev_; // Allowing this type to act as a writable overlay |
| 236 | }; |
| 237 | |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 238 | struct ResourceFirstAccess { |
| 239 | ResourceUsageTag tag; |
| 240 | SyncStageAccessIndex usage_index; |
| 241 | SyncOrdering ordering_rule; |
| 242 | ResourceFirstAccess(ResourceUsageTag tag_, SyncStageAccessIndex usage_index_, SyncOrdering ordering_rule_) |
| 243 | : tag(tag_), usage_index(usage_index_), ordering_rule(ordering_rule_){}; |
| 244 | ResourceFirstAccess(const ResourceFirstAccess &other) = default; |
| 245 | ResourceFirstAccess(ResourceFirstAccess &&other) = default; |
| 246 | ResourceFirstAccess &operator=(const ResourceFirstAccess &rhs) = default; |
| 247 | ResourceFirstAccess &operator=(ResourceFirstAccess &&rhs) = default; |
| 248 | bool operator==(const ResourceFirstAccess &rhs) const { |
| 249 | return (tag == rhs.tag) && (usage_index == rhs.usage_index) && (ordering_rule == rhs.ordering_rule); |
| 250 | } |
| 251 | }; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 252 | |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 253 | using QueueId = uint32_t; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 254 | class ResourceAccessState : public SyncStageAccess { |
| 255 | protected: |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 256 | struct OrderingBarrier { |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 257 | VkPipelineStageFlags2KHR exec_scope; |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 258 | SyncStageAccessFlags access_scope; |
| 259 | OrderingBarrier() = default; |
Nathaniel Cesario | b38a667 | 2021-11-15 12:05:48 -0700 | [diff] [blame] | 260 | OrderingBarrier(const OrderingBarrier &) = default; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 261 | OrderingBarrier(VkPipelineStageFlags2KHR es, SyncStageAccessFlags as) : exec_scope(es), access_scope(as) {} |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 262 | OrderingBarrier &operator=(const OrderingBarrier &) = default; |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 263 | OrderingBarrier &operator|=(const OrderingBarrier &rhs) { |
| 264 | exec_scope |= rhs.exec_scope; |
| 265 | access_scope |= rhs.access_scope; |
| 266 | return *this; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 267 | } |
| 268 | }; |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 269 | using OrderingBarriers = std::array<OrderingBarrier, static_cast<size_t>(SyncOrdering::kNumOrderings)>; |
| 270 | using FirstAccesses = small_vector<ResourceFirstAccess, 3>; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 271 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 272 | // Mutliple read operations can be simlutaneously (and independently) synchronized, |
| 273 | // given the only the second execution scope creates a dependency chain, we have to track each, |
| 274 | // but only up to one per pipeline stage (as another read from the *same* stage become more recent, |
| 275 | // and applicable one for hazard detection |
| 276 | struct ReadState { |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 277 | VkPipelineStageFlags2KHR stage; // The stage of this read |
John Zulauf | 37ceaed | 2020-07-03 16:18:15 -0600 | [diff] [blame] | 278 | SyncStageAccessFlags access; // TODO: Change to FlagBits when we have a None bit enum |
John Zulauf | f51fbb6 | 2020-10-02 14:43:24 -0600 | [diff] [blame] | 279 | // TODO: Revisit whether this needs to support multiple reads per stage |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 280 | VkPipelineStageFlags2KHR barriers; // all applicable barriered stages |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 281 | VkPipelineStageFlags2KHR sync_stages; // reads known to have happened after this |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 282 | ResourceUsageTag tag; |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 283 | QueueId queue; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 284 | VkPipelineStageFlags2KHR pending_dep_chain; // Should be zero except during barrier application |
| 285 | // Excluded from comparison |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 286 | ReadState() = default; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 287 | ReadState(VkPipelineStageFlags2KHR stage_, SyncStageAccessFlags access_, VkPipelineStageFlags2KHR barriers_, |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 288 | ResourceUsageTag tag_); |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 289 | bool operator==(const ReadState &rhs) const { |
John Zulauf | 37ceaed | 2020-07-03 16:18:15 -0600 | [diff] [blame] | 290 | bool same = (stage == rhs.stage) && (access == rhs.access) && (barriers == rhs.barriers) && (tag == rhs.tag); |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 291 | return same; |
| 292 | } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 293 | bool IsReadBarrierHazard(VkPipelineStageFlags2KHR src_exec_scope) const { |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 294 | // If the read stage is not in the src sync scope |
| 295 | // *AND* not execution chained with an existing sync barrier (that's the or) |
| 296 | // then the barrier access is unsafe (R/W after R) |
| 297 | return (src_exec_scope & (stage | barriers)) == 0; |
| 298 | } |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 299 | bool IsReadBarrierHazard(QueueId barrier_queue, VkPipelineStageFlags2KHR src_exec_scope) const { |
| 300 | // If the read stage is not in the src sync scope |
| 301 | // *AND* not execution chained with an existing sync barrier (that's the or) |
| 302 | // then the barrier access is unsafe (R/W after R) |
| 303 | VkPipelineStageFlags2 queue_ordered_stage = (queue == barrier_queue) ? stage : VK_PIPELINE_STAGE_2_NONE; |
| 304 | return (src_exec_scope & (queue_ordered_stage | barriers)) == 0; |
| 305 | } |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 306 | |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 307 | bool operator!=(const ReadState &rhs) const { return !(*this == rhs); } |
John Zulauf | ee98402 | 2022-04-13 16:39:50 -0600 | [diff] [blame] | 308 | void Set(VkPipelineStageFlags2KHR stage_, const SyncStageAccessFlags &access_, VkPipelineStageFlags2KHR barriers_, |
| 309 | ResourceUsageTag tag_); |
John Zulauf | b757830 | 2022-05-19 13:50:18 -0600 | [diff] [blame] | 310 | bool ReadInScopeOrChain(VkPipelineStageFlags2 exec_scope) const { return (exec_scope & (stage | barriers)) != 0; } |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 311 | bool ReadInQueueScopeOrChain(QueueId queue, VkPipelineStageFlags2 exec_scope) const; |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 312 | bool ReadInEventScope(VkPipelineStageFlags2 exec_scope, QueueId scope_queue, ResourceUsageTag scope_tag) const { |
John Zulauf | b757830 | 2022-05-19 13:50:18 -0600 | [diff] [blame] | 313 | // If this read is the same one we included in the set event and in scope, then apply the execution barrier... |
| 314 | // NOTE: That's not really correct... this read stage might *not* have been included in the setevent, and the barriers |
| 315 | // representing the chain might have changed since then (that would be an odd usage), so as a first approximation |
| 316 | // we'll assume the barriers *haven't* been changed since (if the tag hasn't), and while this could be a false |
| 317 | // positive in the case of Set; SomeBarrier; Wait; we'll live with it until we can add more state to the first scope |
| 318 | // capture (the specific write and read stages that *were* in scope at the moment of SetEvents. |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 319 | return (tag < scope_tag) && ReadInQueueScopeOrChain(scope_queue, exec_scope); |
John Zulauf | b757830 | 2022-05-19 13:50:18 -0600 | [diff] [blame] | 320 | } |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 321 | }; |
| 322 | |
| 323 | public: |
| 324 | HazardResult DetectHazard(SyncStageAccessIndex usage_index) const; |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 325 | HazardResult DetectHazard(SyncStageAccessIndex usage_index, SyncOrdering ordering_rule) const; |
| 326 | HazardResult DetectHazard(SyncStageAccessIndex usage_index, const OrderingBarrier &ordering) const; |
John Zulauf | ae84200 | 2021-04-15 18:20:55 -0600 | [diff] [blame] | 327 | HazardResult DetectHazard(const ResourceAccessState &recorded_use, const ResourceUsageRange &tag_range) const; |
| 328 | |
| 329 | HazardResult DetectAsyncHazard(SyncStageAccessIndex usage_index, ResourceUsageTag start_tag) const; |
| 330 | HazardResult DetectAsyncHazard(const ResourceAccessState &recorded_use, const ResourceUsageRange &tag_range, |
| 331 | ResourceUsageTag start_tag) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 332 | |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 333 | HazardResult DetectBarrierHazard(SyncStageAccessIndex usage_index, VkPipelineStageFlags2KHR source_exec_scope, |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 334 | const SyncStageAccessFlags &source_access_scope) const; |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 335 | HazardResult DetectBarrierHazard(SyncStageAccessIndex usage_index, const ResourceAccessState &scope_state, |
| 336 | VkPipelineStageFlags2KHR source_exec_scope, const SyncStageAccessFlags &source_access_scope, |
| 337 | QueueId event_queue, ResourceUsageTag event_tag) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 338 | |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 339 | void Update(SyncStageAccessIndex usage_index, SyncOrdering ordering_rule, ResourceUsageTag tag); |
| 340 | void SetWrite(const SyncStageAccessFlags &usage_bit, ResourceUsageTag tag); |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 341 | void ClearWrite(); |
| 342 | void ClearRead(); |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 343 | void Resolve(const ResourceAccessState &other); |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 344 | void ApplyBarriers(const std::vector<SyncBarrier> &barriers, bool layout_transition); |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 345 | void ApplyBarriersImmediate(const std::vector<SyncBarrier> &barriers); |
John Zulauf | b757830 | 2022-05-19 13:50:18 -0600 | [diff] [blame] | 346 | template <typename ScopeOps> |
| 347 | void ApplyBarrier(ScopeOps &&scope, const SyncBarrier &barrier, bool layout_transition); |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 348 | void ApplyPendingBarriers(ResourceUsageTag tag); |
John Zulauf | ecf4ac5 | 2022-06-06 10:08:42 -0600 | [diff] [blame] | 349 | void ApplySemaphore(const SemaphoreScope &signal, const SemaphoreScope wait); |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 350 | |
| 351 | struct QueueTagPredicate { |
| 352 | QueueId queue; |
| 353 | ResourceUsageTag tag; |
| 354 | bool operator()(QueueId usage_queue, ResourceUsageTag usage_tag); |
| 355 | }; |
| 356 | |
| 357 | struct QueuePredicate { |
| 358 | QueueId queue; |
| 359 | QueuePredicate(QueueId queue_) : queue(queue_) {} |
| 360 | bool operator()(QueueId usage_queue, ResourceUsageTag usage_tag); |
| 361 | }; |
| 362 | struct TagPredicate { |
| 363 | ResourceUsageTag tag; |
| 364 | bool operator()(QueueId usage_queue, ResourceUsageTag usage_tag); |
| 365 | }; |
| 366 | |
| 367 | template <typename Pred> |
| 368 | bool ApplyQueueTagWait(Pred &&); |
John Zulauf | ae84200 | 2021-04-15 18:20:55 -0600 | [diff] [blame] | 369 | bool FirstAccessInTagRange(const ResourceUsageRange &tag_range) const; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 370 | |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 371 | void OffsetTag(ResourceUsageTag offset); |
| 372 | ResourceAccessState(); |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 373 | |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 374 | bool HasPendingState() const { |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 375 | return (0 != pending_layout_transition) || pending_write_barriers.any() || (0 != pending_write_dep_chain); |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 376 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 377 | bool HasWriteOp() const { return last_write != 0; } |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 378 | bool operator==(const ResourceAccessState &rhs) const { |
| 379 | bool same = (write_barriers == rhs.write_barriers) && (write_dependency_chain == rhs.write_dependency_chain) && |
John Zulauf | ab7756b | 2020-12-29 16:10:16 -0700 | [diff] [blame] | 380 | (last_reads == rhs.last_reads) && (last_read_stages == rhs.last_read_stages) && (write_tag == rhs.write_tag) && |
| 381 | (input_attachment_read == rhs.input_attachment_read) && |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 382 | (read_execution_barriers == rhs.read_execution_barriers) && (first_accesses_ == rhs.first_accesses_); |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 383 | return same; |
| 384 | } |
| 385 | bool operator!=(const ResourceAccessState &rhs) const { return !(*this == rhs); } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 386 | VkPipelineStageFlags2KHR GetReadBarriers(const SyncStageAccessFlags &usage) const; |
John Zulauf | 59e2507 | 2020-07-17 10:55:21 -0600 | [diff] [blame] | 387 | SyncStageAccessFlags GetWriteBarriers() const { return write_barriers; } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 388 | bool InSourceScopeOrChain(VkPipelineStageFlags2KHR src_exec_scope, SyncStageAccessFlags src_access_scope) const { |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 389 | return ReadInSourceScopeOrChain(src_exec_scope) || WriteInSourceScopeOrChain(src_exec_scope, src_access_scope); |
| 390 | } |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 391 | void SetQueueId(QueueId id); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 392 | |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 393 | bool WriteInChain(VkPipelineStageFlags2KHR src_exec_scope) const; |
| 394 | bool WriteInScope(const SyncStageAccessFlags &src_access_scope) const; |
John Zulauf | b757830 | 2022-05-19 13:50:18 -0600 | [diff] [blame] | 395 | bool WriteInSourceScopeOrChain(VkPipelineStageFlags2KHR src_exec_scope, SyncStageAccessFlags src_access_scope) const; |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 396 | bool WriteInQueueSourceScopeOrChain(QueueId queue, VkPipelineStageFlags2KHR src_exec_scope, |
| 397 | SyncStageAccessFlags src_access_scope) const; |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 398 | bool WriteInEventScope(VkPipelineStageFlags2KHR src_exec_scope, const SyncStageAccessFlags &src_access_scope, |
| 399 | QueueId scope_queue, ResourceUsageTag scope_tag) const; |
John Zulauf | b757830 | 2022-05-19 13:50:18 -0600 | [diff] [blame] | 400 | |
| 401 | struct UntaggedScopeOps { |
| 402 | bool WriteInScope(const SyncBarrier &barrier, const ResourceAccessState &access) const { |
| 403 | return access.WriteInSourceScopeOrChain(barrier.src_exec_scope.exec_scope, barrier.src_access_scope); |
| 404 | } |
| 405 | bool ReadInScope(const SyncBarrier &barrier, const ReadState &read_state) const { |
| 406 | return read_state.ReadInScopeOrChain(barrier.src_exec_scope.exec_scope); |
| 407 | } |
| 408 | }; |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 409 | |
| 410 | struct QueueScopeOps { |
| 411 | bool WriteInScope(const SyncBarrier &barrier, const ResourceAccessState &access) const { |
| 412 | return access.WriteInQueueSourceScopeOrChain(queue, barrier.src_exec_scope.exec_scope, barrier.src_access_scope); |
| 413 | } |
| 414 | bool ReadInScope(const SyncBarrier &barrier, const ReadState &read_state) const { |
| 415 | return read_state.ReadInQueueScopeOrChain(queue, barrier.src_exec_scope.exec_scope); |
| 416 | } |
| 417 | QueueScopeOps(QueueId scope_queue) : queue(scope_queue) {} |
| 418 | QueueId queue; |
| 419 | }; |
| 420 | |
John Zulauf | b757830 | 2022-05-19 13:50:18 -0600 | [diff] [blame] | 421 | struct EventScopeOps { |
| 422 | bool WriteInScope(const SyncBarrier &barrier, const ResourceAccessState &access) const { |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 423 | return access.WriteInEventScope(barrier.src_exec_scope.exec_scope, barrier.src_access_scope, scope_queue, scope_tag); |
John Zulauf | b757830 | 2022-05-19 13:50:18 -0600 | [diff] [blame] | 424 | } |
| 425 | bool ReadInScope(const SyncBarrier &barrier, const ReadState &read_state) const { |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 426 | return read_state.ReadInEventScope(barrier.src_exec_scope.exec_scope, scope_queue, scope_tag); |
John Zulauf | b757830 | 2022-05-19 13:50:18 -0600 | [diff] [blame] | 427 | } |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 428 | EventScopeOps(QueueId qid, ResourceUsageTag event_tag) : scope_queue(qid), scope_tag(event_tag) {} |
| 429 | QueueId scope_queue; |
John Zulauf | b757830 | 2022-05-19 13:50:18 -0600 | [diff] [blame] | 430 | ResourceUsageTag scope_tag; |
| 431 | }; |
| 432 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 433 | private: |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 434 | static constexpr VkPipelineStageFlags2KHR kInvalidAttachmentStage = ~VkPipelineStageFlags2KHR(0); |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 435 | bool IsWriteHazard(SyncStageAccessFlags usage) const { return (usage & ~write_barriers).any(); } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 436 | bool IsRAWHazard(VkPipelineStageFlags2KHR usage_stage, const SyncStageAccessFlags &usage) const; |
| 437 | bool IsWriteBarrierHazard(VkPipelineStageFlags2KHR src_exec_scope, const SyncStageAccessFlags &src_access_scope) const { |
John Zulauf | 6b58364 | 2021-10-05 17:25:31 -0600 | [diff] [blame] | 438 | // If the previous write is *not* a layout transition |
| 439 | // *AND* is *not* in the 1st access scope |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 440 | // *AND* the current barrier is not in the dependency chain |
| 441 | // *AND* the there is no prior memory barrier for the previous write in the dependency chain |
| 442 | // then the barrier access is unsafe (R/W after W) |
John Zulauf | 6b58364 | 2021-10-05 17:25:31 -0600 | [diff] [blame] | 443 | return (last_write != SYNC_IMAGE_LAYOUT_TRANSITION_BIT) && (last_write & src_access_scope).none() && |
| 444 | (((src_exec_scope & write_dependency_chain) == 0) || (write_barriers & src_access_scope).none()); |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 445 | } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 446 | bool ReadInSourceScopeOrChain(VkPipelineStageFlags2KHR src_exec_scope) const { |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 447 | return (0 != (src_exec_scope & (last_read_stages | read_execution_barriers))); |
| 448 | } |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 449 | |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 450 | static bool IsReadHazard(VkPipelineStageFlags2KHR stage_mask, const VkPipelineStageFlags2KHR barriers) { |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 451 | return stage_mask != (stage_mask & barriers); |
| 452 | } |
| 453 | |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 454 | bool IsReadHazard(VkPipelineStageFlags2KHR stage_mask, const ReadState &read_access) const { |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 455 | return IsReadHazard(stage_mask, read_access.barriers); |
John Zulauf | 0cb5be2 | 2020-01-23 12:18:22 -0700 | [diff] [blame] | 456 | } |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 457 | VkPipelineStageFlags2KHR GetOrderedStages(const OrderingBarrier &ordering) const; |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 458 | |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 459 | void UpdateFirst(ResourceUsageTag tag, SyncStageAccessIndex usage_index, SyncOrdering ordering_rule); |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 460 | void TouchupFirstForLayoutTransition(ResourceUsageTag tag, const OrderingBarrier &layout_ordering); |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 461 | |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 462 | static const OrderingBarrier &GetOrderingRules(SyncOrdering ordering_enum) { |
| 463 | return kOrderingRules[static_cast<size_t>(ordering_enum)]; |
| 464 | } |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 465 | |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 466 | // TODO: Add a NONE (zero) enum to SyncStageAccessFlags for input_attachment_read and last_write |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 467 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 468 | // With reads, each must be "safe" relative to it's prior write, so we need only |
| 469 | // save the most recent write operation (as anything *transitively* unsafe would arleady |
| 470 | // be included |
| 471 | SyncStageAccessFlags write_barriers; // union of applicable barrier masks since last write |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 472 | VkPipelineStageFlags2KHR write_dependency_chain; // intiially zero, but accumulating the dstStages of barriers if they chain. |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 473 | ResourceUsageTag write_tag; |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 474 | QueueId write_queue; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 475 | SyncStageAccessFlags last_write; // only the most recent write |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 476 | |
John Zulauf | f51fbb6 | 2020-10-02 14:43:24 -0600 | [diff] [blame] | 477 | // TODO Input Attachment cleanup for multiple reads in a given stage |
| 478 | // Tracks whether the fragment shader read is input attachment read |
| 479 | bool input_attachment_read; |
John Zulauf | d14743a | 2020-07-03 09:42:39 -0600 | [diff] [blame] | 480 | |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 481 | VkPipelineStageFlags2KHR last_read_stages; |
| 482 | VkPipelineStageFlags2KHR read_execution_barriers; |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 483 | using ReadStates = small_vector<ReadState, 3, uint32_t>; |
| 484 | ReadStates last_reads; |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 485 | |
| 486 | // Pending execution state to support independent parallel barriers |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 487 | VkPipelineStageFlags2KHR pending_write_dep_chain; |
John Zulauf | 89311b4 | 2020-09-29 16:28:47 -0600 | [diff] [blame] | 488 | bool pending_layout_transition; |
| 489 | SyncStageAccessFlags pending_write_barriers; |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 490 | OrderingBarrier pending_layout_ordering_; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 491 | FirstAccesses first_accesses_; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 492 | VkPipelineStageFlags2KHR first_read_stages_; |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 493 | OrderingBarrier first_write_layout_ordering_; |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 494 | |
| 495 | static OrderingBarriers kOrderingRules; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 496 | }; |
John Zulauf | 22aefed | 2021-03-11 18:14:35 -0700 | [diff] [blame] | 497 | using ResourceAccessStateFunction = std::function<void(ResourceAccessState *)>; |
| 498 | using ResourceAccessStateConstFunction = std::function<void(const ResourceAccessState &)>; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 499 | |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 500 | using ResourceAddress = VkDeviceSize; |
| 501 | using ResourceAccessRangeMap = sparse_container::range_map<ResourceAddress, ResourceAccessState>; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 502 | using ResourceAccessRange = typename ResourceAccessRangeMap::key_type; |
John Zulauf | 22aefed | 2021-03-11 18:14:35 -0700 | [diff] [blame] | 503 | using ResourceAccessRangeIndex = typename ResourceAccessRange::index_type; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 504 | using ResourceRangeMergeIterator = sparse_container::parallel_iterator<ResourceAccessRangeMap, const ResourceAccessRangeMap>; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 505 | |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 506 | class AttachmentViewGen { |
| 507 | public: |
| 508 | enum Gen { kViewSubresource = 0, kRenderArea = 1, kDepthOnlyRenderArea = 2, kStencilOnlyRenderArea = 3, kGenSize = 4 }; |
| 509 | AttachmentViewGen(const IMAGE_VIEW_STATE *view_, const VkOffset3D &offset, const VkExtent3D &extent); |
| 510 | AttachmentViewGen(const AttachmentViewGen &other) = default; |
| 511 | AttachmentViewGen(AttachmentViewGen &&other) = default; |
| 512 | AccessAddressType GetAddressType() const; |
| 513 | const IMAGE_VIEW_STATE *GetViewState() const { return view_; } |
| 514 | const ImageRangeGen *GetRangeGen(Gen type) const; |
| 515 | bool IsValid() const { return gen_store_[Gen::kViewSubresource]; } |
| 516 | Gen GetDepthStencilRenderAreaGenType(bool depth_op, bool stencil_op) const; |
| 517 | |
| 518 | private: |
| 519 | using RangeGenStore = layer_data::optional<ImageRangeGen>; |
| 520 | const IMAGE_VIEW_STATE *view_ = nullptr; |
| 521 | VkImageAspectFlags view_mask_ = 0U; |
| 522 | std::array<RangeGenStore, Gen::kGenSize> gen_store_; |
| 523 | }; |
| 524 | |
| 525 | using AttachmentViewGenVector = std::vector<AttachmentViewGen>; |
| 526 | |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 527 | using SyncMemoryBarrier = SyncBarrier; |
| 528 | struct SyncBufferMemoryBarrier { |
| 529 | using Buffer = std::shared_ptr<const BUFFER_STATE>; |
| 530 | Buffer buffer; |
| 531 | SyncBarrier barrier; |
| 532 | ResourceAccessRange range; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 533 | bool IsLayoutTransition() const { return false; } |
| 534 | const ResourceAccessRange &Range() const { return range; }; |
| 535 | const BUFFER_STATE *GetState() const { return buffer.get(); } |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 536 | SyncBufferMemoryBarrier(const Buffer &buffer_, const SyncBarrier &barrier_, const ResourceAccessRange &range_) |
| 537 | : buffer(buffer_), barrier(barrier_), range(range_) {} |
| 538 | SyncBufferMemoryBarrier() = default; |
| 539 | }; |
| 540 | |
| 541 | struct SyncImageMemoryBarrier { |
| 542 | using Image = std::shared_ptr<const IMAGE_STATE>; |
John Zulauf | 110413c | 2021-03-20 05:38:38 -0600 | [diff] [blame] | 543 | |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 544 | Image image; |
| 545 | uint32_t index; |
| 546 | SyncBarrier barrier; |
| 547 | VkImageLayout old_layout; |
| 548 | VkImageLayout new_layout; |
John Zulauf | 110413c | 2021-03-20 05:38:38 -0600 | [diff] [blame] | 549 | VkImageSubresourceRange range; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 550 | |
| 551 | bool IsLayoutTransition() const { return old_layout != new_layout; } |
John Zulauf | 110413c | 2021-03-20 05:38:38 -0600 | [diff] [blame] | 552 | const VkImageSubresourceRange &Range() const { return range; }; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 553 | const IMAGE_STATE *GetState() const { return image.get(); } |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 554 | SyncImageMemoryBarrier(const Image &image_, uint32_t index_, const SyncBarrier &barrier_, VkImageLayout old_layout_, |
| 555 | VkImageLayout new_layout_, const VkImageSubresourceRange &subresource_range_) |
| 556 | : image(image_), |
| 557 | index(index_), |
| 558 | barrier(barrier_), |
| 559 | old_layout(old_layout_), |
| 560 | new_layout(new_layout_), |
John Zulauf | 110413c | 2021-03-20 05:38:38 -0600 | [diff] [blame] | 561 | range(subresource_range_) {} |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 562 | SyncImageMemoryBarrier() = default; |
| 563 | }; |
| 564 | |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 565 | template <typename SubpassNode> |
| 566 | struct SubpassBarrierTrackback { |
| 567 | std::vector<SyncBarrier> barriers; |
| 568 | const SubpassNode *source_subpass = nullptr; |
| 569 | SubpassBarrierTrackback() = default; |
| 570 | SubpassBarrierTrackback(const SubpassBarrierTrackback &) = default; |
| 571 | SubpassBarrierTrackback(const SubpassNode *source_subpass_, VkQueueFlags queue_flags_, |
| 572 | const std::vector<const VkSubpassDependency2 *> &subpass_dependencies_) |
| 573 | : barriers(), source_subpass(source_subpass_) { |
| 574 | barriers.reserve(subpass_dependencies_.size()); |
| 575 | for (const VkSubpassDependency2 *dependency : subpass_dependencies_) { |
| 576 | assert(dependency); |
| 577 | barriers.emplace_back(queue_flags_, *dependency); |
| 578 | } |
| 579 | } |
John Zulauf | 06f6f1e | 2022-04-19 15:28:11 -0600 | [diff] [blame] | 580 | SubpassBarrierTrackback(const SubpassNode *source_subpass_, const SyncBarrier &barrier_) |
| 581 | : barriers(1, barrier_), source_subpass(source_subpass_) {} |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 582 | SubpassBarrierTrackback &operator=(const SubpassBarrierTrackback &) = default; |
| 583 | }; |
| 584 | |
| 585 | struct ReplayTrackbackBarriersAction { |
| 586 | struct TrackbackBarriers : public SubpassBarrierTrackback<ReplayTrackbackBarriersAction> { |
| 587 | using Base = SubpassBarrierTrackback<ReplayTrackbackBarriersAction>; |
| 588 | TrackbackBarriers(const ReplayTrackbackBarriersAction *source_subpass_, VkQueueFlags queue_flags_, |
| 589 | const std::vector<const VkSubpassDependency2 *> &subpass_dependencies_); |
| 590 | void operator()(ResourceAccessState *access) const; |
| 591 | }; |
| 592 | |
| 593 | ReplayTrackbackBarriersAction() = default; |
| 594 | ReplayTrackbackBarriersAction(VkQueueFlags queue_flags, const SubpassDependencyGraphNode &dependencies, |
| 595 | const std::vector<ReplayTrackbackBarriersAction> &contexts); |
| 596 | |
| 597 | void operator()(ResourceAccessState *access) const; |
| 598 | std::vector<TrackbackBarriers> trackback_barriers; |
| 599 | }; |
| 600 | |
| 601 | struct ReplayRenderpassContext { |
| 602 | std::vector<ReplayTrackbackBarriersAction> subpass_contexts; |
| 603 | }; |
| 604 | |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 605 | class SyncOpBase { |
| 606 | public: |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 607 | using ReplayContextPtr = std::shared_ptr<ReplayRenderpassContext>; |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 608 | SyncOpBase() : cmd_type_(CMD_NONE) {} |
| 609 | SyncOpBase(CMD_TYPE cmd_type) : cmd_type_(cmd_type) {} |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 610 | virtual ~SyncOpBase() = default; |
| 611 | |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 612 | const char *CmdName() const { return CommandTypeString(cmd_type_); } |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 613 | const ReplayTrackbackBarriersAction *GetReplayTrackback() const; |
| 614 | |
| 615 | void SetReplayContext(uint32_t subpass, ReplayContextPtr &&replay); |
| 616 | |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 617 | virtual bool Validate(const CommandBufferAccessContext &cb_context) const = 0; |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 618 | virtual ResourceUsageTag Record(CommandBufferAccessContext *cb_context) const = 0; |
| 619 | virtual bool ReplayValidate(ResourceUsageTag recorded_tag, const CommandBufferAccessContext &recorded_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 620 | ResourceUsageTag base_tag, CommandExecutionContext *exec_context) const = 0; |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 621 | virtual void ReplayRecord(QueueId queue_id, ResourceUsageTag tag, AccessContext *access_context, |
| 622 | SyncEventsContext *events_context) const = 0; |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 623 | |
| 624 | protected: |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 625 | // Only non-null and valid for SyncOps within a render pass instance WIP -- think about how to manage for non RPI calls within |
| 626 | // RPI and 2ndarys... |
| 627 | ReplayContextPtr replay_context_; |
| 628 | uint32_t subpass_ = VK_SUBPASS_EXTERNAL; |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 629 | CMD_TYPE cmd_type_; |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 630 | }; |
| 631 | |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 632 | class SyncOpBarriers : public SyncOpBase { |
| 633 | protected: |
| 634 | template <typename Barriers, typename FunctorFactory> |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 635 | static void ApplyBarriers(const Barriers &barriers, const FunctorFactory &factory, QueueId queue_id, ResourceUsageTag tag, |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 636 | AccessContext *context); |
| 637 | template <typename Barriers, typename FunctorFactory> |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 638 | static void ApplyGlobalBarriers(const Barriers &barriers, const FunctorFactory &factory, QueueId queue_id, ResourceUsageTag tag, |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 639 | AccessContext *access_context); |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 640 | |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 641 | SyncOpBarriers(CMD_TYPE cmd_type, const SyncValidator &sync_state, VkQueueFlags queue_flags, VkPipelineStageFlags srcStageMask, |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 642 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, |
| 643 | const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, |
| 644 | const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, |
| 645 | const VkImageMemoryBarrier *pImageMemoryBarriers); |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 646 | SyncOpBarriers(CMD_TYPE cmd_type, const SyncValidator &sync_state, VkQueueFlags queue_flags, uint32_t event_count, |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 647 | const VkDependencyInfoKHR *pDependencyInfo); |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 648 | |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 649 | ~SyncOpBarriers() override = default; |
| 650 | |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 651 | protected: |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 652 | struct BarrierSet { |
| 653 | VkDependencyFlags dependency_flags; |
| 654 | SyncExecScope src_exec_scope; |
| 655 | SyncExecScope dst_exec_scope; |
| 656 | std::vector<SyncMemoryBarrier> memory_barriers; |
| 657 | std::vector<SyncBufferMemoryBarrier> buffer_memory_barriers; |
| 658 | std::vector<SyncImageMemoryBarrier> image_memory_barriers; |
| 659 | bool single_exec_scope; |
| 660 | void MakeMemoryBarriers(const SyncExecScope &src, const SyncExecScope &dst, VkDependencyFlags dependencyFlags, |
| 661 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers); |
| 662 | void MakeBufferMemoryBarriers(const SyncValidator &sync_state, const SyncExecScope &src, const SyncExecScope &dst, |
| 663 | VkDependencyFlags dependencyFlags, uint32_t bufferMemoryBarrierCount, |
| 664 | const VkBufferMemoryBarrier *pBufferMemoryBarriers); |
| 665 | void MakeImageMemoryBarriers(const SyncValidator &sync_state, const SyncExecScope &src, const SyncExecScope &dst, |
| 666 | VkDependencyFlags dependencyFlags, uint32_t imageMemoryBarrierCount, |
| 667 | const VkImageMemoryBarrier *pImageMemoryBarriers); |
| 668 | void MakeMemoryBarriers(VkQueueFlags queue_flags, VkDependencyFlags dependency_flags, uint32_t barrier_count, |
Tony-LunarG | 3f6eceb | 2021-11-18 14:34:49 -0700 | [diff] [blame] | 669 | const VkMemoryBarrier2 *barriers); |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 670 | void MakeBufferMemoryBarriers(const SyncValidator &sync_state, VkQueueFlags queue_flags, VkDependencyFlags dependency_flags, |
Tony-LunarG | 3f6eceb | 2021-11-18 14:34:49 -0700 | [diff] [blame] | 671 | uint32_t barrier_count, const VkBufferMemoryBarrier2 *barriers); |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 672 | void MakeImageMemoryBarriers(const SyncValidator &sync_state, VkQueueFlags queue_flags, VkDependencyFlags dependency_flags, |
Tony-LunarG | 3f6eceb | 2021-11-18 14:34:49 -0700 | [diff] [blame] | 673 | uint32_t barrier_count, const VkImageMemoryBarrier2 *barriers); |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 674 | }; |
| 675 | std::vector<BarrierSet> barriers_; |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 676 | }; |
| 677 | |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 678 | class SyncOpPipelineBarrier : public SyncOpBarriers { |
| 679 | public: |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 680 | SyncOpPipelineBarrier(CMD_TYPE cmd_type, const SyncValidator &sync_state, VkQueueFlags queue_flags, |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 681 | VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 682 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 683 | const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, |
| 684 | const VkImageMemoryBarrier *pImageMemoryBarriers); |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 685 | SyncOpPipelineBarrier(CMD_TYPE cmd_type, const SyncValidator &sync_state, VkQueueFlags queue_flags, |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 686 | const VkDependencyInfoKHR &pDependencyInfo); |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 687 | ~SyncOpPipelineBarrier() override = default; |
| 688 | |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 689 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 690 | ResourceUsageTag Record(CommandBufferAccessContext *cb_context) const override; |
| 691 | bool ReplayValidate(ResourceUsageTag recorded_tag, const CommandBufferAccessContext &recorded_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 692 | ResourceUsageTag base_tag, CommandExecutionContext *exec_context) const override; |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 693 | void ReplayRecord(QueueId queue_id, ResourceUsageTag recorded_tag, AccessContext *access_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 694 | SyncEventsContext *events_context) const override; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 695 | }; |
| 696 | |
| 697 | class SyncOpWaitEvents : public SyncOpBarriers { |
| 698 | public: |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 699 | SyncOpWaitEvents(CMD_TYPE cmd_type, const SyncValidator &sync_state, VkQueueFlags queue_flags, uint32_t eventCount, |
John Zulauf | 36ef928 | 2021-02-02 11:47:24 -0700 | [diff] [blame] | 700 | const VkEvent *pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, |
| 701 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 702 | const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, |
| 703 | const VkImageMemoryBarrier *pImageMemoryBarriers); |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 704 | |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 705 | SyncOpWaitEvents(CMD_TYPE cmd_type, const SyncValidator &sync_state, VkQueueFlags queue_flags, uint32_t eventCount, |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 706 | const VkEvent *pEvents, const VkDependencyInfoKHR *pDependencyInfo); |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 707 | ~SyncOpWaitEvents() override = default; |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 708 | |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 709 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 710 | ResourceUsageTag Record(CommandBufferAccessContext *cb_context) const override; |
| 711 | bool ReplayValidate(ResourceUsageTag recorded_tag, const CommandBufferAccessContext &recorded_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 712 | ResourceUsageTag base_tag, CommandExecutionContext *exec_context) const override; |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 713 | void ReplayRecord(QueueId queue_id, ResourceUsageTag recorded_tag, AccessContext *access_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 714 | SyncEventsContext *events_context) const override; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 715 | |
| 716 | protected: |
John Zulauf | 610e28c | 2021-08-03 17:46:23 -0600 | [diff] [blame] | 717 | static const char *const kIgnored; |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 718 | bool DoValidate(const CommandExecutionContext &ex_context, const ResourceUsageTag base_tag) const; |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 719 | // TODO PHASE2 This is the wrong thing to use for "replay".. as the event state will have moved on since the record |
| 720 | // TODO PHASE2 May need to capture by value w.r.t. "first use" or build up in calling/enqueue context through replay. |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 721 | std::vector<std::shared_ptr<const EVENT_STATE>> events_; |
| 722 | void MakeEventsList(const SyncValidator &sync_state, uint32_t event_count, const VkEvent *events); |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 723 | }; |
| 724 | |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 725 | class SyncOpResetEvent : public SyncOpBase { |
| 726 | public: |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 727 | SyncOpResetEvent(CMD_TYPE cmd_type, const SyncValidator &sync_state, VkQueueFlags queue_flags, VkEvent event, |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 728 | VkPipelineStageFlags2KHR stageMask); |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 729 | ~SyncOpResetEvent() override = default; |
| 730 | |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 731 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 732 | ResourceUsageTag Record(CommandBufferAccessContext *cb_context) const override; |
| 733 | bool ReplayValidate(ResourceUsageTag recorded_tag, const CommandBufferAccessContext &recorded_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 734 | ResourceUsageTag base_tag, CommandExecutionContext *exec_context) const override; |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 735 | void ReplayRecord(QueueId queue_id, ResourceUsageTag recorded_tag, AccessContext *access_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 736 | SyncEventsContext *events_context) const override; |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 737 | |
| 738 | private: |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 739 | bool DoValidate(const CommandExecutionContext &ex_context, const ResourceUsageTag base_tag) const; |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 740 | std::shared_ptr<const EVENT_STATE> event_; |
| 741 | SyncExecScope exec_scope_; |
| 742 | }; |
| 743 | |
| 744 | class SyncOpSetEvent : public SyncOpBase { |
| 745 | public: |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 746 | SyncOpSetEvent(CMD_TYPE cmd_type, const SyncValidator &sync_state, VkQueueFlags queue_flags, VkEvent event, |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 747 | VkPipelineStageFlags2KHR stageMask, const AccessContext *access_context); |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 748 | SyncOpSetEvent(CMD_TYPE cmd_type, const SyncValidator &sync_state, VkQueueFlags queue_flags, VkEvent event, |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 749 | const VkDependencyInfoKHR &dep_info, const AccessContext *access_context); |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 750 | ~SyncOpSetEvent() override = default; |
| 751 | |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 752 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 753 | ResourceUsageTag Record(CommandBufferAccessContext *cb_context) const override; |
| 754 | bool ReplayValidate(ResourceUsageTag recorded_tag, const CommandBufferAccessContext &recorded_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 755 | ResourceUsageTag base_tag, CommandExecutionContext *exec_context) const override; |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 756 | void ReplayRecord(QueueId queue_id, ResourceUsageTag recorded_tag, AccessContext *access_context, |
| 757 | SyncEventsContext *events_context) const override; |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 758 | |
| 759 | private: |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 760 | bool DoValidate(const CommandExecutionContext &ex_context, const ResourceUsageTag base_tag) const; |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 761 | void DoRecord(QueueId queue_id, ResourceUsageTag recorded_tag, const std::shared_ptr<const AccessContext> &access_context, |
| 762 | SyncEventsContext *events_context) const; |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 763 | std::shared_ptr<const EVENT_STATE> event_; |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 764 | // The Access context of the command buffer at record set event time. |
| 765 | std::shared_ptr<const AccessContext> recorded_context_; |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 766 | SyncExecScope src_exec_scope_; |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 767 | // Note that the dep info is *not* dehandled, but retained for comparison with a future WaitEvents2 |
Tony-LunarG | 273f32f | 2021-09-28 08:56:30 -0600 | [diff] [blame] | 768 | std::shared_ptr<safe_VkDependencyInfo> dep_info_; |
John Zulauf | 6ce2437 | 2021-01-30 05:56:25 -0700 | [diff] [blame] | 769 | }; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 770 | |
| 771 | class SyncOpBeginRenderPass : public SyncOpBase { |
| 772 | public: |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 773 | SyncOpBeginRenderPass(CMD_TYPE cmd_type, const SyncValidator &sync_state, const VkRenderPassBeginInfo *pRenderPassBegin, |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 774 | const VkSubpassBeginInfo *pSubpassBeginInfo); |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 775 | ~SyncOpBeginRenderPass() override = default; |
| 776 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 777 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 778 | ResourceUsageTag Record(CommandBufferAccessContext *cb_context) const override; |
| 779 | bool ReplayValidate(ResourceUsageTag recorded_tag, const CommandBufferAccessContext &recorded_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 780 | ResourceUsageTag base_tag, CommandExecutionContext *exec_context) const override; |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 781 | void ReplayRecord(QueueId queue_id, ResourceUsageTag recorded_tag, AccessContext *access_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 782 | SyncEventsContext *events_context) const override; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 783 | |
| 784 | protected: |
| 785 | safe_VkRenderPassBeginInfo renderpass_begin_info_; |
| 786 | safe_VkSubpassBeginInfo subpass_begin_info_; |
| 787 | std::vector<std::shared_ptr<const IMAGE_VIEW_STATE>> shared_attachments_; |
| 788 | std::vector<const IMAGE_VIEW_STATE *> attachments_; |
| 789 | std::shared_ptr<const RENDER_PASS_STATE> rp_state_; |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 790 | std::shared_ptr<ReplayRenderpassContext> replay_context_; // Shared across all subpasses for same renderpass instance |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 791 | }; |
| 792 | |
| 793 | class SyncOpNextSubpass : public SyncOpBase { |
| 794 | public: |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 795 | SyncOpNextSubpass(CMD_TYPE cmd_type, const SyncValidator &sync_state, const VkSubpassBeginInfo *pSubpassBeginInfo, |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 796 | const VkSubpassEndInfo *pSubpassEndInfo); |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 797 | ~SyncOpNextSubpass() override = default; |
| 798 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 799 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 800 | ResourceUsageTag Record(CommandBufferAccessContext *cb_context) const override; |
| 801 | bool ReplayValidate(ResourceUsageTag recorded_tag, const CommandBufferAccessContext &recorded_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 802 | ResourceUsageTag base_tag, CommandExecutionContext *exec_context) const override; |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 803 | void ReplayRecord(QueueId queue_id, ResourceUsageTag recorded_tag, AccessContext *access_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 804 | SyncEventsContext *events_context) const override; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 805 | |
| 806 | protected: |
| 807 | safe_VkSubpassBeginInfo subpass_begin_info_; |
| 808 | safe_VkSubpassEndInfo subpass_end_info_; |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 809 | std::shared_ptr<ReplayRenderpassContext> replay_context_; // Shared across all subpasses for same renderpass instance |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 810 | }; |
| 811 | |
| 812 | class SyncOpEndRenderPass : public SyncOpBase { |
| 813 | public: |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 814 | SyncOpEndRenderPass(CMD_TYPE cmd_type, const SyncValidator &sync_state, const VkSubpassEndInfo *pSubpassEndInfo); |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 815 | ~SyncOpEndRenderPass() override = default; |
| 816 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 817 | bool Validate(const CommandBufferAccessContext &cb_context) const override; |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 818 | ResourceUsageTag Record(CommandBufferAccessContext *cb_context) const override; |
| 819 | bool ReplayValidate(ResourceUsageTag recorded_tag, const CommandBufferAccessContext &recorded_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 820 | ResourceUsageTag base_tag, CommandExecutionContext *exec_context) const override; |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 821 | void ReplayRecord(QueueId queue_id, ResourceUsageTag recorded_tag, AccessContext *access_context, |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 822 | SyncEventsContext *events_context) const override; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 823 | |
| 824 | protected: |
| 825 | safe_VkSubpassEndInfo subpass_end_info_; |
| 826 | }; |
| 827 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 828 | class AccessContext { |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 829 | public: |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 830 | enum DetectOptions : uint32_t { |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 831 | kDetectPrevious = 1U << 0, |
| 832 | kDetectAsync = 1U << 1, |
| 833 | kDetectAll = (kDetectPrevious | kDetectAsync) |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 834 | }; |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 835 | struct AddressRange { |
| 836 | AccessAddressType type; |
| 837 | ResourceAccessRange range; |
| 838 | AddressRange() = default; // the explicit constructor below isn't needed in 20, but would delete the default. |
| 839 | AddressRange(AccessAddressType type_, ResourceAccessRange range_) : type(type_), range(range_) {} |
| 840 | }; |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 841 | using MapArray = std::array<ResourceAccessRangeMap, static_cast<size_t>(AccessAddressType::kTypeCount)>; |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 842 | |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 843 | using TrackBack = SubpassBarrierTrackback<AccessContext>; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 844 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 845 | 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] | 846 | HazardResult DetectHazard(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
Aitor Camacho | e67f2c7 | 2022-06-08 14:41:58 +0200 | [diff] [blame] | 847 | const VkImageSubresourceLayers &subresource, const VkOffset3D &offset, const VkExtent3D &extent, |
| 848 | bool is_depth_sliced) const; |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 849 | template <typename Detector> |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 850 | HazardResult DetectHazard(Detector &detector, const AttachmentViewGen &view_gen, AttachmentViewGen::Gen gen_type, |
| 851 | DetectOptions options) const; |
| 852 | template <typename Detector> |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 853 | HazardResult DetectHazard(Detector &detector, const IMAGE_STATE &image, const VkImageSubresourceRange &subresource_range, |
Aitor Camacho | e67f2c7 | 2022-06-08 14:41:58 +0200 | [diff] [blame] | 854 | const VkOffset3D &offset, const VkExtent3D &extent, bool is_depth_sliced, |
| 855 | DetectOptions options) const; |
John Zulauf | 110413c | 2021-03-20 05:38:38 -0600 | [diff] [blame] | 856 | template <typename Detector> |
| 857 | HazardResult DetectHazard(Detector &detector, const IMAGE_STATE &image, const VkImageSubresourceRange &subresource_range, |
Aitor Camacho | e67f2c7 | 2022-06-08 14:41:58 +0200 | [diff] [blame] | 858 | bool is_depth_sliced, DetectOptions options) const; |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 859 | HazardResult DetectHazard(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
Aitor Camacho | e67f2c7 | 2022-06-08 14:41:58 +0200 | [diff] [blame] | 860 | const VkImageSubresourceRange &subresource_range, bool is_depth_sliced) const; |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 861 | HazardResult DetectHazard(const AttachmentViewGen &view_gen, AttachmentViewGen::Gen gen_type, |
| 862 | SyncStageAccessIndex current_usage, SyncOrdering ordering_rule) const; |
| 863 | |
John Zulauf | 6913342 | 2020-05-20 14:55:53 -0600 | [diff] [blame] | 864 | HazardResult DetectHazard(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 865 | const VkImageSubresourceRange &subresource_range, SyncOrdering ordering_rule, |
Aitor Camacho | e67f2c7 | 2022-06-08 14:41:58 +0200 | [diff] [blame] | 866 | const VkOffset3D &offset, const VkExtent3D &extent, bool is_depth_sliced) const; |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 867 | HazardResult DetectImageBarrierHazard(const IMAGE_STATE &image, const VkImageSubresourceRange &subresource_range, |
| 868 | VkPipelineStageFlags2KHR src_exec_scope, const SyncStageAccessFlags &src_access_scope, |
| 869 | QueueId queue_id, const SyncEventState &sync_event, DetectOptions options) const; |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 870 | HazardResult DetectImageBarrierHazard(const AttachmentViewGen &attachment_view, const SyncBarrier &barrier, |
| 871 | DetectOptions options) const; |
Jeremy Gebben | 40a2294 | 2020-12-22 14:22:06 -0700 | [diff] [blame] | 872 | HazardResult DetectImageBarrierHazard(const IMAGE_STATE &image, VkPipelineStageFlags2KHR src_exec_scope, |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 873 | const SyncStageAccessFlags &src_access_scope, |
Jeremy Gebben | d0de1f8 | 2020-11-09 08:21:07 -0700 | [diff] [blame] | 874 | const VkImageSubresourceRange &subresource_range, DetectOptions options) const; |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 875 | HazardResult DetectImageBarrierHazard(const SyncImageMemoryBarrier &image_barrier) const; |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 876 | HazardResult DetectSubpassTransitionHazard(const TrackBack &track_back, const AttachmentViewGen &attach_view) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 877 | |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 878 | void RecordLayoutTransitions(const RENDER_PASS_STATE &rp_state, uint32_t subpass, |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 879 | const AttachmentViewGenVector &attachment_views, ResourceUsageTag tag); |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 880 | |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 881 | HazardResult DetectFirstUseHazard(const ResourceUsageRange &tag_range, const AccessContext &access_context, |
| 882 | const ReplayTrackbackBarriersAction *replay_barrier) const; |
John Zulauf | ae84200 | 2021-04-15 18:20:55 -0600 | [diff] [blame] | 883 | |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 884 | const TrackBack &GetDstExternalTrackBack() const { return dst_external_; } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 885 | void Reset() { |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 886 | prev_.clear(); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 887 | prev_by_subpass_.clear(); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 888 | async_.clear(); |
John Zulauf | 22aefed | 2021-03-11 18:14:35 -0700 | [diff] [blame] | 889 | src_external_ = nullptr; |
John Zulauf | a0a9829 | 2020-09-18 09:30:10 -0600 | [diff] [blame] | 890 | dst_external_ = TrackBack(); |
Jeremy Gebben | c4b78c5 | 2020-12-11 09:39:47 -0700 | [diff] [blame] | 891 | start_tag_ = ResourceUsageTag(); |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 892 | for (auto &map : access_state_maps_) { |
| 893 | map.clear(); |
| 894 | } |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 895 | } |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 896 | |
| 897 | // Follow the context previous to access the access state, supporting "lazy" import into the context. Not intended for |
| 898 | // subpass layout transition, as the pending state handling is more complex |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 899 | // TODO: See if returning the lower_bound would be useful from a performance POV -- look at the lower_bound overhead |
| 900 | // Would need to add a "hint" overload to parallel_iterator::invalidate_[AB] call, if so. |
John Zulauf | 22aefed | 2021-03-11 18:14:35 -0700 | [diff] [blame] | 901 | template <typename BarrierAction> |
| 902 | void ResolvePreviousAccessStack(AccessAddressType type, const ResourceAccessRange &range, ResourceAccessRangeMap *descent_map, |
| 903 | const ResourceAccessState *infill_state, const BarrierAction &previous_barrie) const; |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 904 | void ResolvePreviousAccess(AccessAddressType type, const ResourceAccessRange &range, ResourceAccessRangeMap *descent_map, |
John Zulauf | 22aefed | 2021-03-11 18:14:35 -0700 | [diff] [blame] | 905 | const ResourceAccessState *infill_state, |
| 906 | const ResourceAccessStateFunction *previous_barrier = nullptr) const; |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 907 | void ResolvePreviousAccesses(); |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 908 | template <typename BarrierAction> |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 909 | void ResolveAccessRange(const AttachmentViewGen &view_gen, AttachmentViewGen::Gen gen_type, BarrierAction &barrier_action, |
| 910 | ResourceAccessRangeMap *descent_map, const ResourceAccessState *infill_state) const; |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 911 | template <typename BarrierAction> |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 912 | void ResolveAccessRange(AccessAddressType type, const ResourceAccessRange &range, BarrierAction &barrier_action, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 913 | ResourceAccessRangeMap *resolve_map, const ResourceAccessState *infill_state, |
| 914 | bool recur_to_infill = true) const; |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 915 | template <typename ResolveOp> |
| 916 | void ResolveFromContext(ResolveOp &&resolve_op, const AccessContext &from_context, |
| 917 | const ResourceAccessState *infill_state = nullptr, bool recur_to_infill = false); |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 918 | |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 919 | void UpdateAccessState(const BUFFER_STATE &buffer, SyncStageAccessIndex current_usage, SyncOrdering ordering_rule, |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 920 | const ResourceAccessRange &range, ResourceUsageTag tag); |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 921 | void UpdateAccessState(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, SyncOrdering ordering_rule, |
John Zulauf | 110413c | 2021-03-20 05:38:38 -0600 | [diff] [blame] | 922 | const VkImageSubresourceRange &subresource_range, const ResourceUsageTag &tag); |
| 923 | void UpdateAccessState(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, SyncOrdering ordering_rule, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 924 | const VkImageSubresourceRange &subresource_range, const VkOffset3D &offset, const VkExtent3D &extent, |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 925 | ResourceUsageTag tag); |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 926 | void UpdateAccessState(const AttachmentViewGen &view_gen, AttachmentViewGen::Gen gen_type, SyncStageAccessIndex current_usage, |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 927 | SyncOrdering ordering_rule, ResourceUsageTag tag); |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 928 | void UpdateAccessState(const IMAGE_STATE &image, SyncStageAccessIndex current_usage, SyncOrdering ordering_rule, |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 929 | const VkImageSubresourceLayers &subresource, const VkOffset3D &offset, const VkExtent3D &extent, |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 930 | ResourceUsageTag tag); |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 931 | void UpdateAttachmentResolveAccess(const RENDER_PASS_STATE &rp_state, const AttachmentViewGenVector &attachment_views, |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 932 | uint32_t subpass, ResourceUsageTag tag); |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 933 | void UpdateAttachmentStoreAccess(const RENDER_PASS_STATE &rp_state, const AttachmentViewGenVector &attachment_views, |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 934 | uint32_t subpass, ResourceUsageTag tag); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 935 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 936 | void ResolveChildContexts(const std::vector<AccessContext> &contexts); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 937 | |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 938 | void ImportAsyncContexts(const AccessContext &from); |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 939 | template <typename Action, typename RangeGen> |
| 940 | void ApplyUpdateAction(AccessAddressType address_type, const Action &action, RangeGen *range_gen_arg); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 941 | template <typename Action> |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 942 | void ApplyUpdateAction(const AttachmentViewGen &view_gen, AttachmentViewGen::Gen gen_type, const Action &action); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 943 | template <typename Action> |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 944 | void ApplyToContext(const Action &barrier_action); |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 945 | static AccessAddressType ImageAddressType(const IMAGE_STATE &image); |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 946 | |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 947 | void DeleteAccess(const AddressRange &address); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 948 | AccessContext(uint32_t subpass, VkQueueFlags queue_flags, const std::vector<SubpassDependencyGraphNode> &dependencies, |
John Zulauf | 1a22429 | 2020-06-30 14:52:13 -0600 | [diff] [blame] | 949 | const std::vector<AccessContext> &contexts, const AccessContext *external_context); |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 950 | |
| 951 | AccessContext() { Reset(); } |
John Zulauf | 7635de3 | 2020-05-29 17:14:15 -0600 | [diff] [blame] | 952 | AccessContext(const AccessContext ©_from) = default; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 953 | |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 954 | ResourceAccessRangeMap &GetAccessStateMap(AccessAddressType type) { return access_state_maps_[static_cast<size_t>(type)]; } |
| 955 | const ResourceAccessRangeMap &GetAccessStateMap(AccessAddressType type) const { |
| 956 | return access_state_maps_[static_cast<size_t>(type)]; |
| 957 | } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 958 | const TrackBack *GetTrackBackFromSubpass(uint32_t subpass) const { |
| 959 | if (subpass == VK_SUBPASS_EXTERNAL) { |
John Zulauf | 22aefed | 2021-03-11 18:14:35 -0700 | [diff] [blame] | 960 | return src_external_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 961 | } else { |
| 962 | assert(subpass < prev_by_subpass_.size()); |
| 963 | return prev_by_subpass_[subpass]; |
| 964 | } |
| 965 | } |
John Zulauf | 16adfc9 | 2020-04-08 10:28:33 -0600 | [diff] [blame] | 966 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 967 | bool ValidateLayoutTransitions(const CommandExecutionContext &ex_context, const RENDER_PASS_STATE &rp_state, |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 968 | const VkRect2D &render_area, uint32_t subpass, const AttachmentViewGenVector &attachment_views, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 969 | CMD_TYPE cmd_type) const; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 970 | bool ValidateLoadOperation(const CommandExecutionContext &ex_context, const RENDER_PASS_STATE &rp_state, |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 971 | const VkRect2D &render_area, uint32_t subpass, const AttachmentViewGenVector &attachment_views, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 972 | CMD_TYPE cmd_type) const; |
| 973 | bool ValidateStoreOperation(const CommandExecutionContext &ex_context, const RENDER_PASS_STATE &rp_state, |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 974 | const VkRect2D &render_area, uint32_t subpass, const AttachmentViewGenVector &attachment_views, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 975 | CMD_TYPE cmd_type) const; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 976 | bool ValidateResolveOperations(const CommandExecutionContext &ex_context, const RENDER_PASS_STATE &rp_state, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 977 | const VkRect2D &render_area, const AttachmentViewGenVector &attachment_views, CMD_TYPE cmd_type, |
| 978 | uint32_t subpass) const; |
John Zulauf | 1507ee4 | 2020-05-18 11:33:09 -0600 | [diff] [blame] | 979 | |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 980 | void SetStartTag(ResourceUsageTag tag) { start_tag_ = tag; } |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 981 | template <typename Action> |
| 982 | void ForAll(Action &&action); |
Jeremy Gebben | c4b78c5 | 2020-12-11 09:39:47 -0700 | [diff] [blame] | 983 | |
John Zulauf | ecf4ac5 | 2022-06-06 10:08:42 -0600 | [diff] [blame] | 984 | // For use during queue submit building up the QueueBatchContext AccessContext for validation, otherwise clear. |
John Zulauf | 06f6f1e | 2022-04-19 15:28:11 -0600 | [diff] [blame] | 985 | void AddAsyncContext(const AccessContext *context); |
| 986 | // For use during queue submit to avoid stale pointers; |
John Zulauf | 06f6f1e | 2022-04-19 15:28:11 -0600 | [diff] [blame] | 987 | void ClearAsyncContext(const AccessContext *context) { async_.clear(); } |
| 988 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 989 | private: |
| 990 | template <typename Detector> |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 991 | HazardResult DetectHazard(AccessAddressType type, Detector &detector, const ResourceAccessRange &range, |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 992 | DetectOptions options) const; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 993 | template <typename Detector> |
John Zulauf | 43cc746 | 2020-12-03 12:33:12 -0700 | [diff] [blame] | 994 | HazardResult DetectAsyncHazard(AccessAddressType type, const Detector &detector, const ResourceAccessRange &range) const; |
John Zulauf | 5f13a79 | 2020-03-10 07:31:21 -0600 | [diff] [blame] | 995 | template <typename Detector> |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 996 | HazardResult DetectPreviousHazard(AccessAddressType type, Detector &detector, const ResourceAccessRange &range) const; |
John Zulauf | 8e3c3e9 | 2021-01-06 11:19:36 -0700 | [diff] [blame] | 997 | void UpdateAccessState(AccessAddressType type, SyncStageAccessIndex current_usage, SyncOrdering ordering_rule, |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 998 | const ResourceAccessRange &range, ResourceUsageTag tag); |
John Zulauf | b02c1eb | 2020-10-06 16:33:36 -0600 | [diff] [blame] | 999 | |
| 1000 | MapArray access_state_maps_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1001 | std::vector<TrackBack> prev_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1002 | std::vector<TrackBack *> prev_by_subpass_; |
Jeremy Gebben | c4b78c5 | 2020-12-11 09:39:47 -0700 | [diff] [blame] | 1003 | std::vector<const AccessContext *> async_; |
John Zulauf | 22aefed | 2021-03-11 18:14:35 -0700 | [diff] [blame] | 1004 | TrackBack *src_external_; |
John Zulauf | e5da6e5 | 2020-03-18 15:32:18 -0600 | [diff] [blame] | 1005 | TrackBack dst_external_; |
Jeremy Gebben | c4b78c5 | 2020-12-11 09:39:47 -0700 | [diff] [blame] | 1006 | ResourceUsageTag start_tag_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1007 | }; |
| 1008 | |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 1009 | struct SyncEventState { |
| 1010 | enum IgnoreReason { NotIgnored = 0, ResetWaitRace, Reset2WaitRace, SetRace, MissingStageBits, SetVsWait2, MissingSetEvent }; |
| 1011 | using EventPointer = std::shared_ptr<const EVENT_STATE>; |
| 1012 | using ScopeMap = ResourceAccessRangeMap; |
| 1013 | EventPointer event; |
| 1014 | CMD_TYPE last_command; // Only Event commands are valid here. |
| 1015 | ResourceUsageTag last_command_tag; // Needed to filter replay validation |
| 1016 | CMD_TYPE unsynchronized_set; |
| 1017 | VkPipelineStageFlags2KHR barriers; |
| 1018 | SyncExecScope scope; |
| 1019 | ResourceUsageTag first_scope_tag; |
| 1020 | bool destroyed; |
| 1021 | std::shared_ptr<const AccessContext> first_scope; |
| 1022 | |
| 1023 | SyncEventState() |
| 1024 | : event(), |
| 1025 | last_command(CMD_NONE), |
| 1026 | last_command_tag(0), |
| 1027 | unsynchronized_set(CMD_NONE), |
| 1028 | barriers(0U), |
| 1029 | scope(), |
| 1030 | first_scope_tag(), |
| 1031 | destroyed(true) {} |
| 1032 | |
| 1033 | SyncEventState(const SyncEventState &) = default; |
| 1034 | SyncEventState(SyncEventState &&) = default; |
| 1035 | |
| 1036 | SyncEventState(const SyncEventState::EventPointer &event_state) : SyncEventState() { |
| 1037 | event = event_state; |
| 1038 | destroyed = (event.get() == nullptr) || event_state->Destroyed(); |
| 1039 | } |
| 1040 | |
| 1041 | void ResetFirstScope(); |
| 1042 | const ScopeMap &FirstScope(AccessAddressType address_type) const { return first_scope->GetAccessStateMap(address_type); } |
| 1043 | IgnoreReason IsIgnoredByWait(CMD_TYPE cmd_type, VkPipelineStageFlags2KHR srcStageMask) const; |
| 1044 | bool HasBarrier(VkPipelineStageFlags2KHR stageMask, VkPipelineStageFlags2KHR exec_scope) const; |
| 1045 | }; |
| 1046 | |
| 1047 | class SyncEventsContext { |
| 1048 | public: |
| 1049 | using Map = layer_data::unordered_map<const EVENT_STATE *, std::shared_ptr<SyncEventState>>; |
| 1050 | using iterator = Map::iterator; |
| 1051 | using const_iterator = Map::const_iterator; |
| 1052 | |
| 1053 | SyncEventState *GetFromShared(const SyncEventState::EventPointer &event_state) { |
| 1054 | const auto find_it = map_.find(event_state.get()); |
| 1055 | if (find_it == map_.end()) { |
| 1056 | if (!event_state.get()) return nullptr; |
| 1057 | |
| 1058 | const auto *event_plain_ptr = event_state.get(); |
| 1059 | auto sync_state = std::make_shared<SyncEventState>(event_state); |
| 1060 | auto insert_pair = map_.emplace(event_plain_ptr, sync_state); |
| 1061 | return insert_pair.first->second.get(); |
| 1062 | } |
| 1063 | return find_it->second.get(); |
| 1064 | } |
| 1065 | |
| 1066 | const SyncEventState *Get(const EVENT_STATE *event_state) const { |
| 1067 | const auto find_it = map_.find(event_state); |
| 1068 | if (find_it == map_.end()) { |
| 1069 | return nullptr; |
| 1070 | } |
| 1071 | return find_it->second.get(); |
| 1072 | } |
| 1073 | const SyncEventState *Get(const SyncEventState::EventPointer &event_state) const { return Get(event_state.get()); } |
| 1074 | |
| 1075 | void ApplyBarrier(const SyncExecScope &src, const SyncExecScope &dst, ResourceUsageTag tag); |
| 1076 | void ApplyTaggedWait(VkQueueFlags queue_flags, ResourceUsageTag tag); |
| 1077 | |
| 1078 | // stl style naming for range-for support |
| 1079 | inline iterator begin() { return map_.begin(); } |
| 1080 | inline const_iterator begin() const { return map_.begin(); } |
| 1081 | inline iterator end() { return map_.end(); } |
| 1082 | inline const_iterator end() const { return map_.end(); } |
| 1083 | |
| 1084 | void Destroy(const EVENT_STATE *event_state) { |
| 1085 | auto sync_it = map_.find(event_state); |
| 1086 | if (sync_it != map_.end()) { |
| 1087 | sync_it->second->destroyed = true; |
| 1088 | map_.erase(sync_it); |
| 1089 | } |
| 1090 | } |
| 1091 | void Clear() { map_.clear(); } |
| 1092 | |
| 1093 | SyncEventsContext &DeepCopy(const SyncEventsContext &from); |
| 1094 | |
| 1095 | private: |
| 1096 | Map map_; |
| 1097 | }; |
| 1098 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1099 | class RenderPassAccessContext { |
| 1100 | public: |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 1101 | static AttachmentViewGenVector CreateAttachmentViewGen(const VkRect2D &render_area, |
| 1102 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views); |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1103 | RenderPassAccessContext() : rp_state_(nullptr), render_area_(VkRect2D()), current_subpass_(0) {} |
| 1104 | RenderPassAccessContext(const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, VkQueueFlags queue_flags, |
| 1105 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views, const AccessContext *external_context); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1106 | |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1107 | bool ValidateDrawSubpassAttachment(const CommandExecutionContext &ex_context, const CMD_BUFFER_STATE &cmd_buffer, |
| 1108 | CMD_TYPE cmd_type) const; |
| 1109 | void RecordDrawSubpassAttachment(const CMD_BUFFER_STATE &cmd_buffer, ResourceUsageTag tag); |
| 1110 | bool ValidateNextSubpass(const CommandExecutionContext &ex_context, CMD_TYPE cmd_type) const; |
| 1111 | bool ValidateEndRenderPass(const CommandExecutionContext &ex_context, CMD_TYPE cmd_type) const; |
| 1112 | bool ValidateFinalSubpassLayoutTransitions(const CommandExecutionContext &ex_context, CMD_TYPE cmd_type) const; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1113 | |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 1114 | void RecordLayoutTransitions(ResourceUsageTag tag); |
| 1115 | void RecordLoadOperations(ResourceUsageTag tag); |
John Zulauf | 41a9c7c | 2021-12-07 15:59:53 -0700 | [diff] [blame] | 1116 | void RecordBeginRenderPass(ResourceUsageTag tag, ResourceUsageTag load_tag); |
| 1117 | void RecordNextSubpass(ResourceUsageTag store_tag, ResourceUsageTag barrier_tag, ResourceUsageTag load_tag); |
| 1118 | void RecordEndRenderPass(AccessContext *external_context, ResourceUsageTag store_tag, ResourceUsageTag barrier_tag); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1119 | |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 1120 | AccessContext &CurrentContext() { return subpass_contexts_[current_subpass_]; } |
| 1121 | const AccessContext &CurrentContext() const { return subpass_contexts_[current_subpass_]; } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1122 | const std::vector<AccessContext> &GetContexts() const { return subpass_contexts_; } |
| 1123 | uint32_t GetCurrentSubpass() const { return current_subpass_; } |
| 1124 | const RENDER_PASS_STATE *GetRenderPassState() const { return rp_state_; } |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1125 | AccessContext *CreateStoreResolveProxy() const; |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 1126 | std::shared_ptr<ReplayRenderpassContext> GetReplayContext() const { return replay_context_; } |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1127 | |
| 1128 | private: |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1129 | const RENDER_PASS_STATE *rp_state_; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1130 | const VkRect2D render_area_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1131 | uint32_t current_subpass_; |
| 1132 | std::vector<AccessContext> subpass_contexts_; |
John Zulauf | d0ec59f | 2021-03-13 14:25:08 -0700 | [diff] [blame] | 1133 | AttachmentViewGenVector attachment_views_; |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 1134 | std::shared_ptr<ReplayRenderpassContext> replay_context_; // Each SyncOp for this renderpass instance will have a copy |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1135 | }; |
| 1136 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1137 | // Command execution context is the base class for command buffer and queue contexts |
| 1138 | // Preventing unintented leakage of subclass specific state, storing enough information |
| 1139 | // for message logging. |
| 1140 | // TODO: determine where to draw the design split for tag tracking (is there anything command to Queues and CB's) |
| 1141 | class CommandExecutionContext { |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1142 | public: |
John Zulauf | 3c788ef | 2022-02-22 12:12:30 -0700 | [diff] [blame] | 1143 | using AccessLog = std::vector<ResourceUsageRecord>; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1144 | CommandExecutionContext() : sync_state_(nullptr) {} |
John Zulauf | 3c788ef | 2022-02-22 12:12:30 -0700 | [diff] [blame] | 1145 | CommandExecutionContext(const SyncValidator *sync_validator) : sync_state_(sync_validator) {} |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1146 | virtual ~CommandExecutionContext() = default; |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 1147 | virtual AccessContext *GetCurrentAccessContext() = 0; |
| 1148 | virtual SyncEventsContext *GetCurrentEventsContext() = 0; |
| 1149 | virtual const AccessContext *GetCurrentAccessContext() const = 0; |
| 1150 | virtual const SyncEventsContext *GetCurrentEventsContext() const = 0; |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 1151 | virtual QueueId GetQueueId() const = 0; |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 1152 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1153 | const SyncValidator &GetSyncState() const { |
| 1154 | assert(sync_state_); |
| 1155 | return *sync_state_; |
| 1156 | } |
John Zulauf | 3c788ef | 2022-02-22 12:12:30 -0700 | [diff] [blame] | 1157 | |
John Zulauf | 3c788ef | 2022-02-22 12:12:30 -0700 | [diff] [blame] | 1158 | ResourceUsageRange ImportRecordedAccessLog(const CommandBufferAccessContext &recorded_context); |
John Zulauf | 06f6f1e | 2022-04-19 15:28:11 -0600 | [diff] [blame] | 1159 | std::string FormatHazard(const HazardResult &hazard) const; |
| 1160 | |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 1161 | virtual ResourceUsageTag GetTagLimit() const = 0; |
| 1162 | virtual VulkanTypedHandle Handle() const = 0; |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 1163 | virtual std::string FormatUsage(ResourceUsageTag tag) const = 0; |
John Zulauf | 3c788ef | 2022-02-22 12:12:30 -0700 | [diff] [blame] | 1164 | virtual void InsertRecordedAccessLogEntries(const CommandBufferAccessContext &cb_context) = 0; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1165 | |
| 1166 | protected: |
John Zulauf | 3c788ef | 2022-02-22 12:12:30 -0700 | [diff] [blame] | 1167 | const SyncValidator *sync_state_; |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1168 | }; |
| 1169 | |
| 1170 | class CommandBufferAccessContext : public CommandExecutionContext { |
| 1171 | public: |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 1172 | using SyncOpPointer = std::shared_ptr<SyncOpBase>; |
| 1173 | struct SyncOpEntry { |
| 1174 | ResourceUsageTag tag; |
| 1175 | SyncOpPointer sync_op; |
| 1176 | SyncOpEntry(ResourceUsageTag tag_, SyncOpPointer &&sync_op_) : tag(tag_), sync_op(std::move(sync_op_)) {} |
| 1177 | SyncOpEntry() = default; |
| 1178 | SyncOpEntry(const SyncOpEntry &other) = default; |
| 1179 | }; |
| 1180 | |
John Zulauf | 3c788ef | 2022-02-22 12:12:30 -0700 | [diff] [blame] | 1181 | CommandBufferAccessContext(const SyncValidator *sync_validator = nullptr) |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1182 | : CommandExecutionContext(sync_validator), |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 1183 | cb_state_(), |
| 1184 | queue_flags_(), |
| 1185 | destroyed_(false), |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 1186 | access_log_(), |
John Zulauf | 3c2a0b3 | 2021-07-14 11:14:52 -0600 | [diff] [blame] | 1187 | cbs_referenced_(), |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 1188 | command_number_(0), |
| 1189 | subcommand_number_(0), |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1190 | reset_count_(0), |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1191 | cb_access_context_(), |
| 1192 | current_context_(&cb_access_context_), |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 1193 | events_context_(), |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 1194 | render_pass_contexts_(), |
| 1195 | current_renderpass_context_(), |
| 1196 | sync_ops_() {} |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1197 | CommandBufferAccessContext(SyncValidator &sync_validator, std::shared_ptr<CMD_BUFFER_STATE> &cb_state, VkQueueFlags queue_flags) |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1198 | : CommandBufferAccessContext(&sync_validator) { |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1199 | cb_state_ = cb_state; |
| 1200 | queue_flags_ = queue_flags; |
| 1201 | } |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 1202 | |
| 1203 | struct AsProxyContext {}; |
| 1204 | CommandBufferAccessContext(const CommandBufferAccessContext &real_context, AsProxyContext dummy); |
| 1205 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1206 | ~CommandBufferAccessContext() override = default; |
| 1207 | CommandExecutionContext &GetExecutionContext() { return *this; } |
| 1208 | const CommandExecutionContext &GetExecutionContext() const { return *this; } |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 1209 | |
| 1210 | void Reset() { |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 1211 | access_log_.clear(); |
John Zulauf | 3c2a0b3 | 2021-07-14 11:14:52 -0600 | [diff] [blame] | 1212 | cbs_referenced_.clear(); |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 1213 | sync_ops_.clear(); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1214 | command_number_ = 0; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 1215 | subcommand_number_ = 0; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1216 | reset_count_++; |
| 1217 | cb_access_context_.Reset(); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1218 | render_pass_contexts_.clear(); |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1219 | current_context_ = &cb_access_context_; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1220 | current_renderpass_context_ = nullptr; |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 1221 | events_context_.Clear(); |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 1222 | } |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 1223 | void MarkDestroyed() { destroyed_ = true; } |
| 1224 | bool IsDestroyed() const { return destroyed_; } |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 1225 | |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 1226 | std::string FormatUsage(ResourceUsageTag tag) const override; |
John Zulauf | 06f6f1e | 2022-04-19 15:28:11 -0600 | [diff] [blame] | 1227 | std::string FormatUsage(const ResourceFirstAccess &access) const; // Only command buffers have "first usage" |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 1228 | AccessContext *GetCurrentAccessContext() override { return current_context_; } |
| 1229 | SyncEventsContext *GetCurrentEventsContext() override { return &events_context_; } |
| 1230 | const AccessContext *GetCurrentAccessContext() const override { return current_context_; } |
| 1231 | const SyncEventsContext *GetCurrentEventsContext() const override { return &events_context_; } |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 1232 | QueueId GetQueueId() const override; |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 1233 | |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1234 | RenderPassAccessContext *GetCurrentRenderPassContext() { return current_renderpass_context_; } |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1235 | const RenderPassAccessContext *GetCurrentRenderPassContext() const { return current_renderpass_context_; } |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1236 | ResourceUsageTag RecordBeginRenderPass(CMD_TYPE cmd_type, const RENDER_PASS_STATE &rp_state, const VkRect2D &render_area, |
John Zulauf | 41a9c7c | 2021-12-07 15:59:53 -0700 | [diff] [blame] | 1237 | const std::vector<const IMAGE_VIEW_STATE *> &attachment_views); |
John Zulauf | d511570 | 2021-01-18 12:34:33 -0700 | [diff] [blame] | 1238 | |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1239 | bool ValidateDispatchDrawDescriptorSet(VkPipelineBindPoint pipelineBindPoint, CMD_TYPE cmd_type) const; |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 1240 | void RecordDispatchDrawDescriptorSet(VkPipelineBindPoint pipelineBindPoint, ResourceUsageTag tag); |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1241 | bool ValidateDrawVertex(uint32_t vertexCount, uint32_t firstVertex, CMD_TYPE cmd_type) const; |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 1242 | void RecordDrawVertex(uint32_t vertexCount, uint32_t firstVertex, ResourceUsageTag tag); |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1243 | bool ValidateDrawVertexIndex(uint32_t indexCount, uint32_t firstIndex, CMD_TYPE cmd_type) const; |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 1244 | void RecordDrawVertexIndex(uint32_t indexCount, uint32_t firstIndex, ResourceUsageTag tag); |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1245 | bool ValidateDrawSubpassAttachment(CMD_TYPE cmd_type) const; |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 1246 | void RecordDrawSubpassAttachment(ResourceUsageTag tag); |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1247 | ResourceUsageTag RecordNextSubpass(CMD_TYPE cmd_type); |
| 1248 | ResourceUsageTag RecordEndRenderPass(CMD_TYPE cmd_type); |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 1249 | void RecordDestroyEvent(VkEvent event); |
John Zulauf | 49beb11 | 2020-11-04 16:06:31 -0700 | [diff] [blame] | 1250 | |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 1251 | bool ValidateFirstUse(CommandExecutionContext *proxy_context, const char *func_name, uint32_t index) const; |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1252 | void RecordExecutedCommandBuffer(const CommandBufferAccessContext &recorded_context); |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1253 | void ResolveExecutedCommandBuffer(const AccessContext &recorded_context, ResourceUsageTag offset); |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 1254 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1255 | const CMD_BUFFER_STATE *GetCommandBufferState() const { return cb_state_.get(); } |
| 1256 | VkQueueFlags GetQueueFlags() const { return queue_flags_; } |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 1257 | |
John Zulauf | 41a9c7c | 2021-12-07 15:59:53 -0700 | [diff] [blame] | 1258 | ResourceUsageTag NextSubcommandTag(CMD_TYPE command, ResourceUsageRecord::SubcommandType subcommand); |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 1259 | ResourceUsageTag GetTagLimit() const override { return access_log_.size(); } |
| 1260 | VulkanTypedHandle Handle() const override { |
| 1261 | if (cb_state_) { |
| 1262 | return cb_state_->Handle(); |
| 1263 | } |
| 1264 | return VulkanTypedHandle(static_cast<VkCommandBuffer>(VK_NULL_HANDLE), kVulkanObjectTypeCommandBuffer); |
| 1265 | } |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 1266 | |
John Zulauf | 41a9c7c | 2021-12-07 15:59:53 -0700 | [diff] [blame] | 1267 | ResourceUsageTag NextCommandTag(CMD_TYPE command, |
| 1268 | ResourceUsageRecord::SubcommandType subcommand = ResourceUsageRecord::SubcommandType::kNone); |
| 1269 | ResourceUsageTag NextIndexedCommandTag(CMD_TYPE command, uint32_t index); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1270 | |
John Zulauf | 3c788ef | 2022-02-22 12:12:30 -0700 | [diff] [blame] | 1271 | std::shared_ptr<const CMD_BUFFER_STATE> GetCBStateShared() const { return cb_state_; } |
| 1272 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 1273 | const CMD_BUFFER_STATE &GetCBState() const { |
| 1274 | assert(cb_state_); |
| 1275 | return *(cb_state_.get()); |
| 1276 | } |
| 1277 | CMD_BUFFER_STATE &GetCBState() { |
| 1278 | assert(cb_state_); |
| 1279 | return *(cb_state_.get()); |
| 1280 | } |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 1281 | |
John Zulauf | 1bf3052 | 2021-09-03 15:39:06 -0600 | [diff] [blame] | 1282 | template <class T, class... Args> |
| 1283 | void RecordSyncOp(Args &&...args) { |
| 1284 | // T must be as derived from SyncOpBase or the compiler will flag the next line as an error. |
| 1285 | SyncOpPointer sync_op(std::make_shared<T>(std::forward<Args>(args)...)); |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 1286 | RecordSyncOp(std::move(sync_op)); // Call the non-template version |
John Zulauf | 1bf3052 | 2021-09-03 15:39:06 -0600 | [diff] [blame] | 1287 | } |
John Zulauf | 3c788ef | 2022-02-22 12:12:30 -0700 | [diff] [blame] | 1288 | const AccessLog &GetAccessLog() const { return access_log_; } |
| 1289 | void InsertRecordedAccessLogEntries(const CommandBufferAccessContext &cb_context) override; |
John Zulauf | 06f6f1e | 2022-04-19 15:28:11 -0600 | [diff] [blame] | 1290 | const std::vector<SyncOpEntry> &GetSyncOps() const { return sync_ops_; }; |
John Zulauf | 8eda156 | 2021-04-13 17:06:41 -0600 | [diff] [blame] | 1291 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1292 | private: |
John Zulauf | bb89045 | 2021-12-14 11:30:18 -0700 | [diff] [blame] | 1293 | // As this is passing around a shared pointer to record, move to avoid needless atomics. |
| 1294 | void RecordSyncOp(SyncOpPointer &&sync_op); |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 1295 | std::shared_ptr<CMD_BUFFER_STATE> cb_state_; |
| 1296 | VkQueueFlags queue_flags_; |
| 1297 | bool destroyed_; |
| 1298 | |
John Zulauf | 3c788ef | 2022-02-22 12:12:30 -0700 | [diff] [blame] | 1299 | AccessLog access_log_; |
John Zulauf | 3c2a0b3 | 2021-07-14 11:14:52 -0600 | [diff] [blame] | 1300 | layer_data::unordered_set<std::shared_ptr<const CMD_BUFFER_STATE>> cbs_referenced_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1301 | uint32_t command_number_; |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 1302 | uint32_t subcommand_number_; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1303 | uint32_t reset_count_; |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 1304 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1305 | AccessContext cb_access_context_; |
John Zulauf | 540266b | 2020-04-06 18:54:53 -0600 | [diff] [blame] | 1306 | AccessContext *current_context_; |
John Zulauf | 669dfd5 | 2021-01-27 17:15:28 -0700 | [diff] [blame] | 1307 | SyncEventsContext events_context_; |
John Zulauf | 4fa6846 | 2021-04-26 21:04:22 -0600 | [diff] [blame] | 1308 | |
| 1309 | // Don't need the following for an active proxy cb context |
| 1310 | std::vector<RenderPassAccessContext> render_pass_contexts_; |
| 1311 | RenderPassAccessContext *current_renderpass_context_; |
| 1312 | std::vector<SyncOpEntry> sync_ops_; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1313 | }; |
| 1314 | |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1315 | class QueueSyncState; |
| 1316 | |
| 1317 | // Store the ResourceUsageRecords for the global tag range. The prev_ field allows for |
| 1318 | // const Validation phase access from the cmd state "overlay" seamlessly. |
| 1319 | class AccessLogger { |
| 1320 | public: |
| 1321 | struct BatchRecord { |
| 1322 | BatchRecord() = default; |
| 1323 | BatchRecord(const BatchRecord &other) = default; |
| 1324 | BatchRecord(BatchRecord &&other) = default; |
| 1325 | BatchRecord(const QueueSyncState *q, uint64_t submit, uint32_t batch) |
| 1326 | : queue(q), submit_index(submit), batch_index(batch) {} |
| 1327 | BatchRecord &operator=(const BatchRecord &other) = default; |
| 1328 | const QueueSyncState *queue; |
| 1329 | uint64_t submit_index; |
| 1330 | uint32_t batch_index; |
| 1331 | }; |
| 1332 | |
| 1333 | struct AccessRecord { |
| 1334 | const BatchRecord *batch; |
| 1335 | const ResourceUsageRecord *record; |
| 1336 | bool IsValid() const { return batch && record; } |
| 1337 | }; |
| 1338 | |
| 1339 | // BatchLog lookup is batch relative, thus the batch doesn't need to track it's offset |
| 1340 | class BatchLog { |
| 1341 | public: |
| 1342 | BatchLog() = default; |
| 1343 | BatchLog(const BatchLog &batch) = default; |
| 1344 | BatchLog(BatchLog &&other) = default; |
| 1345 | BatchLog &operator=(const BatchLog &other) = default; |
| 1346 | BatchLog &operator=(BatchLog &&other) = default; |
| 1347 | BatchLog(const BatchRecord &batch) : batch_(batch) {} |
| 1348 | |
| 1349 | size_t Size() const { return log_.size(); } |
| 1350 | const BatchRecord &GetBatch() const { return batch_; } |
| 1351 | AccessRecord operator[](size_t index) const; |
| 1352 | |
| 1353 | void Append(const CommandExecutionContext::AccessLog &other); |
| 1354 | |
| 1355 | private: |
| 1356 | BatchRecord batch_; |
| 1357 | layer_data::unordered_set<std::shared_ptr<const CMD_BUFFER_STATE>> cbs_referenced_; |
| 1358 | CommandExecutionContext::AccessLog log_; |
| 1359 | }; |
| 1360 | |
| 1361 | using AccessLogRangeMap = sparse_container::range_map<ResourceUsageTag, BatchLog>; |
| 1362 | |
| 1363 | AccessLogger(const AccessLogger *prev = nullptr) : prev_(prev) {} |
| 1364 | // AccessLogger lookup is based on global tags |
| 1365 | AccessRecord operator[](ResourceUsageTag tag) const; |
| 1366 | BatchLog *AddBatch(const QueueSyncState *queue_state, uint64_t submit_id, uint32_t batch_id, const ResourceUsageRange &range); |
| 1367 | void MergeMove(AccessLogger &&child); |
| 1368 | void Reset(); |
| 1369 | |
| 1370 | private: |
| 1371 | const AccessLogger *prev_; |
| 1372 | AccessLogRangeMap access_log_map_; |
| 1373 | }; |
| 1374 | |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1375 | // TODO need a map from fence to submbit batch id |
| 1376 | class QueueBatchContext : public CommandExecutionContext { |
| 1377 | public: |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1378 | using ConstBatchSet = layer_data::unordered_set<std::shared_ptr<const QueueBatchContext>>; |
| 1379 | using BatchSet = layer_data::unordered_set<std::shared_ptr<QueueBatchContext>>; |
| 1380 | static constexpr bool TruePred(const std::shared_ptr<const QueueBatchContext> &) { return true; } |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1381 | struct CmdBufferEntry { |
| 1382 | uint32_t index = 0; |
| 1383 | std::shared_ptr<const CommandBufferAccessContext> cb; |
| 1384 | CmdBufferEntry(uint32_t index_, std::shared_ptr<const CommandBufferAccessContext> &&cb_) |
| 1385 | : index(index_), cb(std::move(cb_)) {} |
| 1386 | }; |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1387 | |
| 1388 | // For Wait operations we have to |
| 1389 | struct QueueWormBase { |
| 1390 | std::vector<AccessContext::AddressRange> erase_list; |
| 1391 | bool erase_all = true; |
| 1392 | }; |
| 1393 | |
| 1394 | struct QueueWaitWorm : QueueWormBase { |
| 1395 | ResourceAccessState::QueuePredicate predicate; |
| 1396 | QueueWaitWorm(QueueId queue_, ResourceUsageTag tag_ = ResourceUsageRecord::kMaxIndex); |
| 1397 | void operator()(AccessAddressType address_type, ResourceAccessRangeMap::value_type &access); |
| 1398 | }; |
| 1399 | |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1400 | using CommandBuffers = std::vector<CmdBufferEntry>; |
| 1401 | |
| 1402 | std::string FormatUsage(ResourceUsageTag tag) const override; |
| 1403 | AccessContext *GetCurrentAccessContext() override { return &access_context_; } |
| 1404 | const AccessContext *GetCurrentAccessContext() const override { return &access_context_; } |
| 1405 | SyncEventsContext *GetCurrentEventsContext() override { return &events_context_; } |
| 1406 | const SyncEventsContext *GetCurrentEventsContext() const override { return &events_context_; } |
| 1407 | const QueueSyncState *GetQueueSyncState() const { return queue_state_; } |
| 1408 | VkQueueFlags GetQueueFlags() const; |
John Zulauf | 0011952 | 2022-05-23 19:07:42 -0600 | [diff] [blame] | 1409 | QueueId GetQueueId() const override; |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1410 | |
| 1411 | void SetBatchLog(AccessLogger &loggger, uint64_t sumbit_id, uint32_t batch_id); |
| 1412 | void ResetAccessLog() { |
| 1413 | logger_ = nullptr; |
| 1414 | batch_log_ = nullptr; |
| 1415 | } |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 1416 | void ResetEventsContext() { events_context_.Clear(); } |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1417 | ResourceUsageTag GetTagLimit() const override { return batch_log_->Size() + tag_range_.begin; } |
| 1418 | // begin is the tag bias / .size() is the number of total records that should eventually be in access_log_ |
| 1419 | ResourceUsageRange GetTagRange() const { return tag_range_; } |
| 1420 | void InsertRecordedAccessLogEntries(const CommandBufferAccessContext &cb_context) override; |
| 1421 | |
| 1422 | void SetTagBias(ResourceUsageTag); |
| 1423 | CommandBuffers::const_iterator begin() const { return command_buffers_.cbegin(); } |
| 1424 | CommandBuffers::const_iterator end() const { return command_buffers_.cend(); } |
| 1425 | |
John Zulauf | cb7e167 | 2022-05-04 13:46:08 -0600 | [diff] [blame] | 1426 | QueueBatchContext(const SyncValidator &sync_state, const QueueSyncState &queue_state); |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1427 | QueueBatchContext() = delete; |
| 1428 | |
John Zulauf | cb7e167 | 2022-05-04 13:46:08 -0600 | [diff] [blame] | 1429 | template <typename BatchInfo> |
| 1430 | void Setup(const std::shared_ptr<const QueueBatchContext> &prev_batch, const BatchInfo &batch_info, |
| 1431 | SignaledSemaphores &signaled); |
| 1432 | |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1433 | void ResolveSubmittedCommandBuffer(const AccessContext &recorded_context, ResourceUsageTag offset); |
| 1434 | |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1435 | VulkanTypedHandle Handle() const override; |
| 1436 | |
| 1437 | template <typename BatchInfo, typename Fn> |
| 1438 | static void ForEachWaitSemaphore(const BatchInfo &batch_info, Fn &&func); |
| 1439 | |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1440 | void ApplyTaggedWait(QueueId queue_id, ResourceUsageTag tag); |
| 1441 | void ApplyDeviceWait(); |
| 1442 | |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1443 | private: |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1444 | // The BatchInfo is either the Submit or Submit2 version with traits allowing generic acces |
| 1445 | template <typename BatchInfo> |
| 1446 | class SubmitInfoAccessor {}; |
| 1447 | template <typename BatchInfo> |
John Zulauf | cb7e167 | 2022-05-04 13:46:08 -0600 | [diff] [blame] | 1448 | void SetupAccessContext(const std::shared_ptr<const QueueBatchContext> &prev, const BatchInfo &batch_info, |
| 1449 | SignaledSemaphores &signaled_semaphores); |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1450 | template <typename BatchInfo> |
| 1451 | void SetupCommandBufferInfo(const BatchInfo &batch_info); |
| 1452 | |
John Zulauf | ecf4ac5 | 2022-06-06 10:08:42 -0600 | [diff] [blame] | 1453 | std::shared_ptr<QueueBatchContext> ResolveOneWaitSemaphore(VkSemaphore sem, VkPipelineStageFlags2 wait_mask, |
| 1454 | SignaledSemaphores &signaled); |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1455 | |
| 1456 | const QueueSyncState *queue_state_ = nullptr; |
| 1457 | ResourceUsageRange tag_range_ = ResourceUsageRange(0, 0); // Range of tags referenced by cbs_referenced |
| 1458 | |
| 1459 | AccessContext access_context_; |
| 1460 | SyncEventsContext events_context_; |
| 1461 | |
| 1462 | // Clear these after validation and import |
| 1463 | CommandBuffers command_buffers_; |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1464 | ConstBatchSet async_batches_; |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1465 | // When null use the global logger |
| 1466 | AccessLogger *logger_ = nullptr; |
| 1467 | AccessLogger::BatchLog *batch_log_ = nullptr; |
| 1468 | }; |
John Zulauf | bbda457 | 2022-04-19 16:20:45 -0600 | [diff] [blame] | 1469 | |
| 1470 | class QueueSyncState { |
| 1471 | public: |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1472 | constexpr static QueueId kQueueIdBase = QueueId(0); |
| 1473 | constexpr static QueueId kQueueIdInvalid = ~kQueueIdBase; |
| 1474 | QueueSyncState(const std::shared_ptr<QUEUE_STATE> &queue_state, VkQueueFlags queue_flags, QueueId id) |
| 1475 | : submit_index_(0), queue_state_(queue_state), last_batch_(), queue_flags_(queue_flags), id_(id) {} |
John Zulauf | bbda457 | 2022-04-19 16:20:45 -0600 | [diff] [blame] | 1476 | |
| 1477 | VulkanTypedHandle Handle() const { |
| 1478 | if (queue_state_) { |
| 1479 | return queue_state_->Handle(); |
| 1480 | } |
| 1481 | return VulkanTypedHandle(static_cast<VkQueue>(VK_NULL_HANDLE), kVulkanObjectTypeQueue); |
| 1482 | } |
| 1483 | std::shared_ptr<const QueueBatchContext> LastBatch() const { return last_batch_; } |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1484 | std::shared_ptr<QueueBatchContext> LastBatch() { return last_batch_; } |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1485 | void SetLastBatch(std::shared_ptr<QueueBatchContext> &&last); |
John Zulauf | bbda457 | 2022-04-19 16:20:45 -0600 | [diff] [blame] | 1486 | QUEUE_STATE *GetQueueState() { return queue_state_.get(); } |
| 1487 | const QUEUE_STATE *GetQueueState() const { return queue_state_.get(); } |
| 1488 | VkQueueFlags GetQueueFlags() const { return queue_flags_; } |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1489 | QueueId GetQueueId() const { return id_; } |
John Zulauf | bbda457 | 2022-04-19 16:20:45 -0600 | [diff] [blame] | 1490 | |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1491 | uint64_t ReserveSubmitId() const; // Method is const but updates mutable sumbit_index atomically. |
| 1492 | |
John Zulauf | bbda457 | 2022-04-19 16:20:45 -0600 | [diff] [blame] | 1493 | private: |
| 1494 | mutable std::atomic<uint64_t> submit_index_; |
| 1495 | std::shared_ptr<QUEUE_STATE> queue_state_; |
| 1496 | std::shared_ptr<QueueBatchContext> last_batch_; |
| 1497 | const VkQueueFlags queue_flags_; |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1498 | QueueId id_; |
John Zulauf | bbda457 | 2022-04-19 16:20:45 -0600 | [diff] [blame] | 1499 | }; |
| 1500 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1501 | class SyncValidator : public ValidationStateTracker, public SyncStageAccess { |
| 1502 | public: |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1503 | using StateTracker = ValidationStateTracker; |
John Zulauf | ea943c5 | 2022-02-22 11:05:17 -0700 | [diff] [blame] | 1504 | SyncValidator() { container_type = LayerObjectTypeSyncValidation; } |
John Zulauf | 888bb9d | 2022-05-20 16:13:00 -0600 | [diff] [blame] | 1505 | virtual ~SyncValidator() { ResetCommandBufferCallbacks(); }; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1506 | |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1507 | // Global tag range for submitted command buffers resource usage logs |
| 1508 | mutable std::atomic<ResourceUsageTag> tag_limit_{0}; // This is reserved in Validation phase, thus mutable and atomic |
| 1509 | ResourceUsageRange ReserveGlobalTagRange(size_t tag_count) const; // Note that the tag_limit_ is mutable this has side effects |
| 1510 | // This is a snapshot value only |
John Zulauf | 697c0e1 | 2022-04-19 16:31:12 -0600 | [diff] [blame] | 1511 | AccessLogger global_access_log_; |
| 1512 | |
John Zulauf | ea943c5 | 2022-02-22 11:05:17 -0700 | [diff] [blame] | 1513 | layer_data::unordered_map<VkCommandBuffer, std::shared_ptr<CommandBufferAccessContext>> cb_access_state; |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 1514 | |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1515 | using QueueSyncStatesMap = layer_data::unordered_map<VkQueue, std::shared_ptr<QueueSyncState>>; |
John Zulauf | bbda457 | 2022-04-19 16:20:45 -0600 | [diff] [blame] | 1516 | layer_data::unordered_map<VkQueue, std::shared_ptr<QueueSyncState>> queue_sync_states_; |
John Zulauf | cb7e167 | 2022-05-04 13:46:08 -0600 | [diff] [blame] | 1517 | SignaledSemaphores signaled_semaphores_; |
John Zulauf | e7f6a5e | 2021-01-16 14:31:18 -0700 | [diff] [blame] | 1518 | |
John Zulauf | bbda457 | 2022-04-19 16:20:45 -0600 | [diff] [blame] | 1519 | const QueueSyncState *GetQueueSyncState(VkQueue queue) const; |
| 1520 | QueueSyncState *GetQueueSyncState(VkQueue queue); |
| 1521 | std::shared_ptr<const QueueSyncState> GetQueueSyncStateShared(VkQueue queue) const; |
| 1522 | std::shared_ptr<QueueSyncState> GetQueueSyncStateShared(VkQueue queue); |
| 1523 | |
John Zulauf | e0757ba | 2022-06-10 16:51:45 -0600 | [diff] [blame^] | 1524 | QueueBatchContext::BatchSet GetQueueBatchSnapshot(); |
| 1525 | |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1526 | template <typename Predicate> |
| 1527 | QueueBatchContext::ConstBatchSet GetQueueLastBatchSnapshot(Predicate &&pred) const; |
| 1528 | QueueBatchContext::ConstBatchSet GetQueueLastBatchSnapshot() const { |
| 1529 | return GetQueueLastBatchSnapshot(QueueBatchContext::TruePred); |
| 1530 | }; |
| 1531 | |
| 1532 | template <typename Predicate> |
| 1533 | QueueBatchContext::BatchSet GetQueueLastBatchSnapshot(Predicate &&pred); |
| 1534 | QueueBatchContext::BatchSet GetQueueLastBatchSnapshot() { return GetQueueLastBatchSnapshot(QueueBatchContext::TruePred); }; |
John Zulauf | bbda457 | 2022-04-19 16:20:45 -0600 | [diff] [blame] | 1535 | |
| 1536 | std::shared_ptr<CommandBufferAccessContext> AccessContextFactory(VkCommandBuffer command_buffer); |
John Zulauf | ea943c5 | 2022-02-22 11:05:17 -0700 | [diff] [blame] | 1537 | CommandBufferAccessContext *GetAccessContext(VkCommandBuffer command_buffer); |
| 1538 | CommandBufferAccessContext *GetAccessContextNoInsert(VkCommandBuffer command_buffer); |
| 1539 | const CommandBufferAccessContext *GetAccessContext(VkCommandBuffer command_buffer) const; |
| 1540 | std::shared_ptr<CommandBufferAccessContext> GetAccessContextShared(VkCommandBuffer command_buffer); |
| 1541 | std::shared_ptr<const CommandBufferAccessContext> GetAccessContextShared(VkCommandBuffer command_buffer) const; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1542 | |
John Zulauf | d1f85d4 | 2020-04-15 12:23:15 -0600 | [diff] [blame] | 1543 | void ResetCommandBufferCallback(VkCommandBuffer command_buffer); |
| 1544 | void FreeCommandBufferCallback(VkCommandBuffer command_buffer); |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1545 | void RecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1546 | const VkSubpassBeginInfo *pSubpassBeginInfo, CMD_TYPE cmd_type); |
John Zulauf | 64ffe55 | 2021-02-06 10:25:07 -0700 | [diff] [blame] | 1547 | void RecordCmdNextSubpass(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 1548 | const VkSubpassEndInfo *pSubpassEndInfo, CMD_TYPE command); |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1549 | void RecordCmdEndRenderPass(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo, CMD_TYPE cmd_type); |
John Zulauf | 33fc1d5 | 2020-07-17 11:01:10 -0600 | [diff] [blame] | 1550 | bool SupressedBoundDescriptorWAW(const HazardResult &hazard) const; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1551 | |
Jeremy Gebben | 36a3b83 | 2022-03-23 10:54:18 -0600 | [diff] [blame] | 1552 | void CreateDevice(const VkDeviceCreateInfo *pCreateInfo) override; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1553 | |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1554 | bool ValidateBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1555 | const VkSubpassBeginInfo *pSubpassBeginInfo, CMD_TYPE cmd_type) const; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1556 | |
| 1557 | bool PreCallValidateCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1558 | VkSubpassContents contents) const override; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1559 | |
| 1560 | bool PreCallValidateCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1561 | const VkSubpassBeginInfo *pSubpassBeginInfo) const override; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1562 | |
| 1563 | bool PreCallValidateCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1564 | const VkSubpassBeginInfo *pSubpassBeginInfo) const override; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1565 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1566 | bool PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1567 | const VkBufferCopy *pRegions) const override; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1568 | |
| 1569 | void PreCallRecordCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1570 | const VkBufferCopy *pRegions) override; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1571 | |
John Zulauf | 4a6105a | 2020-11-17 15:11:05 -0700 | [diff] [blame] | 1572 | void PreCallRecordDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks *pAllocator) override; |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1573 | bool PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2KHR *pCopyBufferInfos) const override; |
Tony-LunarG | ef03547 | 2021-11-02 10:23:33 -0600 | [diff] [blame] | 1574 | bool PreCallValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2 *pCopyBufferInfos) const override; |
| 1575 | bool ValidateCmdCopyBuffer2(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2 *pCopyBufferInfos, CMD_TYPE cmd_type) const; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1576 | |
Tony-LunarG | ef03547 | 2021-11-02 10:23:33 -0600 | [diff] [blame] | 1577 | void RecordCmdCopyBuffer2(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2KHR *pCopyBufferInfos, CMD_TYPE cmd_type); |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1578 | void PreCallRecordCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2KHR *pCopyBufferInfos) override; |
Tony-LunarG | ef03547 | 2021-11-02 10:23:33 -0600 | [diff] [blame] | 1579 | void PreCallRecordCmdCopyBuffer2(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2 *pCopyBufferInfos) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1580 | |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 1581 | bool PreCallValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 1582 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1583 | const VkImageCopy *pRegions) const override; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 1584 | |
| 1585 | void PreCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1586 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions) override; |
John Zulauf | 5c5e88d | 2019-12-26 11:22:02 -0700 | [diff] [blame] | 1587 | |
Tony-LunarG | b61514a | 2021-11-02 12:36:51 -0600 | [diff] [blame] | 1588 | bool ValidateCmdCopyImage2(VkCommandBuffer commandBuffer, const VkCopyImageInfo2 *pCopyImageInfo, CMD_TYPE cmd_type) const; |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1589 | bool PreCallValidateCmdCopyImage2KHR(VkCommandBuffer commandBuffer, const VkCopyImageInfo2KHR *pCopyImageInfo) const override; |
Tony-LunarG | b61514a | 2021-11-02 12:36:51 -0600 | [diff] [blame] | 1590 | bool PreCallValidateCmdCopyImage2(VkCommandBuffer commandBuffer, const VkCopyImageInfo2 *pCopyImageInfo) const override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1591 | |
Tony-LunarG | b61514a | 2021-11-02 12:36:51 -0600 | [diff] [blame] | 1592 | void RecordCmdCopyImage2(VkCommandBuffer commandBuffer, const VkCopyImageInfo2 *pCopyImageInfo, CMD_TYPE cmd_type); |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1593 | void PreCallRecordCmdCopyImage2KHR(VkCommandBuffer commandBuffer, const VkCopyImageInfo2KHR *pCopyImageInfo) override; |
Tony-LunarG | b61514a | 2021-11-02 12:36:51 -0600 | [diff] [blame] | 1594 | void PreCallRecordCmdCopyImage2(VkCommandBuffer commandBuffer, const VkCopyImageInfo2 *pCopyImageInfo) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1595 | |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1596 | bool PreCallValidateCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, |
| 1597 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 1598 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 1599 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 1600 | uint32_t imageMemoryBarrierCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1601 | const VkImageMemoryBarrier *pImageMemoryBarriers) const override; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1602 | |
| 1603 | void PreCallRecordCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, |
| 1604 | VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, |
| 1605 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 1606 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1607 | uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1608 | |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 1609 | bool PreCallValidateCmdPipelineBarrier2KHR(VkCommandBuffer commandBuffer, |
| 1610 | const VkDependencyInfoKHR *pDependencyInfo) const override; |
Tony-LunarG | 3f6eceb | 2021-11-18 14:34:49 -0700 | [diff] [blame] | 1611 | bool PreCallValidateCmdPipelineBarrier2(VkCommandBuffer commandBuffer, const VkDependencyInfo *pDependencyInfo) const override; |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 1612 | void PreCallRecordCmdPipelineBarrier2KHR(VkCommandBuffer commandBuffer, const VkDependencyInfoKHR *pDependencyInfo) override; |
Tony-LunarG | 3f6eceb | 2021-11-18 14:34:49 -0700 | [diff] [blame] | 1613 | void PreCallRecordCmdPipelineBarrier2(VkCommandBuffer commandBuffer, const VkDependencyInfo *pDependencyInfo) override; |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 1614 | |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1615 | void PostCallRecordBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1616 | VkResult result) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1617 | |
| 1618 | void PostCallRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1619 | VkSubpassContents contents) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1620 | void PostCallRecordCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1621 | const VkSubpassBeginInfo *pSubpassBeginInfo) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1622 | void PostCallRecordCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1623 | const VkSubpassBeginInfo *pSubpassBeginInfo) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1624 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1625 | bool ValidateCmdNextSubpass(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1626 | const VkSubpassEndInfo *pSubpassEndInfo, CMD_TYPE cmd_type) const; |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1627 | bool PreCallValidateCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) const override; |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1628 | bool PreCallValidateCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 1629 | const VkSubpassEndInfo *pSubpassEndInfo) const override; |
| 1630 | bool PreCallValidateCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
| 1631 | const VkSubpassEndInfo *pSubpassEndInfo) const override; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1632 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1633 | void PostCallRecordCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1634 | void PostCallRecordCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1635 | const VkSubpassEndInfo *pSubpassEndInfo) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1636 | void PostCallRecordCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1637 | const VkSubpassEndInfo *pSubpassEndInfo) override; |
John Zulauf | 3d84f1b | 2020-03-09 13:33:25 -0600 | [diff] [blame] | 1638 | |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1639 | bool ValidateCmdEndRenderPass(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo, CMD_TYPE cmd_type) const; |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1640 | bool PreCallValidateCmdEndRenderPass(VkCommandBuffer commandBuffer) const override; |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1641 | bool PreCallValidateCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo) const override; |
| 1642 | bool PreCallValidateCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo) const override; |
John Zulauf | 355e49b | 2020-04-24 15:11:15 -0600 | [diff] [blame] | 1643 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1644 | void PostCallRecordCmdEndRenderPass(VkCommandBuffer commandBuffer) override; |
| 1645 | void PostCallRecordCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo) override; |
| 1646 | void PostCallRecordCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1647 | |
sfricke-samsung | 71f04e3 | 2022-03-16 01:21:21 -0500 | [diff] [blame] | 1648 | template <typename RegionType> |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1649 | bool ValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
sfricke-samsung | 71f04e3 | 2022-03-16 01:21:21 -0500 | [diff] [blame] | 1650 | VkImageLayout dstImageLayout, uint32_t regionCount, const RegionType *pRegions, |
Tony Barbour | 845d29b | 2021-11-09 11:43:14 -0700 | [diff] [blame] | 1651 | CMD_TYPE cmd_type) const; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1652 | bool PreCallValidateCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
| 1653 | VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1654 | const VkBufferImageCopy *pRegions) const override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1655 | bool PreCallValidateCmdCopyBufferToImage2KHR(VkCommandBuffer commandBuffer, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1656 | const VkCopyBufferToImageInfo2KHR *pCopyBufferToImageInfo) const override; |
Tony Barbour | 845d29b | 2021-11-09 11:43:14 -0700 | [diff] [blame] | 1657 | bool PreCallValidateCmdCopyBufferToImage2(VkCommandBuffer commandBuffer, |
| 1658 | const VkCopyBufferToImageInfo2 *pCopyBufferToImageInfo) const override; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1659 | |
sfricke-samsung | 71f04e3 | 2022-03-16 01:21:21 -0500 | [diff] [blame] | 1660 | template <typename RegionType> |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1661 | void RecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
sfricke-samsung | 71f04e3 | 2022-03-16 01:21:21 -0500 | [diff] [blame] | 1662 | VkImageLayout dstImageLayout, uint32_t regionCount, const RegionType *pRegions, |
Tony Barbour | 845d29b | 2021-11-09 11:43:14 -0700 | [diff] [blame] | 1663 | CMD_TYPE cmd_type); |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1664 | void PreCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1665 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy *pRegions) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1666 | void PreCallRecordCmdCopyBufferToImage2KHR(VkCommandBuffer commandBuffer, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1667 | const VkCopyBufferToImageInfo2KHR *pCopyBufferToImageInfo) override; |
Tony Barbour | 845d29b | 2021-11-09 11:43:14 -0700 | [diff] [blame] | 1668 | void PreCallRecordCmdCopyBufferToImage2(VkCommandBuffer commandBuffer, |
| 1669 | const VkCopyBufferToImageInfo2 *pCopyBufferToImageInfo) override; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1670 | |
sfricke-samsung | 71f04e3 | 2022-03-16 01:21:21 -0500 | [diff] [blame] | 1671 | template <typename RegionType> |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1672 | bool ValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
sfricke-samsung | 71f04e3 | 2022-03-16 01:21:21 -0500 | [diff] [blame] | 1673 | VkBuffer dstBuffer, uint32_t regionCount, const RegionType *pRegions, |
Tony-LunarG | af3632a | 2021-11-10 15:51:57 -0700 | [diff] [blame] | 1674 | CMD_TYPE cmd_type) const; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1675 | bool PreCallValidateCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1676 | VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions) const override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1677 | bool PreCallValidateCmdCopyImageToBuffer2KHR(VkCommandBuffer commandBuffer, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1678 | const VkCopyImageToBufferInfo2KHR *pCopyImageToBufferInfo) const override; |
Tony-LunarG | af3632a | 2021-11-10 15:51:57 -0700 | [diff] [blame] | 1679 | bool PreCallValidateCmdCopyImageToBuffer2(VkCommandBuffer commandBuffer, |
| 1680 | const VkCopyImageToBufferInfo2 *pCopyImageToBufferInfo) const override; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1681 | |
sfricke-samsung | 71f04e3 | 2022-03-16 01:21:21 -0500 | [diff] [blame] | 1682 | template <typename RegionType> |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1683 | void RecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
sfricke-samsung | 71f04e3 | 2022-03-16 01:21:21 -0500 | [diff] [blame] | 1684 | VkBuffer dstBuffer, uint32_t regionCount, const RegionType *pRegions, CMD_TYPE cmd_type); |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1685 | void PreCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1686 | VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1687 | void PreCallRecordCmdCopyImageToBuffer2KHR(VkCommandBuffer commandBuffer, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1688 | const VkCopyImageToBufferInfo2KHR *pCopyImageToBufferInfo) override; |
Tony-LunarG | af3632a | 2021-11-10 15:51:57 -0700 | [diff] [blame] | 1689 | void PreCallRecordCmdCopyImageToBuffer2(VkCommandBuffer commandBuffer, |
| 1690 | const VkCopyImageToBufferInfo2 *pCopyImageToBufferInfo) override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1691 | |
| 1692 | template <typename RegionType> |
| 1693 | bool ValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 1694 | VkImageLayout dstImageLayout, uint32_t regionCount, const RegionType *pRegions, VkFilter filter, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1695 | CMD_TYPE cmd_type) const; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1696 | |
| 1697 | bool PreCallValidateCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 1698 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1699 | const VkImageBlit *pRegions, VkFilter filter) const override; |
| 1700 | bool PreCallValidateCmdBlitImage2KHR(VkCommandBuffer commandBuffer, const VkBlitImageInfo2KHR *pBlitImageInfo) const override; |
Tony-LunarG | 542ae91 | 2021-11-04 16:06:44 -0600 | [diff] [blame] | 1701 | bool PreCallValidateCmdBlitImage2(VkCommandBuffer commandBuffer, const VkBlitImageInfo2 *pBlitImageInfo) const override; |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1702 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1703 | template <typename RegionType> |
| 1704 | void RecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 1705 | VkImageLayout dstImageLayout, uint32_t regionCount, const RegionType *pRegions, VkFilter filter, |
| 1706 | ResourceUsageTag tag); |
locke-lunarg | a19c71d | 2020-03-02 18:17:04 -0700 | [diff] [blame] | 1707 | void PreCallRecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, |
| 1708 | VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1709 | VkFilter filter) override; |
| 1710 | void PreCallRecordCmdBlitImage2KHR(VkCommandBuffer commandBuffer, const VkBlitImageInfo2KHR *pBlitImageInfo) override; |
Tony-LunarG | 542ae91 | 2021-11-04 16:06:44 -0600 | [diff] [blame] | 1711 | void PreCallRecordCmdBlitImage2(VkCommandBuffer commandBuffer, const VkBlitImageInfo2 *pBlitImageInfo) override; |
locke-lunarg | 36ba259 | 2020-04-03 09:42:04 -0600 | [diff] [blame] | 1712 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 1713 | bool ValidateIndirectBuffer(const CommandBufferAccessContext &cb_context, const AccessContext &context, |
| 1714 | VkCommandBuffer commandBuffer, const VkDeviceSize struct_size, const VkBuffer buffer, |
| 1715 | const VkDeviceSize offset, const uint32_t drawCount, const uint32_t stride, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1716 | CMD_TYPE cmd_type) const; |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 1717 | void RecordIndirectBuffer(AccessContext &context, ResourceUsageTag tag, const VkDeviceSize struct_size, const VkBuffer buffer, |
| 1718 | const VkDeviceSize offset, const uint32_t drawCount, uint32_t stride); |
locke-lunarg | 36ba259 | 2020-04-03 09:42:04 -0600 | [diff] [blame] | 1719 | |
John Zulauf | faea0ee | 2021-01-14 14:01:32 -0700 | [diff] [blame] | 1720 | bool ValidateCountBuffer(const CommandBufferAccessContext &cb_context, const AccessContext &context, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1721 | VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, CMD_TYPE cmd_type) const; |
John Zulauf | 1494072 | 2021-04-12 15:19:02 -0600 | [diff] [blame] | 1722 | void RecordCountBuffer(AccessContext &context, ResourceUsageTag tag, VkBuffer buffer, VkDeviceSize offset); |
locke-lunarg | 93d68af | 2020-05-12 17:18:03 -0600 | [diff] [blame] | 1723 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1724 | bool PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) const override; |
| 1725 | void PreCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1726 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1727 | bool PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset) const override; |
| 1728 | void PreCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1729 | |
| 1730 | bool PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1731 | uint32_t firstInstance) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1732 | void PreCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1733 | uint32_t firstInstance) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1734 | |
| 1735 | bool PreCallValidateCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1736 | uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1737 | void PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1738 | uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1739 | |
| 1740 | bool PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1741 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1742 | void PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1743 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1744 | |
| 1745 | bool PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1746 | uint32_t drawCount, uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1747 | void PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1748 | uint32_t drawCount, uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1749 | |
locke-lunarg | ff255f9 | 2020-05-13 18:53:52 -0600 | [diff] [blame] | 1750 | bool ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, |
| 1751 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1752 | CMD_TYPE cmd_type) const; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1753 | bool PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1754 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1755 | uint32_t stride) const override; |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 1756 | void RecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, |
| 1757 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride, CMD_TYPE cmd_type); |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1758 | void PreCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1759 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1760 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1761 | bool PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1762 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1763 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1764 | void PreCallRecordCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1765 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1766 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1767 | bool PreCallValidateCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1768 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1769 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1770 | void PreCallRecordCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1771 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1772 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1773 | |
locke-lunarg | ff255f9 | 2020-05-13 18:53:52 -0600 | [diff] [blame] | 1774 | bool ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1775 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
sjfricke | 0bea06e | 2022-06-05 09:22:26 +0900 | [diff] [blame] | 1776 | uint32_t stride, CMD_TYPE cmd_type) const; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1777 | bool PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1778 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1779 | uint32_t stride) const override; |
sfricke-samsung | 85584a7 | 2021-09-30 21:43:38 -0700 | [diff] [blame] | 1780 | void RecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1781 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 1782 | uint32_t stride, CMD_TYPE cmd_type); |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1783 | void PreCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1784 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1785 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1786 | bool PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1787 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1788 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1789 | void PreCallRecordCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1790 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1791 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1792 | bool PreCallValidateCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1793 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1794 | uint32_t stride) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1795 | void PreCallRecordCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
| 1796 | VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1797 | uint32_t stride) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1798 | |
| 1799 | bool PreCallValidateCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 1800 | const VkClearColorValue *pColor, uint32_t rangeCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1801 | const VkImageSubresourceRange *pRanges) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1802 | void PreCallRecordCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 1803 | const VkClearColorValue *pColor, uint32_t rangeCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1804 | const VkImageSubresourceRange *pRanges) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1805 | |
| 1806 | bool PreCallValidateCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 1807 | const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1808 | const VkImageSubresourceRange *pRanges) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1809 | void PreCallRecordCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, |
| 1810 | const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1811 | const VkImageSubresourceRange *pRanges) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1812 | |
| 1813 | bool PreCallValidateCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, |
| 1814 | uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1815 | VkDeviceSize stride, VkQueryResultFlags flags) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1816 | void PreCallRecordCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, |
| 1817 | uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1818 | VkQueryResultFlags flags) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1819 | |
| 1820 | bool PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1821 | uint32_t data) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1822 | void PreCallRecordCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1823 | uint32_t data) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1824 | |
| 1825 | bool PreCallValidateCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 1826 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1827 | const VkImageResolve *pRegions) const override; |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1828 | |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1829 | void PreCallRecordCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, |
| 1830 | VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1831 | const VkImageResolve *pRegions) override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1832 | |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1833 | bool PreCallValidateCmdResolveImage2KHR(VkCommandBuffer commandBuffer, const VkResolveImageInfo2KHR *pResolveImageInfo) const override; |
Tony-LunarG | 562fc10 | 2021-11-12 13:58:35 -0700 | [diff] [blame] | 1834 | bool PreCallValidateCmdResolveImage2(VkCommandBuffer commandBuffer, const VkResolveImageInfo2* pResolveImageInfo) const override; |
| 1835 | bool ValidateCmdResolveImage2(VkCommandBuffer commandBuffer, const VkResolveImageInfo2* pResolveImageInfo, CMD_TYPE cmd_type) const; |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1836 | void PreCallRecordCmdResolveImage2KHR(VkCommandBuffer commandBuffer, const VkResolveImageInfo2KHR *pResolveImageInfo) override; |
Tony-LunarG | 562fc10 | 2021-11-12 13:58:35 -0700 | [diff] [blame] | 1837 | void PreCallRecordCmdResolveImage2(VkCommandBuffer commandBuffer, const VkResolveImageInfo2* pResolveImageInfo) override; |
| 1838 | void RecordCmdResolveImage2(VkCommandBuffer commandBuffer, const VkResolveImageInfo2* pResolveImageInfo, CMD_TYPE cmd_type); |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 1839 | |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1840 | bool PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1841 | VkDeviceSize dataSize, const void *pData) const override; |
locke-lunarg | e1a6702 | 2020-04-29 00:15:36 -0600 | [diff] [blame] | 1842 | void PreCallRecordCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1843 | VkDeviceSize dataSize, const void *pData) override; |
locke-lunarg | ff255f9 | 2020-05-13 18:53:52 -0600 | [diff] [blame] | 1844 | |
| 1845 | bool PreCallValidateCmdWriteBufferMarkerAMD(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1846 | VkBuffer dstBuffer, VkDeviceSize dstOffset, uint32_t marker) const override; |
locke-lunarg | ff255f9 | 2020-05-13 18:53:52 -0600 | [diff] [blame] | 1847 | void PreCallRecordCmdWriteBufferMarkerAMD(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, |
Jeremy Gebben | f892469 | 2020-10-28 16:27:14 -0600 | [diff] [blame] | 1848 | VkBuffer dstBuffer, VkDeviceSize dstOffset, uint32_t marker) override; |
John Zulauf | 49beb11 | 2020-11-04 16:06:31 -0700 | [diff] [blame] | 1849 | |
| 1850 | bool PreCallValidateCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) const override; |
| 1851 | void PostCallRecordCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) override; |
| 1852 | |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 1853 | bool PreCallValidateCmdSetEvent2KHR(VkCommandBuffer commandBuffer, VkEvent event, |
| 1854 | const VkDependencyInfoKHR *pDependencyInfo) const override; |
Tony-LunarG | c43525f | 2021-11-15 16:12:38 -0700 | [diff] [blame] | 1855 | bool PreCallValidateCmdSetEvent2(VkCommandBuffer commandBuffer, VkEvent event, |
| 1856 | const VkDependencyInfo *pDependencyInfo) const override; |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 1857 | void PostCallRecordCmdSetEvent2KHR(VkCommandBuffer commandBuffer, VkEvent event, |
| 1858 | const VkDependencyInfoKHR *pDependencyInfo) override; |
Tony-LunarG | c43525f | 2021-11-15 16:12:38 -0700 | [diff] [blame] | 1859 | void PostCallRecordCmdSetEvent2(VkCommandBuffer commandBuffer, VkEvent event, const VkDependencyInfo *pDependencyInfo) override; |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 1860 | |
John Zulauf | 49beb11 | 2020-11-04 16:06:31 -0700 | [diff] [blame] | 1861 | bool PreCallValidateCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) const override; |
| 1862 | void PostCallRecordCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) override; |
| 1863 | |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 1864 | bool PreCallValidateCmdResetEvent2KHR(VkCommandBuffer commandBuffer, VkEvent event, |
| 1865 | VkPipelineStageFlags2KHR stageMask) const override; |
Tony-LunarG | a2662db | 2021-11-16 07:26:24 -0700 | [diff] [blame] | 1866 | bool PreCallValidateCmdResetEvent2(VkCommandBuffer commandBuffer, VkEvent event, |
| 1867 | VkPipelineStageFlags2 stageMask) const override; |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 1868 | void PostCallRecordCmdResetEvent2KHR(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags2KHR stageMask) override; |
Tony-LunarG | a2662db | 2021-11-16 07:26:24 -0700 | [diff] [blame] | 1869 | void PostCallRecordCmdResetEvent2(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags2 stageMask) override; |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 1870 | |
John Zulauf | 49beb11 | 2020-11-04 16:06:31 -0700 | [diff] [blame] | 1871 | bool PreCallValidateCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, |
| 1872 | VkPipelineStageFlags sourceStageMask, VkPipelineStageFlags dstStageMask, |
| 1873 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 1874 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 1875 | uint32_t imageMemoryBarrierCount, |
| 1876 | const VkImageMemoryBarrier *pImageMemoryBarriers) const override; |
| 1877 | void PostCallRecordCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, |
| 1878 | VkPipelineStageFlags sourceStageMask, VkPipelineStageFlags dstStageMask, |
| 1879 | uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, |
| 1880 | uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, |
| 1881 | uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers) override; |
John Zulauf | 4edde62 | 2021-02-15 08:54:50 -0700 | [diff] [blame] | 1882 | bool PreCallValidateCmdWaitEvents2KHR(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, |
| 1883 | const VkDependencyInfoKHR *pDependencyInfos) const override; |
| 1884 | void PostCallRecordCmdWaitEvents2KHR(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, |
| 1885 | const VkDependencyInfoKHR *pDependencyInfos) override; |
Tony-LunarG | 1364cf5 | 2021-11-17 16:10:11 -0700 | [diff] [blame] | 1886 | bool PreCallValidateCmdWaitEvents2(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, |
| 1887 | const VkDependencyInfo *pDependencyInfos) const override; |
| 1888 | void PostCallRecordCmdWaitEvents2(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, |
| 1889 | const VkDependencyInfo *pDependencyInfos) override; |
Jeremy Gebben | df3fcc3 | 2021-02-15 08:53:17 -0700 | [diff] [blame] | 1890 | bool PreCallValidateCmdWriteBufferMarker2AMD(VkCommandBuffer commandBuffer, VkPipelineStageFlags2KHR stage, VkBuffer dstBuffer, |
| 1891 | VkDeviceSize dstOffset, uint32_t marker) const override; |
| 1892 | void PreCallRecordCmdWriteBufferMarker2AMD(VkCommandBuffer commandBuffer, VkPipelineStageFlags2KHR stage, VkBuffer dstBuffer, |
| 1893 | VkDeviceSize dstOffset, uint32_t marker) override; |
John Zulauf | ae84200 | 2021-04-15 18:20:55 -0600 | [diff] [blame] | 1894 | bool PreCallValidateCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, |
| 1895 | const VkCommandBuffer *pCommandBuffers) const override; |
| 1896 | void PreCallRecordCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, |
| 1897 | const VkCommandBuffer *pCommandBuffers) override; |
John Zulauf | 1d5f9c1 | 2022-05-13 14:51:08 -0600 | [diff] [blame] | 1898 | void PostCallRecordQueueWaitIdle(VkQueue queue, VkResult result) override; |
| 1899 | void PostCallRecordDeviceWaitIdle(VkDevice device, VkResult result) override; |
John Zulauf | bbda457 | 2022-04-19 16:20:45 -0600 | [diff] [blame] | 1900 | bool PreCallValidateQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, |
| 1901 | VkFence fence) const override; |
| 1902 | void PostCallRecordQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence, |
| 1903 | VkResult result) override; |
| 1904 | bool PreCallValidateQueueSubmit2KHR(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2KHR *pSubmits, |
| 1905 | VkFence fence) const override; |
| 1906 | void PostCallRecordQueueSubmit2KHR(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2KHR *pSubmits, VkFence fence, |
| 1907 | VkResult result) override; |
John Zulauf | 9cb530d | 2019-09-30 14:14:10 -0600 | [diff] [blame] | 1908 | }; |