blob: fe018e494f5ee766505c3ff58b0fa5698233bf7b [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
jvanverthe50f3e72016-03-28 07:03:06 -070013#include "vk/GrVkDefines.h"
Michael Jurka3251ed82017-04-05 09:52:55 -070014#include "vk/GrVkInterface.h"
Greg Daniel81df0412018-05-31 13:13:33 -040015#include "vk/GrVkMemoryAllocator.h"
Greg Danielde811432018-05-30 22:58:20 +000016
jvanverthfd7bd452016-03-25 06:29:52 -070017enum GrVkExtensionFlags {
Jim Van Verth6a40abc2017-11-02 16:56:09 +000018 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,
jvanverthfd7bd452016-03-25 06:29:52 -070025};
26
27enum GrVkFeatureFlags {
28 kGeometryShader_GrVkFeatureFlag = 0x0001,
29 kDualSrcBlend_GrVkFeatureFlag = 0x0002,
30 kSampleRateShading_GrVkFeatureFlag = 0x0004,
31};
32
jvanverth633b3562016-03-23 11:01:22 -070033// 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 Wagner63fd7602017-10-09 15:45:33 -040035// 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 Danielf730c182018-07-02 20:15:37 +000037// 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.
41struct SK_API GrVkBackendContext {
bungeman6bd52842016-10-27 09:30:08 -070042 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 Daniel81df0412018-05-31 13:13:33 -040051 sk_sp<GrVkMemoryAllocator> fMemoryAllocator;
Greg Danieldc13c212018-06-28 23:29:35 +000052
Greg Danielf730c182018-07-02 20:15:37 +000053 // 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;
jvanverth633b3562016-03-23 11:01:22 -070056};
57
58#endif