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 | |
| 13 | #include "vulkan/vulkan.h" |
| 14 | |
| 15 | #ifdef SK_DEBUG |
| 16 | #define ENABLE_VK_LAYERS |
| 17 | #endif |
| 18 | |
| 19 | struct GrVkInterface; |
| 20 | |
jvanverth | fd7bd45 | 2016-03-25 06:29:52 -0700 | [diff] [blame^] | 21 | enum GrVkExtensionFlags { |
| 22 | kEXT_debug_report_GrVkExtensionFlag = 0x0001, |
| 23 | kNV_glsl_shader_GrVkExtensionFlag = 0x0002, |
| 24 | }; |
| 25 | |
| 26 | enum GrVkFeatureFlags { |
| 27 | kGeometryShader_GrVkFeatureFlag = 0x0001, |
| 28 | kDualSrcBlend_GrVkFeatureFlag = 0x0002, |
| 29 | kSampleRateShading_GrVkFeatureFlag = 0x0004, |
| 30 | }; |
| 31 | |
jvanverth | 633b356 | 2016-03-23 11:01:22 -0700 | [diff] [blame] | 32 | // The BackendContext contains all of the base Vulkan objects needed by the GrVkGpu. The assumption |
| 33 | // is that the client will set these up and pass them to the GrVkGpu constructor. The VkDevice |
| 34 | // created must support at least one graphics queue, which is passed in as well. |
| 35 | // The QueueFamilyIndex must match the family of the given queue. It is needed for CommandPool |
| 36 | // creation, and any GrBackendObjects handed to us (e.g., for wrapped textures) need to be created |
| 37 | // in or transitioned to that family. |
| 38 | struct GrVkBackendContext : public SkRefCnt { |
| 39 | VkInstance fInstance; |
| 40 | VkPhysicalDevice fPhysicalDevice; |
| 41 | VkDevice fDevice; |
| 42 | VkQueue fQueue; |
| 43 | uint32_t fQueueFamilyIndex; |
jvanverth | fd7bd45 | 2016-03-25 06:29:52 -0700 | [diff] [blame^] | 44 | uint32_t fMinAPIVersion; |
| 45 | uint32_t fExtensions; |
| 46 | uint32_t fFeatures; |
jvanverth | 633b356 | 2016-03-23 11:01:22 -0700 | [diff] [blame] | 47 | SkAutoTUnref<const GrVkInterface> fInterface; |
| 48 | |
| 49 | // Helper function to create the default Vulkan objects needed by the GrVkGpu object |
| 50 | static const GrVkBackendContext* Create(); |
| 51 | |
| 52 | ~GrVkBackendContext() override; |
| 53 | }; |
| 54 | |
| 55 | #endif |