Add test group for the VK_KHR_protected_memory extension
authorPeter Gal <pgal.u-szeged@partner.samsung.com>
Fri, 19 May 2017 15:16:23 +0000 (17:16 +0200)
committerPeter Gal <pgal.u-szeged@partner.samsung.com>
Thu, 7 Sep 2017 16:53:46 +0000 (18:53 +0200)
* Added framework update for the extension.
* Created basic structure for the VK_KHR_protected_memory extension tests.
* Created a ProtectedContext class which contains the required instance and device
  initializations for the protected test cases.
* Created a simple test case(s) where a protected attachment clearing
  on render pass start is tested.

New tests:
* dEQP-VK.protected_memory.attachment.load_op.*

Components: Vulkan, Framework
VK-GL-CTS issue: 118

Change-Id: I42e8b4f05c3a71c1c3bbc56894e33f5a46b735c6

23 files changed:
AndroidGen.mk
android/cts/master/vk-master.txt
external/vulkancts/framework/vulkan/vkBasicTypes.inl
external/vulkancts/framework/vulkan/vkGetStructureTypeImpl.inl
external/vulkancts/framework/vulkan/vkMemUtil.cpp
external/vulkancts/framework/vulkan/vkMemUtil.hpp
external/vulkancts/framework/vulkan/vkStrUtil.inl
external/vulkancts/framework/vulkan/vkStrUtilImpl.inl
external/vulkancts/framework/vulkan/vkStructTypes.inl
external/vulkancts/modules/vulkan/CMakeLists.txt
external/vulkancts/modules/vulkan/protected_memory/CMakeLists.txt [new file with mode: 0644]
external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentLoadTests.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentLoadTests.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemContext.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemImageValidator.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemImageValidator.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemTests.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemTests.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemUtils.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemUtils.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/vktTestPackage.cpp
external/vulkancts/mustpass/1.0.3/vk-default.txt
external/vulkancts/scripts/src/vulkan.h.in

index da12c01..c5fc3e4 100644 (file)
@@ -163,6 +163,10 @@ LOCAL_SRC_FILES := \
        external/vulkancts/modules/vulkan/pipeline/vktPipelineTimestampTests.cpp \
        external/vulkancts/modules/vulkan/pipeline/vktPipelineVertexInputTests.cpp \
        external/vulkancts/modules/vulkan/pipeline/vktPipelineVertexUtil.cpp \
+       external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentLoadTests.cpp \
+       external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemImageValidator.cpp \
+       external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemTests.cpp \
+       external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemUtils.cpp \
        external/vulkancts/modules/vulkan/query_pool/vktQueryPoolOcclusionTests.cpp \
        external/vulkancts/modules/vulkan/query_pool/vktQueryPoolStatisticsTests.cpp \
        external/vulkancts/modules/vulkan/query_pool/vktQueryPoolTests.cpp \
@@ -995,6 +999,7 @@ LOCAL_C_INCLUDES := \
        $(deqp_dir)/external/vulkancts/modules/vulkan/memory \
        $(deqp_dir)/external/vulkancts/modules/vulkan/multiview \
        $(deqp_dir)/external/vulkancts/modules/vulkan/pipeline \
+       $(deqp_dir)/external/vulkancts/modules/vulkan/protected_memory \
        $(deqp_dir)/external/vulkancts/modules/vulkan/query_pool \
        $(deqp_dir)/external/vulkancts/modules/vulkan/rasterization \
        $(deqp_dir)/external/vulkancts/modules/vulkan/renderpass \
index d294fa2..0d584d3 100644 (file)
@@ -265293,3 +265293,20 @@ dEQP-VK.ycbcr.copy.g16_b16_r16_3plane_444_unorm_khr.g16_b16_r16_3plane_444_unorm
 dEQP-VK.ycbcr.copy.g16_b16_r16_3plane_444_unorm_khr.g16_b16_r16_3plane_444_unorm_khr.optimal_optimal_disjoint
 dEQP-VK.ycbcr.copy.g16_b16_r16_3plane_444_unorm_khr.g16_b16_r16_3plane_444_unorm_khr.optimal_disjoint_optimal
 dEQP-VK.ycbcr.copy.g16_b16_r16_3plane_444_unorm_khr.g16_b16_r16_3plane_444_unorm_khr.optimal_disjoint_optimal_disjoint
+dEQP-VK.protected_memory.attachment.load_op.static.clear_1
+dEQP-VK.protected_memory.attachment.load_op.static.clear_2
+dEQP-VK.protected_memory.attachment.load_op.static.clear_3
+dEQP-VK.protected_memory.attachment.load_op.static.clear_4
+dEQP-VK.protected_memory.attachment.load_op.static.clear_5
+dEQP-VK.protected_memory.attachment.load_op.static.clear_6
+dEQP-VK.protected_memory.attachment.load_op.static.clear_7
+dEQP-VK.protected_memory.attachment.load_op.random.clear_1
+dEQP-VK.protected_memory.attachment.load_op.random.clear_2
+dEQP-VK.protected_memory.attachment.load_op.random.clear_3
+dEQP-VK.protected_memory.attachment.load_op.random.clear_4
+dEQP-VK.protected_memory.attachment.load_op.random.clear_5
+dEQP-VK.protected_memory.attachment.load_op.random.clear_6
+dEQP-VK.protected_memory.attachment.load_op.random.clear_7
+dEQP-VK.protected_memory.attachment.load_op.random.clear_8
+dEQP-VK.protected_memory.attachment.load_op.random.clear_9
+dEQP-VK.protected_memory.attachment.load_op.random.clear_10
index df5cd61..fbc1fbd 100644 (file)
@@ -238,6 +238,9 @@ enum VkStructureType
        VK_STRUCTURE_TYPE_MEMORY_GET_ANDROID_HARDWARE_BUFFER_INFO_ANDROID                               = 1000129004,
        VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_EXTERNAL_FORMAT_PROPERTIES_ANDROID    = 1000129005,
        VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID                                                                               = 1000129006,
+       VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO_KHR                                                                             = 1000145000,
+       VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES_KHR                                 = 1000145001,
+       VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES_KHR                               = 1000145002,
        VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR                                                 = 1000146000,
        VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR                                                  = 1000146001,
        VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR                                                             = 1000147000,
@@ -1047,6 +1050,7 @@ enum VkImageCreateFlagBits
        VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR                          = 0x00000100,
        VK_IMAGE_CREATE_ALIAS_BIT_KHR                                           = 0x00000400,
        VK_IMAGE_CREATE_DISJOINT_BIT_KHR                                        = 0x00000200,
+       VK_IMAGE_CREATE_PROTECTED_BIT_KHR                                       = 0x00000800,
 };
 typedef deUint32 VkImageCreateFlags;
 
@@ -1068,6 +1072,7 @@ enum VkQueueFlagBits
        VK_QUEUE_COMPUTE_BIT            = 0x00000002,
        VK_QUEUE_TRANSFER_BIT           = 0x00000004,
        VK_QUEUE_SPARSE_BINDING_BIT     = 0x00000008,
+       VK_QUEUE_PROTECTED_BIT_KHR      = 0x00000010,
 };
 typedef deUint32 VkQueueFlags;
 
@@ -1078,6 +1083,7 @@ enum VkMemoryPropertyFlagBits
        VK_MEMORY_PROPERTY_HOST_COHERENT_BIT    = 0x00000004,
        VK_MEMORY_PROPERTY_HOST_CACHED_BIT              = 0x00000008,
        VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 0x00000010,
+       VK_MEMORY_PROPERTY_PROTECTED_BIT_KHR    = 0x00000020,
 };
 typedef deUint32 VkMemoryPropertyFlags;
 
@@ -1088,6 +1094,12 @@ enum VkMemoryHeapFlagBits
 };
 typedef deUint32 VkMemoryHeapFlags;
 
+enum VkDeviceQueueCreateFlagBits
+{
+       VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT_KHR        = 0x00000001,
+};
+typedef deUint32 VkDeviceQueueCreateFlags;
+
 enum VkPipelineStageFlagBits
 {
        VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT                                               = 0x00000001,
@@ -1172,6 +1184,7 @@ enum VkBufferCreateFlagBits
        VK_BUFFER_CREATE_SPARSE_BINDING_BIT             = 0x00000001,
        VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT   = 0x00000002,
        VK_BUFFER_CREATE_SPARSE_ALIASED_BIT             = 0x00000004,
+       VK_BUFFER_CREATE_PROTECTED_BIT_KHR              = 0x00000008,
 };
 typedef deUint32 VkBufferCreateFlags;
 
@@ -1284,6 +1297,7 @@ enum VkCommandPoolCreateFlagBits
 {
        VK_COMMAND_POOL_CREATE_TRANSIENT_BIT                    = 0x00000001,
        VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 0x00000002,
+       VK_COMMAND_POOL_CREATE_PROTECTED_BIT_KHR                = 0x00000004,
 };
 typedef deUint32 VkCommandPoolCreateFlags;
 
@@ -1476,8 +1490,6 @@ typedef deUint32 VkInstanceCreateFlags;
 
 typedef deUint32 VkDeviceCreateFlags;
 
-typedef deUint32 VkDeviceQueueCreateFlags;
-
 typedef deUint32 VkMemoryMapFlags;
 
 typedef deUint32 VkSemaphoreCreateFlags;
index 55d7650..900d55e 100644 (file)
@@ -451,6 +451,21 @@ template<> VkStructureType getStructureType<VkMemoryDedicatedAllocateInfoKHR> (v
        return VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR;
 }
 
+template<> VkStructureType getStructureType<VkProtectedSubmitInfoKHR> (void)
+{
+       return VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO_KHR;
+}
+
+template<> VkStructureType getStructureType<VkPhysicalDeviceProtectedMemoryFeaturesKHR> (void)
+{
+       return VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES_KHR;
+}
+
+template<> VkStructureType getStructureType<VkPhysicalDeviceProtectedMemoryPropertiesKHR> (void)
+{
+       return VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES_KHR;
+}
+
 template<> VkStructureType getStructureType<VkBufferMemoryRequirementsInfo2KHR> (void)
 {
        return VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR;
index 78ea104..99fb644 100644 (file)
@@ -105,6 +105,7 @@ const MemoryRequirement MemoryRequirement::Any                              = MemoryRequirement(0x0u);
 const MemoryRequirement MemoryRequirement::HostVisible         = MemoryRequirement(MemoryRequirement::FLAG_HOST_VISIBLE);
 const MemoryRequirement MemoryRequirement::Coherent                    = MemoryRequirement(MemoryRequirement::FLAG_COHERENT);
 const MemoryRequirement MemoryRequirement::LazilyAllocated     = MemoryRequirement(MemoryRequirement::FLAG_LAZY_ALLOCATION);
+const MemoryRequirement MemoryRequirement::Protected           = MemoryRequirement(MemoryRequirement::FLAG_PROTECTED);
 
 bool MemoryRequirement::matchesHeap (VkMemoryPropertyFlags heapFlags) const
 {
@@ -113,6 +114,8 @@ bool MemoryRequirement::matchesHeap (VkMemoryPropertyFlags heapFlags) const
                DE_FATAL("Coherent memory must be host-visible");
        if ((m_flags & FLAG_HOST_VISIBLE) && (m_flags & FLAG_LAZY_ALLOCATION))
                DE_FATAL("Lazily allocated memory cannot be mappable");
+       if ((m_flags & FLAG_PROTECTED) && (m_flags & FLAG_HOST_VISIBLE))
+               DE_FATAL("Protected memory cannot be mappable");
 
        // host-visible
        if ((m_flags & FLAG_HOST_VISIBLE) && !(heapFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))
@@ -126,6 +129,10 @@ bool MemoryRequirement::matchesHeap (VkMemoryPropertyFlags heapFlags) const
        if ((m_flags & FLAG_LAZY_ALLOCATION) && !(heapFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT))
                return false;
 
+       // protected
+       if ((m_flags & FLAG_PROTECTED) && !(heapFlags & VK_MEMORY_PROPERTY_PROTECTED_BIT_KHR))
+               return false;
+
        return true;
 }
 
index 91b1b83..9c3638f 100644 (file)
@@ -79,6 +79,7 @@ public:
        static const MemoryRequirement  HostVisible;
        static const MemoryRequirement  Coherent;
        static const MemoryRequirement  LazilyAllocated;
+       static const MemoryRequirement  Protected;
 
        inline MemoryRequirement                operator|                       (MemoryRequirement requirement) const
        {
@@ -104,6 +105,7 @@ private:
                FLAG_HOST_VISIBLE               = 1u << 0u,
                FLAG_COHERENT                   = 1u << 1u,
                FLAG_LAZY_ALLOCATION    = 1u << 2u,
+               FLAG_PROTECTED                  = 1u << 3u,
        };
 };
 
