blob: 6d45a2045da69d807338af9938cbc8fe609ef388 [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
21// The BackendContext contains all of the base Vulkan objects needed by the GrVkGpu. The assumption
22// is that the client will set these up and pass them to the GrVkGpu constructor. The VkDevice
23// created must support at least one graphics queue, which is passed in as well.
24// The QueueFamilyIndex must match the family of the given queue. It is needed for CommandPool
25// creation, and any GrBackendObjects handed to us (e.g., for wrapped textures) need to be created
26// in or transitioned to that family.
27struct GrVkBackendContext : public SkRefCnt {
28 VkInstance fInstance;
29 VkPhysicalDevice fPhysicalDevice;
30 VkDevice fDevice;
31 VkQueue fQueue;
32 uint32_t fQueueFamilyIndex;
33 SkAutoTUnref<const GrVkInterface> fInterface;
34
35 // Helper function to create the default Vulkan objects needed by the GrVkGpu object
36 static const GrVkBackendContext* Create();
37
38 ~GrVkBackendContext() override;
39};
40
41#endif