Chromium Code Reviews| Index: src/gpu/vk/GrVkRenderPass.cpp |
| diff --git a/src/gpu/vk/GrVkRenderPass.cpp b/src/gpu/vk/GrVkRenderPass.cpp |
| index 46964d771fef6c5ced347e180a795c31f81c058f..84c9c521ccfd00bb50baba7c4403ef41cee4d5a4 100644 |
| --- a/src/gpu/vk/GrVkRenderPass.cpp |
| +++ b/src/gpu/vk/GrVkRenderPass.cpp |
| @@ -15,24 +15,26 @@ |
| typedef GrVkRenderPass::AttachmentsDescriptor::AttachmentDesc AttachmentDesc; |
| +const GrVkRenderPass::LoadStoreOps GrVkRenderPass::kBasicLoadStoreOps; |
|
jvanverth1
2016/06/02 21:26:48
I think you might need to put this inside of GrVkR
egdaniel
2016/06/06 14:14:58
Done.
|
| + |
| void setup_vk_attachment_description(VkAttachmentDescription* attachment, |
| - const AttachmentDesc& desc, |
| - VkImageLayout layout) { |
| + const AttachmentDesc& desc, |
| + VkImageLayout layout) { |
| attachment->flags = 0; |
| attachment->format = desc.fFormat; |
| 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 +45,18 @@ 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); |
| + 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 +75,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 +94,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 +109,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 +146,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 +260,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) { |