index be615e0..cc96ab5 100644 (file)
@@ -149,6 +149,7 @@ tcu::Format::Bitfield<32>   getSampleCountFlagsStr                                                  (VkSampleCountFlags value
 tcu::Format::Bitfield<32>      getQueueFlagsStr                                                                (VkQueueFlags value);
 tcu::Format::Bitfield<32>      getMemoryPropertyFlagsStr                                               (VkMemoryPropertyFlags value);
 tcu::Format::Bitfield<32>      getMemoryHeapFlagsStr                                                   (VkMemoryHeapFlags value);
+tcu::Format::Bitfield<32>      getDeviceQueueCreateFlagsStr                                    (VkDeviceQueueCreateFlags value);
 tcu::Format::Bitfield<32>      getPipelineStageFlagsStr                                                (VkPipelineStageFlags value);
 tcu::Format::Bitfield<32>      getImageAspectFlagsStr                                                  (VkImageAspectFlags value);
 tcu::Format::Bitfield<32>      getSparseImageFormatFlagsStr                                    (VkSparseImageFormatFlags value);
@@ -193,7 +194,6 @@ tcu::Format::Bitfield<32>   getMemoryAllocateFlagsKHXStr                                    (VkMemoryAllocateFlag
 tcu::Format::Bitfield<32>      getDeviceGroupPresentModeFlagsKHXStr                    (VkDeviceGroupPresentModeFlagsKHX value);
 tcu::Format::Bitfield<32>      getInstanceCreateFlagsStr                                               (VkInstanceCreateFlags value);
 tcu::Format::Bitfield<32>      getDeviceCreateFlagsStr                                                 (VkDeviceCreateFlags value);
-tcu::Format::Bitfield<32>      getDeviceQueueCreateFlagsStr                                    (VkDeviceQueueCreateFlags value);
 tcu::Format::Bitfield<32>      getMemoryMapFlagsStr                                                    (VkMemoryMapFlags value);
 tcu::Format::Bitfield<32>      getSemaphoreCreateFlagsStr                                              (VkSemaphoreCreateFlags value);
 tcu::Format::Bitfield<32>      getEventCreateFlagsStr                                                  (VkEventCreateFlags value);
@@ -389,6 +389,9 @@ std::ostream&       operator<<      (std::ostream& s, const VkImportFenceFdInfoKHR& value);
 std::ostream&  operator<<      (std::ostream& s, const VkFenceGetFdInfoKHR& value);
 std::ostream&  operator<<      (std::ostream& s, const VkMemoryDedicatedRequirementsKHR& value);
 std::ostream&  operator<<      (std::ostream& s, const VkMemoryDedicatedAllocateInfoKHR& value);
+std::ostream&  operator<<      (std::ostream& s, const VkProtectedSubmitInfoKHR& value);
+std::ostream&  operator<<      (std::ostream& s, const VkPhysicalDeviceProtectedMemoryFeaturesKHR& value);
+std::ostream&  operator<<      (std::ostream& s, const VkPhysicalDeviceProtectedMemoryPropertiesKHR& value);
 std::ostream&  operator<<      (std::ostream& s, const VkBufferMemoryRequirementsInfo2KHR& value);
 std::ostream&  operator<<      (std::ostream& s, const VkImageMemoryRequirementsInfo2KHR& value);
 std::ostream&  operator<<      (std::ostream& s, const VkImageSparseMemoryRequirementsInfo2KHR& value);
index de3e622..e211a20 100644 (file)
@@ -249,6 +249,9 @@ const char* getStructureTypeName (VkStructureType value)
                case VK_STRUCTURE_TYPE_MEMORY_GET_ANDROID_HARDWARE_BUFFER_INFO_ANDROID:                         return "VK_STRUCTURE_TYPE_MEMORY_GET_ANDROID_HARDWARE_BUFFER_INFO_ANDROID";
                case VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_EXTERNAL_FORMAT_PROPERTIES_ANDROID:      return "VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_EXTERNAL_FORMAT_PROPERTIES_ANDROID";
                case VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID:                                                                         return "VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID";
+               case VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO_KHR:                                                                       return "VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO_KHR";
+               case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES_KHR:                           return "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES_KHR";
+               case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES_KHR:                         return "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES_KHR";
                case VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR:                                           return "VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR";
                case VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR:                                            return "VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR";
                case VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR:                                                       return "VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR";
@@ -1166,6 +1169,7 @@ tcu::Format::Bitfield<32> getImageCreateFlagsStr (VkImageCreateFlags value)
                tcu::Format::BitDesc(VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR,                            "VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR"),
                tcu::Format::BitDesc(VK_IMAGE_CREATE_ALIAS_BIT_KHR,                                                     "VK_IMAGE_CREATE_ALIAS_BIT_KHR"),
                tcu::Format::BitDesc(VK_IMAGE_CREATE_DISJOINT_BIT_KHR,                                          "VK_IMAGE_CREATE_DISJOINT_BIT_KHR"),
+               tcu::Format::BitDesc(VK_IMAGE_CREATE_PROTECTED_BIT_KHR,                                         "VK_IMAGE_CREATE_PROTECTED_BIT_KHR"),
        };
        return tcu::Format::Bitfield<32>(value, DE_ARRAY_BEGIN(s_desc), DE_ARRAY_END(s_desc));
 }
@@ -1193,6 +1197,7 @@ tcu::Format::Bitfield<32> getQueueFlagsStr (VkQueueFlags value)
                tcu::Format::BitDesc(VK_QUEUE_COMPUTE_BIT,                      "VK_QUEUE_COMPUTE_BIT"),
                tcu::Format::BitDesc(VK_QUEUE_TRANSFER_BIT,                     "VK_QUEUE_TRANSFER_BIT"),
                tcu::Format::BitDesc(VK_QUEUE_SPARSE_BINDING_BIT,       "VK_QUEUE_SPARSE_BINDING_BIT"),
+               tcu::Format::BitDesc(VK_QUEUE_PROTECTED_BIT_KHR,        "VK_QUEUE_PROTECTED_BIT_KHR"),
        };
        return tcu::Format::Bitfield<32>(value, DE_ARRAY_BEGIN(s_desc), DE_ARRAY_END(s_desc));
 }
@@ -1206,6 +1211,7 @@ tcu::Format::Bitfield<32> getMemoryPropertyFlagsStr (VkMemoryPropertyFlags value
                tcu::Format::BitDesc(VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,              "VK_MEMORY_PROPERTY_HOST_COHERENT_BIT"),
                tcu::Format::BitDesc(VK_MEMORY_PROPERTY_HOST_CACHED_BIT,                "VK_MEMORY_PROPERTY_HOST_CACHED_BIT"),
                tcu::Format::BitDesc(VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT,   "VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT"),
+               tcu::Format::BitDesc(VK_MEMORY_PROPERTY_PROTECTED_BIT_KHR,              "VK_MEMORY_PROPERTY_PROTECTED_BIT_KHR"),
        };
        return tcu::Format::Bitfield<32>(value, DE_ARRAY_BEGIN(s_desc), DE_ARRAY_END(s_desc));
 }
@@ -1220,6 +1226,15 @@ tcu::Format::Bitfield<32> getMemoryHeapFlagsStr (VkMemoryHeapFlags value)
        return tcu::Format::Bitfield<32>(value, DE_ARRAY_BEGIN(s_desc), DE_ARRAY_END(s_desc));
 }
 
+tcu::Format::Bitfield<32> getDeviceQueueCreateFlagsStr (VkDeviceQueueCreateFlags value)
+{
+       static const tcu::Format::BitDesc s_desc[] =
+       {
+               tcu::Format::BitDesc(VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT_KHR,  "VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT_KHR"),
+       };
+       return tcu::Format::Bitfield<32>(value, DE_ARRAY_BEGIN(s_desc), DE_ARRAY_END(s_desc));
+}
+
 tcu::Format::Bitfield<32> getPipelineStageFlagsStr (VkPipelineStageFlags value)
 {
        static const tcu::Format::BitDesc s_desc[] =
@@ -1327,6 +1342,7 @@ tcu::Format::Bitfield<32> getBufferCreateFlagsStr (VkBufferCreateFlags value)
                tcu::Format::BitDesc(VK_BUFFER_CREATE_SPARSE_BINDING_BIT,       "VK_BUFFER_CREATE_SPARSE_BINDING_BIT"),
                tcu::Format::BitDesc(VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT,     "VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT"),
                tcu::Format::BitDesc(VK_BUFFER_CREATE_SPARSE_ALIASED_BIT,       "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT"),
+               tcu::Format::BitDesc(VK_BUFFER_CREATE_PROTECTED_BIT_KHR,        "VK_BUFFER_CREATE_PROTECTED_BIT_KHR"),
        };
        return tcu::Format::Bitfield<32>(value, DE_ARRAY_BEGIN(s_desc), DE_ARRAY_END(s_desc));
 }
@@ -1475,6 +1491,7 @@ tcu::Format::Bitfield<32> getCommandPoolCreateFlagsStr (VkCommandPoolCreateFlags
        {
                tcu::Format::BitDesc(VK_COMMAND_POOL_CREATE_TRANSIENT_BIT,                              "VK_COMMAND_POOL_CREATE_TRANSIENT_BIT"),
                tcu::Format::BitDesc(VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,   "VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT"),
+               tcu::Format::BitDesc(VK_COMMAND_POOL_CREATE_PROTECTED_BIT_KHR,                  "VK_COMMAND_POOL_CREATE_PROTECTED_BIT_KHR"),
        };
        return tcu::Format::Bitfield<32>(value, DE_ARRAY_BEGIN(s_desc), DE_ARRAY_END(s_desc));
 }
@@ -1740,11 +1757,6 @@ tcu::Format::Bitfield<32> getDeviceCreateFlagsStr (VkDeviceCreateFlags value)
        return tcu::Format::Bitfield<32>(value, DE_NULL, DE_NULL);
 }
 
