1 #ifndef _VKTPROTECTEDMEMCONTEXT_HPP 2 #define _VKTPROTECTEDMEMCONTEXT_HPP 3 /*------------------------------------------------------------------------ 4 * Vulkan Conformance Tests 5 * ------------------------ 6 * 7 * Copyright (c) 2017 The Khronos Group Inc. 8 * Copyright (c) 2017 Samsung Electronics Co., Ltd. 9 * 10 * Licensed under the Apache License, Version 2.0 (the "License"); 11 * you may not use this file except in compliance with the License. 12 * You may obtain a copy of the License at 13 * 14 * http://www.apache.org/licenses/LICENSE-2.0 15 * 16 * Unless required by applicable law or agreed to in writing, software 17 * distributed under the License is distributed on an "AS IS" BASIS, 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 * See the License for the specific language governing permissions and 20 * limitations under the License. 21 * 22 *//*! 23 * \file 24 * \brief Protected Memory image validator helper 25 *//*--------------------------------------------------------------------*/ 26 27 #include "tcuVector.hpp" 28 #include "vkDefs.hpp" 29 #include "vktTestCase.hpp" 30 #include "vktCustomInstancesDevices.hpp" 31 32 #include "vktProtectedMemUtils.hpp" 33 #include "tcuCommandLine.hpp" 34 #include "vkMemUtil.hpp" 35 #include "vkWsiUtil.hpp" 36 37 namespace vkt 38 { 39 namespace ProtectedMem 40 { 41 42 class ProtectedContext 43 { 44 public: 45 ProtectedContext (Context& ctx, 46 const std::vector<std::string> instanceExtensions = std::vector<std::string>(), 47 const std::vector<std::string> deviceExtensions = std::vector<std::string>()); 48 49 ProtectedContext (Context& ctx, 50 vk::wsi::Type wsiType, 51 vk::wsi::Display& display, 52 vk::wsi::Window& window, 53 const std::vector<std::string> instanceExtensions = std::vector<std::string>(), 54 const std::vector<std::string> deviceExtensions = std::vector<std::string>()); 55 getDeviceInterface(void) const56 const vk::DeviceInterface& getDeviceInterface (void) const { return m_deviceDriver; } getDevice(void) const57 vk::VkDevice getDevice (void) const { return *m_device; } getDeviceDriver(void) const58 const vk::DeviceDriver& getDeviceDriver (void) const { return m_deviceDriver; } getPhysicalDevice(void) const59 vk::VkPhysicalDevice getPhysicalDevice (void) const { return m_phyDevice; } getQueue(void) const60 vk::VkQueue getQueue (void) const { return m_queue; } getQueueFamilyIndex(void) const61 deUint32 getQueueFamilyIndex (void) const { return m_queueFamilyIndex; } 62 getTestContext(void) const63 tcu::TestContext& getTestContext (void) const { return m_context.getTestContext(); } getBinaryCollection(void) const64 vk::BinaryCollection& getBinaryCollection (void) const { return m_context.getBinaryCollection(); } getDefaultAllocator(void) const65 vk::Allocator& getDefaultAllocator (void) const { return *m_allocator; } 66 getInstanceDriver(void) const67 const vk::InstanceDriver& getInstanceDriver (void) const { return m_vki; } getInstance(void) const68 vk::VkInstance getInstance (void) const { return m_instance; } getSurface(void) const69 const vk::VkSurfaceKHR getSurface (void) const { return *m_surface; } 70 71 72 private: createAllocator(void)73 vk::Allocator* createAllocator (void) 74 { 75 const vk::VkPhysicalDeviceMemoryProperties memoryProperties = 76 vk::getPhysicalDeviceMemoryProperties(m_vki, m_phyDevice); 77 78 // \todo [2015-07-24 jarkko] support allocator selection/configuration from command line (or compile time) 79 return new vk::SimpleAllocator(getDeviceInterface(), getDevice(), memoryProperties); 80 } 81 82 Context& m_context; 83 const vk::PlatformInterface& m_interface; 84 CustomInstance m_instance; 85 const vk::InstanceDriver& m_vki; 86 vk::VkPhysicalDevice m_phyDevice; 87 const vk::Move<vk::VkSurfaceKHR> m_surface; 88 deUint32 m_queueFamilyIndex; 89 vk::Move<vk::VkDevice> m_device; 90 const de::UniquePtr<vk::Allocator> m_allocator; 91 vk::DeviceDriver m_deviceDriver; 92 vk::VkQueue m_queue; 93 }; 94 95 class ProtectedTestInstance : public TestInstance 96 { 97 public: ProtectedTestInstance(Context & ctx)98 ProtectedTestInstance (Context& ctx) 99 : TestInstance (ctx) 100 , m_protectedContext (ctx) 101 {} 102 protected: 103 ProtectedContext m_protectedContext; 104 }; 105 106 } // ProtectedMem 107 } // vkt 108 109 #endif // _VKTPROTECTEDMEMCONTEXT_HPP 110