1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2017 The Khronos Group Inc.
6  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  *//*!
21  * \file
22  * \brief Protected Memory
23  *//*--------------------------------------------------------------------*/
24 #include "vktProtectedMemContext.hpp"
25 
26 namespace vkt
27 {
28 namespace ProtectedMem
29 {
30 
ProtectedContext(Context & ctx,const std::vector<std::string> instanceExtensions,const std::vector<std::string> deviceExtensions)31 ProtectedContext::ProtectedContext(Context &ctx, const std::vector<std::string> instanceExtensions,
32                                    const std::vector<std::string> deviceExtensions)
33     : m_context(ctx)
34     , m_interface(m_context.getPlatformInterface())
35     , m_instance(makeProtectedMemInstance(m_context, instanceExtensions))
36     , m_vki(m_instance.getDriver())
37     , m_phyDevice(vk::chooseDevice(m_vki, m_instance, m_context.getTestContext().getCommandLine()))
38     , m_queueFamilyIndex(chooseProtectedMemQueueFamilyIndex(m_vki, m_phyDevice))
39     , m_device(makeProtectedMemDevice(m_interface, m_instance, m_vki, m_phyDevice, m_queueFamilyIndex,
40                                       ctx.getUsedApiVersion(), deviceExtensions,
41 #ifdef CTS_USES_VULKANSC
42                                       ctx.getResourceInterface(),
43 #endif // CTS_USES_VULKANSC
44                                       ctx.getTestContext().getCommandLine()))
45     , m_deviceDriver(m_context.getPlatformInterface(), m_instance, *m_device, m_context.getUsedApiVersion(),
46                      m_context.getTestContext().getCommandLine())
47     , m_allocator(createAllocator())
48     , m_queue(getProtectedQueue(m_deviceDriver, *m_device, m_queueFamilyIndex, 0))
49 {
50 }
51 
ProtectedContext(Context & ctx,vk::wsi::Type wsiType,vk::wsi::Display & display,vk::wsi::Window & window,const std::vector<std::string> instanceExtensions,const std::vector<std::string> deviceExtensions)52 ProtectedContext::ProtectedContext(Context &ctx, vk::wsi::Type wsiType, vk::wsi::Display &display,
53                                    vk::wsi::Window &window, const std::vector<std::string> instanceExtensions,
54                                    const std::vector<std::string> deviceExtensions)
55     : m_context(ctx)
56     , m_interface(m_context.getPlatformInterface())
57     , m_instance(makeProtectedMemInstance(m_context, instanceExtensions))
58     , m_vki(m_instance.getDriver())
59     , m_phyDevice(vk::chooseDevice(m_vki, m_instance, m_context.getTestContext().getCommandLine()))
60     , m_surface(vk::wsi::createSurface(m_vki, m_instance, wsiType, display, window,
61                                        m_context.getTestContext().getCommandLine()))
62     , m_queueFamilyIndex(chooseProtectedMemQueueFamilyIndex(m_vki, m_phyDevice, *m_surface))
63     , m_device(makeProtectedMemDevice(m_interface, m_instance, m_vki, m_phyDevice, m_queueFamilyIndex,
64                                       ctx.getUsedApiVersion(), deviceExtensions,
65 #ifdef CTS_USES_VULKANSC
66                                       ctx.getResourceInterface(),
67 #endif // CTS_USES_VULKANSC
68                                       ctx.getTestContext().getCommandLine()))
69     , m_deviceDriver(m_interface, m_instance, *m_device, m_context.getUsedApiVersion(),
70                      m_context.getTestContext().getCommandLine())
71     , m_allocator(createAllocator())
72     , m_queue(getProtectedQueue(m_deviceDriver, *m_device, m_queueFamilyIndex, 0))
73 {
74 }
75 
76 } // namespace ProtectedMem
77 } // namespace vkt
78