1 // 2 // Copyright 2021 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // vk_command_buffer_utils: 7 // Helpers for secondary command buffer implementations. 8 // 9 10 #ifndef LIBANGLE_RENDERER_VULKAN_VK_COMMAND_BUFFER_UTILS_H_ 11 #define LIBANGLE_RENDERER_VULKAN_VK_COMMAND_BUFFER_UTILS_H_ 12 13 #include "common/PackedEnums.h" 14 #include "common/angleutils.h" 15 16 namespace rx 17 { 18 namespace vk 19 { 20 21 enum class ProtectionType : uint8_t 22 { 23 Unprotected = 0, 24 Protected = 1, 25 26 InvalidEnum = 2, 27 EnumCount = 2, 28 }; 29 30 using ProtectionTypes = angle::PackedEnumBitSet<ProtectionType, uint8_t>; 31 ConvertProtectionBoolToType(bool isProtected)32ANGLE_INLINE ProtectionType ConvertProtectionBoolToType(bool isProtected) 33 { 34 return (isProtected ? ProtectionType::Protected : ProtectionType::Unprotected); 35 } 36 37 // A helper class to track commands recorded to a command buffer. 38 class CommandBufferCommandTracker 39 { 40 public: onDraw()41 void onDraw() { ++mRenderPassWriteCommandCount; } onClearAttachments()42 void onClearAttachments() { ++mRenderPassWriteCommandCount; } getRenderPassWriteCommandCount()43 uint32_t getRenderPassWriteCommandCount() const { return mRenderPassWriteCommandCount; } 44 reset()45 void reset() { *this = CommandBufferCommandTracker{}; } 46 47 private: 48 // The number of commands recorded that can modify a render pass attachment, i.e. 49 // vkCmdClearAttachment and vkCmdDraw*. Used to know if a command might have written to an 50 // attachment after it was invalidated. 51 uint32_t mRenderPassWriteCommandCount = 0; 52 }; 53 54 } // namespace vk 55 } // namespace rx 56 57 #endif // LIBANGLE_RENDERER_VULKAN_VK_COMMAND_BUFFER_UTILS_H_ 58