diff options
Diffstat (limited to 'src/gpu/vk/GrVkRenderPass.cpp')
-rw-r--r-- | src/gpu/vk/GrVkRenderPass.cpp | 67 |
1 files changed, 59 insertions, 8 deletions
diff --git a/src/gpu/vk/GrVkRenderPass.cpp b/src/gpu/vk/GrVkRenderPass.cpp index c56bafa92d..6a0f953a1c 100644 --- a/src/gpu/vk/GrVkRenderPass.cpp +++ b/src/gpu/vk/GrVkRenderPass.cpp @@ -23,16 +23,16 @@ void setup_vk_attachment_description(VkAttachmentDescription* attachment, SkAssertResult(GrSampleCountToVkSampleCount(desc.fSamples, &attachment->samples)); switch (layout) { case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: - attachment->loadOp = desc.fLoadOp; - attachment->storeOp = desc.fStoreOp; + attachment->loadOp = desc.fLoadStoreOps.fLoadOp; + attachment->storeOp = desc.fLoadStoreOps.fStoreOp; attachment->stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachment->stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; break; case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: attachment->loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachment->storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - attachment->stencilLoadOp = desc.fLoadOp; - attachment->stencilStoreOp = desc.fStoreOp; + attachment->stencilLoadOp = desc.fLoadStoreOps.fLoadOp; + attachment->stencilStoreOp = desc.fLoadStoreOps.fStoreOp; break; default: SkFAIL("Unexpected attachment layout"); @@ -43,15 +43,21 @@ void setup_vk_attachment_description(VkAttachmentDescription* attachment, } void GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& target) { - // Get attachment information from render target. This includes which attachments the render - // target has (color, resolve, stencil) and the attachments format and sample count. - target.getAttachmentsDescriptor(&fAttachmentsDescriptor, &fAttachmentFlags); + static const GrVkRenderPass::LoadStoreOps kBasicLoadStoreOps(VK_ATTACHMENT_LOAD_OP_LOAD, + VK_ATTACHMENT_STORE_OP_STORE); + this->init(gpu, target, kBasicLoadStoreOps, kBasicLoadStoreOps, kBasicLoadStoreOps); +} + +void GrVkRenderPass::init(const GrVkGpu* gpu, + const LoadStoreOps& colorOp, + const LoadStoreOps& resolveOp, + const LoadStoreOps& stencilOp) { uint32_t numAttachments = fAttachmentsDescriptor.fAttachmentCount; // Attachment descriptions to be set on the render pass SkTArray<VkAttachmentDescription> attachments(numAttachments); attachments.reset(numAttachments); - memset(attachments.begin(), 0, numAttachments*sizeof(VkAttachmentDescription)); + memset(attachments.begin(), 0, numAttachments * sizeof(VkAttachmentDescription)); // Refs to attachments on the render pass (as described by teh VkAttachmentDescription above), // that are used by the subpass. @@ -70,6 +76,7 @@ void GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& targ subpassDesc.pInputAttachments = nullptr; if (fAttachmentFlags & kColor_AttachmentFlag) { // set up color attachment + fAttachmentsDescriptor.fColor.fLoadStoreOps = colorOp; setup_vk_attachment_description(&attachments[currentAttachment], fAttachmentsDescriptor.fColor, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); @@ -88,6 +95,7 @@ void GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& targ if (fAttachmentFlags & kResolve_AttachmentFlag) { // set up resolve attachment + fAttachmentsDescriptor.fResolve.fLoadStoreOps = resolveOp; setup_vk_attachment_description(&attachments[currentAttachment], fAttachmentsDescriptor.fResolve, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); @@ -102,6 +110,7 @@ void GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& targ if (fAttachmentFlags & kStencil_AttachmentFlag) { // set up stencil attachment + fAttachmentsDescriptor.fStencil.fLoadStoreOps = stencilOp; setup_vk_attachment_description(&attachments[currentAttachment], fAttachmentsDescriptor.fStencil, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); @@ -138,6 +147,27 @@ void GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& targ &fRenderPass)); } +void GrVkRenderPass::init(const GrVkGpu* gpu, + const GrVkRenderPass& compatibleRenderPass, + const LoadStoreOps& colorOp, + const LoadStoreOps& resolveOp, + const LoadStoreOps& stencilOp) { + fAttachmentFlags = compatibleRenderPass.fAttachmentFlags; + fAttachmentsDescriptor = compatibleRenderPass.fAttachmentsDescriptor; + this->init(gpu, colorOp, resolveOp, stencilOp); +} + +void GrVkRenderPass::init(const GrVkGpu* gpu, + const GrVkRenderTarget& target, + const LoadStoreOps& colorOp, + const LoadStoreOps& resolveOp, + const LoadStoreOps& stencilOp) { + // Get attachment information from render target. This includes which attachments the render + // target has (color, resolve, stencil) and the attachments format and sample count. + target.getAttachmentsDescriptor(&fAttachmentsDescriptor, &fAttachmentFlags); + this->init(gpu, colorOp, resolveOp, stencilOp); +} + void GrVkRenderPass::freeGPUData(const GrVkGpu* gpu) const { GR_VK_CALL(gpu->vkInterface(), DestroyRenderPass(gpu->device(), fRenderPass, nullptr)); } @@ -231,6 +261,27 @@ bool GrVkRenderPass::isCompatible(const GrVkRenderTarget& target) const { return true; } +bool GrVkRenderPass::equalLoadStoreOps(const LoadStoreOps& colorOps, + const LoadStoreOps& resolveOps, + const LoadStoreOps& stencilOps) const { + if (fAttachmentFlags & kColor_AttachmentFlag) { + if (fAttachmentsDescriptor.fColor.fLoadStoreOps != colorOps) { + return false; + } + } + if (fAttachmentFlags & kResolve_AttachmentFlag) { + if (fAttachmentsDescriptor.fResolve.fLoadStoreOps != resolveOps) { + return false; + } + } + if (fAttachmentFlags & kStencil_AttachmentFlag) { + if (fAttachmentsDescriptor.fStencil.fLoadStoreOps != stencilOps) { + return false; + } + } + return true; +} + void GrVkRenderPass::genKey(GrProcessorKeyBuilder* b) const { b->add32(fAttachmentFlags); if (fAttachmentFlags & kColor_AttachmentFlag) { |