1 #ifndef _VKTPROTECTEDMEMCONTEXT_HPP
2 #define _VKTPROTECTEDMEMCONTEXT_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2017 The Khronos Group Inc.
8 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
14 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 * \brief Protected Memory image validator helper
25 *//*--------------------------------------------------------------------*/
27 #include "tcuVector.hpp"
29 #include "vktTestCase.hpp"
31 #include "vktProtectedMemUtils.hpp"
32 #include "tcuCommandLine.hpp"
33 #include "vkMemUtil.hpp"
37 namespace ProtectedMem
41 class ProtectedContext
44 ProtectedContext (Context& ctx)
46 , m_interface (m_context.getPlatformInterface())
47 , m_instance (makeProtectedMemInstance(m_interface, m_context))
48 , m_vki (m_interface, *m_instance)
49 , m_phyDevice (vk::chooseDevice(m_vki, *m_instance, m_context.getTestContext().getCommandLine()))
50 , m_queueFamilyIndex (chooseProtectedMemQueueFamilyIndex(m_vki, m_phyDevice))
51 , m_device (makeProtectedMemDevice(m_vki, m_phyDevice, m_queueFamilyIndex, ctx.getUsedApiVersion()))
52 , m_allocator (createAllocator())
53 , m_deviceDriver (m_vki, *m_device)
54 , m_queue (getProtectedQueue(m_deviceDriver, *m_device, m_queueFamilyIndex, 0))
57 const vk::DeviceInterface& getDeviceInterface (void) const { return m_deviceDriver; }
58 vk::VkDevice getDevice (void) const { return *m_device; }
59 vk::VkQueue getQueue (void) const { return m_queue; }
60 deUint32 getQueueFamilyIndex (void) const { return m_queueFamilyIndex; }
62 tcu::TestContext& getTestContext (void) const { return m_context.getTestContext(); }
63 vk::BinaryCollection& getBinaryCollection (void) const { return m_context.getBinaryCollection(); }
64 vk::Allocator& getDefaultAllocator (void) const { return *m_allocator; }
67 vk::Allocator* createAllocator (void)
69 const vk::VkPhysicalDeviceMemoryProperties memoryProperties =
70 vk::getPhysicalDeviceMemoryProperties(m_vki, m_phyDevice);
72 // \todo [2015-07-24 jarkko] support allocator selection/configuration from command line (or compile time)
73 return new vk::SimpleAllocator(getDeviceInterface(), getDevice(), memoryProperties);
77 const vk::PlatformInterface& m_interface;
78 vk::Move<vk::VkInstance> m_instance;
79 vk::InstanceDriver m_vki;
80 vk::VkPhysicalDevice m_phyDevice;
81 deUint32 m_queueFamilyIndex;
82 vk::Move<vk::VkDevice> m_device;
83 const de::UniquePtr<vk::Allocator> m_allocator;
84 vk::DeviceDriver m_deviceDriver;
88 class ProtectedTestInstance : public TestInstance
91 ProtectedTestInstance (Context& ctx)
93 , m_protectedContext (ctx)
96 ProtectedContext m_protectedContext;
102 #endif // _VKTPROTECTEDMEMCONTEXT_HPP