• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
31 #include "vktProtectedMemUtils.hpp"
32 #include "tcuCommandLine.hpp"
33 #include "vkMemUtil.hpp"
34 #include "vkWsiUtil.hpp"
35 
36 namespace vkt
37 {
38 namespace ProtectedMem
39 {
40 
41 class ProtectedContext
42 {
43 public:
44 		ProtectedContext	(Context&						ctx,
45 							 const std::vector<std::string>	instanceExtensions = std::vector<std::string>(),
46 							 const std::vector<std::string>	deviceExtensions = std::vector<std::string>());
47 
48 		ProtectedContext	(Context&						ctx,
49 							 vk::wsi::Type					wsiType,
50 							 vk::wsi::Display&				display,
51 							 vk::wsi::Window&				window,
52 							 const std::vector<std::string>	instanceExtensions = std::vector<std::string>(),
53 							 const std::vector<std::string>	deviceExtensions = std::vector<std::string>());
54 
getDeviceInterface(void) const55 	const vk::DeviceInterface&					getDeviceInterface	(void) const	{ return m_deviceDriver;					}
getDevice(void) const56 	vk::VkDevice								getDevice			(void) const	{ return *m_device;							}
getDeviceDriver(void) const57 	const vk::DeviceDriver&						getDeviceDriver		(void) const	{ return m_deviceDriver;					}
getPhysicalDevice(void) const58 	vk::VkPhysicalDevice						getPhysicalDevice	(void) const	{ return m_phyDevice;						}
getQueue(void) const59 	vk::VkQueue									getQueue			(void) const	{ return m_queue;							}
getQueueFamilyIndex(void) const60 	deUint32									getQueueFamilyIndex	(void) const	{ return m_queueFamilyIndex;				}
61 
getTestContext(void) const62 	tcu::TestContext&							getTestContext		(void) const	{ return m_context.getTestContext();		}
getBinaryCollection(void) const63 	vk::BinaryCollection&						getBinaryCollection	(void) const	{ return m_context.getBinaryCollection();	}
getDefaultAllocator(void) const64 	vk::Allocator&								getDefaultAllocator	(void) const	{ return *m_allocator;	}
65 
getInstanceDriver(void) const66 	const vk::InstanceDriver&					getInstanceDriver	(void) const	{ return m_vki;								}
getInstance(void) const67 	vk::VkInstance								getInstance			(void) const	{ return *m_instance;						}
getSurface(void) const68 	const vk::VkSurfaceKHR						getSurface			(void) const	{ return *m_surface;						}
69 
70 
71 private:
createAllocator(void)72 	vk::Allocator* createAllocator (void)
73 	{
74 		const vk::VkPhysicalDeviceMemoryProperties memoryProperties =
75 			vk::getPhysicalDeviceMemoryProperties(m_vki, m_phyDevice);
76 
77 		// \todo [2015-07-24 jarkko] support allocator selection/configuration from command line (or compile time)
78 		return new vk::SimpleAllocator(getDeviceInterface(), getDevice(), memoryProperties);
79 	}
80 
81 	Context&							m_context;
82 	const vk::PlatformInterface&		m_interface;
83 	vk::Move<vk::VkInstance>			m_instance;
84 	vk::InstanceDriver					m_vki;
85 	vk::VkPhysicalDevice				m_phyDevice;
86 	const vk::Move<vk::VkSurfaceKHR>	m_surface;
87 	deUint32							m_queueFamilyIndex;
88 	vk::Move<vk::VkDevice>				m_device;
89 	const de::UniquePtr<vk::Allocator>	m_allocator;
90 	vk::DeviceDriver					m_deviceDriver;
91 	vk::VkQueue							m_queue;
92 };
93 
94 class ProtectedTestInstance : public TestInstance
95 {
96 public:
ProtectedTestInstance(Context & ctx)97 				ProtectedTestInstance	(Context& ctx)
98 					: TestInstance			(ctx)
99 					, m_protectedContext	(ctx)
100 				{}
101 protected:
102 	ProtectedContext	m_protectedContext;
103 };
104 
105 } // ProtectedMem
106 } // vkt
107 
108 #endif // _VKTPROTECTEDMEMCONTEXT_HPP
109