blob: 8f4ba04584ed92e2dd2d9bfd525a91bc96d85b08 [file] [log] [blame]
jvanverth633b3562016-03-23 11:01:22 -07001/*
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
19struct GrVkInterface;
20
jvanverthfd7bd452016-03-25 06:29:52 -070021enum GrVkExtensionFlags {
22 kEXT_debug_report_GrVkExtensionFlag = 0x0001,
23 kNV_glsl_shader_GrVkExtensionFlag = 0x0002,
24};
25
26enum GrVkFeatureFlags {
27 kGeometryShader_GrVkFeatureFlag = 0x0001,
28 kDualSrcBlend_GrVkFeatureFlag = 0x0002,
29 kSampleRateShading_GrVkFeatureFlag = 0x0004,
30};
31
jvanverth633b3562016-03-23 11:01:22 -070032// 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.
38struct GrVkBackendContext : public SkRefCnt {
39 VkInstance fInstance;
40 VkPhysicalDevice fPhysicalDevice;
41 VkDevice fDevice;
42 VkQueue fQueue;
43 uint32_t fQueueFamilyIndex;
jvanverthfd7bd452016-03-25 06:29:52 -070044 uint32_t fMinAPIVersion;
45 uint32_t fExtensions;
46 uint32_t fFeatures;
jvanverth633b3562016-03-23 11:01:22 -070047 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