-tcu::Format::Bitfield<32> getDeviceQueueCreateFlagsStr (VkDeviceQueueCreateFlags value)
-{
-       return tcu::Format::Bitfield<32>(value, DE_NULL, DE_NULL);
-}
-
 tcu::Format::Bitfield<32> getMemoryMapFlagsStr (VkMemoryMapFlags value)
 {
        return tcu::Format::Bitfield<32>(value, DE_NULL, DE_NULL);
@@ -4047,6 +4059,36 @@ std::ostream& operator<< (std::ostream& s, const VkMemoryDedicatedAllocateInfoKH
        return s;
 }
 
+std::ostream& operator<< (std::ostream& s, const VkProtectedSubmitInfoKHR& value)
+{
+       s << "VkProtectedSubmitInfoKHR = {\n";
+       s << "\tsType = " << value.sType << '\n';
+       s << "\tpNext = " << value.pNext << '\n';
+       s << "\tprotectedSubmit = " << value.protectedSubmit << '\n';
+       s << '}';
+       return s;
+}
+
+std::ostream& operator<< (std::ostream& s, const VkPhysicalDeviceProtectedMemoryFeaturesKHR& value)
+{
+       s << "VkPhysicalDeviceProtectedMemoryFeaturesKHR = {\n";
+       s << "\tsType = " << value.sType << '\n';
+       s << "\tpNext = " << value.pNext << '\n';
+       s << "\tprotectedMemory = " << value.protectedMemory << '\n';
+       s << '}';
+       return s;
+}
+
+std::ostream& operator<< (std::ostream& s, const VkPhysicalDeviceProtectedMemoryPropertiesKHR& value)
+{
+       s << "VkPhysicalDeviceProtectedMemoryPropertiesKHR = {\n";
+       s << "\tsType = " << value.sType << '\n';
+       s << "\tpNext = " << value.pNext << '\n';
+       s << "\tprotectedNoFault = " << value.protectedNoFault << '\n';
+       s << '}';
+       return s;
+}
+
 std::ostream& operator<< (std::ostream& s, const VkBufferMemoryRequirementsInfo2KHR& value)
 {
        s << "VkBufferMemoryRequirementsInfo2KHR = {\n";
index ab3b068..806dde2 100644 (file)
@@ -1655,6 +1655,27 @@ struct VkMemoryDedicatedAllocateInfoKHR
        VkBuffer                buffer;
 };
 
+struct VkProtectedSubmitInfoKHR
+{
+       VkStructureType sType;
+       const void*             pNext;
+       VkBool32                protectedSubmit;
+};
+
+struct VkPhysicalDeviceProtectedMemoryFeaturesKHR
+{
+       VkStructureType sType;
+       void*                   pNext;
+       VkBool32                protectedMemory;
+};
+
+struct VkPhysicalDeviceProtectedMemoryPropertiesKHR
+{
+       VkStructureType sType;
+       void*                   pNext;
+       VkBool32                protectedNoFault;
+};
+
 struct VkBufferMemoryRequirementsInfo2KHR
 {
        VkStructureType sType;
index e2ce486..401ca29 100644 (file)
@@ -28,6 +28,7 @@ add_subdirectory(renderpass)
 add_subdirectory(multiview)
 add_subdirectory(subgroups)
 add_subdirectory(ycbcr)
+add_subdirectory(protected_memory)
 
 include_directories(
        api
@@ -58,6 +59,7 @@ include_directories(
        multiview
        subgroups
        ycbcr
+       protected_memory
        )
 
 set(DEQP_VK_SRCS
@@ -113,6 +115,7 @@ set(DEQP_VK_LIBS
        deqp-vk-multiview
        deqp-vk-subgroups
        deqp-vk-ycbcr
+       deqp-vk-protected-memory
        )
 
 if (DE_COMPILER_IS_MSC AND (DE_PTR_SIZE EQUAL 4))
diff --git a/external/vulkancts/modules/vulkan/protected_memory/CMakeLists.txt b/external/vulkancts/modules/vulkan/protected_memory/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9eef019
--- /dev/null
@@ -0,0 +1,21 @@
+include_directories(..)
+
+set(DEQP_VK_PROTECTED_MEMORY_SRCS
+       vktProtectedMemContext.hpp
+       vktProtectedMemUtils.cpp
+       vktProtectedMemUtils.hpp
+       vktProtectedMemImageValidator.cpp
+       vktProtectedMemImageValidator.hpp
+       vktProtectedMemAttachmentLoadTests.cpp
+       vktProtectedMemAttachmentLoadTests.hpp
+       vktProtectedMemTests.cpp
+       vktProtectedMemTests.hpp
+       )
+
+set(DEQP_VK_PROTECTED_MEMORY_LIBS
+       tcutil
+       vkutil
+       )
+
+add_library(deqp-vk-protected-memory STATIC ${DEQP_VK_PROTECTED_MEMORY_SRCS})
+target_link_libraries(deqp-vk-protected-memory ${DEQP_VK_PROTECTED_MEMORY_LIBS})
diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentLoadTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentLoadTests.cpp
new file mode 100644 (file)
index 0000000..79b7386
--- /dev/null
@@ -0,0 +1,337 @@
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2017 The Khronos Group Inc.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Protected memory attachment render pass load tests
+ *//*--------------------------------------------------------------------*/
+
+#include "vktProtectedMemAttachmentLoadTests.hpp"
+
+#include "deRandom.hpp"
+#include "tcuTestLog.hpp"
+#include "tcuVector.hpp"
+
+#include "vkPrograms.hpp"
+#include "vktTestCase.hpp"
+#include "vktTestGroupUtil.hpp"
+#include "vkTypeUtil.hpp"
+#include "vkBuilderUtil.hpp"
+
+#include "vktProtectedMemContext.hpp"
+#include "vktProtectedMemUtils.hpp"
+#include "vktProtectedMemImageValidator.hpp"
+
+namespace vkt
+{
+namespace ProtectedMem
+{
+
+namespace
+{
+
+enum {
+       RENDER_WIDTH    = 128,
+       RENDER_HEIGHT   = 128,
+};
+
+
+class AttachmentLoadTestInstance : public ProtectedTestInstance
+{
+public:
+                                                               AttachmentLoadTestInstance      (Context&                                       ctx,
+                                                                                                                        const vk::VkClearValue&        clearValue,
+                                                                                                                        const ValidationData&          refData,
+                                                                                                                        const ImageValidator&          validator);
+       virtual tcu::TestStatus         iterate                                         (void);
+
+private:
+       const vk::VkFormat                      m_imageFormat;
+       const vk::VkClearValue&         m_clearValue;
+       const ValidationData&           m_refData;
+       const ImageValidator&           m_validator;
+};
+
+
+class AttachmentLoadTestCase : public TestCase
+{
+public:
+                                                       AttachmentLoadTestCase  (tcu::TestContext&              testCtx,
+                                                                                                        const std::string&             name,
+                                                                                                        vk::VkClearValue               clearValue,
+                                                                                                        ValidationData                 data)
+                                                               : TestCase              (testCtx, name, "Clear on render pass initialization.")
+                                                               , m_clearValue  (clearValue)
+                                                               , m_refData             (data)
+                                                       {
+                                                       }
+
+       virtual                                 ~AttachmentLoadTestCase (void) {}
+       virtual TestInstance*   createInstance  (Context&                               ctx) const
+                                                       {
+                                                               return new AttachmentLoadTestInstance(ctx, m_clearValue, m_refData, m_validator);
+                                                       }
+       virtual void                    initPrograms    (vk::SourceCollections& programCollection) const
+                                                       {
+                                                               m_validator.initPrograms(programCollection);
+                                                       }
+private:
+       vk::VkClearValue                m_clearValue;
+       ValidationData                  m_refData;
+       ImageValidator                  m_validator;
+};
+
+AttachmentLoadTestInstance::AttachmentLoadTestInstance (Context&                                       ctx,
+                                                                                                                const vk::VkClearValue&        clearValue,
+                                                                                                                const ValidationData&          refData,
+                                                                                                                const ImageValidator&          validator)
+       : ProtectedTestInstance (ctx)
+       , m_imageFormat (vk::VK_FORMAT_R8G8B8A8_UNORM)
+       , m_clearValue  (clearValue)
+       , m_refData             (refData)
+       , m_validator   (validator)
+{
+}
+
+tcu::TestStatus AttachmentLoadTestInstance::iterate()
+{
+       ProtectedContext&                                       ctx                                     (m_protectedContext);
+       const vk::DeviceInterface&                      vk                                      = ctx.getDeviceInterface();
+       const vk::VkDevice                                      device                          = ctx.getDevice();
+       const vk::VkQueue                                       queue                           = ctx.getQueue();
+       const deUint32                                          queueFamilyIndex        = ctx.getQueueFamilyIndex();
+
+       // Create output image
+       de::MovePtr<vk::ImageWithMemory>        colorImage                      (createImage2D(ctx, PROTECTION_ENABLED, queueFamilyIndex,
+                                                                                                                                                       RENDER_WIDTH, RENDER_HEIGHT,
+                                                                                                                                                       m_imageFormat,
+                                                                                                                                                       vk::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|vk::VK_IMAGE_USAGE_SAMPLED_BIT));
+       vk::Unique<vk::VkImageView>                     colorImageView          (createImageView(ctx, **colorImage, m_imageFormat));
+
+       vk::Unique<vk::VkRenderPass>            renderPass                      (createRenderPass(ctx, m_imageFormat));
+       vk::Unique<vk::VkFramebuffer>           framebuffer                     (createFramebuffer(ctx, RENDER_WIDTH, RENDER_HEIGHT, *renderPass, *colorImageView));
+       vk::Unique<vk::VkPipelineLayout>        pipelineLayout          (createPipelineLayout(ctx, 0u, DE_NULL));
+
+       vk::Unique<vk::VkCommandPool>           cmdPool                         (makeCommandPool(vk, device, PROTECTION_ENABLED, queueFamilyIndex));
+       vk::Unique<vk::VkCommandBuffer>         cmdBuffer                       (vk::allocateCommandBuffer(vk, device, *cmdPool, vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY));
+
+       // Begin cmd buffer
+       beginCommandBuffer(vk, *cmdBuffer);
+
+       // Start image barrier
+       {
+               const vk::VkImageMemoryBarrier  startImgBarrier         =
+               {
+                       vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,                     // sType
+                       DE_NULL,                                                                                        // pNext
+                       0,                                                                                                      // srcAccessMask
+                       vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,                       // dstAccessMask
+                       vk::VK_IMAGE_LAYOUT_UNDEFINED,                                          // oldLayout
+                       vk::VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,           // newLayout
+                       queueFamilyIndex,                                                                       // srcQueueFamilyIndex
+                       queueFamilyIndex,                                                                       // dstQueueFamilyIndex
+                       **colorImage,                                                                           // image
+                       {
+                               vk::VK_IMAGE_ASPECT_COLOR_BIT,                                  // aspectMask
+                               0u,                                                                                             // baseMipLevel
+                               1u,                                                                                             // mipLevels
+                               0u,                                                                                             // baseArraySlice
+                               1u,                                                                                             // subresourceRange
+                       }
+               };
+
+               vk.cmdPipelineBarrier(*cmdBuffer,
+                                                               vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
+                                                               vk::VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
+                                                               (vk::VkDependencyFlags)0,
+                                                               0, (const vk::VkMemoryBarrier*)DE_NULL,
+                                                               0, (const vk::VkBufferMemoryBarrier*)DE_NULL,
+                                                               1, &startImgBarrier);
+       }
+
+       // Image clear
+       const vk::VkRenderPassBeginInfo         passBeginInfo           =
+       {
+               vk::VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,           // sType
+               DE_NULL,                                                                                        // pNext
+               *renderPass,                                                                            // renderPass
+               *framebuffer,                                                                           // framebuffer
+               { {0, 0}, {RENDER_WIDTH, RENDER_HEIGHT} },                      // renderArea
+               1u,                                                                                                     // clearValueCount
+               &m_clearValue,                                                                          // pClearValues
+       };
+
+       vk.cmdBeginRenderPass(*cmdBuffer, &passBeginInfo, vk::VK_SUBPASS_CONTENTS_INLINE);
+       vk.cmdEndRenderPass(*cmdBuffer);
+
+       {
+               const vk::VkImageMemoryBarrier  endImgBarrier           =
+               {
+                       vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,                     // sType
+                       DE_NULL,                                                                                        // pNext
+                       vk::VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,                       // srcAccessMask
+                       vk::VK_ACCESS_SHADER_READ_BIT,                                          // dstAccessMask
+                       vk::VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,           // oldLayout
+                       vk::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,           // newLayout
+                       queueFamilyIndex,                                                                       // srcQueueFamilyIndex
+                       queueFamilyIndex,                                                                       // dstQueueFamilyIndex
+                       **colorImage,                                                                           // image
+                       {
+                               vk::VK_IMAGE_ASPECT_COLOR_BIT,                                  // aspectMask
+                               0u,                                                                                             // baseMipLevel
+                               1u,                                                                                             // mipLevels
+                               0u,                                                                                             // baseArraySlice
+                               1u,                                                                                             // subresourceRange
+                       }
+               };
+               vk.cmdPipelineBarrier(*cmdBuffer,
+                                                               vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
+                                                               vk::VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
+                                                               (vk::VkDependencyFlags)0,
+                                                               0, (const vk::VkMemoryBarrier*)DE_NULL,
+                                                               0, (const vk::VkBufferMemoryBarrier*)DE_NULL,
+                                                               1, &endImgBarrier);
+       }
+
+       VK_CHECK(vk.endCommandBuffer(*cmdBuffer));
+
+       // Submit command buffer
+       const vk::Unique<vk::VkFence>   fence           (vk::createFence(vk, device));
+       VK_CHECK(queueSubmit(ctx, PROTECTION_ENABLED, queue, *cmdBuffer, *fence, ~0ull));
+
+       // Log out test data
+       ctx.getTestContext().getLog()
+               << tcu::TestLog::Message << "Color clear value: " << tcu::Vec4(m_clearValue.color.float32) << tcu::TestLog::EndMessage
+               << tcu::TestLog::Message << "Depth clear value: " << m_clearValue.depthStencil.depth << tcu::TestLog::EndMessage
+               << tcu::TestLog::Message << "Stencil clear value: " << m_clearValue.depthStencil.stencil << tcu::TestLog::EndMessage;
+
+       // Validate resulting image
+       if (m_validator.validateImage(ctx, m_refData, **colorImage, m_imageFormat))
+               return tcu::TestStatus::pass("Everything went OK");
+       else
+               return tcu::TestStatus::fail("Something went really wrong");
+}
+
+} // anonymous
+
+tcu::TestCaseGroup*    createAttachmentLoadTests (tcu::TestContext& testCtx)
+{
+       struct {
+               const vk::VkClearValue          clearValue;
+               const ValidationData            data;
+       } testData[] = {
+               {       vk::makeClearValueColorF32(1.0f, 0.0f, 0.0f, 1.0f),
+                       {
+                               { tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f),  tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
+                                 tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f),  tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
+                               { tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f),  tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f),
+                                 tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f),  tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), }
+                       }
+               },
+               {       vk::makeClearValueColorF32(0.0f, 1.0f, 0.0f, 1.0f),
+                       {
+                               { tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f),  tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
+                                 tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f),  tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
+                               { tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f),  tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f),
+                                 tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f),  tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), }
+                       }
+               },
+               {       vk::makeClearValueColorF32(0.0f, 0.0f, 1.0f, 1.0f),
+                       {
+                               { tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f),  tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
+                                 tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f),  tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
+                               { tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f),  tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f),
+                                 tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f),  tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), }
+                       }
+               },
+               {       vk::makeClearValueColorF32(0.0f, 0.0f, 0.0f, 1.0f),
+                       {
+                               { tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f),  tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
+                                 tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f),  tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
+                               { tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f),  tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f),
+                                 tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f),  tcu::Vec4(0.0f, 0.0f, 0.0f, 1.0f), }
+                       }
+               },
+               {       vk::makeClearValueColorF32(1.0f, 0.0f, 0.0f, 1.0f),
+                       {
+                               { tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f),  tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
+                                 tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f),  tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
+                               { tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f),  tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f),
+                                 tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f),  tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), }
+                       }
+               },
+               {       vk::makeClearValueColorF32(1.0f, 0.0f, 0.0f, 0.0f),
+                       {
+                               { tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f),  tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
+                                 tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f),  tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
+                               { tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f),  tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f),
+                                 tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f),  tcu::Vec4(1.0f, 0.0f, 0.0f, 0.0f), }
+                       }
+               },
+               {       vk::makeClearValueColorF32(0.1f, 0.2f, 0.3f, 0.0f),
+                       {
+                               { tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f),  tcu::Vec4(1.0f, 1.0f, 0.0f, 0.0f),
+                                 tcu::Vec4(0.1f, 0.1f, 0.0f, 0.0f),  tcu::Vec4(0.5f, 0.5f, 0.0f, 0.0f), },
+                               { tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f),  tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f),
+                                 tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f),  tcu::Vec4(0.1f, 0.2f, 0.3f, 0.0f), }
+                       }
+               },
+       };
+
+       de::MovePtr<tcu::TestCaseGroup> loadStaticTests (new tcu::TestCaseGroup(testCtx, "static", "Attachment Load Op Tests with static input"));
+
+       for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(testData); ++ndx)
+       {
+               const std::string name = "clear_" + de::toString(ndx + 1);
+               loadStaticTests->addChild(new AttachmentLoadTestCase(testCtx, name.c_str(), testData[ndx].clearValue, testData[ndx].data));
+       }
+
+       /* Add a few randomized tests */
+       de::MovePtr<tcu::TestCaseGroup> loadRandomTests         (new tcu::TestCaseGroup(testCtx, "random", "Attachment Load Op Tests with random input"));
+       const int                                               testCount                       = 10;
+       de::Random                                              rnd                                     (testCtx.getCommandLine().getBaseSeed());
+       for (int ndx = 0; ndx < testCount; ++ndx)
+       {
+               const std::string       name            = "clear_" + de::toString(ndx + 1);
+               vk::VkClearValue        clearValue      = vk::makeClearValueColorF32(
+                                                                                       rnd.getFloat(0.0, 1.0f),
+                                                                                       rnd.getFloat(0.0, 1.0f),
+                                                                                       rnd.getFloat(0.0, 1.0f),
+                                                                                       rnd.getFloat(0.0, 1.0f));
+
+               tcu::Vec4                       refValue        (clearValue.color.float32[0], clearValue.color.float32[1], clearValue.color.float32[2], clearValue.color.float32[3]);
+               ValidationData          data = {
+                       { tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)),
+                         tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)),
+                         tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)),
+                         tcu::Vec4(rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f), rnd.getFloat(0.0f, 1.0f)) },
+                       { refValue, refValue, refValue, refValue }
+               };
+
+               loadRandomTests->addChild(new AttachmentLoadTestCase(testCtx, name.c_str(), clearValue, data));
+       }
+
+       de::MovePtr<tcu::TestCaseGroup> loadTests (new tcu::TestCaseGroup(testCtx, "load_op", "Attachment Load Op Tests"));
+       loadTests->addChild(loadStaticTests.release());
+       loadTests->addChild(loadRandomTests.release());
+       return loadTests.release();
+}
+
+} // ProtectedMem
+} // vkt
diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentLoadTests.hpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemAttachmentLoadTests.hpp
new file mode 100644 (file)
index 0000000..3604ce0
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef _VKTPROTECTEDMEMATTACHMENTLOADTESTS_HPP
+#define _VKTPROTECTEDMEMATTACHMENTLOADTESTS_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2017 The Khronos Group Inc.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Protected memory attachment render pass load tests
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+#include "tcuTestCase.hpp"
+
+namespace vkt
+{
+namespace ProtectedMem
+{
+
+tcu::TestCaseGroup*            createAttachmentLoadTests       (tcu::TestContext& testCtx);
+
+} // ProtectedMem
+} // vkt
+
+#endif // _VKTPROTECTEDMEMATTACHMENTLOADTESTS_HPP
diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemContext.hpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemContext.hpp
new file mode 100644 (file)
index 0000000..a772149
--- /dev/null
@@ -0,0 +1,102 @@
+#ifndef _VKTPROTECTEDMEMCONTEXT_HPP
+#define _VKTPROTECTEDMEMCONTEXT_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2017 The Khronos Group Inc.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Protected Memory image validator helper
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuVector.hpp"
+#include "vkDefs.hpp"
+#include "vktTestCase.hpp"
+
+#include "vktProtectedMemUtils.hpp"
+#include "tcuCommandLine.hpp"
+#include "vkMemUtil.hpp"
+
+namespace vkt
+{
+namespace ProtectedMem
+{
+
+
+class ProtectedContext
+{
+public:
+               ProtectedContext        (Context& ctx)
+                       : m_context                             (ctx)
+                       , m_interface                   (m_context.getPlatformInterface())
+                       , m_instance                    (makeProtectedMemInstance(m_interface, m_context.getTestContext().getCommandLine().isValidationEnabled()))
+                       , m_vki                                 (m_interface, *m_instance)
+                       , m_phyDevice                   (vk::chooseDevice(m_vki, *m_instance, m_context.getTestContext().getCommandLine()))
+                       , m_queueFamilyIndex    (chooseProtectedMemQueueFamilyIndex(m_vki, m_phyDevice))
+                       , m_device                              (makeProtectedMemDevice(m_vki, m_phyDevice, m_queueFamilyIndex))
+                       , m_allocator                   (createAllocator())
+                       , m_deviceDriver                (m_vki, *m_device)
+                       , m_queue                               (vk::getDeviceQueue(m_deviceDriver, *m_device, m_queueFamilyIndex, 0))
+               {}
+
+       const vk::DeviceInterface&                                      getDeviceInterface      (void) const    { return m_deviceDriver;                                        }
+       vk::VkDevice                                                            getDevice                       (void) const    { return *m_device;                                                     }
+       vk::VkQueue                                                                     getQueue                        (void) const    { return m_queue;                                                       }
+       deUint32                                                                        getQueueFamilyIndex     (void) const    { return m_queueFamilyIndex;                            }
+
+       tcu::TestContext&                                                       getTestContext          (void) const    { return m_context.getTestContext();            }
+       vk::ProgramCollection<vk::ProgramBinary>&       getBinaryCollection     (void) const    { return m_context.getBinaryCollection();       }
+       vk::Allocator&                                                          getDefaultAllocator     (void) const    { return *m_allocator;  }
+
+private:
+       vk::Allocator* createAllocator (void)
+       {
+               const vk::VkPhysicalDeviceMemoryProperties memoryProperties =
+                       vk::getPhysicalDeviceMemoryProperties(m_vki, m_phyDevice);
+
+               // \todo [2015-07-24 jarkko] support allocator selection/configuration from command line (or compile time)
+               return new vk::SimpleAllocator(getDeviceInterface(), getDevice(), memoryProperties);
+       }
+
+       Context&                                                m_context;
+       const vk::PlatformInterface&    m_interface;
+       vk::Move<vk::VkInstance>                m_instance;
+       vk::InstanceDriver                              m_vki;
+       vk::VkPhysicalDevice                    m_phyDevice;
+       deUint32                                                m_queueFamilyIndex;
+       vk::Move<vk::VkDevice>                  m_device;
+       const de::UniquePtr<vk::Allocator>      m_allocator;
+       vk::DeviceDriver                                m_deviceDriver;
+       vk::VkQueue                                             m_queue;
+};
+
+class ProtectedTestInstance : public TestInstance
+{
+public:
+                               ProtectedTestInstance   (Context& ctx)
+                                       : TestInstance                  (ctx)
+                                       , m_protectedContext    (ctx)
+                               {}
+protected:
+       ProtectedContext        m_protectedContext;
+};
+
+} // ProtectedMem
+} // vkt
+
+#endif // _VKTPROTECTEDMEMCONTEXT_HPP
diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemImageValidator.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemImageValidator.cpp
new file mode 100644 (file)
index 0000000..a168f12
--- /dev/null
@@ -0,0 +1,248 @@
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2017 The Khronos Group Inc.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Protected Memory image validator helper
+ *//*--------------------------------------------------------------------*/
+
+#include "vktProtectedMemImageValidator.hpp"
+
+#include "tcuTestLog.hpp"
+
+#include "vkBuilderUtil.hpp"
+#include "vkPrograms.hpp"
+#include "vkTypeUtil.hpp"
+#include "vktTestCase.hpp"
+#include "vktTestGroupUtil.hpp"
+
+#include "vktProtectedMemUtils.hpp"
+#include "vktProtectedMemContext.hpp"
+namespace vkt
+{
+namespace ProtectedMem
+{
+
+void ImageValidator::initPrograms (vk::SourceCollections& programCollection) const
+{
+       // Layout:
+       //  set = 0, location = 0 -> uniform sampler2D u_protectedImage
+       //  set = 0, location = 1 -> buffer ProtectedHelper (2 * uint)
+       //  set = 0, location = 2 -> uniform Data (2 * vec2 + 4 * vec4)
+       const char* validatorShader = "#version 450\n"
+                                         "layout(local_size_x = 1) in;\n"
+                                         "\n"
+                                         "layout(set=0, binding=0) uniform sampler2D u_protectedImage;\n"
+                                         "\n"
+                                         "layout(set=0, binding=1) buffer ProtectedHelper\n"
+                                         "{\n"
+                                         "    highp uint zero; // set to 0\n"
+                                         "    highp uint dummyOut;\n"
+                                         "} helper;\n"
+                                         "\n"
+                                         "layout(set=0, binding=2) uniform Data\n"
+                                         "{\n"
+                                         "    highp vec2 protectedImageCoord[4];\n"
+                                         "    highp vec4 protectedImageRef[4];\n"
+                                         "};\n"
+                                         "\n"
+                                         "void error ()\n"
+                                         "{\n"
+                                         "    for (uint x = 0; x < 10; x += helper.zero)\n"
+                                         "        atomicAdd(helper.dummyOut, 1u);\n"
+                                         "}\n"
+                                         "\n"
+                                         "bool compare (vec4 a, vec4 b, float threshold)\n"
+                                         "{\n"
+                                         "    return all(lessThanEqual(abs(a - b), vec4(threshold)));\n"
+                                         "}\n"
+                                         "\n"
+                                         "void main (void)\n"
+                                         "{\n"
+                                         "    float threshold = 0.1;\n"
+                                         "    for (uint i = 0; i < 4; i++)\n"
+                                         "    {\n"
+                                         "        if (!compare(texture(u_protectedImage, protectedImageCoord[i]), protectedImageRef[i], threshold))\n"
+                                         "            error();\n"
+                                         "    }\n"
+                                         "}\n";
+
+       const char* resetSSBOShader = "#version 450\n"
+                                         "layout(local_size_x = 1) in;\n"
+                                         "\n"
+                                         "layout(set=0, binding=1) buffer ProtectedHelper\n"
+                                         "{\n"
+                                         "    highp uint zero; // set to 0\n"
+                                         "    highp uint dummyOut;\n"
+                                         "} helper;\n"
+                                         "\n"
+                                         "void main (void)\n"
+                                         "{\n"
+                                         "    helper.zero = 0;\n"
+                                         "}\n";
+
+       programCollection.glslSources.add("ResetSSBO") << glu::ComputeSource(resetSSBOShader);
+       programCollection.glslSources.add("ImageValidator") << glu::ComputeSource(validatorShader);
+}
+
+bool ImageValidator::validateImage (ProtectedContext& ctx, const ValidationData& refData,
+                                                                       const vk::VkImage image, const vk::VkFormat imageFormat) const
+{
+       // Log out a few reference info
+       {
+               ctx.getTestContext().getLog()
+                       << tcu::TestLog::Message << "Reference coordinates: \n"
+                               << "1: " << refData.coords[0] << "\n"
+                               << "2: " << refData.coords[1] << "\n"
+                               << "3: " << refData.coords[2] << "\n"
+                               << "4: " << refData.coords[3] << "\n"
+                               << tcu::TestLog::EndMessage
+                       << tcu::TestLog::Message << "Reference color values: \n"
+                               << "1: " << refData.values[0] << "\n"
+                               << "2: " << refData.values[1] << "\n"
+                               << "3: " << refData.values[2] << "\n"
+                               << "4: " << refData.values[3] << "\n"
+                       << tcu::TestLog::EndMessage;
+       }
+
+       const deUint64                                                  oneSec                          = 1000 * 1000 * 1000;
+
+       const vk::DeviceInterface&                              vk                                      = ctx.getDeviceInterface();
+       const vk::VkDevice                                              device                          = ctx.getDevice();
+       const vk::VkQueue                                               queue                           = ctx.getQueue();
+       const deUint32                                                  queueFamilyIndex        = ctx.getQueueFamilyIndex();
+
+       const deUint32                                                  refUniformSize          = sizeof(refData);
+       de::UniquePtr<vk::BufferWithMemory>             refUniform                      (makeBuffer(ctx,
+                                                                                                                                               PROTECTION_DISABLED,
+                                                                                                                                               queueFamilyIndex,
+                                                                                                                                               refUniformSize,
+                                                                                                                                               vk::VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
+                                                                                                                                               vk::MemoryRequirement::HostVisible));
+       // Set the reference uniform data
+       {
+               deMemcpy(refUniform->getAllocation().getHostPtr(), &refData, refUniformSize);
+               vk::flushMappedMemoryRange(vk, device, refUniform->getAllocation().getMemory(), refUniform->getAllocation().getOffset(), refUniformSize);
+       }
+
+       const deUint32                                                  helperBufferSize        = (deUint32)(2 * sizeof(deUint32));
+       de::MovePtr<vk::BufferWithMemory>               helperBuffer            (makeBuffer(ctx,
+                                                                                                                                                       PROTECTION_ENABLED,
+                                                                                                                                                       queueFamilyIndex,
+                                                                                                                                                       helperBufferSize,
+                                                                                                                                                       vk::VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
+                                                                                                                                                       vk::MemoryRequirement::Protected));
+       vk::Unique<vk::VkShaderModule>                  resetSSBOShader         (vk::createShaderModule(vk, device, ctx.getBinaryCollection().get("ResetSSBO"), 0));
+       vk::Unique<vk::VkShaderModule>                  validatorShader         (vk::createShaderModule(vk, device, ctx.getBinaryCollection().get("ImageValidator"), 0));
+
+       vk::Unique<vk::VkSampler>                               sampler                         (makeSampler(vk, device));
+       const vk::VkImageViewCreateInfo                 viewParams                      =
+       {
+               vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,   // sType
+               DE_NULL,                                                                                // pNext
+               0u,                                                                                             // flags
+               image,                                                                                  // image
+               vk::VK_IMAGE_VIEW_TYPE_2D,                                              // viewType
+               imageFormat,                                                                    // format
+               vk::makeComponentMappingRGBA(),                                 // components
+               {
+                       vk::VK_IMAGE_ASPECT_COLOR_BIT,  // aspectMask
+                       0u,                                                             // baseMipLevel
+                       1u,                                                             // mipLeves
+                       0u,                                                             // baseArraySlice
+                       1u,                                                             // arraySize
+               }                                                                                               // subresourceRange
+       };
+       vk::Unique<vk::VkImageView>                             imageView                       (vk::createImageView(vk, device, &viewParams));
+
+       // Create descriptors
+       vk::Unique<vk::VkDescriptorSetLayout>   descriptorSetLayout(vk::DescriptorSetLayoutBuilder()
+               .addSingleSamplerBinding(vk::VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, vk::VK_SHADER_STAGE_COMPUTE_BIT, DE_NULL)
+               .addSingleBinding(vk::VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, vk::VK_SHADER_STAGE_COMPUTE_BIT)
+               .addSingleBinding(vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, vk::VK_SHADER_STAGE_COMPUTE_BIT)
+               .build(vk, device));
+       vk::Unique<vk::VkDescriptorPool>                descriptorPool(vk::DescriptorPoolBuilder()
+               .addType(vk::VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1u)
+               .addType(vk::VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1u)
+               .addType(vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1u)
+               .build(vk, device, vk::VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, 1u));
+       vk::Unique<vk::VkDescriptorSet>                 descriptorSet           (makeDescriptorSet(vk, device, *descriptorPool, *descriptorSetLayout));
+
+       // Update descriptor set infirmation
+       {
+               vk::VkDescriptorBufferInfo      descRefUniform  = makeDescriptorBufferInfo(**refUniform, 0, refUniformSize);
+               vk::VkDescriptorBufferInfo      descBuffer              = makeDescriptorBufferInfo(**helperBuffer, 0, helperBufferSize);
+               vk::VkDescriptorImageInfo       descSampledImg  = makeDescriptorImageInfo(*sampler, *imageView, vk::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+
+               vk::DescriptorSetUpdateBuilder()
+                       .writeSingle(*descriptorSet, vk::DescriptorSetUpdateBuilder::Location::binding(0u), vk::VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, &descSampledImg)
+                       .writeSingle(*descriptorSet, vk::DescriptorSetUpdateBuilder::Location::binding(1u), vk::VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, &descBuffer)
+                       .writeSingle(*descriptorSet, vk::DescriptorSetUpdateBuilder::Location::binding(2u), vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &descRefUniform)
+                       .update(vk, device);
+       }
+
+       // Build pipeline
+       vk::Unique<vk::VkPipelineLayout>                pipelineLayout          (makePipelineLayout(vk, device, *descriptorSetLayout));
+
+       vk::Unique<vk::VkCommandPool>                   cmdPool                         (makeCommandPool(vk, device, PROTECTION_ENABLED, queueFamilyIndex));
+
+       // Reset helper SSBO
+       {
+               const vk::Unique<vk::VkFence>           fence                           (vk::createFence(vk, device));
+               vk::Unique<vk::VkPipeline>                      resetSSBOPipeline       (makeComputePipeline(vk, device, *pipelineLayout, *resetSSBOShader, DE_NULL));
+               vk::Unique<vk::VkCommandBuffer>         resetCmdBuffer          (vk::allocateCommandBuffer(vk, device, *cmdPool, vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY));
+               beginCommandBuffer(vk, *resetCmdBuffer);
+
+               vk.cmdBindPipeline(*resetCmdBuffer, vk::VK_PIPELINE_BIND_POINT_COMPUTE, *resetSSBOPipeline);
+               vk.cmdBindDescriptorSets(*resetCmdBuffer, vk::VK_PIPELINE_BIND_POINT_COMPUTE, *pipelineLayout, 0u, 1u, &*descriptorSet, 0u, DE_NULL);
+               vk.cmdDispatch(*resetCmdBuffer, 1u, 1u, 1u);
+
+               VK_CHECK(vk.endCommandBuffer(*resetCmdBuffer));
+               VK_CHECK(queueSubmit(ctx, PROTECTION_ENABLED, queue, *resetCmdBuffer, *fence, ~0ull));
+       }
+
+       // Create validation compute commands & submit
+       vk::VkResult                                                    queueSubmitResult;
+       {
+               const vk::Unique<vk::VkFence>           fence                           (vk::createFence(vk, device));
+               vk::Unique<vk::VkPipeline>                      validationPipeline      (makeComputePipeline(vk, device, *pipelineLayout, *validatorShader, DE_NULL));
+               vk::Unique<vk::VkCommandBuffer>         cmdBuffer                       (vk::allocateCommandBuffer(vk, device, *cmdPool, vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY));
+
+               beginCommandBuffer(vk, *cmdBuffer);
+
+               vk.cmdBindPipeline(*cmdBuffer, vk::VK_PIPELINE_BIND_POINT_COMPUTE, *validationPipeline);
+               vk.cmdBindDescriptorSets(*cmdBuffer, vk::VK_PIPELINE_BIND_POINT_COMPUTE, *pipelineLayout, 0u, 1u, &*descriptorSet, 0u, DE_NULL);
+               vk.cmdDispatch(*cmdBuffer, 1u, 1u, 1u);
+
+               VK_CHECK(vk.endCommandBuffer(*cmdBuffer));
+
+               queueSubmitResult                                                                               = queueSubmit(ctx, PROTECTION_ENABLED, queue, *cmdBuffer, *fence, oneSec);
+       }
+
+       // \todo do we need to check the fence status?
+       if (queueSubmitResult == vk::VK_TIMEOUT)
+               return false;
+
+       // at this point the submit result should be VK_TRUE
+       VK_CHECK(queueSubmitResult);
+       return true;
+}
+
+} // ProtectedMem
+} // vkt
diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemImageValidator.hpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemImageValidator.hpp
new file mode 100644 (file)
index 0000000..e37e652
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef _VKTPROTECTEDMEMIMAGEVALIDATOR_HPP
+#define _VKTPROTECTEDMEMIMAGEVALIDATOR_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2017 The Khronos Group Inc.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Protected Memory image validator helper
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuVector.hpp"
+#include "vkDefs.hpp"
+#include "vktTestCase.hpp"
+
+namespace vkt
+{
+namespace ProtectedMem
+{
+
+class ProtectedContext;
+
+struct ValidationData {
+       const tcu::Vec4 coords[4];
+       const tcu::Vec4 values[4];
+};
+
+class ImageValidator
+{
+public:
+                                                       ImageValidator  (void)
+                                                       {}
+                                                       ~ImageValidator () {}
+       void                                    initPrograms    (vk::SourceCollections& programCollection) const;
+
+       bool                                    validateImage   (ProtectedContext&              ctx,
+                                                                                        const ValidationData&  refData,
+                                                                                        const vk::VkImage              image,
+                                                                                        const vk::VkFormat             imageFormat) const;
+};
+
+} // ProtectedMem
+} // vkt
+
+#endif // _VKTPROTECTEDMEMIMAGEVALIDATOR_HPP
diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemTests.cpp
new file mode 100644 (file)
index 0000000..ea95e78
--- /dev/null
@@ -0,0 +1,53 @@
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2017 The Khronos Group Inc.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Protected memory tests
+ *//*--------------------------------------------------------------------*/
+
+#include "vktProtectedMemTests.hpp"
+
+#include "vktTestCase.hpp"
+#include "vktTestGroupUtil.hpp"
+
+#include "vktProtectedMemAttachmentLoadTests.hpp"
+
+namespace vkt
+{
+namespace ProtectedMem
+{
+
+tcu::TestCaseGroup* createTests (tcu::TestContext& testCtx)
+{
+       de::MovePtr<tcu::TestCaseGroup> protectedTests (new tcu::TestCaseGroup(testCtx, "protected_memory", "Protected Memory Tests"));
+
+       // Attachment test case group
+       {
+               de::MovePtr<tcu::TestCaseGroup> attachmentTestGroup (new tcu::TestCaseGroup(testCtx, "attachment", "Protected Memory Attachment Tests"));
+               attachmentTestGroup->addChild(createAttachmentLoadTests(testCtx));
+               protectedTests->addChild(attachmentTestGroup.release());
+       }
+
+       return protectedTests.release();
+
+}
+
+} // ProtectedMem
+} // vkt
diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemTests.hpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemTests.hpp
new file mode 100644 (file)
index 0000000..34dafc4
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef _VKTPROTECTEDMEMTESTS_HPP
+#define _VKTPROTECTEDMEMTESTS_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2017 The Khronos Group Inc.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Protected Memory Tests
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+#include "tcuTestCase.hpp"
+
+namespace vkt
+{
+namespace ProtectedMem
+{
+
+tcu::TestCaseGroup*            createTests     (tcu::TestContext& testCtx);
+
+} // ProtectedMem
+} // vkt
+
+#endif // _VKTPROTECTEDMEMTESTS_HPP
diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemUtils.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemUtils.cpp
new file mode 100644 (file)
index 0000000..3aa761b
--- /dev/null
@@ -0,0 +1,539 @@
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2017 The Khronos Group Inc.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Protected Memory Utility methods
+ *//*--------------------------------------------------------------------*/
+
+#include "vktProtectedMemUtils.hpp"
+
+#include "vkDeviceUtil.hpp"
+#include "vkQueryUtil.hpp"
+#include "vkTypeUtil.hpp"
+#include "vkDebugReportUtil.hpp"
+
+#include "vkPlatform.hpp"
+#include "vktProtectedMemContext.hpp"
+
+namespace vkt
+{
+namespace ProtectedMem
+{
+
+typedef std::vector<vk::VkExtensionProperties> Extensions;
+
+std::vector<std::string> getValidationLayers (const vk::PlatformInterface& vkp)
+{
+       static const char*      s_magicLayer            = "VK_LAYER_LUNARG_standard_validation";
+       static const char*      s_defaultLayers[]       =
+       {
+               "VK_LAYER_GOOGLE_threading",
+               "VK_LAYER_LUNARG_parameter_validation",
+               "VK_LAYER_LUNARG_device_limits",
+               "VK_LAYER_LUNARG_object_tracker",
+               "VK_LAYER_LUNARG_image",
+               "VK_LAYER_LUNARG_core_validation",
+               "VK_LAYER_LUNARG_swapchain",
+               "VK_LAYER_GOOGLE_unique_objects"
+       };
+       const std::vector<vk::VkLayerProperties>        supportedLayers (enumerateInstanceLayerProperties(vkp));
+       std::vector<std::string>                                        enabledLayers;
+
+       if (isLayerSupported(supportedLayers, vk::RequiredLayer(s_magicLayer)))
+               enabledLayers.push_back(s_magicLayer);
+       else
+       {
+               for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_defaultLayers); ++ndx)
+               {
+                       if (isLayerSupported(supportedLayers, vk::RequiredLayer(s_defaultLayers[ndx])))
+                               enabledLayers.push_back(s_defaultLayers[ndx]);
+               }
+       }
+
+       return enabledLayers;
+}
+
+
+vk::Move<vk::VkInstance> makeProtectedMemInstance (const vk::PlatformInterface& vkp, bool isValidationEnabled)
+{
+       const Extensions                        supportedExtensions(vk::enumerateInstanceExtensionProperties(vkp, DE_NULL));
+       std::vector<std::string>        enabledLayers;
+       std::vector<std::string>        requiredExtensions;
+
+       if (isValidationEnabled)
+       {
+               if (!vk::isDebugReportSupported(vkp))
+                       TCU_THROW(NotSupportedError, "VK_EXT_debug_report is not supported");
+
+               enabledLayers = getValidationLayers(vkp);
+               if (enabledLayers.empty())
+                       TCU_THROW(NotSupportedError, "No validation layers found");
+       }
+
+       requiredExtensions.push_back("VK_KHR_get_physical_device_properties2");
+
+       for (std::vector<std::string>::const_iterator requiredExtName = requiredExtensions.begin();
+               requiredExtName != requiredExtensions.end();
+               ++requiredExtName)
+       {
+               if (!isExtensionSupported(supportedExtensions, vk::RequiredExtension(*requiredExtName)))
+                       TCU_THROW(NotSupportedError, (*requiredExtName + " is not supported").c_str());
+       }
+
+       return vk::createDefaultInstance(vkp, enabledLayers, requiredExtensions);
+}
+
+deUint32 chooseProtectedMemQueueFamilyIndex    (const vk::InstanceDriver&      vkd,
+                                                                                        vk::VkPhysicalDevice           physicalDevice)
+{
+       std::vector<vk::VkQueueFamilyProperties>        properties;
+       deUint32                                                                        numFamilies             = 0;
+
+       vkd.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numFamilies, DE_NULL);
+       DE_ASSERT(numFamilies > 0);
+       properties.resize(numFamilies);
+
+       vkd.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numFamilies, properties.data());
+
+       // Get a universal protected queue family index
+       vk::VkQueueFlags        requiredFlags = vk::VK_QUEUE_GRAPHICS_BIT
+                                                                               | vk::VK_QUEUE_COMPUTE_BIT
+                                                                               | vk::VK_QUEUE_PROTECTED_BIT_KHR;
+       for (size_t idx = 0; idx < properties.size(); ++idx)
+       {
+               vk::VkQueueFlags        flags = properties[idx].queueFlags;
+
+               if ((flags & requiredFlags) == requiredFlags)
+                       return (deUint32)idx;
+       }
+
+       TCU_THROW(NotSupportedError, "No matching universal protected queue found");
+}
+
+vk::Move<vk::VkDevice> makeProtectedMemDevice (const vk::InstanceDriver&       vkd,
+                                                                                          vk::VkPhysicalDevice                 physicalDevice,
+                                                                                          const deUint32                               queueFamilyIndex)
+{
+       const Extensions                                        supportedExtensions     (vk::enumerateDeviceExtensionProperties(vkd, physicalDevice, DE_NULL));
+       deUint32                                                        extensionsCount         = 1;
+       const char* const                                       extensions[]            =
+       {
+               "VK_KHR_protected_memory"
+       };
+
+       // Check if the physical device supports the protected memory extension name
+       for (deUint32 ndx = 0; ndx < extensionsCount; ++ndx)
+       {
+               if (!isExtensionSupported(supportedExtensions, vk::RequiredExtension(extensions[ndx])))
+                       TCU_THROW(NotSupportedError, (std::string(extensions[ndx]) + " is not supported").c_str());
+       }
+
+       // Check if the protected memory can be enabled on the physical device.
+       vk::VkPhysicalDeviceProtectedMemoryFeaturesKHR  protectedFeature =
+       {
+               vk::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES_KHR,    // sType
+               DE_NULL,                                                                                                                                // pNext
+               VK_FALSE                                                                                                                                // protectedMemory
+       };
+       vk::VkPhysicalDeviceFeatures                                    features;
+       deMemset(&features, 0, sizeof(vk::VkPhysicalDeviceFeatures));
+
+       vk::VkPhysicalDeviceFeatures2KHR                                featuresExt             =
+       {
+               vk::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR,                                   // sType
+               &protectedFeature,                                                                                                              // pNext
+               features
+       };
+
+       vkd.getPhysicalDeviceFeatures2KHR(physicalDevice, &featuresExt);
+
+       if (protectedFeature.protectedMemory == VK_FALSE)
+               TCU_THROW(NotSupportedError, "Protected Memory feature not supported by the device");
+
+       const float                                                     queuePriorities[]       = { 1.0f };
+       const vk::VkDeviceQueueCreateInfo       queueInfos[]            =
+       {
+               {
+                       vk::VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
+                       DE_NULL,
+                       (vk::VkDeviceQueueCreateFlags)vk::VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT_KHR,
+                       queueFamilyIndex,
+                       DE_LENGTH_OF_ARRAY(queuePriorities),
+                       queuePriorities
+               }
+       };
+
+       const vk::VkDeviceCreateInfo            deviceParams            =
+       {
+               vk::VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,                       // sType
+               &featuresExt,                                                                           // pNext
+               (vk::VkDeviceCreateFlags)0,                                                     // flags
+               DE_LENGTH_OF_ARRAY(queueInfos),                                         // queueCreateInfosCount
+               &queueInfos[0],                                                                         // pQueueCreateInfos
+               0u,                                                                                                     // enabledLayerCount
+               DE_NULL,                                                                                        // pEnabledLayerNames
+               extensionsCount,                                                                        // enabledExtensionCount
+               DE_ARRAY_BEGIN(extensions),                                                     // pEnabledExtensionNames
+               DE_NULL                                                                                         // pEnabledFeatures
+       };
+
+       return vk::createDevice(vkd, physicalDevice, &deviceParams, DE_NULL);
+}
+
+de::MovePtr<vk::ImageWithMemory>       createImage2D           (ProtectedContext&              context,
+                                                                                                                ProtectionMode                 protectionMode,
+                                                                                                                const deUint32                 queueFamilyIdx,
+                                                                                                                deUint32                               width,
+                                                                                                                deUint32                               height,
+                                                                                                                vk::VkFormat                   format,
+                                                                                                                vk::VkImageUsageFlags  usageFlags)
+{
+       const vk::DeviceInterface&      vk                      = context.getDeviceInterface();
+       const vk::VkDevice&                     device          = context.getDevice();
+       vk::Allocator&                          allocator       = context.getDefaultAllocator();
+
+       deUint32                                        flags           = (protectionMode == PROTECTION_ENABLED)
+                                                                                               ? vk::VK_IMAGE_CREATE_PROTECTED_BIT_KHR
+                                                                                               : (vk::VkImageCreateFlagBits)0u;
+
+       const vk::VkImageCreateInfo     params          =
+       {
+               vk::VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,                // VkStructureType                      stype
+               DE_NULL,                                                                                // const void*                          pNext
+               (vk::VkImageCreateFlags)flags,                                  // VkImageCreateFlags           flags
+               vk::VK_IMAGE_TYPE_2D,                                                   // VkImageType                          imageType
+               format,                                                                                 // VkFormat                                     format
+               { width, height, 1 },                                                   // VkExtent3D                           extent
+               1u,                                                                                             // deUint32                                     mipLevels
+               1u,                                                                                             // deUint32                                     arrayLayers
+               vk::VK_SAMPLE_COUNT_1_BIT,                                              // VkSampleCountFlagBits        samples
+               vk::VK_IMAGE_TILING_OPTIMAL,                                    // VkImageTiling                        tiling
+               usageFlags,                                                                             // VkImageUsageFlags            usage
+               vk::VK_SHARING_MODE_EXCLUSIVE,                                  // VkSharingMode                        sharingMode
+               1u,                                                                                             // deUint32                                     queueFamilyIndexCount
+               &queueFamilyIdx,                                                                // const deUint32*                      pQueueFamilyIndices
+               vk::VK_IMAGE_LAYOUT_UNDEFINED,                                  // VkImageLayout                        initialLayout
+       };
+
+       vk::MemoryRequirement           memReq          = (protectionMode == PROTECTION_ENABLED)
+                                                                                               ? vk::MemoryRequirement::Protected
+                                                                                               : vk::MemoryRequirement::Any;
+
+       return de::MovePtr<vk::ImageWithMemory>(new vk::ImageWithMemory(vk, device, allocator, params, memReq));
+}
+
+de::MovePtr<vk::BufferWithMemory> makeBuffer (ProtectedContext&                        context,
+                                                                                         ProtectionMode                        protectionMode,
+                                                                                         const deUint32                        queueFamilyIdx,
+                                                                                         deUint32                                      size,
+                                                                                         vk::VkBufferUsageFlags        usageFlags,
+                                                                                         vk::MemoryRequirement         memReq)
+{
+       const vk::DeviceInterface&              vk                      = context.getDeviceInterface();
+       const vk::VkDevice&                             device          = context.getDevice();
+       vk::Allocator&                                  allocator       = context.getDefaultAllocator();
+
+       deUint32                                                flags           = (protectionMode == PROTECTION_ENABLED)
+                                                                                                       ? vk::VK_BUFFER_CREATE_PROTECTED_BIT_KHR
+                                                                                                       : (vk::VkBufferCreateFlagBits)0u;
+
+       const vk::VkBufferCreateInfo    params          =
+       {
+               vk::VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,       // sType
+               DE_NULL,                                                                        // pNext
+               (vk::VkBufferCreateFlagBits)flags,                      // flags
+               (vk::VkDeviceSize)size,                                         // size
+               usageFlags,                                                                     // usage
+               vk::VK_SHARING_MODE_EXCLUSIVE,                          // sharingMode
+               1u,                                                                                     // queueFamilyCount
+               &queueFamilyIdx,                                                        // pQueueFamilyIndices
+       };
+
+       return de::MovePtr<vk::BufferWithMemory>(new vk::BufferWithMemory(vk, device, allocator, params, memReq));
+}
+
+vk::Move<vk::VkImageView> createImageView (ProtectedContext& context, vk::VkImage image, vk::VkFormat format)
+{
+       const vk::VkImageViewCreateInfo params =
+       {
+               vk::VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,           // sType
+               DE_NULL,                                                                                        // pNext
+               0u,                                                                                                     // flags
+               image,                                                                                          // image
+               vk::VK_IMAGE_VIEW_TYPE_2D,                                                      // viewType
+               format,                                                                                         // format
+               vk::makeComponentMappingRGBA(),                                         // components
+               { vk::VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u,1u },       // subresourceRange
+       };
+
+       return vk::createImageView(context.getDeviceInterface(), context.getDevice(), &params);
+}
+
+vk::Move<vk::VkRenderPass> createRenderPass (ProtectedContext& context, vk::VkFormat format)
+{
+       const vk::VkDevice                                      vkDevice                                = context.getDevice();
+       const vk::DeviceInterface&                      vk                                              = context.getDeviceInterface();
+
+       const vk::VkAttachmentDescription       attachmentDescription   =
+       {
+               0u,                                                                                             // VkAttachmentDescriptorFlags  flags;
+               format,                                                                                 // VkFormat                                             format;
+               vk::VK_SAMPLE_COUNT_1_BIT,                                              // VkSampleCountFlagBits                samples;
+               vk::VK_ATTACHMENT_LOAD_OP_CLEAR,                                // VkAttachmentLoadOp                   loadOp;
+               vk::VK_ATTACHMENT_STORE_OP_STORE,                               // VkAttachmentStoreOp                  storeOp;
+               vk::VK_ATTACHMENT_LOAD_OP_DONT_CARE,                    // VkAttachmentLoadOp                   stencilLoadOp;
+               vk::VK_ATTACHMENT_STORE_OP_DONT_CARE,                   // VkAttachmentStoreOp                  stencilStoreOp;
+               vk::VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,   // VkImageLayout                                initialLayout;
+               vk::VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,   // VkImageLayout                                finalLayout;
+       };
+
+       const vk::VkAttachmentReference         attachmentReference             =
+       {
+               0u,                                                                                             // deUint32                     attachment;
+               vk::VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL    // VkImageLayout        layout;
+       };
+
+       const vk::VkSubpassDescription          subpassDescription              =
+       {
+               0u,                                                                                     // VkSubpassDescriptionFlags    flags;
+               vk::VK_PIPELINE_BIND_POINT_GRAPHICS,            // VkPipelineBindPoint                  pipelineBindPoint;
+               0u,                                                                                     // deUint32                                             inputAttachmentCount;
+               DE_NULL,                                                                        // const VkAttachmentReference* pInputAttachments;
+               1u,                                                                                     // deUint32                                             colorAttachmentCount;
+               &attachmentReference,                                           // const VkAttachmentReference* pColorAttachments;
+               DE_NULL,                                                                        // const VkAttachmentReference* pResolveAttachments;
+               DE_NULL,                                                                        // const VkAttachmentReference* pDepthStencilAttachment;
+               0u,                                                                                     // deUint32                                             preserveAttachmentCount;
+               DE_NULL                                                                         // const VkAttachmentReference* pPreserveAttachments;
+       };
+
+       const vk::VkRenderPassCreateInfo        renderPassParams                =
+       {
+               vk::VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,  // VkStructureType                                      sType;
+               DE_NULL,                                                                                // const void*                                          pNext;
+               0u,                                                                                             // VkRenderPassCreateFlags                      flags;
+               1u,                                                                                             // deUint32                                                     attachmentCount;
+               &attachmentDescription,                                                 // const VkAttachmentDescription*       pAttachments;
+               1u,                                                                                             // deUint32                                                     subpassCount;
+               &subpassDescription,                                                    // const VkSubpassDescription*          pSubpasses;
+               0u,                                                                                             // deUint32                                                     dependencyCount;
+               DE_NULL                                                                                 // const VkSubpassDependency*           pDependencies;
+       };
+
+       return vk::createRenderPass(vk, vkDevice, &renderPassParams);
+}
+
+vk::Move<vk::VkFramebuffer> createFramebuffer (ProtectedContext& context, deUint32 width, deUint32 height,
+                                                                                               vk::VkRenderPass renderPass, vk::VkImageView colorImageView)
+{
+       const vk::VkDevice                                      vkDevice                        = context.getDevice();
+       const vk::DeviceInterface&                      vk                                      = context.getDeviceInterface();
+
+       const vk::VkFramebufferCreateInfo       framebufferParams       =
+       {
+               vk::VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,  // VkStructureType                      sType;
+               DE_NULL,                                                                                // const void*                          pNext;
+               0u,                                                                                             // VkFramebufferCreateFlags     flags;
+               renderPass,                                                                             // VkRenderPass                         renderPass;
+               1u,                                                                                             // deUint32                                     attachmentCount;
+               &colorImageView,                                                                // const VkImageView*           pAttachments;
+               width,                                                                                  // deUint32                                     width;
+               height,                                                                                 // deUint32                                     height;
+               1u                                                                                              // deUint32                                     layers;
+       };
+
+       return vk::createFramebuffer(vk, vkDevice, &framebufferParams);
+}
+
+
+vk::Move<vk::VkPipelineLayout> createPipelineLayout (ProtectedContext& context, deUint32 layoutCount, vk::VkDescriptorSetLayout* setLayouts)
+{
+       const vk::VkPipelineLayoutCreateInfo    params  =
+       {
+               vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,      // sType
+               DE_NULL,                                                                                        // pNext
+               0u,                                                                                                     // flags
+               layoutCount,                                                                            // setLayoutCount
+               setLayouts,                                                                                     // pSetLayouts
+               0u,                                                                                                     // pushConstantRangeCount
+               DE_NULL,                                                                                        // pPushContantRanges
+       };
+
+       return vk::createPipelineLayout(context.getDeviceInterface(), context.getDevice(), &params);
+}
+
+void beginCommandBuffer (const vk::DeviceInterface& vk, const vk::VkCommandBuffer commandBuffer)
+{
+       const vk::VkCommandBufferBeginInfo      beginInfo       =
+       {
+               vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,        // sType
+               DE_NULL,                                                                                        // pNext
+               0u,                                                                                                     // flags
+               (const vk::VkCommandBufferInheritanceInfo*)DE_NULL,     // pInheritanceInfo
+       };
+       VK_CHECK(vk.beginCommandBuffer(commandBuffer, &beginInfo));
+}
+
+
+vk::VkResult queueSubmit (ProtectedContext&            context,
+                                                 ProtectionMode                protectionMode,
+                                                 vk::VkQueue                   queue,
+                                                 vk::VkCommandBuffer   cmdBuffer,
+                                                 vk::VkFence                   fence,
+                                                 uint64_t                              timeout)
+{
+       const vk::DeviceInterface&                      vk                      = context.getDeviceInterface();
+       const vk::VkDevice&                                     device          = context.getDevice();
+
+       // Basic submit info
+       vk::VkSubmitInfo                                        submitInfo      =
+       {
+               vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,                      // sType
+               DE_NULL,                                                                        // pNext
+               0u,                                                                                     // waitSemaphoreCount
+               DE_NULL,                                                                        // pWaitSempahores
+               (const vk::VkPipelineStageFlags*)DE_NULL,       // stageFlags
+               1u,                                                                                     // commandBufferCount
+               &cmdBuffer,                                                                     // pCommandBuffers
+               0u,                                                                                     // signalSemaphoreCount
+               DE_NULL,                                                                        // pSignalSemaphores
+       };
+
+       // Protected extension submit info
+       const vk::VkProtectedSubmitInfoKHR      protectedInfo   =
+       {
+               vk::VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO_KHR,        // sType
+               DE_NULL,                                                                                        // pNext
+               VK_TRUE,                                                                                        // protectedSubmit
+       };
+
+       if (protectionMode == PROTECTION_ENABLED) {
+               submitInfo.pNext = &protectedInfo;
+       }
+
+       VK_CHECK(vk.queueSubmit(queue, 1u, &submitInfo, fence));
+       return vk.waitForFences(device, 1u, &fence, DE_TRUE, timeout);
+}
+
+vk::Move<vk::VkDescriptorSet> makeDescriptorSet (const vk::DeviceInterface&                    vk,
+                                                                                                const vk::VkDevice                                     device,
+                                                                                                const vk::VkDescriptorPool                     descriptorPool,
+                                                                                                const vk::VkDescriptorSetLayout        setLayout)
+{
+       const vk::VkDescriptorSetAllocateInfo allocateParams =
+       {
+               vk::VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,     // VkStructureType                              sType;
+               DE_NULL,                                                                                        // const void*                                  pNext;
+               descriptorPool,                                                                         // VkDescriptorPool                             descriptorPool;
+               1u,                                                                                                     // deUint32                                             setLayoutCount;
+               &setLayout,                                                                                     // const VkDescriptorSetLayout* pSetLayouts;
+       };
+       return vk::allocateDescriptorSet(vk, device, &allocateParams);
+}
+
+
+vk::Move<vk::VkPipelineLayout> makePipelineLayout (const vk::DeviceInterface&          vk,
+                                                                                                  const vk::VkDevice                           device,
+                                                                                                  const vk::VkDescriptorSetLayout      descriptorSetLayout)
+{
+       const vk::VkPipelineLayoutCreateInfo info =
+       {
+               vk::VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,      // VkStructureType                              sType;
+               DE_NULL,                                                                                        // const void*                                  pNext;
+               (vk::VkPipelineLayoutCreateFlags)0,                                     // VkPipelineLayoutCreateFlags  flags;
+               1u,                                                                                                     // deUint32                                             setLayoutCount;
+               &descriptorSetLayout,                                                           // const VkDescriptorSetLayout* pSetLayouts;
+               0u,                                                                                                     // deUint32                                             pushConstantRangeCount;
+               DE_NULL,                                                                                        // const VkPushConstantRange*   pPushConstantRanges;
+       };
+       return vk::createPipelineLayout(vk, device, &info);
+}
+
+vk::Move<vk::VkPipeline> makeComputePipeline (const vk::DeviceInterface&               vk,
+                                                                                         const vk::VkDevice                            device,
+                                                                                         const vk::VkPipelineLayout            pipelineLayout,
+                                                                                         const vk::VkShaderModule                      shaderModule,
+                                                                                         const vk::VkSpecializationInfo*       specInfo)
+{
+       const vk::VkPipelineShaderStageCreateInfo shaderStageInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,        // VkStructureType                                      sType;
+               DE_NULL,                                                                                                        // const void*                                          pNext;
+               (vk::VkPipelineShaderStageCreateFlags)0,                                        // VkPipelineShaderStageCreateFlags     flags;
+               vk::VK_SHADER_STAGE_COMPUTE_BIT,                                                        // VkShaderStageFlagBits                        stage;
+               shaderModule,                                                                                           // VkShaderModule                                       module;
+               "main",                                                                                                         // const char*                                          pName;
+               specInfo,                                                                                                       // const VkSpecializationInfo*          pSpecializationInfo;
+       };
+       const vk::VkComputePipelineCreateInfo pipelineInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,     // VkStructureType                                      sType;
+               DE_NULL,                                                                                        // const void*                                          pNext;
+               (vk::VkPipelineCreateFlags)0,                                           // VkPipelineCreateFlags                        flags;
+               shaderStageInfo,                                                                        // VkPipelineShaderStageCreateInfo      stage;
+               pipelineLayout,                                                                         // VkPipelineLayout                                     layout;
+               DE_NULL,                                                                                        // VkPipeline                                           basePipelineHandle;
+               0,                                                                                                      // deInt32                                                      basePipelineIndex;
+       };
+       return vk::createComputePipeline(vk, device, DE_NULL , &pipelineInfo);
+}
+
+vk::Move<vk::VkSampler> makeSampler (const vk::DeviceInterface& vk, const vk::VkDevice& device)
+{
+       const vk::VkSamplerCreateInfo createInfo =
+       {
+               vk::VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
+               DE_NULL,
+               0u,
+
+               vk::VK_FILTER_NEAREST,
+               vk::VK_FILTER_NEAREST,
+
+               vk::VK_SAMPLER_MIPMAP_MODE_LINEAR,
+               vk::VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
+               vk::VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
+               vk::VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
+               0.0f,
+               VK_FALSE,
+               1.0f,
+               VK_FALSE,
+               vk::VK_COMPARE_OP_ALWAYS,
+               0.0f,
+               0.0f,
+               vk::VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK,
+               VK_FALSE
+       };
+
+       return vk::createSampler(vk, device, &createInfo);
+}
+
+vk::Move<vk::VkCommandPool> makeCommandPool (const vk::DeviceInterface&        vk,
+                                                                                        const vk::VkDevice&            device,
+                                                                                        ProtectionMode                         protectionMode,
+                                                                                        const deUint32                         queueFamilyIdx)
+{
+       const deUint32  poolFlags       = vk::VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT
+                                                                       | ((protectionMode == PROTECTION_ENABLED) ? vk::VK_COMMAND_POOL_CREATE_PROTECTED_BIT_KHR : 0x0);
+
+       return vk::createCommandPool(vk, device, poolFlags, queueFamilyIdx);
+}
+
+} // ProtectedMem
+} // vkt
diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemUtils.hpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemUtils.hpp
new file mode 100644 (file)
index 0000000..0cfc49a
--- /dev/null
@@ -0,0 +1,119 @@
+#ifndef _VKTPROTECTEDMEMUTILS_HPP
+#define _VKTPROTECTEDMEMUTILS_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2017 The Khronos Group Inc.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Protected Memory Utility methods
+ *//*--------------------------------------------------------------------*/
+
+#include "deUniquePtr.hpp"
+#include "vktTestCase.hpp"
+#include "vkDefs.hpp"
+#include "vkRefUtil.hpp"
+#include "vkMemUtil.hpp"
+#include "vkDeviceUtil.hpp"
+#include "vkPlatform.hpp"
+#include "vkBufferWithMemory.hpp"
+#include "vkImageWithMemory.hpp"
+
+namespace vkt
+{
+namespace ProtectedMem
+{
+
+class ProtectedContext;
+
+enum ProtectionMode {
+       PROTECTION_DISABLED     = 0,
+       PROTECTION_ENABLED      = 1,
+};
+
+vk::Move<vk::VkInstance>                       makeProtectedMemInstance                        (const vk::PlatformInterface&           vkp,
+                                                                                                                                                bool                                                           isValidationEnabled);
+deUint32                                                       chooseProtectedMemQueueFamilyIndex      (const vk::InstanceDriver&                      vkd,
+                                                                                                                                                vk::VkPhysicalDevice                           physicalDevice);
+
+vk::Move<vk::VkDevice>                         makeProtectedMemDevice                          (const vk::InstanceDriver&                      vkd,
+                                                                                                                                                vk::VkPhysicalDevice                           physicalDevice,
+                                                                                                                                                const deUint32                                         queueFamilyIndex);
+
+
+de::MovePtr<vk::ImageWithMemory>       createImage2D                                           (ProtectedContext&                                      context,
+                                                                                                                                                ProtectionMode                                         protectionMode,
+                                                                                                                                                const deUint32                                         queueFamilyIdx,
+                                                                                                                                                deUint32                                                       width,
+                                                                                                                                                deUint32                                                       height,
+                                                                                                                                                vk::VkFormat                                           format,
+                                                                                                                                                vk::VkImageUsageFlags                          usageFlags);
+de::MovePtr<vk::BufferWithMemory>      makeBuffer                                                      (ProtectedContext&                                      context,
+                                                                                                                                                ProtectionMode                                         protectionMode,
+                                                                                                                                                const deUint32                                         queueFamilyIdx,
+                                                                                                                                                deUint32                                                       size,
+                                                                                                                                                vk::VkBufferUsageFlags                         flags,
+                                                                                                                                                vk::MemoryRequirement                          memReq);
+
+vk::Move<vk::VkImageView>                      createImageView                                         (ProtectedContext&                                      context,
+                                                                                                                                                vk::VkImage                                            image,
+                                                                                                                                                vk::VkFormat                                           format);
+vk::Move<vk::VkRenderPass>                     createRenderPass                                        (ProtectedContext&                                      context,
+                                                                                                                                                vk::VkFormat                                           format);
+vk::Move<vk::VkFramebuffer>                    createFramebuffer                                       (ProtectedContext&                                      context,
+                                                                                                                                                deUint32                                                       width,
+                                                                                                                                                deUint32                                                       height,
+                                                                                                                                                vk::VkRenderPass                                       renderPass,
+                                                                                                                                                vk::VkImageView                                        colorImageView);
+vk::Move<vk::VkPipelineLayout>         createPipelineLayout                            (ProtectedContext&                                      context,
+                                                                                                                                                deUint32                                                       layoutCount,
+                                                                                                                                                vk::VkDescriptorSetLayout*                     setLayouts);
+void                                                           beginCommandBuffer                                      (const vk::DeviceInterface&                     vk,
+                                                                                                                                                const vk::VkCommandBuffer                      commandBuffer);
+vk::VkResult                                           queueSubmit                                                     (ProtectedContext&                                      context,
+                                                                                                                                                ProtectionMode                                         protectionMode,
+                                                                                                                                                vk::VkQueue                                            queue,
+                                                                                                                                                vk::VkCommandBuffer                            cmdBuffer,
+                                                                                                                                                vk::VkFence                                            fence,
+                                                                                                                                                uint64_t                                                       timeout);
+
+vk::Move<vk::VkDescriptorSet>          makeDescriptorSet                                       (const vk::DeviceInterface&                     vk,
+                                                                                                                                                const vk::VkDevice                                     device,
+                                                                                                                                                const vk::VkDescriptorPool                     descriptorPool,
+                                                                                                                                                const vk::VkDescriptorSetLayout        setLayout);
+vk::Move<vk::VkPipelineLayout>         makePipelineLayout                                      (const vk::DeviceInterface&                     vk,
+                                                                                                                                                const vk::VkDevice                                     device,
+                                                                                                                                                const vk::VkDescriptorSetLayout        descriptorSetLayout);
+
+vk::Move<vk::VkPipeline>                       makeComputePipeline                                     (const vk::DeviceInterface&                     vk,
+                                                                                                                                                const vk::VkDevice                                     device,
+                                                                                                                                                const vk::VkPipelineLayout                     pipelineLayout,
+                                                                                                                                                const vk::VkShaderModule                       shaderModule,
+                                                                                                                                                const vk::VkSpecializationInfo*        specInfo);
+
+vk::Move<vk::VkSampler>                                makeSampler                                                     (const vk::DeviceInterface&                     vk,
+                                                                                                                                                const vk::VkDevice&                            device);
+vk::Move<vk::VkCommandPool>                    makeCommandPool                                         (const vk::DeviceInterface&                     vk,
+                                                                                                                                                const vk::VkDevice&                            device,
+                                                                                                                                                ProtectionMode                                         protectionMode,
+                                                                                                                                                const deUint32                                         queueFamilyIdx);
+
+} // ProtectedMem
+} // vkt
+
+#endif // _VKTPROTECTEDMEMUTILS_HPP
index 063c64e..84b7fee 100644 (file)
@@ -81,6 +81,7 @@
 #include "vktMultiViewTests.hpp"
 #include "vktSubgroupsTests.hpp"
 #include "vktYCbCrTests.hpp"
