OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrVkBackendContext_DEFINED | 8 #ifndef GrVkBackendContext_DEFINED |
9 #define GrVkBackendContext_DEFINED | 9 #define GrVkBackendContext_DEFINED |
10 | 10 |
11 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
12 | 12 |
13 #include "vk/GrVkDefines.h" | 13 #include "vk/GrVkDefines.h" |
14 | 14 |
15 #ifdef SK_DEBUG | 15 #ifdef SK_DEBUG |
16 #define ENABLE_VK_LAYERS | 16 #define ENABLE_VK_LAYERS |
17 #endif | 17 #endif |
18 | 18 |
19 struct GrVkInterface; | 19 struct GrVkInterface; |
20 | 20 |
21 enum GrVkExtensionFlags { | 21 enum GrVkExtensionFlags { |
22 kEXT_debug_report_GrVkExtensionFlag = 0x0001, | 22 kEXT_debug_report_GrVkExtensionFlag = 0x0001, |
23 kNV_glsl_shader_GrVkExtensionFlag = 0x0002, | 23 kNV_glsl_shader_GrVkExtensionFlag = 0x0002, |
24 kKHR_surface_GrVkExtensionFlag = 0x0004, | 24 kKHR_surface_GrVkExtensionFlag = 0x0004, |
25 kKHR_swapchain_GrVkExtensionFlag = 0x0008, | 25 kKHR_swapchain_GrVkExtensionFlag = 0x0008, |
26 kKHR_win32_surface_GrVkExtensionFlag = 0x0010, | 26 kKHR_win32_surface_GrVkExtensionFlag = 0x0010, |
27 kKHR_android_surface_GrVkExtensionFlag = 0x0020, | 27 kKHR_android_surface_GrVkExtensionFlag = 0x0020, |
28 kKHR_xlib_surface_GrVkExtensionFlag = 0x0040, | 28 kKHR_xcb_surface_GrVkExtensionFlag = 0x0040, |
29 }; | 29 }; |
30 | 30 |
31 enum GrVkFeatureFlags { | 31 enum GrVkFeatureFlags { |
32 kGeometryShader_GrVkFeatureFlag = 0x0001, | 32 kGeometryShader_GrVkFeatureFlag = 0x0001, |
33 kDualSrcBlend_GrVkFeatureFlag = 0x0002, | 33 kDualSrcBlend_GrVkFeatureFlag = 0x0002, |
34 kSampleRateShading_GrVkFeatureFlag = 0x0004, | 34 kSampleRateShading_GrVkFeatureFlag = 0x0004, |
35 }; | 35 }; |
36 | 36 |
37 // The BackendContext contains all of the base Vulkan objects needed by the GrVk
Gpu. The assumption | 37 // The BackendContext contains all of the base Vulkan objects needed by the GrVk
Gpu. The assumption |
38 // is that the client will set these up and pass them to the GrVkGpu constructor
. The VkDevice | 38 // is that the client will set these up and pass them to the GrVkGpu constructor
. The VkDevice |
39 // created must support at least one graphics queue, which is passed in as well.
| 39 // created must support at least one graphics queue, which is passed in as well.
|
40 // The QueueFamilyIndex must match the family of the given queue. It is needed f
or CommandPool | 40 // The QueueFamilyIndex must match the family of the given queue. It is needed f
or CommandPool |
41 // creation, and any GrBackendObjects handed to us (e.g., for wrapped textures)
need to be created | 41 // creation, and any GrBackendObjects handed to us (e.g., for wrapped textures)
need to be created |
42 // in or transitioned to that family. | 42 // in or transitioned to that family. |
43 struct GrVkBackendContext : public SkRefCnt { | 43 struct GrVkBackendContext : public SkRefCnt { |
44 VkInstance fInstance; | 44 VkInstance fInstance; |
45 VkPhysicalDevice fPhysicalDevice; | 45 VkPhysicalDevice fPhysicalDevice; |
46 VkDevice fDevice; | 46 VkDevice fDevice; |
47 VkQueue fQueue; | 47 VkQueue fQueue; |
48 uint32_t fGraphicsQueueIndex; | 48 uint32_t fGraphicsQueueIndex; |
49 uint32_t fMinAPIVersion; | 49 uint32_t fMinAPIVersion; |
50 uint32_t fExtensions; | 50 uint32_t fExtensions; |
51 uint32_t fFeatures; | 51 uint32_t fFeatures; |
52 SkAutoTUnref<const GrVkInterface> fInterface; | 52 SkAutoTUnref<const GrVkInterface> fInterface; |
53 | 53 |
54 // Helper function to create the default Vulkan objects needed by the GrVkGp
u object | 54 // Helper function to create the default Vulkan objects needed by the GrVkGp
u object |
55 // If presentQueueIndex is non-NULL, will try to set up presentQueue as part
of device | 55 // If presentQueueIndex is non-NULL, will try to set up presentQueue as part
of device |
56 // creation. canPresent() is a device-dependent function. | 56 // creation. canPresent() is a device-dependent function. |
57 static const GrVkBackendContext* Create(uint32_t* presentQueueIndex = nullpt
r, | 57 static const GrVkBackendContext* Create(uint32_t* presentQueueIndex = nullpt
r, |
58 bool(*canPresent)(VkInstance, VkPhysicalDevice, uint32_t que
ueIndex) = nullptr); | 58 bool(*canPresent)(VkInstance, VkPhysicalDevice, uint32_t que
ueIndex, |
| 59 void* platformData) = nullptr, |
| 60 void* platformData = nullptr); |
59 | 61 |
60 ~GrVkBackendContext() override; | 62 ~GrVkBackendContext() override; |
61 }; | 63 }; |
62 | 64 |
63 #endif | 65 #endif |
OLD | NEW |