aboutsummaryrefslogtreecommitdiff
path: root/src/deps/skia/include/gpu/vk
diff options
context:
space:
mode:
Diffstat (limited to 'src/deps/skia/include/gpu/vk')
-rw-r--r--src/deps/skia/include/gpu/vk/BUILD.bazel56
-rw-r--r--src/deps/skia/include/gpu/vk/GrVkBackendContext.h76
-rw-r--r--src/deps/skia/include/gpu/vk/GrVkExtensions.h63
-rw-r--r--src/deps/skia/include/gpu/vk/GrVkMemoryAllocator.h140
-rw-r--r--src/deps/skia/include/gpu/vk/GrVkTypes.h187
-rw-r--r--src/deps/skia/include/gpu/vk/GrVkVulkan.h32
6 files changed, 554 insertions, 0 deletions
diff --git a/src/deps/skia/include/gpu/vk/BUILD.bazel b/src/deps/skia/include/gpu/vk/BUILD.bazel
new file mode 100644
index 000000000..a2f41750e
--- /dev/null
+++ b/src/deps/skia/include/gpu/vk/BUILD.bazel
@@ -0,0 +1,56 @@
+load("//bazel:macros.bzl", "generated_cc_atom")
+
+generated_cc_atom(
+ name = "GrVkBackendContext_hdr",
+ hdrs = ["GrVkBackendContext.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ ":GrVkMemoryAllocator_hdr",
+ ":GrVkTypes_hdr",
+ "//include/core:SkRefCnt_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "GrVkExtensions_hdr",
+ hdrs = ["GrVkExtensions.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ ":GrVkTypes_hdr",
+ "//include/core:SkString_hdr",
+ "//include/private:SkTArray_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "GrVkMemoryAllocator_hdr",
+ hdrs = ["GrVkMemoryAllocator.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ ":GrVkTypes_hdr",
+ "//include/core:SkRefCnt_hdr",
+ "//include/gpu:GrTypes_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "GrVkTypes_hdr",
+ hdrs = ["GrVkTypes.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ ":GrVkVulkan_hdr",
+ "//include/core:SkTypes_hdr",
+ "//include/gpu:GrTypes_hdr",
+ ],
+)
+
+generated_cc_atom(
+ name = "GrVkVulkan_hdr",
+ hdrs = ["GrVkVulkan.h"],
+ visibility = ["//:__subpackages__"],
+ deps = [
+ "//include/core:SkTypes_hdr",
+ "//include/third_party/vulkan/vulkan:vulkan_android_hdr",
+ "//include/third_party/vulkan/vulkan:vulkan_core_hdr",
+ ],
+)
diff --git a/src/deps/skia/include/gpu/vk/GrVkBackendContext.h b/src/deps/skia/include/gpu/vk/GrVkBackendContext.h
new file mode 100644
index 000000000..a4fd336ff
--- /dev/null
+++ b/src/deps/skia/include/gpu/vk/GrVkBackendContext.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrVkBackendContext_DEFINED
+#define GrVkBackendContext_DEFINED
+
+#include "include/core/SkRefCnt.h"
+#include "include/gpu/vk/GrVkMemoryAllocator.h"
+#include "include/gpu/vk/GrVkTypes.h"
+
+class GrVkExtensions;
+
+enum GrVkExtensionFlags {
+ kEXT_debug_report_GrVkExtensionFlag = 0x0001,
+ kNV_glsl_shader_GrVkExtensionFlag = 0x0002,
+ kKHR_surface_GrVkExtensionFlag = 0x0004,
+ kKHR_swapchain_GrVkExtensionFlag = 0x0008,
+ kKHR_win32_surface_GrVkExtensionFlag = 0x0010,
+ kKHR_android_surface_GrVkExtensionFlag = 0x0020,
+ kKHR_xcb_surface_GrVkExtensionFlag = 0x0040,
+};
+
+enum GrVkFeatureFlags {
+ kGeometryShader_GrVkFeatureFlag = 0x0001,
+ kDualSrcBlend_GrVkFeatureFlag = 0x0002,
+ kSampleRateShading_GrVkFeatureFlag = 0x0004,
+};
+
+// It is not guarenteed VkPhysicalDeviceProperties2 will be in the client's header so we forward
+// declare it here to be safe.
+struct VkPhysicalDeviceFeatures2;
+
+// The BackendContext contains all of the base Vulkan objects needed by the GrVkGpu. The assumption
+// is that the client will set these up and pass them to the GrVkGpu constructor. The VkDevice
+// created must support at least one graphics queue, which is passed in as well.
+// The QueueFamilyIndex must match the family of the given queue. It is needed for CommandPool
+// creation, and any GrBackendObjects handed to us (e.g., for wrapped textures) needs to be created
+// in or transitioned to that family. The refs held by members of this struct must be released
+// (either by deleting the struct or manually releasing the refs) before the underlying vulkan
+// device and instance are destroyed.
+struct SK_API GrVkBackendContext {
+ VkInstance fInstance;
+ VkPhysicalDevice fPhysicalDevice;
+ VkDevice fDevice;
+ VkQueue fQueue;
+ uint32_t fGraphicsQueueIndex;
+ uint32_t fMinAPIVersion; // Deprecated. Set fInstanceVersion instead.
+ uint32_t fInstanceVersion = 0; // Deprecated. Set fMaxApiVersion instead
+ // The max api version set here should match the value set in VkApplicationInfo::apiVersion when
+ // then VkInstance was created.
+ uint32_t fMaxAPIVersion = 0;
+ uint32_t fExtensions = 0; // Deprecated. Use fVkExtensions instead.
+ const GrVkExtensions* fVkExtensions = nullptr;
+ uint32_t fFeatures; // Deprecated. Use fDeviceFeatures[2] instead.
+ // The client can create their VkDevice with either a VkPhysicalDeviceFeatures or
+ // VkPhysicalDeviceFeatures2 struct, thus we have to support taking both. The
+ // VkPhysicalDeviceFeatures2 struct is needed so we know if the client enabled any extension
+ // specific features. If fDeviceFeatures2 is not null then we ignore fDeviceFeatures. If both
+ // fDeviceFeatures and fDeviceFeatures2 are null we will assume no features are enabled.
+ const VkPhysicalDeviceFeatures* fDeviceFeatures = nullptr;
+ const VkPhysicalDeviceFeatures2* fDeviceFeatures2 = nullptr;
+ sk_sp<GrVkMemoryAllocator> fMemoryAllocator;
+ GrVkGetProc fGetProc = nullptr;
+ // This is deprecated and should be set to false. The client is responsible for managing the
+ // lifetime of the VkInstance and VkDevice objects.
+ bool fOwnsInstanceAndDevice = false;
+ // Indicates that we are working with protected content and all CommandPool and Queue operations
+ // should be done in a protected context.
+ GrProtected fProtectedContext = GrProtected::kNo;
+};
+
+#endif
diff --git a/src/deps/skia/include/gpu/vk/GrVkExtensions.h b/src/deps/skia/include/gpu/vk/GrVkExtensions.h
new file mode 100644
index 000000000..e78543dc7
--- /dev/null
+++ b/src/deps/skia/include/gpu/vk/GrVkExtensions.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrVkExtensions_DEFINED
+#define GrVkExtensions_DEFINED
+
+#include "include/core/SkString.h"
+#include "include/gpu/vk/GrVkTypes.h"
+#include "include/private/SkTArray.h"
+
+/**
+ * Helper class that eats in an array of extensions strings for instance and device and allows for
+ * quicker querying if an extension is present.
+ */
+class SK_API GrVkExtensions {
+public:
+ GrVkExtensions() {}
+
+ void init(GrVkGetProc, VkInstance, VkPhysicalDevice,
+ uint32_t instanceExtensionCount, const char* const* instanceExtensions,
+ uint32_t deviceExtensionCount, const char* const* deviceExtensions);
+
+ bool hasExtension(const char[], uint32_t minVersion) const;
+
+ struct Info {
+ Info() {}
+ Info(const char* name) : fName(name), fSpecVersion(0) {}
+
+ SkString fName;
+ uint32_t fSpecVersion;
+
+ struct Less {
+ bool operator()(const Info& a, const SkString& b) const {
+ return strcmp(a.fName.c_str(), b.c_str()) < 0;
+ }
+ bool operator()(const SkString& a, const GrVkExtensions::Info& b) const {
+ return strcmp(a.c_str(), b.fName.c_str()) < 0;
+ }
+ };
+ };
+
+#ifdef SK_DEBUG
+ void dump() const {
+ SkDebugf("**Vulkan Extensions**\n");
+ for (int i = 0; i < fExtensions.count(); ++i) {
+ SkDebugf("%s. Version: %d\n",
+ fExtensions[i].fName.c_str(), fExtensions[i].fSpecVersion);
+ }
+ SkDebugf("**End Vulkan Extensions**\n");
+ }
+#endif
+
+private:
+ void getSpecVersions(GrVkGetProc getProc, VkInstance, VkPhysicalDevice);
+
+ SkTArray<Info> fExtensions;
+};
+
+#endif
diff --git a/src/deps/skia/include/gpu/vk/GrVkMemoryAllocator.h b/src/deps/skia/include/gpu/vk/GrVkMemoryAllocator.h
new file mode 100644
index 000000000..e3782dba1
--- /dev/null
+++ b/src/deps/skia/include/gpu/vk/GrVkMemoryAllocator.h
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrVkMemoryAllocator_DEFINED
+#define GrVkMemoryAllocator_DEFINED
+
+#include "include/core/SkRefCnt.h"
+#include "include/gpu/GrTypes.h"
+#include "include/gpu/vk/GrVkTypes.h"
+
+class GrVkMemoryAllocator : public SkRefCnt {
+public:
+ enum class AllocationPropertyFlags {
+ kNone = 0,
+ // Allocation will be placed in its own VkDeviceMemory and not suballocated from some larger
+ // block.
+ kDedicatedAllocation = 0x1,
+ // Says that the backing memory can only be accessed by the device. Additionally the device
+ // may lazily allocate the memory. This cannot be used with buffers that will be host
+ // visible. Setting this flag does not guarantee that we will allocate memory that respects
+ // it, but we will try to prefer memory that can respect it.
+ kLazyAllocation = 0x2,
+ // The allocation will be mapped immediately and stay mapped until it is destroyed. This
+ // flag is only valid for buffers which are host visible (i.e. must have a usage other than
+ // BufferUsage::kGpuOnly).
+ kPersistentlyMapped = 0x4,
+ // Allocation can only be accessed by the device using a protected context.
+ kProtected = 0x8,
+ };
+
+ GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(AllocationPropertyFlags);
+
+ enum class BufferUsage {
+ // Buffers that will only be accessed from the device (large const buffers). Will always be
+ // in device local memory.
+ kGpuOnly,
+ // Buffers that typically will be updated multiple times by the host and read on the gpu
+ // (e.g. uniform or vertex buffers). CPU writes will generally be sequential in the buffer
+ // and will try to take advantage of the write-combined nature of the gpu buffers. Thus this
+ // will always be mappable and coherent memory, and it will prefer to be in device local
+ // memory.
+ kCpuWritesGpuReads,
+ // Buffers that will be accessed on the host and copied to another GPU resource (transfer
+ // buffers). Will always be mappable and coherent memory.
+ kTransfersFromCpuToGpu,
+ // Buffers which are typically writted to by the GPU and then read on the host. Will always
+ // be mappable memory, and will prefer cached memory.
+ kTransfersFromGpuToCpu,
+ };
+
+ // DEPRECATED: Use and implement allocateImageMemory instead
+ virtual bool allocateMemoryForImage(VkImage, AllocationPropertyFlags, GrVkBackendMemory*) {
+ // The default implementation here is so clients can delete this virtual as the switch to
+ // the new one which returns a VkResult.
+ return false;
+ }
+
+ virtual VkResult allocateImageMemory(VkImage image, AllocationPropertyFlags flags,
+ GrVkBackendMemory* memory) {
+ bool result = this->allocateMemoryForImage(image, flags, memory);
+ // VK_ERROR_INITIALIZATION_FAILED is a bogus result to return from this function, but it is
+ // just something to return that is not VK_SUCCESS and can't be interpreted by a caller to
+ // mean something specific happened like device lost or oom. This will be removed once we
+ // update clients to implement this virtual.
+ return result ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED;
+ }
+
+ // DEPRECATED: Use and implement allocateBufferMemory instead
+ virtual bool allocateMemoryForBuffer(VkBuffer, BufferUsage, AllocationPropertyFlags,
+ GrVkBackendMemory*) {
+ // The default implementation here is so clients can delete this virtual as the switch to
+ // the new one which returns a VkResult.
+ return false;
+ }
+
+ virtual VkResult allocateBufferMemory(VkBuffer buffer,
+ BufferUsage usage,
+ AllocationPropertyFlags flags,
+ GrVkBackendMemory* memory) {
+ bool result = this->allocateMemoryForBuffer(buffer, usage, flags, memory);
+ // VK_ERROR_INITIALIZATION_FAILED is a bogus result to return from this function, but it is
+ // just something to return that is not VK_SUCCESS and can't be interpreted by a caller to
+ // mean something specific happened like device lost or oom. This will be removed once we
+ // update clients to implement this virtual.
+ return result ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED;
+ }
+
+
+ // Fills out the passed in GrVkAlloc struct for the passed in GrVkBackendMemory.
+ virtual void getAllocInfo(const GrVkBackendMemory&, GrVkAlloc*) const = 0;
+
+ // Maps the entire allocation and returns a pointer to the start of the allocation. The
+ // implementation may map more memory than just the allocation, but the returned pointer must
+ // point at the start of the memory for the requested allocation.
+ virtual void* mapMemory(const GrVkBackendMemory&) { return nullptr; }
+ virtual VkResult mapMemory(const GrVkBackendMemory& memory, void** data) {
+ *data = this->mapMemory(memory);
+ // VK_ERROR_INITIALIZATION_FAILED is a bogus result to return from this function, but it is
+ // just something to return that is not VK_SUCCESS and can't be interpreted by a caller to
+ // mean something specific happened like device lost or oom. This will be removed once we
+ // update clients to implement this virtual.
+ return *data ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED;
+ }
+ virtual void unmapMemory(const GrVkBackendMemory&) = 0;
+
+ // The following two calls are used for managing non-coherent memory. The offset is relative to
+ // the start of the allocation and not the underlying VkDeviceMemory. Additionaly the client
+ // must make sure that the offset + size passed in is less that or equal to the allocation size.
+ // It is the responsibility of the implementation to make sure all alignment requirements are
+ // followed. The client should not have to deal with any sort of alignment issues.
+ virtual void flushMappedMemory(const GrVkBackendMemory&, VkDeviceSize, VkDeviceSize) {}
+ virtual VkResult flushMemory(const GrVkBackendMemory& memory, VkDeviceSize offset,
+ VkDeviceSize size) {
+ this->flushMappedMemory(memory, offset, size);
+ return VK_SUCCESS;
+ }
+ virtual void invalidateMappedMemory(const GrVkBackendMemory&, VkDeviceSize, VkDeviceSize) {}
+ virtual VkResult invalidateMemory(const GrVkBackendMemory& memory, VkDeviceSize offset,
+ VkDeviceSize size) {
+ this->invalidateMappedMemory(memory, offset, size);
+ return VK_SUCCESS;
+ }
+
+ virtual void freeMemory(const GrVkBackendMemory&) = 0;
+
+ // Returns the total amount of memory that is allocated and in use by an allocation for this
+ // allocator.
+ virtual uint64_t totalUsedMemory() const = 0;
+
+ // Returns the total amount of memory that is allocated by this allocator.
+ virtual uint64_t totalAllocatedMemory() const = 0;
+};
+
+GR_MAKE_BITFIELD_CLASS_OPS(GrVkMemoryAllocator::AllocationPropertyFlags)
+
+#endif
diff --git a/src/deps/skia/include/gpu/vk/GrVkTypes.h b/src/deps/skia/include/gpu/vk/GrVkTypes.h
new file mode 100644
index 000000000..7b95962fa
--- /dev/null
+++ b/src/deps/skia/include/gpu/vk/GrVkTypes.h
@@ -0,0 +1,187 @@
+
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrVkTypes_DEFINED
+#define GrVkTypes_DEFINED
+
+#include "include/core/SkTypes.h"
+#include "include/gpu/vk/GrVkVulkan.h"
+
+#ifndef VK_VERSION_1_1
+#error Skia requires the use of Vulkan 1.1 headers
+#endif
+
+#include <functional>
+#include "include/gpu/GrTypes.h"
+
+typedef intptr_t GrVkBackendMemory;
+
+/**
+ * Types for interacting with Vulkan resources created externally to Skia. GrBackendObjects for
+ * Vulkan textures are really const GrVkImageInfo*
+ */
+struct GrVkAlloc {
+ // can be VK_NULL_HANDLE iff is an RT and is borrowed
+ VkDeviceMemory fMemory = VK_NULL_HANDLE;
+ VkDeviceSize fOffset = 0;
+ VkDeviceSize fSize = 0; // this can be indeterminate iff Tex uses borrow semantics
+ uint32_t fFlags = 0;
+ GrVkBackendMemory fBackendMemory = 0; // handle to memory allocated via GrVkMemoryAllocator.
+
+ enum Flag {
+ kNoncoherent_Flag = 0x1, // memory must be flushed to device after mapping
+ kMappable_Flag = 0x2, // memory is able to be mapped.
+ kLazilyAllocated_Flag = 0x4, // memory was created with lazy allocation
+ };
+
+ bool operator==(const GrVkAlloc& that) const {
+ return fMemory == that.fMemory && fOffset == that.fOffset && fSize == that.fSize &&
+ fFlags == that.fFlags && fUsesSystemHeap == that.fUsesSystemHeap;
+ }
+
+private:
+ friend class GrVkHeap; // For access to usesSystemHeap
+ bool fUsesSystemHeap = false;
+};
+
+// This struct is used to pass in the necessary information to create a VkSamplerYcbcrConversion
+// object for an VkExternalFormatANDROID.
+struct GrVkYcbcrConversionInfo {
+ bool operator==(const GrVkYcbcrConversionInfo& that) const {
+ // Invalid objects are not required to have all other fields initialized or matching.
+ if (!this->isValid() && !that.isValid()) {
+ return true;
+ }
+ return this->fFormat == that.fFormat &&
+ this->fExternalFormat == that.fExternalFormat &&
+ this->fYcbcrModel == that.fYcbcrModel &&
+ this->fYcbcrRange == that.fYcbcrRange &&
+ this->fXChromaOffset == that.fXChromaOffset &&
+ this->fYChromaOffset == that.fYChromaOffset &&
+ this->fChromaFilter == that.fChromaFilter &&
+ this->fForceExplicitReconstruction == that.fForceExplicitReconstruction;
+ }
+ bool operator!=(const GrVkYcbcrConversionInfo& that) const { return !(*this == that); }
+
+ bool isValid() const { return fYcbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY; }
+
+ // Format of the source image. Must be set to VK_FORMAT_UNDEFINED for external images or
+ // a valid image format otherwise.
+ VkFormat fFormat = VK_FORMAT_UNDEFINED;
+
+ // The external format. Must be non-zero for external images, zero otherwise.
+ // Should be compatible to be used in a VkExternalFormatANDROID struct.
+ uint64_t fExternalFormat = 0;
+
+ VkSamplerYcbcrModelConversion fYcbcrModel = VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY;
+ VkSamplerYcbcrRange fYcbcrRange = VK_SAMPLER_YCBCR_RANGE_ITU_FULL;
+ VkChromaLocation fXChromaOffset = VK_CHROMA_LOCATION_COSITED_EVEN;
+ VkChromaLocation fYChromaOffset = VK_CHROMA_LOCATION_COSITED_EVEN;
+ VkFilter fChromaFilter = VK_FILTER_NEAREST;
+ VkBool32 fForceExplicitReconstruction = false;
+
+ // For external images format features here should be those returned by a call to
+ // vkAndroidHardwareBufferFormatPropertiesANDROID
+ VkFormatFeatureFlags fFormatFeatures = 0;
+};
+
+/*
+ * When wrapping a GrBackendTexture or GrBackendRendenderTarget, the fCurrentQueueFamily should
+ * either be VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_EXTERNAL, or VK_QUEUE_FAMILY_FOREIGN_EXT. If
+ * fSharingMode is VK_SHARING_MODE_EXCLUSIVE then fCurrentQueueFamily can also be the graphics
+ * queue index passed into Skia.
+ */
+struct GrVkImageInfo {
+ VkImage fImage = VK_NULL_HANDLE;
+ GrVkAlloc fAlloc;
+ VkImageTiling fImageTiling = VK_IMAGE_TILING_OPTIMAL;
+ VkImageLayout fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+ VkFormat fFormat = VK_FORMAT_UNDEFINED;
+ VkImageUsageFlags fImageUsageFlags = 0;
+ uint32_t fSampleCount = 1;
+ uint32_t fLevelCount = 0;
+ uint32_t fCurrentQueueFamily = VK_QUEUE_FAMILY_IGNORED;
+ GrProtected fProtected = GrProtected::kNo;
+ GrVkYcbcrConversionInfo fYcbcrConversionInfo;
+ VkSharingMode fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+ bool fPartOfSwapchainOrAndroidWindow = false;
+#endif
+
+#if GR_TEST_UTILS
+ bool operator==(const GrVkImageInfo& that) const {
+ bool equal = fImage == that.fImage && fAlloc == that.fAlloc &&
+ fImageTiling == that.fImageTiling &&
+ fImageLayout == that.fImageLayout &&
+ fFormat == that.fFormat &&
+ fImageUsageFlags == that.fImageUsageFlags &&
+ fSampleCount == that.fSampleCount &&
+ fLevelCount == that.fLevelCount &&
+ fCurrentQueueFamily == that.fCurrentQueueFamily &&
+ fProtected == that.fProtected &&
+ fYcbcrConversionInfo == that.fYcbcrConversionInfo &&
+ fSharingMode == that.fSharingMode;
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+ equal = equal && (fPartOfSwapchainOrAndroidWindow == that.fPartOfSwapchainOrAndroidWindow);
+#endif
+ return equal;
+ }
+#endif
+};
+
+using GrVkGetProc = std::function<PFN_vkVoidFunction(
+ const char*, // function name
+ VkInstance, // instance or VK_NULL_HANDLE
+ VkDevice // device or VK_NULL_HANDLE
+ )>;
+
+/**
+ * This object is wrapped in a GrBackendDrawableInfo and passed in as an argument to
+ * drawBackendGpu() calls on an SkDrawable. The drawable will use this info to inject direct
+ * Vulkan calls into our stream of GPU draws.
+ *
+ * The SkDrawable is given a secondary VkCommandBuffer in which to record draws. The GPU backend
+ * will then execute that command buffer within a render pass it is using for its own draws. The
+ * drawable is also given the attachment of the color index, a compatible VkRenderPass, and the
+ * VkFormat of the color attachment so that it can make VkPipeline objects for the draws. The
+ * SkDrawable must not alter the state of the VkRenderpass or sub pass.
+ *
+ * Additionally, the SkDrawable may fill in the passed in fDrawBounds with the bounds of the draws
+ * that it submits to the command buffer. This will be used by the GPU backend for setting the
+ * bounds in vkCmdBeginRenderPass. If fDrawBounds is not updated, we will assume that the entire
+ * attachment may have been written to.
+ *
+ * The SkDrawable is always allowed to create its own command buffers and submit them to the queue
+ * to render offscreen textures which will be sampled in draws added to the passed in
+ * VkCommandBuffer. If this is done the SkDrawable is in charge of adding the required memory
+ * barriers to the queue for the sampled images since the Skia backend will not do this.
+ */
+struct GrVkDrawableInfo {
+ VkCommandBuffer fSecondaryCommandBuffer;
+ uint32_t fColorAttachmentIndex;
+ VkRenderPass fCompatibleRenderPass;
+ VkFormat fFormat;
+ VkRect2D* fDrawBounds;
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+ bool fFromSwapchainOrAndroidWindow;
+#endif
+};
+
+struct GrVkSurfaceInfo {
+ uint32_t fSampleCount = 1;
+ uint32_t fLevelCount = 0;
+ GrProtected fProtected = GrProtected::kNo;
+
+ VkImageTiling fImageTiling = VK_IMAGE_TILING_OPTIMAL;
+ VkFormat fFormat = VK_FORMAT_UNDEFINED;
+ VkImageUsageFlags fImageUsageFlags = 0;
+ GrVkYcbcrConversionInfo fYcbcrConversionInfo;
+ VkSharingMode fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
+};
+
+#endif
diff --git a/src/deps/skia/include/gpu/vk/GrVkVulkan.h b/src/deps/skia/include/gpu/vk/GrVkVulkan.h
new file mode 100644
index 000000000..65cbf9b8b
--- /dev/null
+++ b/src/deps/skia/include/gpu/vk/GrVkVulkan.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrVkVulkan_DEFINED
+#define GrVkVulkan_DEFINED
+
+#include "include/core/SkTypes.h"
+
+#if SKIA_IMPLEMENTATION || !defined(SK_VULKAN)
+#include "include/third_party/vulkan/vulkan/vulkan_core.h"
+#else
+// For google3 builds we don't set SKIA_IMPLEMENTATION so we need to make sure that the vulkan
+// headers stay up to date for our needs
+#include <vulkan/vulkan_core.h>
+#endif
+
+#ifdef SK_BUILD_FOR_ANDROID
+// This is needed to get android extensions for external memory
+#if SKIA_IMPLEMENTATION || !defined(SK_VULKAN)
+#include "include/third_party/vulkan/vulkan/vulkan_android.h"
+#else
+// For google3 builds we don't set SKIA_IMPLEMENTATION so we need to make sure that the vulkan
+// headers stay up to date for our needs
+#include <vulkan/vulkan_android.h>
+#endif
+#endif
+
+#endif