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