1 // 2 // Copyright 2016 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // DeviceVk.h: 7 // Defines the class interface for DeviceVk, implementing DeviceImpl. 8 // 9 10 #ifndef LIBANGLE_RENDERER_VULKAN_DEVICEVK_H_ 11 #define LIBANGLE_RENDERER_VULKAN_DEVICEVK_H_ 12 13 #include "libANGLE/renderer/DeviceImpl.h" 14 15 #include "common/vulkan/vk_headers.h" 16 17 namespace rx 18 { 19 namespace vk 20 { 21 class Renderer; 22 } 23 24 class DeviceVk : public DeviceImpl 25 { 26 public: 27 DeviceVk(); 28 ~DeviceVk() override; 29 30 egl::Error initialize() override; 31 egl::Error getAttribute(const egl::Display *display, 32 EGLint attribute, 33 void **outValue) override; 34 void generateExtensions(egl::DeviceExtensions *outExtensions) const override; getRenderer()35 vk::Renderer *getRenderer() const { return mRenderer; } 36 37 private: 38 // Wrappers for some global vulkan methods which need to read env variables. 39 // The wrappers will set those env variables before calling those global methods. 40 static VKAPI_ATTR VkResult VKAPI_CALL 41 WrappedCreateInstance(const VkInstanceCreateInfo *pCreateInfo, 42 const VkAllocationCallbacks *pAllocator, 43 VkInstance *pInstance); 44 static VKAPI_ATTR VkResult VKAPI_CALL 45 WrappedEnumerateInstanceExtensionProperties(const char *pLayerName, 46 uint32_t *pPropertyCount, 47 VkExtensionProperties *pProperties); 48 static VKAPI_ATTR VkResult VKAPI_CALL 49 WrappedEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, 50 VkLayerProperties *pProperties); 51 static VKAPI_ATTR VkResult VKAPI_CALL WrappedEnumerateInstanceVersion(uint32_t *pApiVersion); 52 static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL WrappedGetInstanceProcAddr(VkInstance instance, 53 const char *pName); 54 55 vk::Renderer *mRenderer = nullptr; 56 }; 57 58 } // namespace rx 59 60 #endif // LIBANGLE_RENDERER_VULKAN_DEVICEVK_H_ 61