| 1 |
|
| 2 |
/* |
| 3 |
* Copyright 2016 Google Inc. |
| 4 |
* |
| 5 |
* Use of this source code is governed by a BSD-style license that can be |
| 6 |
* found in the LICENSE file. |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef GrVkTypes_DEFINED |
| 10 |
#define GrVkTypes_DEFINED |
| 11 |
|
| 12 |
#include "include/gpu/GpuTypes.h" |
| 13 |
#include "include/gpu/vk/VulkanTypes.h" |
| 14 |
|
| 15 |
/* |
| 16 |
* When wrapping a GrBackendTexture or GrBackendRendenderTarget, the fCurrentQueueFamily should |
| 17 |
* either be VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_EXTERNAL, or VK_QUEUE_FAMILY_FOREIGN_EXT. If |
| 18 |
* fSharingMode is VK_SHARING_MODE_EXCLUSIVE then fCurrentQueueFamily can also be the graphics |
| 19 |
* queue index passed into Skia. |
| 20 |
*/ |
| 21 |
struct GrVkImageInfo { |
| 22 |
VkImage fImage = VK_NULL_HANDLE; |
| 23 |
skgpu::VulkanAlloc fAlloc; |
| 24 |
VkImageTiling fImageTiling = VK_IMAGE_TILING_OPTIMAL; |
| 25 |
VkImageLayout fImageLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 26 |
VkFormat fFormat = VK_FORMAT_UNDEFINED; |
| 27 |
VkImageUsageFlags fImageUsageFlags = 0; |
| 28 |
uint32_t fSampleCount = 1; |
| 29 |
uint32_t fLevelCount = 0; |
| 30 |
uint32_t fCurrentQueueFamily = VK_QUEUE_FAMILY_IGNORED; |
| 31 |
skgpu::Protected fProtected = skgpu::Protected::kNo; |
| 32 |
skgpu::VulkanYcbcrConversionInfo fYcbcrConversionInfo; |
| 33 |
VkSharingMode fSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 34 |
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 35 |
bool fPartOfSwapchainOrAndroidWindow = false; |
| 36 |
#endif |
| 37 |
|
| 38 |
bool operator==(const GrVkImageInfo& that) const { |
| 39 |
bool equal = fImage == that.fImage && fAlloc == that.fAlloc && |
| 40 |
fImageTiling == that.fImageTiling && |
| 41 |
fImageLayout == that.fImageLayout && |
| 42 |
fFormat == that.fFormat && |
| 43 |
fImageUsageFlags == that.fImageUsageFlags && |
| 44 |
fSampleCount == that.fSampleCount && |
| 45 |
fLevelCount == that.fLevelCount && |
| 46 |
fCurrentQueueFamily == that.fCurrentQueueFamily && |
| 47 |
fProtected == that.fProtected && |
| 48 |
fYcbcrConversionInfo == that.fYcbcrConversionInfo && |
| 49 |
fSharingMode == that.fSharingMode; |
| 50 |
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 51 |
equal = equal && (fPartOfSwapchainOrAndroidWindow == that.fPartOfSwapchainOrAndroidWindow); |
| 52 |
#endif |
| 53 |
return equal; |
| 54 |
} |
| 55 |
}; |
| 56 |
|
| 57 |
/** |
| 58 |
* This object is wrapped in a GrBackendDrawableInfo and passed in as an argument to |
| 59 |
* drawBackendGpu() calls on an SkDrawable. The drawable will use this info to inject direct |
| 60 |
* Vulkan calls into our stream of GPU draws. |
| 61 |
* |
| 62 |
* The SkDrawable is given a secondary VkCommandBuffer in which to record draws. The GPU backend |
| 63 |
* will then execute that command buffer within a render pass it is using for its own draws. The |
| 64 |
* drawable is also given the attachment of the color index, a compatible VkRenderPass, and the |
| 65 |
* VkFormat of the color attachment so that it can make VkPipeline objects for the draws. The |
| 66 |
* SkDrawable must not alter the state of the VkRenderpass or sub pass. |
| 67 |
* |
| 68 |
* Additionally, the SkDrawable may fill in the passed in fDrawBounds with the bounds of the draws |
| 69 |
* that it submits to the command buffer. This will be used by the GPU backend for setting the |
| 70 |
* bounds in vkCmdBeginRenderPass. If fDrawBounds is not updated, we will assume that the entire |
| 71 |
* attachment may have been written to. |
| 72 |
* |
| 73 |
* The SkDrawable is always allowed to create its own command buffers and submit them to the queue |
| 74 |
* to render offscreen textures which will be sampled in draws added to the passed in |
| 75 |
* VkCommandBuffer. If this is done the SkDrawable is in charge of adding the required memory |
| 76 |
* barriers to the queue for the sampled images since the Skia backend will not do this. |
| 77 |
*/ |
| 78 |
struct GrVkDrawableInfo { |
| 79 |
VkCommandBuffer fSecondaryCommandBuffer; |
| 80 |
uint32_t fColorAttachmentIndex; |
| 81 |
VkRenderPass fCompatibleRenderPass; |
| 82 |
VkFormat fFormat; |
| 83 |
VkRect2D* fDrawBounds; |
| 84 |
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
| 85 |
bool fFromSwapchainOrAndroidWindow; |
| 86 |
#endif |
| 87 |
}; |
| 88 |
|
| 89 |
struct GrVkSurfaceInfo { |
| 90 |
uint32_t fSampleCount = 1; |
| 91 |
uint32_t fLevelCount = 0; |
| 92 |
skgpu::Protected fProtected = skgpu::Protected::kNo; |
| 93 |
|
| 94 |
VkImageTiling fImageTiling = VK_IMAGE_TILING_OPTIMAL; |
| 95 |
VkFormat fFormat = VK_FORMAT_UNDEFINED; |
| 96 |
VkImageUsageFlags fImageUsageFlags = 0; |
| 97 |
skgpu::VulkanYcbcrConversionInfo fYcbcrConversionInfo; |
| 98 |
VkSharingMode fSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 99 |
}; |
| 100 |
|
| 101 |
#endif |