+#include "vktProtectedMemTests.hpp"
 
 #include <vector>
 #include <sstream>
@@ -408,6 +409,7 @@ void TestPackage::init (void)
        addChild(MultiView::createTests                 (m_testCtx));
        addChild(subgroups::createTests                 (m_testCtx));
        addChild(ycbcr::createTests                             (m_testCtx));
+       addChild(ProtectedMem::createTests              (m_testCtx));
 }
 
 } // vkt
index a833272..2bbd8fa 100644 (file)
@@ -265575,3 +265575,20 @@ dEQP-VK.ycbcr.copy.g16_b16_r16_3plane_444_unorm_khr.g16_b16_r16_3plane_444_unorm
 dEQP-VK.ycbcr.copy.g16_b16_r16_3plane_444_unorm_khr.g16_b16_r16_3plane_444_unorm_khr.optimal_optimal_disjoint
 dEQP-VK.ycbcr.copy.g16_b16_r16_3plane_444_unorm_khr.g16_b16_r16_3plane_444_unorm_khr.optimal_disjoint_optimal
 dEQP-VK.ycbcr.copy.g16_b16_r16_3plane_444_unorm_khr.g16_b16_r16_3plane_444_unorm_khr.optimal_disjoint_optimal_disjoint
+dEQP-VK.protected_memory.attachment.load_op.static.clear_1
+dEQP-VK.protected_memory.attachment.load_op.static.clear_2
+dEQP-VK.protected_memory.attachment.load_op.static.clear_3
+dEQP-VK.protected_memory.attachment.load_op.static.clear_4
+dEQP-VK.protected_memory.attachment.load_op.static.clear_5
+dEQP-VK.protected_memory.attachment.load_op.static.clear_6
+dEQP-VK.protected_memory.attachment.load_op.static.clear_7
+dEQP-VK.protected_memory.attachment.load_op.random.clear_1
+dEQP-VK.protected_memory.attachment.load_op.random.clear_2
+dEQP-VK.protected_memory.attachment.load_op.random.clear_3
+dEQP-VK.protected_memory.attachment.load_op.random.clear_4
+dEQP-VK.protected_memory.attachment.load_op.random.clear_5
+dEQP-VK.protected_memory.attachment.load_op.random.clear_6
+dEQP-VK.protected_memory.attachment.load_op.random.clear_7
+dEQP-VK.protected_memory.attachment.load_op.random.clear_8
+dEQP-VK.protected_memory.attachment.load_op.random.clear_9
+dEQP-VK.protected_memory.attachment.load_op.random.clear_10
index f0073d3..a6a9e5f 100644 (file)
@@ -301,6 +301,9 @@ typedef enum VkStructureType {
     VK_STRUCTURE_TYPE_MEMORY_GET_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129004,
     VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_EXTERNAL_FORMAT_PROPERTIES_ANDROID = 1000129005,
     VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID = 1000129006,
+    VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO_KHR = 1000145000,
+    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES_KHR = 1000145001,
+    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES_KHR = 1000145002,
     VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR = 1000146000,
     VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR = 1000146001,
     VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR = 1000147000,
@@ -1030,6 +1033,7 @@ typedef enum VkImageCreateFlagBits {
     VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR = 0x00000100,
     VK_IMAGE_CREATE_ALIAS_BIT_KHR = 0x00000400,
     VK_IMAGE_CREATE_DISJOINT_BIT_KHR = 0x00000200,
+    VK_IMAGE_CREATE_PROTECTED_BIT_KHR = 0x00000800,
     VK_IMAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
 } VkImageCreateFlagBits;
 typedef VkFlags VkImageCreateFlags;
@@ -1051,6 +1055,7 @@ typedef enum VkQueueFlagBits {
     VK_QUEUE_COMPUTE_BIT = 0x00000002,
     VK_QUEUE_TRANSFER_BIT = 0x00000004,
     VK_QUEUE_SPARSE_BINDING_BIT = 0x00000008,
+    VK_QUEUE_PROTECTED_BIT_KHR = 0x00000010,
     VK_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
 } VkQueueFlagBits;
 typedef VkFlags VkQueueFlags;
@@ -1061,6 +1066,7 @@ typedef enum VkMemoryPropertyFlagBits {
     VK_MEMORY_PROPERTY_HOST_COHERENT_BIT = 0x00000004,
     VK_MEMORY_PROPERTY_HOST_CACHED_BIT = 0x00000008,
     VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 0x00000010,
+    VK_MEMORY_PROPERTY_PROTECTED_BIT_KHR = 0x00000020,
     VK_MEMORY_PROPERTY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
 } VkMemoryPropertyFlagBits;
 typedef VkFlags VkMemoryPropertyFlags;
@@ -1072,6 +1078,11 @@ typedef enum VkMemoryHeapFlagBits {
 } VkMemoryHeapFlagBits;
 typedef VkFlags VkMemoryHeapFlags;
 typedef VkFlags VkDeviceCreateFlags;
+
+typedef enum VkDeviceQueueCreateFlagBits {
+    VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT_KHR = 0x00000001,
+    VK_DEVICE_QUEUE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkDeviceQueueCreateFlagBits;
 typedef VkFlags VkDeviceQueueCreateFlags;
 
 typedef enum VkPipelineStageFlagBits {
@@ -1161,6 +1172,7 @@ typedef enum VkBufferCreateFlagBits {
     VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 0x00000001,
     VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002,
     VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004,
+    VK_BUFFER_CREATE_PROTECTED_BIT_KHR = 0x00000008,
     VK_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
 } VkBufferCreateFlagBits;
 typedef VkFlags VkBufferCreateFlags;
@@ -1295,6 +1307,7 @@ typedef VkFlags VkDependencyFlags;
 typedef enum VkCommandPoolCreateFlagBits {
     VK_COMMAND_POOL_CREATE_TRANSIENT_BIT = 0x00000001,
     VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 0x00000002,
+    VK_COMMAND_POOL_CREATE_PROTECTED_BIT_KHR = 0x00000004,
     VK_COMMAND_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
 } VkCommandPoolCreateFlagBits;
 typedef VkFlags VkCommandPoolCreateFlags;
@@ -4502,6 +4515,27 @@ typedef struct VkMemoryDedicatedAllocateInfoKHR {
     VkBuffer           buffer;
 } VkMemoryDedicatedAllocateInfoKHR;
 
+#define VK_KHR_protected_memory 1
+#define VK_KHR_PROTECTED_MEMORY_SPEC_VERSION 1
+#define VK_KHR_PROTECTED_MEMORY_EXTENSION_NAME "VK_KHR_protected_memory"
+
+typedef struct VkProtectedSubmitInfoKHR {
+    VkStructureType    sType;
+    const void*        pNext;
+    VkBool32           protectedSubmit;
+} VkProtectedSubmitInfoKHR;
+
+typedef struct VkPhysicalDeviceProtectedMemoryFeaturesKHR {
+    VkStructureType    sType;
+    void*              pNext;
+    VkBool32           protectedMemory;
+} VkPhysicalDeviceProtectedMemoryFeaturesKHR;
+
+typedef struct VkPhysicalDeviceProtectedMemoryPropertiesKHR {
+    VkStructureType    sType;
+    void*              pNext;
+    VkBool32           protectedNoFault;
+} VkPhysicalDeviceProtectedMemoryPropertiesKHR;
 
 #define VK_KHR_get_memory_requirements2 1
 #define VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION 1