blob: d3de7d40b9a8c3bcde060996969d1b8a51de2f4a [file] [log] [blame]
Jeremy Gebben159b3cc2021-06-03 09:09:03 -06001/* Copyright (c) 2015-2021 The Khronos Group Inc.
2 * Copyright (c) 2015-2021 Valve Corporation
3 * Copyright (c) 2015-2021 LunarG, Inc.
4 * Copyright (C) 2015-2021 Google Inc.
5 * Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * Author: Courtney Goeltzenleuchter <courtneygo@google.com>
20 * Author: Tobin Ehlis <tobine@google.com>
21 * Author: Chris Forbes <chrisf@ijw.co.nz>
22 * Author: Mark Lobodzinski <mark@lunarg.com>
23 * Author: Dave Houlton <daveh@lunarg.com>
24 * Author: John Zulauf <jzulauf@lunarg.com>
25 * Author: Tobias Hector <tobias.hector@amd.com>
26 */
27#pragma once
28#include "base_node.h"
29#include "query_state.h"
30#include "command_validation.h"
31#include "hash_vk_types.h"
32#include "subresource_adapter.h"
33#include "image_layout_map.h"
34#include "pipeline_state.h"
35#include "device_state.h"
36#include "descriptor_sets.h"
37#include "qfo_transfer.h"
38
Jeremy Gebben1ec89332021-08-05 13:51:49 -060039struct SUBPASS_INFO;
40class FRAMEBUFFER_STATE;
Jeremy Gebben159b3cc2021-06-03 09:09:03 -060041class RENDER_PASS_STATE;
42class CoreChecks;
43class ValidationStateTracker;
44
45class EVENT_STATE : public BASE_NODE {
46 public:
47 int write_in_use;
48 VkPipelineStageFlags2KHR stageMask = VkPipelineStageFlags2KHR(0);
49 VkEventCreateFlags flags;
50
51 EVENT_STATE(VkEvent event_, VkEventCreateFlags flags_)
52 : BASE_NODE(event_, kVulkanObjectTypeEvent), write_in_use(0), flags(flags_) {}
53
54 VkEvent event() const { return handle_.Cast<VkEvent>(); }
55};
56
57// Only CoreChecks uses this, but the state tracker stores it.
58constexpr static auto kInvalidLayout = image_layout_map::kInvalidLayout;
59using ImageSubresourceLayoutMap = image_layout_map::ImageSubresourceLayoutMap;
60typedef layer_data::unordered_map<VkEvent, VkPipelineStageFlags2KHR> EventToStageMap;
61
62// Track command pools and their command buffers
63class COMMAND_POOL_STATE : public BASE_NODE {
64 public:
Jeremy Gebben1ec89332021-08-05 13:51:49 -060065 const VkCommandPoolCreateFlags createFlags;
66 const uint32_t queueFamilyIndex;
67 const VkQueueFlags queue_flags;
68 const bool unprotected; // can't be used for protected memory
Jeremy Gebben159b3cc2021-06-03 09:09:03 -060069 // Cmd buffers allocated from this pool
70 layer_data::unordered_set<VkCommandBuffer> commandBuffers;
71
72 COMMAND_POOL_STATE(VkCommandPool cp, const VkCommandPoolCreateInfo *pCreateInfo, VkQueueFlags flags)
73 : BASE_NODE(cp, kVulkanObjectTypeCommandPool),
74 createFlags(pCreateInfo->flags),
75 queueFamilyIndex(pCreateInfo->queueFamilyIndex),
Jeremy Gebben1ec89332021-08-05 13:51:49 -060076 queue_flags(flags),
Jeremy Gebben159b3cc2021-06-03 09:09:03 -060077 unprotected((pCreateInfo->flags & VK_COMMAND_POOL_CREATE_PROTECTED_BIT) == 0) {}
78
79 VkCommandPool commandPool() const { return handle_.Cast<VkCommandPool>(); }
80
81 virtual ~COMMAND_POOL_STATE() { Destroy(); }
82
83 void Destroy() override {
84 commandBuffers.clear();
85 BASE_NODE::Destroy();
86 }
87};
88
Jeremy Gebben159b3cc2021-06-03 09:09:03 -060089// Autogenerated as part of the command_validation.h codegen
90const char *CommandTypeString(CMD_TYPE type);
91
92enum CB_STATE {
93 CB_NEW, // Newly created CB w/o any cmds
94 CB_RECORDING, // BeginCB has been called on this CB
95 CB_RECORDED, // EndCB has been called on this CB
96 CB_INVALID_COMPLETE, // had a complete recording, but was since invalidated
97 CB_INVALID_INCOMPLETE, // fouled before recording was completed
98};
99
100// CB Status -- used to track status of various bindings on cmd buffer objects
101typedef uint64_t CBStatusFlags;
102enum CBStatusFlagBits : uint64_t {
103 // clang-format off
104 CBSTATUS_NONE = 0x00000000, // No status is set
105 CBSTATUS_LINE_WIDTH_SET = 0x00000001, // Line width has been set
106 CBSTATUS_DEPTH_BIAS_SET = 0x00000002, // Depth bias has been set
107 CBSTATUS_BLEND_CONSTANTS_SET = 0x00000004, // Blend constants state has been set
108 CBSTATUS_DEPTH_BOUNDS_SET = 0x00000008, // Depth bounds state object has been set
109 CBSTATUS_STENCIL_READ_MASK_SET = 0x00000010, // Stencil read mask has been set
110 CBSTATUS_STENCIL_WRITE_MASK_SET = 0x00000020, // Stencil write mask has been set
111 CBSTATUS_STENCIL_REFERENCE_SET = 0x00000040, // Stencil reference has been set
112 CBSTATUS_VIEWPORT_SET = 0x00000080,
113 CBSTATUS_SCISSOR_SET = 0x00000100,
114 CBSTATUS_INDEX_BUFFER_BOUND = 0x00000200, // Index buffer has been set
115 CBSTATUS_EXCLUSIVE_SCISSOR_SET = 0x00000400,
116 CBSTATUS_SHADING_RATE_PALETTE_SET = 0x00000800,
117 CBSTATUS_LINE_STIPPLE_SET = 0x00001000,
118 CBSTATUS_VIEWPORT_W_SCALING_SET = 0x00002000,
119 CBSTATUS_CULL_MODE_SET = 0x00004000,
120 CBSTATUS_FRONT_FACE_SET = 0x00008000,
121 CBSTATUS_PRIMITIVE_TOPOLOGY_SET = 0x00010000,
122 CBSTATUS_VIEWPORT_WITH_COUNT_SET = 0x00020000,
123 CBSTATUS_SCISSOR_WITH_COUNT_SET = 0x00040000,
124 CBSTATUS_VERTEX_INPUT_BINDING_STRIDE_SET = 0x00080000,
125 CBSTATUS_DEPTH_TEST_ENABLE_SET = 0x00100000,
126 CBSTATUS_DEPTH_WRITE_ENABLE_SET = 0x00200000,
127 CBSTATUS_DEPTH_COMPARE_OP_SET = 0x00400000,
128 CBSTATUS_DEPTH_BOUNDS_TEST_ENABLE_SET = 0x00800000,
129 CBSTATUS_STENCIL_TEST_ENABLE_SET = 0x01000000,
130 CBSTATUS_STENCIL_OP_SET = 0x02000000,
131 CBSTATUS_DISCARD_RECTANGLE_SET = 0x04000000,
132 CBSTATUS_SAMPLE_LOCATIONS_SET = 0x08000000,
133 CBSTATUS_COARSE_SAMPLE_ORDER_SET = 0x10000000,
134 CBSTATUS_PATCH_CONTROL_POINTS_SET = 0x20000000,
135 CBSTATUS_RASTERIZER_DISCARD_ENABLE_SET = 0x40000000,
136 CBSTATUS_DEPTH_BIAS_ENABLE_SET = 0x80000000,
137 CBSTATUS_LOGIC_OP_SET = 0x100000000,
138 CBSTATUS_PRIMITIVE_RESTART_ENABLE_SET = 0x200000000,
139 CBSTATUS_VERTEX_INPUT_SET = 0x400000000,
140 CBSTATUS_ALL_STATE_SET = 0x7FFFFFDFF, // All state set (intentionally exclude index buffer)
141 // clang-format on
142};
143
144VkDynamicState ConvertToDynamicState(CBStatusFlagBits flag);
145CBStatusFlagBits ConvertToCBStatusFlagBits(VkDynamicState state);
146std::string DynamicStateString(CBStatusFlags input_value);
147
148struct BufferBinding {
149 std::shared_ptr<BUFFER_STATE> buffer_state;
150 VkDeviceSize size;
151 VkDeviceSize offset;
152 VkDeviceSize stride;
153
154 BufferBinding() : buffer_state(), size(0), offset(0), stride(0) {}
155 virtual ~BufferBinding() {}
156
157 virtual void reset() { *this = BufferBinding(); }
158};
159
160struct IndexBufferBinding : BufferBinding {
161 VkIndexType index_type;
162
163 IndexBufferBinding() : BufferBinding(), index_type(static_cast<VkIndexType>(0)) {}
164 virtual ~IndexBufferBinding() {}
165
166 virtual void reset() override { *this = IndexBufferBinding(); }
167};
168
169struct CBVertexBufferBindingInfo {
170 std::vector<BufferBinding> vertex_buffer_bindings;
171};
172
173typedef subresource_adapter::BothRangeMap<VkImageLayout, 16> GlobalImageLayoutRangeMap;
174typedef layer_data::unordered_map<VkImage, layer_data::optional<GlobalImageLayoutRangeMap>> GlobalImageLayoutMap;
175
176typedef layer_data::unordered_map<VkImage, layer_data::optional<ImageSubresourceLayoutMap>> CommandBufferImageLayoutMap;
177
Jeremy Gebben159b3cc2021-06-03 09:09:03 -0600178
179class CMD_BUFFER_STATE : public REFCOUNTED_NODE {
180 public:
181 VkCommandBufferAllocateInfo createInfo = {};
182 VkCommandBufferBeginInfo beginInfo;
183 VkCommandBufferInheritanceInfo inheritanceInfo;
184 std::shared_ptr<const COMMAND_POOL_STATE> command_pool;
Jeremy Gebben1ec89332021-08-05 13:51:49 -0600185 ValidationStateTracker *dev_data;
Jeremy Gebben159b3cc2021-06-03 09:09:03 -0600186 bool hasDrawCmd;
187 bool hasTraceRaysCmd;
188 bool hasBuildAccelerationStructureCmd;
189 bool hasDispatchCmd;
190 bool unprotected; // can't be used for protected memory
191
192 CB_STATE state; // Track cmd buffer update state
193 uint64_t commandCount; // Number of commands recorded. Currently only used with VK_KHR_performance_query
194 uint64_t submitCount; // Number of times CB has been submitted
195 typedef uint64_t ImageLayoutUpdateCount;
196 ImageLayoutUpdateCount image_layout_change_count; // The sequence number for changes to image layout (for cached validation)
197 CBStatusFlags status; // Track status of various bindings on cmd buffer
198 CBStatusFlags static_status; // All state bits provided by current graphics pipeline
199 // rather than dynamic state
200 CBStatusFlags dynamic_status; // dynamic state set up in pipeline
201 // Currently storing "lastBound" objects on per-CB basis
202 // long-term may want to create caches of "lastBound" states and could have
203 // each individual CMD_NODE referencing its own "lastBound" state
204 // Store last bound state for Gfx & Compute pipeline bind points
205 std::array<LAST_BOUND_STATE, BindPoint_Count> lastBound; // index is LvlBindPoint.
206
207 struct CmdDrawDispatchInfo {
208 CMD_TYPE cmd_type;
209 std::string function;
210 std::vector<std::pair<const uint32_t, DescriptorRequirement>> binding_infos;
211 VkFramebuffer framebuffer;
212 std::shared_ptr<std::vector<SUBPASS_INFO>> subpasses;
213 std::shared_ptr<std::vector<IMAGE_VIEW_STATE *>> attachments;
214 };
215 layer_data::unordered_map<VkDescriptorSet, std::vector<CmdDrawDispatchInfo>> validate_descriptorsets_in_queuesubmit;
216
217 // If VK_NV_inherited_viewport_scissor is enabled and VkCommandBufferInheritanceViewportScissorInfoNV::viewportScissor2D is
218 // true, then is the nonempty list of viewports passed in pViewportDepths. Otherwise, this is empty.
219 std::vector<VkViewport> inheritedViewportDepths;
220
221 // For each draw command D recorded to this command buffer, let
222 // * g_D be the graphics pipeline used
223 // * v_G be the viewportCount of g_D (0 if g_D disables rasterization or enables VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT)
224 // * s_G be the scissorCount of g_D (0 if g_D disables rasterization or enables VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT)
225 // Then this value is max(0, max(v_G for all D in cb), max(s_G for all D in cb))
226 uint32_t usedViewportScissorCount;
227 uint32_t pipelineStaticViewportCount; // v_G for currently-bound graphics pipeline.
228 uint32_t pipelineStaticScissorCount; // s_G for currently-bound graphics pipeline.
229
230 uint32_t viewportMask;
231 uint32_t viewportWithCountMask;
232 uint32_t viewportWithCountCount;
233 uint32_t scissorMask;
234 uint32_t scissorWithCountMask;
235 uint32_t scissorWithCountCount;
236
237 // Dynamic viewports set in this command buffer; if bit j of viewportMask is set then dynamicViewports[j] is valid, but the
238 // converse need not be true.
239 std::vector<VkViewport> dynamicViewports;
240
241 // Bits set when binding graphics pipeline defining corresponding static state, or executing any secondary command buffer.
242 // Bits unset by calling a corresponding vkCmdSet[State] cmd.
243 uint32_t trashedViewportMask;
244 uint32_t trashedScissorMask;
245 bool trashedViewportCount;
246 bool trashedScissorCount;
247
248 // True iff any draw command recorded to this command buffer consumes dynamic viewport/scissor with count state.
249 bool usedDynamicViewportCount;
250 bool usedDynamicScissorCount;
251
252 uint32_t initial_device_mask;
253 VkPrimitiveTopology primitiveTopology;
254
255 safe_VkRenderPassBeginInfo activeRenderPassBeginInfo;
256 std::shared_ptr<RENDER_PASS_STATE> activeRenderPass;
257 std::shared_ptr<std::vector<SUBPASS_INFO>> active_subpasses;
258 std::shared_ptr<std::vector<IMAGE_VIEW_STATE *>> active_attachments;
259 std::set<std::shared_ptr<IMAGE_VIEW_STATE>> attachments_view_states;
260
261 VkSubpassContents activeSubpassContents;
262 uint32_t active_render_pass_device_mask;
263 uint32_t activeSubpass;
264 std::shared_ptr<FRAMEBUFFER_STATE> activeFramebuffer;
265 layer_data::unordered_set<std::shared_ptr<FRAMEBUFFER_STATE>> framebuffers;
266 // Unified data structs to track objects bound to this command buffer as well as object
267 // dependencies that have been broken : either destroyed objects, or updated descriptor sets
268 layer_data::unordered_set<VulkanTypedHandle> object_bindings;
269 layer_data::unordered_map<VulkanTypedHandle, LogObjectList> broken_bindings;
270
271 QFOTransferBarrierSets<QFOBufferTransferBarrier> qfo_transfer_buffer_barriers;
272 QFOTransferBarrierSets<QFOImageTransferBarrier> qfo_transfer_image_barriers;
273
274 layer_data::unordered_set<VkEvent> waitedEvents;
275 std::vector<VkEvent> writeEventsBeforeWait;
276 std::vector<VkEvent> events;
277 layer_data::unordered_set<QueryObject> activeQueries;
278 layer_data::unordered_set<QueryObject> startedQueries;
279 layer_data::unordered_set<QueryObject> resetQueries;
280 CommandBufferImageLayoutMap image_layout_map;
281 CBVertexBufferBindingInfo current_vertex_buffer_binding_info;
282 bool vertex_buffer_used; // Track for perf warning to make sure any bound vtx buffer used
283 VkCommandBuffer primaryCommandBuffer;
284 // If primary, the secondary command buffers we will call.
285 // If secondary, the primary command buffers we will be called by.
286 layer_data::unordered_set<CMD_BUFFER_STATE *> linkedCommandBuffers;
287 // Validation functions run at primary CB queue submit time
288 std::vector<std::function<bool(const ValidationStateTracker *device_data, const class QUEUE_STATE *queue_state)>>
289 queue_submit_functions;
Hans-Kristian Arntzen59c2c3f2021-06-14 11:40:12 +0200290 // Used by some layers to defer actions until vkCmdEndRenderPass time.
291 // Layers using this are responsible for inserting the callbacks into queue_submit_functions.
292 std::vector<std::function<bool(const ValidationStateTracker *device_data, const class QUEUE_STATE *queue_state)>>
293 queue_submit_functions_after_render_pass;
Jeremy Gebben159b3cc2021-06-03 09:09:03 -0600294 // Validation functions run when secondary CB is executed in primary
295 std::vector<std::function<bool(const CMD_BUFFER_STATE *, const FRAMEBUFFER_STATE *)>> cmd_execute_commands_functions;
296 std::vector<
297 std::function<bool(const ValidationStateTracker *device_data, bool do_validate, EventToStageMap *localEventToStageMap)>>
298 eventUpdates;
299 std::vector<std::function<bool(const ValidationStateTracker *device_data, bool do_validate, VkQueryPool &firstPerfQueryPool,
300 uint32_t perfQueryPass, QueryMap *localQueryToStateMap)>>
301 queryUpdates;
302 layer_data::unordered_set<cvdescriptorset::DescriptorSet *> validated_descriptor_sets;
303 // Contents valid only after an index buffer is bound (CBSTATUS_INDEX_BUFFER_BOUND set)
304 IndexBufferBinding index_buffer_binding;
305 bool performance_lock_acquired = false;
306 bool performance_lock_released = false;
307
308 // Cache of current insert label...
309 LoggingLabel debug_label;
310
311 std::vector<uint8_t> push_constant_data;
312 PushConstantRangesId push_constant_data_ranges;
313
314 std::map<VkShaderStageFlagBits, std::vector<uint8_t>>
315 push_constant_data_update; // vector's value is enum PushConstantByteState.
316 VkPipelineLayout push_constant_pipeline_layout_set;
317
318 // Used for Best Practices tracking
319 uint32_t small_indexed_draw_call_count;
320
321 bool transform_feedback_active{false};
ziga-lunarg40f5fbc2021-08-14 23:06:41 +0200322 bool conditional_rendering_active{false};
Jeremy Gebben159b3cc2021-06-03 09:09:03 -0600323
Jeremy Gebben1ec89332021-08-05 13:51:49 -0600324 CMD_BUFFER_STATE(ValidationStateTracker*, VkCommandBuffer cb, const VkCommandBufferAllocateInfo *pCreateInfo,
325 std::shared_ptr<COMMAND_POOL_STATE> &cmd_pool);
Jeremy Gebben159b3cc2021-06-03 09:09:03 -0600326
327 ~CMD_BUFFER_STATE() { Destroy(); }
328
329 void Destroy() override;
330
331 VkCommandBuffer commandBuffer() const { return handle_.Cast<VkCommandBuffer>(); }
332
Jeremy Gebben159b3cc2021-06-03 09:09:03 -0600333 IMAGE_VIEW_STATE *GetActiveAttachmentImageViewState(uint32_t index);
334 const IMAGE_VIEW_STATE *GetActiveAttachmentImageViewState(uint32_t index) const;
335
336 void AddChild(BASE_NODE *child_node);
337
338 void RemoveChild(BASE_NODE *child_node);
339
340 void Reset();
341
Jeremy Gebben1ec89332021-08-05 13:51:49 -0600342 void IncrementResources();
343
344 void ResetPushConstantDataIfIncompatible(const PIPELINE_LAYOUT_STATE *pipeline_layout_state);
345
Jeremy Gebben159b3cc2021-06-03 09:09:03 -0600346 ImageSubresourceLayoutMap *GetImageSubresourceLayoutMap(const IMAGE_STATE &image_state);
347 const ImageSubresourceLayoutMap *GetImageSubresourceLayoutMap(VkImage image) const;
348
349 const QFOTransferBarrierSets<QFOImageTransferBarrier> &GetQFOBarrierSets(const QFOImageTransferBarrier &type_tag) const {
350 return qfo_transfer_image_barriers;
351 }
352
353 const QFOTransferBarrierSets<QFOBufferTransferBarrier> &GetQFOBarrierSets(const QFOBufferTransferBarrier &type_tag) const {
354 return qfo_transfer_buffer_barriers;
355 }
356
357 QFOTransferBarrierSets<QFOImageTransferBarrier> &GetQFOBarrierSets(const QFOImageTransferBarrier &type_tag) {
358 return qfo_transfer_image_barriers;
359 }
360
361 QFOTransferBarrierSets<QFOBufferTransferBarrier> &GetQFOBarrierSets(const QFOBufferTransferBarrier &type_tag) {
362 return qfo_transfer_buffer_barriers;
363 }
364
365 PIPELINE_STATE *GetCurrentPipeline(VkPipelineBindPoint pipelineBindPoint) const {
366 const auto lv_bind_point = ConvertToLvlBindPoint(pipelineBindPoint);
367 return lastBound[lv_bind_point].pipeline_state;
368 }
369
370 void GetCurrentPipelineAndDesriptorSets(VkPipelineBindPoint pipelineBindPoint, const PIPELINE_STATE **rtn_pipe,
371 const std::vector<LAST_BOUND_STATE::PER_SET> **rtn_sets) const {
372 const auto lv_bind_point = ConvertToLvlBindPoint(pipelineBindPoint);
373 const auto &last_bound_it = lastBound[lv_bind_point];
374 if (!last_bound_it.IsUsing()) {
375 return;
376 }
377 *rtn_pipe = last_bound_it.pipeline_state;
378 *rtn_sets = &(last_bound_it.per_set);
379 }
380
381 VkQueueFlags GetQueueFlags() const {
382 return command_pool->queue_flags;
383 }
384
Jeremy Gebbenefead332021-06-18 08:22:44 -0600385 template <typename Barrier>
Jeremy Gebben7ba56152021-06-18 10:40:10 -0600386 inline bool IsReleaseOp(const Barrier &barrier) const {
387 return (IsTransferOp(barrier)) && (command_pool->queueFamilyIndex == barrier.srcQueueFamilyIndex);
388 }
389 template <typename Barrier>
390 inline bool IsAcquireOp(const Barrier &barrier) const {
391 return (IsTransferOp(barrier)) && (command_pool->queueFamilyIndex == barrier.dstQueueFamilyIndex);
Jeremy Gebbenefead332021-06-18 08:22:44 -0600392 }
393
Jeremy Gebben1ec89332021-08-05 13:51:49 -0600394 void Begin(const VkCommandBufferBeginInfo *pBeginInfo);
395 void End(VkResult result);
396
397 void BeginQuery(const QueryObject &query_obj);
398 void EndQuery(const QueryObject &query_obj);
399 void EndQueries(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount);
400 void ResetQueryPool(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount);
401
402 void BeginRenderPass(const VkRenderPassBeginInfo *pRenderPassBegin, VkSubpassContents contents);
403 void NextSubpass(VkSubpassContents contents);
404 void EndRenderPass();
405
406 void ExecuteCommands(uint32_t commandBuffersCount, const VkCommandBuffer *pCommandBuffers);
407
408 void UpdateLastBoundDescriptorSets(VkPipelineBindPoint pipeline_bind_point, const PIPELINE_LAYOUT_STATE *pipeline_layout,
409 uint32_t first_set, uint32_t set_count, const VkDescriptorSet *pDescriptorSets,
410 cvdescriptorset::DescriptorSet *push_descriptor_set, uint32_t dynamic_offset_count,
411 const uint32_t *p_dynamic_offsets);
412
413 void PushDescriptorSetState(VkPipelineBindPoint pipelineBindPoint, PIPELINE_LAYOUT_STATE *pipeline_layout, uint32_t set,
414 uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites);
415
416 void UpdateStateCmdDrawDispatchType(CMD_TYPE cmd_type, VkPipelineBindPoint bind_point, const char *function);
417 void UpdateStateCmdDrawType(CMD_TYPE cmd_type, VkPipelineBindPoint bind_point, const char *function);
418 void UpdateDrawState(CMD_TYPE cmd_type, const VkPipelineBindPoint bind_point, const char *function);
419
420 void SetImageViewLayout(const IMAGE_VIEW_STATE &view_state, VkImageLayout layout, VkImageLayout layoutStencil);
421 void SetImageViewInitialLayout(const IMAGE_VIEW_STATE &view_state, VkImageLayout layout);
422
423 void SetImageLayout(const IMAGE_STATE &image_state, const VkImageSubresourceRange &image_subresource_range,
424 VkImageLayout layout, VkImageLayout expected_layout = kInvalidLayout);
425 void SetImageLayout(const IMAGE_STATE &image_state, const VkImageSubresourceLayers &image_subresource_layers,
426 VkImageLayout layout);
427 void SetImageInitialLayout(VkImage image, const VkImageSubresourceRange &range, VkImageLayout layout);
428 void SetImageInitialLayout(const IMAGE_STATE &image_state, const VkImageSubresourceRange &range, VkImageLayout layout);
429 void SetImageInitialLayout(const IMAGE_STATE &image_state, const VkImageSubresourceLayers &layers, VkImageLayout layout);
430
Jeremy Gebben159b3cc2021-06-03 09:09:03 -0600431 protected:
432 void NotifyInvalidate(const LogObjectList &invalid_handles, bool unlink) override;
Jeremy Gebben1ec89332021-08-05 13:51:49 -0600433 void UpdateAttachmentsView(const VkRenderPassBeginInfo *pRenderPassBegin);
Jeremy Gebben159b3cc2021-06-03 09:09:03 -0600434};
Jeremy Gebben7ba56152021-06-18 10:40:10 -0600435
436// specializations for barriers that cannot do queue family ownership transfers
437template <>
438inline bool CMD_BUFFER_STATE::IsReleaseOp(const VkMemoryBarrier &barrier) const {
439 return false;
440}
441template <>
442inline bool CMD_BUFFER_STATE::IsReleaseOp(const VkMemoryBarrier2KHR &barrier) const {
443 return false;
444}
445template <>
446inline bool CMD_BUFFER_STATE::IsReleaseOp(const VkSubpassDependency2 &barrier) const {
447 return false;
448}
449template <>
450inline bool CMD_BUFFER_STATE::IsAcquireOp(const VkMemoryBarrier &barrier) const {
451 return false;
452}
453template <>
454inline bool CMD_BUFFER_STATE::IsAcquireOp(const VkMemoryBarrier2KHR &barrier) const {
455 return false;
456}
457template <>
458inline bool CMD_BUFFER_STATE::IsAcquireOp(const VkSubpassDependency2 &barrier) const {
459 return false;
460}