23int determine_uint32_count(
int rpAttachmentCount,
int subpassCount,
int subpassDependencyCount ) {
30 SkASSERT(
static_cast<uint32_t
>(rpAttachmentCount) <= (1u << 8));
31 SkASSERT(
static_cast<uint32_t
>(subpassCount) <= (1u << 8));
32 SkASSERT(
static_cast<uint32_t
>(subpassDependencyCount) <= (1u << 8));
36 num32DataCnt += 3 * rpAttachmentCount;
41 num32DataCnt += subpassCount;
43 num32DataCnt += 6 * subpassDependencyCount;
48void add_attachment_description_info_to_key(ResourceKey::Builder& builder,
49 const TextureInfo& textureInfo,
53 VulkanTextureInfo vkTexInfo;
54 if (textureInfo.isValid() && textureInfo.getVulkanTextureInfo(&vkTexInfo)) {
55 builder[builderIdx++] = vkTexInfo.fFormat;
56 builder[builderIdx++] = vkTexInfo.fSampleCount;
57 SkASSERT(
sizeof(loadOp) < (1u << 8));
58 SkASSERT(
sizeof(storeOp) < (1u << 8));
59 builder[builderIdx++] =
static_cast<uint8_t
>(loadOp) << 8 |
static_cast<uint8_t
>(storeOp);
68void add_subpass_info_to_key(ResourceKey::Builder& builder,
70 bool hasColorAttachment,
71 bool hasColorResolveAttachment,
72 bool hasDepthStencilAttachment,
73 bool loadMSAAFromResolve,
75 int subpassDependencyCount) {
79 const int mainSubpassIdx = loadMSAAFromResolve ? 1 : 0;
81 static constexpr int kAttachmentUnused = std::numeric_limits<uint8_t>::max();
86 for (
int j = 0; j < subpassCount; j++) {
87 if (j == mainSubpassIdx) {
88 uint32_t attachmentIdxKeyInfo;
91 attachmentIdxKeyInfo |=
93 : kAttachmentUnused) << 8;
94 attachmentIdxKeyInfo |=
96 : kAttachmentUnused) << 16;
98 attachmentIdxKeyInfo |= kAttachmentUnused << 24;
100 builder[builderIdx++] = attachmentIdxKeyInfo;
105 (kAttachmentUnused << 8) |
106 (kAttachmentUnused << 16) |
115 for (
int i = 0; i < subpassDependencyCount; i++) {
116 builder[builderIdx++] = 0 | (mainSubpassIdx << 8);
126void populate_key(VulkanRenderPass::VulkanRenderPassMetaData& rpMetaData,
127 ResourceKey::Builder& builder,
129 bool compatibleOnly) {
130 builder[builderIdx++] = rpMetaData.fAttachments.size() |
131 (rpMetaData.fSubpassCount << 8) |
132 (rpMetaData.fSubpassDependencyCount << 16);
135 for (
int i = 0; i < rpMetaData.fAttachments.size(); i++) {
136 add_attachment_description_info_to_key(
138 rpMetaData.fAttachments[i]->fTextureInfo,
142 compatibleOnly ?
LoadOp::kLoad : rpMetaData.fAttachments[i]->fLoadOp,
143 compatibleOnly ?
StoreOp::
kStore : rpMetaData.fAttachments[i]->fStoreOp);
146 add_subpass_info_to_key(builder,
148 rpMetaData.fHasColorAttachment,
149 rpMetaData.fHasColorResolveAttachment,
150 rpMetaData.fHasDepthStencilAttachment,
151 rpMetaData.fLoadMSAAFromResolve,
152 rpMetaData.fSubpassCount,
153 rpMetaData.fSubpassDependencyCount);
207 populate_key(rpMetaData, builder, startingIdx, compatibleOnly);
216 bool compatibleOnly) {
217 populate_key(rpMetaData, builder, builderIdx,
true);
236 outAttachment->
flags = 0;
241 outAttachment->
samples = sampleCount;
242 switch (initialLayout) {
260 SK_ABORT(
"Unexpected attachment layout");
270 bool compatibleOnly) {
276 bool hasColorAttachment = colorAttachmentTextureInfo.
isValid();
277 bool hasColorResolveAttachment = colorResolveAttachmentTextureInfo.isValid();
278 bool hasDepthStencilAttachment = depthStencilAttachmentTextureInfo.isValid();
287 bool loadMSAAFromResolve =
false;
288 if (hasColorAttachment) {
290 colorAttachmentTextureInfo.getVulkanTextureInfo(&colorAttachTexInfo);
306 if (hasColorResolveAttachment) {
310 colorResolveAttachmentTextureInfo.getVulkanTextureInfo(&resolveAttachTexInfo);
317 &vkResolveAttachDesc,
318 resolveAttachTexInfo,
338 if (hasDepthStencilAttachment) {
340 depthStencilAttachmentTextureInfo.getVulkanTextureInfo(&depthStencilTexInfo);
346 &vkDepthStencilAttachDesc,
348 depthStencilAttachDesc,
363 renderPassInfo.
pNext =
nullptr;
364 renderPassInfo.
flags = 0;
365 renderPassInfo.
subpassCount = loadMSAAFromResolve ? 2 : 1;
372 if (loadMSAAFromResolve) {
378 loadSubpassDesc.
flags = 0;
390 const int mainSubpassIdx = loadMSAAFromResolve ? 1 : 0;
403 mainSubpassDesc.
flags = 0;
423 CreateRenderPass(context->
device(), &renderPassInfo,
nullptr, &
renderPass));
442 , fSharedContext(context)
449 DestroyRenderPass(fSharedContext->
device(), fRenderPass,
nullptr));
void setup_vk_attachment_description(VkAttachmentDescription *attachment, const AttachmentDesc &desc, VkImageLayout startLayout, VkImageLayout endLayout)
#define SkAssertResult(cond)
#define SK_ABORT(message,...)
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
#define VULKAN_CALL(IFACE, X)
#define VULKAN_CALL_RESULT(SHARED_CONTEXT, RESULT, X)
Type::kYUV Type::kRGBA() int(0.7 *637)
static ResourceType GenerateResourceType()
const GraphiteResourceKey & key() const
void freeGpuData() override
static constexpr int kColorAttachmentIdx
static void AddRenderPassInfoToKey(VulkanRenderPassMetaData &rpMetaData, ResourceKey::Builder &builder, int &builderIdx, bool compatibleOnly)
VkRenderPass renderPass() const
static sk_sp< VulkanRenderPass > MakeRenderPass(const VulkanSharedContext *, const RenderPassDesc &, bool compatibleOnly)
static constexpr int kColorResolveAttachmentIdx
static constexpr int kDepthStencilAttachmentIdx
static GraphiteResourceKey MakeRenderPassKey(const RenderPassDesc &, bool compatibleOnly)
const skgpu::VulkanInterface * interface() const
static constexpr int kLoadOpCount
static const VkAttachmentLoadOp vkLoadOp[]
static constexpr int kStoreOpCount
static const VkAttachmentStoreOp vkStoreOp[]
static constexpr bool SampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits *vkSamples)
VkAttachmentLoadOp loadOp
VkAttachmentStoreOp stencilStoreOp
VkSampleCountFlagBits samples
VkAttachmentDescriptionFlags flags
VkAttachmentStoreOp storeOp
VkImageLayout initialLayout
VkImageLayout finalLayout
VkAttachmentLoadOp stencilLoadOp
const VkSubpassDescription * pSubpasses
const VkSubpassDependency * pDependencies
const VkAttachmentDescription * pAttachments
VkRenderPassCreateFlags flags
const VkAttachmentReference * pDepthStencilAttachment
VkSubpassDescriptionFlags flags
uint32_t inputAttachmentCount
const VkAttachmentReference * pResolveAttachments
const uint32_t * pPreserveAttachments
const VkAttachmentReference * pInputAttachments
uint32_t colorAttachmentCount
const VkAttachmentReference * pColorAttachments
VkPipelineBindPoint pipelineBindPoint
uint32_t preserveAttachmentCount
AttachmentDesc fDepthStencilAttachment
AttachmentDesc fColorResolveAttachment
AttachmentDesc fColorAttachment
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
@ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
@ VK_IMAGE_LAYOUT_UNDEFINED
@ VK_IMAGE_LAYOUT_GENERAL
@ VK_DEPENDENCY_BY_REGION_BIT
@ VK_PIPELINE_BIND_POINT_GRAPHICS
#define VK_ATTACHMENT_UNUSED
@ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
@ VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
@ VK_ATTACHMENT_LOAD_OP_DONT_CARE
@ VK_ATTACHMENT_STORE_OP_DONT_CARE
@ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
@ VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO