jvanverth | 633b356 | 2016-03-23 11:01:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrVkBackendContext_DEFINED |
| 9 | #define GrVkBackendContext_DEFINED |
| 10 | |
| 11 | #include "SkRefCnt.h" |
| 12 | |
jvanverth | e50f3e7 | 2016-03-28 07:03:06 -0700 | [diff] [blame] | 13 | #include "vk/GrVkDefines.h" |
Michael Jurka | 3251ed8 | 2017-04-05 09:52:55 -0700 | [diff] [blame] | 14 | #include "vk/GrVkInterface.h" |
Greg Daniel | 81df041 | 2018-05-31 13:13:33 -0400 | [diff] [blame] | 15 | #include "vk/GrVkMemoryAllocator.h" |
Greg Daniel | de81143 | 2018-05-30 22:58:20 +0000 | [diff] [blame] | 16 | |
jvanverth | fd7bd45 | 2016-03-25 06:29:52 -0700 | [diff] [blame] | 17 | enum GrVkExtensionFlags { |
Jim Van Verth | 6a40abc | 2017-11-02 16:56:09 +0000 | [diff] [blame] | 18 | kEXT_debug_report_GrVkExtensionFlag = 0x0001, |
| 19 | kNV_glsl_shader_GrVkExtensionFlag = 0x0002, |
| 20 | kKHR_surface_GrVkExtensionFlag = 0x0004, |
| 21 | kKHR_swapchain_GrVkExtensionFlag = 0x0008, |
| 22 | kKHR_win32_surface_GrVkExtensionFlag = 0x0010, |
| 23 | kKHR_android_surface_GrVkExtensionFlag = 0x0020, |
| 24 | kKHR_xcb_surface_GrVkExtensionFlag = 0x0040, |
jvanverth | fd7bd45 | 2016-03-25 06:29:52 -0700 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | enum GrVkFeatureFlags { |
| 28 | kGeometryShader_GrVkFeatureFlag = 0x0001, |
| 29 | kDualSrcBlend_GrVkFeatureFlag = 0x0002, |
| 30 | kSampleRateShading_GrVkFeatureFlag = 0x0004, |
| 31 | }; |
| 32 | |
jvanverth | 633b356 | 2016-03-23 11:01:22 -0700 | [diff] [blame] | 33 | // The BackendContext contains all of the base Vulkan objects needed by the GrVkGpu. The assumption |
| 34 | // is that the client will set these up and pass them to the GrVkGpu constructor. The VkDevice |
Ben Wagner | 63fd760 | 2017-10-09 15:45:33 -0400 | [diff] [blame] | 35 | // created must support at least one graphics queue, which is passed in as well. |
| 36 | // The QueueFamilyIndex must match the family of the given queue. It is needed for CommandPool |
Greg Daniel | f730c18 | 2018-07-02 20:15:37 +0000 | [diff] [blame^] | 37 | // creation, and any GrBackendObjects handed to us (e.g., for wrapped textures) needs to be created |
| 38 | // in or transitioned to that family. The refs held by members of this struct must be released |
| 39 | // (either by deleting the struct or manually releasing the refs) before the underlying vulkan |
| 40 | // device and instance are destroyed. |
| 41 | struct SK_API GrVkBackendContext { |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 42 | VkInstance fInstance; |
| 43 | VkPhysicalDevice fPhysicalDevice; |
| 44 | VkDevice fDevice; |
| 45 | VkQueue fQueue; |
| 46 | uint32_t fGraphicsQueueIndex; |
| 47 | uint32_t fMinAPIVersion; |
| 48 | uint32_t fExtensions; |
| 49 | uint32_t fFeatures; |
| 50 | sk_sp<const GrVkInterface> fInterface; |
Greg Daniel | 81df041 | 2018-05-31 13:13:33 -0400 | [diff] [blame] | 51 | sk_sp<GrVkMemoryAllocator> fMemoryAllocator; |
Greg Daniel | dc13c21 | 2018-06-28 23:29:35 +0000 | [diff] [blame] | 52 | |
Greg Daniel | f730c18 | 2018-07-02 20:15:37 +0000 | [diff] [blame^] | 53 | // This is deprecated and should be set to false. The client is responsible for managing the |
| 54 | // lifetime of the VkInstance and VkDevice objects. |
| 55 | bool fOwnsInstanceAndDevice = false; |
jvanverth | 633b356 | 2016-03-23 11:01:22 -0700 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | #endif |