1164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel/* 2164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel* Copyright 2015 Google Inc. 3164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel* 4164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel* Use of this source code is governed by a BSD-style license that can be 5164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel* found in the LICENSE file. 6164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel*/ 7164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 8164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel#include "GrVkRenderPass.h" 9164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 1022281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel#include "GrProcessor.h" 11164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel#include "GrVkFramebuffer.h" 12164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel#include "GrVkGpu.h" 13164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel#include "GrVkRenderTarget.h" 14164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel#include "GrVkUtil.h" 15164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 16d62e28b19a23b913c549b7891ecf79e779577181egdanieltypedef GrVkRenderPass::AttachmentsDescriptor::AttachmentDesc AttachmentDesc; 17d62e28b19a23b913c549b7891ecf79e779577181egdaniel 18d62e28b19a23b913c549b7891ecf79e779577181egdanielvoid setup_vk_attachment_description(VkAttachmentDescription* attachment, 19d62e28b19a23b913c549b7891ecf79e779577181egdaniel const AttachmentDesc& desc, 20d62e28b19a23b913c549b7891ecf79e779577181egdaniel VkImageLayout layout) { 21164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel attachment->flags = 0; 22d62e28b19a23b913c549b7891ecf79e779577181egdaniel attachment->format = desc.fFormat; 23d62e28b19a23b913c549b7891ecf79e779577181egdaniel SkAssertResult(GrSampleCountToVkSampleCount(desc.fSamples, &attachment->samples)); 24d62e28b19a23b913c549b7891ecf79e779577181egdaniel switch (layout) { 25d62e28b19a23b913c549b7891ecf79e779577181egdaniel case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: 262feb0938dcf223da3641daf15f5d525db88a6967egdaniel attachment->loadOp = desc.fLoadStoreOps.fLoadOp; 272feb0938dcf223da3641daf15f5d525db88a6967egdaniel attachment->storeOp = desc.fLoadStoreOps.fStoreOp; 28d62e28b19a23b913c549b7891ecf79e779577181egdaniel attachment->stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; 29d62e28b19a23b913c549b7891ecf79e779577181egdaniel attachment->stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; 30d62e28b19a23b913c549b7891ecf79e779577181egdaniel break; 31d62e28b19a23b913c549b7891ecf79e779577181egdaniel case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: 32d62e28b19a23b913c549b7891ecf79e779577181egdaniel attachment->loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; 33d62e28b19a23b913c549b7891ecf79e779577181egdaniel attachment->storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; 342feb0938dcf223da3641daf15f5d525db88a6967egdaniel attachment->stencilLoadOp = desc.fLoadStoreOps.fLoadOp; 352feb0938dcf223da3641daf15f5d525db88a6967egdaniel attachment->stencilStoreOp = desc.fLoadStoreOps.fStoreOp; 36d62e28b19a23b913c549b7891ecf79e779577181egdaniel break; 37d62e28b19a23b913c549b7891ecf79e779577181egdaniel default: 38d62e28b19a23b913c549b7891ecf79e779577181egdaniel SkFAIL("Unexpected attachment layout"); 39d62e28b19a23b913c549b7891ecf79e779577181egdaniel } 40d62e28b19a23b913c549b7891ecf79e779577181egdaniel 41164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel attachment->initialLayout = layout; 42164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel attachment->finalLayout = layout; 43164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel} 44164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 45164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Danielvoid GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& target) { 462feb0938dcf223da3641daf15f5d525db88a6967egdaniel static const GrVkRenderPass::LoadStoreOps kBasicLoadStoreOps(VK_ATTACHMENT_LOAD_OP_LOAD, 472feb0938dcf223da3641daf15f5d525db88a6967egdaniel VK_ATTACHMENT_STORE_OP_STORE); 48164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 49ce3bfb1ed155880585b2d0bb0a8d3e43306e23f2egdaniel this->init(gpu, target, kBasicLoadStoreOps, kBasicLoadStoreOps); 502feb0938dcf223da3641daf15f5d525db88a6967egdaniel} 512feb0938dcf223da3641daf15f5d525db88a6967egdaniel 522feb0938dcf223da3641daf15f5d525db88a6967egdanielvoid GrVkRenderPass::init(const GrVkGpu* gpu, 532feb0938dcf223da3641daf15f5d525db88a6967egdaniel const LoadStoreOps& colorOp, 542feb0938dcf223da3641daf15f5d525db88a6967egdaniel const LoadStoreOps& stencilOp) { 55164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel uint32_t numAttachments = fAttachmentsDescriptor.fAttachmentCount; 56164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel // Attachment descriptions to be set on the render pass 57164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel SkTArray<VkAttachmentDescription> attachments(numAttachments); 58164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel attachments.reset(numAttachments); 592feb0938dcf223da3641daf15f5d525db88a6967egdaniel memset(attachments.begin(), 0, numAttachments * sizeof(VkAttachmentDescription)); 60164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 61164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel // Refs to attachments on the render pass (as described by teh VkAttachmentDescription above), 62164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel // that are used by the subpass. 63164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel VkAttachmentReference colorRef; 64164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel VkAttachmentReference stencilRef; 65164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel uint32_t currentAttachment = 0; 66164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 67ce3bfb1ed155880585b2d0bb0a8d3e43306e23f2egdaniel // Go through each of the attachment types (color, stencil) and set the necessary 68164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel // on the various Vk structs. 69164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel VkSubpassDescription subpassDesc; 70164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel memset(&subpassDesc, 0, sizeof(VkSubpassDescription)); 71164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel subpassDesc.flags = 0; 72164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; 73164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel subpassDesc.inputAttachmentCount = 0; 74164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel subpassDesc.pInputAttachments = nullptr; 75ce3bfb1ed155880585b2d0bb0a8d3e43306e23f2egdaniel subpassDesc.pResolveAttachments = nullptr; 76ce3bfb1ed155880585b2d0bb0a8d3e43306e23f2egdaniel 77164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel if (fAttachmentFlags & kColor_AttachmentFlag) { 78164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel // set up color attachment 792feb0938dcf223da3641daf15f5d525db88a6967egdaniel fAttachmentsDescriptor.fColor.fLoadStoreOps = colorOp; 80d62e28b19a23b913c549b7891ecf79e779577181egdaniel setup_vk_attachment_description(&attachments[currentAttachment], 81d62e28b19a23b913c549b7891ecf79e779577181egdaniel fAttachmentsDescriptor.fColor, 82d62e28b19a23b913c549b7891ecf79e779577181egdaniel VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); 83164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel // setup subpass use of attachment 84164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel colorRef.attachment = currentAttachment++; 85164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel colorRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; 86164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel subpassDesc.colorAttachmentCount = 1; 8777a86f81f39227ea53441af2afc647f589a96a0dGreg Daniel 8877a86f81f39227ea53441af2afc647f589a96a0dGreg Daniel if (VK_ATTACHMENT_LOAD_OP_CLEAR == colorOp.fLoadOp) { 8977a86f81f39227ea53441af2afc647f589a96a0dGreg Daniel fClearValueCount++; 9077a86f81f39227ea53441af2afc647f589a96a0dGreg Daniel } 91164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } else { 92164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel // I don't think there should ever be a time where we don't have a color attachment 93164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel SkASSERT(false); 94164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel colorRef.attachment = VK_ATTACHMENT_UNUSED; 95164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel colorRef.layout = VK_IMAGE_LAYOUT_UNDEFINED; 96164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel subpassDesc.colorAttachmentCount = 0; 97164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } 98164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel subpassDesc.pColorAttachments = &colorRef; 99164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 100164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel if (fAttachmentFlags & kStencil_AttachmentFlag) { 101164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel // set up stencil attachment 1022feb0938dcf223da3641daf15f5d525db88a6967egdaniel fAttachmentsDescriptor.fStencil.fLoadStoreOps = stencilOp; 103d62e28b19a23b913c549b7891ecf79e779577181egdaniel setup_vk_attachment_description(&attachments[currentAttachment], 104d62e28b19a23b913c549b7891ecf79e779577181egdaniel fAttachmentsDescriptor.fStencil, 105d62e28b19a23b913c549b7891ecf79e779577181egdaniel VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); 106164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel // setup subpass use of attachment 107164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel stencilRef.attachment = currentAttachment++; 108164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel stencilRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; 10977a86f81f39227ea53441af2afc647f589a96a0dGreg Daniel if (VK_ATTACHMENT_LOAD_OP_CLEAR == stencilOp.fLoadOp) { 11077a86f81f39227ea53441af2afc647f589a96a0dGreg Daniel fClearValueCount++; 11177a86f81f39227ea53441af2afc647f589a96a0dGreg Daniel } 112164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } else { 113164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel stencilRef.attachment = VK_ATTACHMENT_UNUSED; 114164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel stencilRef.layout = VK_IMAGE_LAYOUT_UNDEFINED; 115164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } 116164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel subpassDesc.pDepthStencilAttachment = &stencilRef; 117164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 118164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel subpassDesc.preserveAttachmentCount = 0; 119164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel subpassDesc.pPreserveAttachments = nullptr; 120164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 121164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel SkASSERT(numAttachments == currentAttachment); 122164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 123164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel // Create the VkRenderPass compatible with the attachment descriptions above 124164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel VkRenderPassCreateInfo createInfo; 125164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel memset(&createInfo, 0, sizeof(VkRenderPassCreateInfo)); 126164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel createInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; 127164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel createInfo.pNext = nullptr; 128164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel createInfo.flags = 0; 129164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel createInfo.attachmentCount = numAttachments; 130164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel createInfo.pAttachments = attachments.begin(); 131164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel createInfo.subpassCount = 1; 132164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel createInfo.pSubpasses = &subpassDesc; 133164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel createInfo.dependencyCount = 0; 134164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel createInfo.pDependencies = nullptr; 135164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 136164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel GR_VK_CALL_ERRCHECK(gpu->vkInterface(), CreateRenderPass(gpu->device(), 137164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel &createInfo, 138164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel nullptr, 139164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel &fRenderPass)); 14027bb28473912181cf9a838e9282e86cb62e2d44begdaniel 14127bb28473912181cf9a838e9282e86cb62e2d44begdaniel // Get granularity for this render pass 14227bb28473912181cf9a838e9282e86cb62e2d44begdaniel GR_VK_CALL(gpu->vkInterface(), GetRenderAreaGranularity(gpu->device(), 14327bb28473912181cf9a838e9282e86cb62e2d44begdaniel fRenderPass, 14427bb28473912181cf9a838e9282e86cb62e2d44begdaniel &fGranularity)); 145164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel} 146164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 1472feb0938dcf223da3641daf15f5d525db88a6967egdanielvoid GrVkRenderPass::init(const GrVkGpu* gpu, 1482feb0938dcf223da3641daf15f5d525db88a6967egdaniel const GrVkRenderPass& compatibleRenderPass, 1492feb0938dcf223da3641daf15f5d525db88a6967egdaniel const LoadStoreOps& colorOp, 1502feb0938dcf223da3641daf15f5d525db88a6967egdaniel const LoadStoreOps& stencilOp) { 1512feb0938dcf223da3641daf15f5d525db88a6967egdaniel fAttachmentFlags = compatibleRenderPass.fAttachmentFlags; 1522feb0938dcf223da3641daf15f5d525db88a6967egdaniel fAttachmentsDescriptor = compatibleRenderPass.fAttachmentsDescriptor; 153ce3bfb1ed155880585b2d0bb0a8d3e43306e23f2egdaniel this->init(gpu, colorOp, stencilOp); 1542feb0938dcf223da3641daf15f5d525db88a6967egdaniel} 1552feb0938dcf223da3641daf15f5d525db88a6967egdaniel 1562feb0938dcf223da3641daf15f5d525db88a6967egdanielvoid GrVkRenderPass::init(const GrVkGpu* gpu, 15777a86f81f39227ea53441af2afc647f589a96a0dGreg Daniel const GrVkRenderTarget& target, 1582feb0938dcf223da3641daf15f5d525db88a6967egdaniel const LoadStoreOps& colorOp, 1592feb0938dcf223da3641daf15f5d525db88a6967egdaniel const LoadStoreOps& stencilOp) { 1602feb0938dcf223da3641daf15f5d525db88a6967egdaniel // Get attachment information from render target. This includes which attachments the render 161ce3bfb1ed155880585b2d0bb0a8d3e43306e23f2egdaniel // target has (color, stencil) and the attachments format and sample count. 1622feb0938dcf223da3641daf15f5d525db88a6967egdaniel target.getAttachmentsDescriptor(&fAttachmentsDescriptor, &fAttachmentFlags); 163ce3bfb1ed155880585b2d0bb0a8d3e43306e23f2egdaniel this->init(gpu, colorOp, stencilOp); 1642feb0938dcf223da3641daf15f5d525db88a6967egdaniel} 1652feb0938dcf223da3641daf15f5d525db88a6967egdaniel 166164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Danielvoid GrVkRenderPass::freeGPUData(const GrVkGpu* gpu) const { 167164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel GR_VK_CALL(gpu->vkInterface(), DestroyRenderPass(gpu->device(), fRenderPass, nullptr)); 168164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel} 169164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 170164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel// Works under the assumption that color attachment will always be the first attachment in our 171164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel// attachment array if it exists. 172164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Danielbool GrVkRenderPass::colorAttachmentIndex(uint32_t* index) const { 173164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel *index = 0; 174164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel if (fAttachmentFlags & kColor_AttachmentFlag) { 175164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel return true; 176164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } 177164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel return false; 178164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel} 179164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 180164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel// Works under the assumption that stencil attachment will always be after the color and resolve 181164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel// attachment. 182164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Danielbool GrVkRenderPass::stencilAttachmentIndex(uint32_t* index) const { 183164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel *index = 0; 184164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel if (fAttachmentFlags & kColor_AttachmentFlag) { 185164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel ++(*index); 186164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } 187164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel if (fAttachmentFlags & kStencil_AttachmentFlag) { 188164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel return true; 189164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } 190164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel return false; 191164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel} 192164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 1939a6cf800bc392fb4ba5065efb64f5b0320098d1aegdanielbool GrVkRenderPass::isCompatible(const AttachmentsDescriptor& desc, 1949a6cf800bc392fb4ba5065efb64f5b0320098d1aegdaniel const AttachmentFlags& flags) const { 195164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel if (flags != fAttachmentFlags) { 196164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel return false; 197164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } 198164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 199164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel if (fAttachmentFlags & kColor_AttachmentFlag) { 200d62e28b19a23b913c549b7891ecf79e779577181egdaniel if (!fAttachmentsDescriptor.fColor.isCompatible(desc.fColor)) { 201164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel return false; 202164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } 203164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } 204164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel if (fAttachmentFlags & kStencil_AttachmentFlag) { 205d62e28b19a23b913c549b7891ecf79e779577181egdaniel if (!fAttachmentsDescriptor.fStencil.isCompatible(desc.fStencil)) { 206164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel return false; 207164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } 208164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel } 209164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel 210164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel return true; 211164a9f061c5186ae931cc23a3c73f32472e80ff5Greg Daniel} 21222281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel 2139a6cf800bc392fb4ba5065efb64f5b0320098d1aegdanielbool GrVkRenderPass::isCompatible(const GrVkRenderTarget& target) const { 2149a6cf800bc392fb4ba5065efb64f5b0320098d1aegdaniel AttachmentsDescriptor desc; 2159a6cf800bc392fb4ba5065efb64f5b0320098d1aegdaniel AttachmentFlags flags; 2169a6cf800bc392fb4ba5065efb64f5b0320098d1aegdaniel target.getAttachmentsDescriptor(&desc, &flags); 2179a6cf800bc392fb4ba5065efb64f5b0320098d1aegdaniel 2189a6cf800bc392fb4ba5065efb64f5b0320098d1aegdaniel return this->isCompatible(desc, flags); 2199a6cf800bc392fb4ba5065efb64f5b0320098d1aegdaniel} 2209a6cf800bc392fb4ba5065efb64f5b0320098d1aegdaniel 2219a6cf800bc392fb4ba5065efb64f5b0320098d1aegdanielbool GrVkRenderPass::isCompatible(const GrVkRenderPass& renderPass) const { 2229a6cf800bc392fb4ba5065efb64f5b0320098d1aegdaniel return this->isCompatible(renderPass.fAttachmentsDescriptor, renderPass.fAttachmentFlags); 2239a6cf800bc392fb4ba5065efb64f5b0320098d1aegdaniel} 2249a6cf800bc392fb4ba5065efb64f5b0320098d1aegdaniel 2252feb0938dcf223da3641daf15f5d525db88a6967egdanielbool GrVkRenderPass::equalLoadStoreOps(const LoadStoreOps& colorOps, 2262feb0938dcf223da3641daf15f5d525db88a6967egdaniel const LoadStoreOps& stencilOps) const { 2272feb0938dcf223da3641daf15f5d525db88a6967egdaniel if (fAttachmentFlags & kColor_AttachmentFlag) { 2282feb0938dcf223da3641daf15f5d525db88a6967egdaniel if (fAttachmentsDescriptor.fColor.fLoadStoreOps != colorOps) { 2292feb0938dcf223da3641daf15f5d525db88a6967egdaniel return false; 2302feb0938dcf223da3641daf15f5d525db88a6967egdaniel } 2312feb0938dcf223da3641daf15f5d525db88a6967egdaniel } 2322feb0938dcf223da3641daf15f5d525db88a6967egdaniel if (fAttachmentFlags & kStencil_AttachmentFlag) { 2332feb0938dcf223da3641daf15f5d525db88a6967egdaniel if (fAttachmentsDescriptor.fStencil.fLoadStoreOps != stencilOps) { 2342feb0938dcf223da3641daf15f5d525db88a6967egdaniel return false; 2352feb0938dcf223da3641daf15f5d525db88a6967egdaniel } 2362feb0938dcf223da3641daf15f5d525db88a6967egdaniel } 2372feb0938dcf223da3641daf15f5d525db88a6967egdaniel return true; 2382feb0938dcf223da3641daf15f5d525db88a6967egdaniel} 2392feb0938dcf223da3641daf15f5d525db88a6967egdaniel 24022281c13a13c4b4e275516e9fe02185a53a7e5aaegdanielvoid GrVkRenderPass::genKey(GrProcessorKeyBuilder* b) const { 24122281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel b->add32(fAttachmentFlags); 24222281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel if (fAttachmentFlags & kColor_AttachmentFlag) { 24322281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel b->add32(fAttachmentsDescriptor.fColor.fFormat); 24422281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel b->add32(fAttachmentsDescriptor.fColor.fSamples); 24522281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel } 24622281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel if (fAttachmentFlags & kStencil_AttachmentFlag) { 24722281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel b->add32(fAttachmentsDescriptor.fStencil.fFormat); 24822281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel b->add32(fAttachmentsDescriptor.fStencil.fSamples); 24922281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel } 25022281c13a13c4b4e275516e9fe02185a53a7e5aaegdaniel} 251