Chromium Code Reviews| Index: src/gpu/vk/GrVkRenderPass.cpp |
| diff --git a/src/gpu/vk/GrVkRenderPass.cpp b/src/gpu/vk/GrVkRenderPass.cpp |
| index 1aedab4cfa985dd35fcef1d7ec173f9129cd576d..aeb69247328ed6dc4ae590bf1c446c48f34ab2a5 100644 |
| --- a/src/gpu/vk/GrVkRenderPass.cpp |
| +++ b/src/gpu/vk/GrVkRenderPass.cpp |
| @@ -13,17 +13,26 @@ |
| #include "GrVkRenderTarget.h" |
| #include "GrVkUtil.h" |
| -void setup_simple_vk_attachment_description(VkAttachmentDescription* attachment, |
| - VkFormat format, |
| - uint32_t samples, |
| +typedef GrVkRenderPass::AttachmentsDescriptor::AttachmentDesc AttachmentDesc; |
| + |
| +void setup_vk_attachment_description(VkAttachmentDescription* attachment, |
| + const AttachmentDesc& desc, |
| VkImageLayout layout) { |
| attachment->flags = 0; |
| - attachment->format = format; |
| - SkAssertResult(GrSampleCountToVkSampleCount(samples, &attachment->samples)); |
| - attachment->loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; |
| - attachment->storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| - attachment->stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; |
| - attachment->stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; |
| + attachment->format = desc.fFormat; |
| + SkAssertResult(GrSampleCountToVkSampleCount(desc.fSamples, &attachment->samples)); |
| + if (VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == layout) { |
|
jvanverth1
2016/05/18 20:42:21
I think a switch statement would be clearer here.
egdaniel
2016/06/02 17:26:25
Done.
|
| + attachment->loadOp = desc.fLoadOp; |
| + attachment->storeOp = desc.fStoreOp; |
| + attachment->stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| + attachment->stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| + } else { |
| + SkASSERT(VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL == layout); |
| + 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->initialLayout = layout; |
| attachment->finalLayout = layout; |
| } |
| @@ -56,10 +65,9 @@ void GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& targ |
| subpassDesc.pInputAttachments = nullptr; |
| if (fAttachmentFlags & kColor_AttachmentFlag) { |
| // set up color attachment |
| - setup_simple_vk_attachment_description(&attachments[currentAttachment], |
| - fAttachmentsDescriptor.fColor.fFormat, |
| - fAttachmentsDescriptor.fColor.fSamples, |
| - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); |
| + setup_vk_attachment_description(&attachments[currentAttachment], |
| + fAttachmentsDescriptor.fColor, |
| + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); |
| // setup subpass use of attachment |
| colorRef.attachment = currentAttachment++; |
| colorRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| @@ -75,10 +83,9 @@ void GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& targ |
| if (fAttachmentFlags & kResolve_AttachmentFlag) { |
| // set up resolve attachment |
| - setup_simple_vk_attachment_description(&attachments[currentAttachment], |
| - fAttachmentsDescriptor.fResolve.fFormat, |
| - fAttachmentsDescriptor.fResolve.fSamples, |
| - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); |
| + setup_vk_attachment_description(&attachments[currentAttachment], |
| + fAttachmentsDescriptor.fResolve, |
| + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); |
| // setup subpass use of attachment |
| resolveRef.attachment = currentAttachment++; |
| // I'm really not sure what the layout should be for the resolve textures. |
| @@ -90,10 +97,9 @@ void GrVkRenderPass::initSimple(const GrVkGpu* gpu, const GrVkRenderTarget& targ |
| if (fAttachmentFlags & kStencil_AttachmentFlag) { |
| // set up stencil attachment |
| - setup_simple_vk_attachment_description(&attachments[currentAttachment], |
| - fAttachmentsDescriptor.fStencil.fFormat, |
| - fAttachmentsDescriptor.fStencil.fSamples, |
| - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); |
| + setup_vk_attachment_description(&attachments[currentAttachment], |
| + fAttachmentsDescriptor.fStencil, |
| + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); |
| // setup subpass use of attachment |
| stencilRef.attachment = currentAttachment++; |
| stencilRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| @@ -202,17 +208,17 @@ bool GrVkRenderPass::isCompatible(const GrVkRenderTarget& target) const { |
| } |
| if (fAttachmentFlags & kColor_AttachmentFlag) { |
| - if (fAttachmentsDescriptor.fColor != desc.fColor) { |
| + if (!fAttachmentsDescriptor.fColor.isCompatible(desc.fColor)) { |
| return false; |
| } |
| } |
| if (fAttachmentFlags & kResolve_AttachmentFlag) { |
| - if (fAttachmentsDescriptor.fResolve != desc.fResolve) { |
| + if (!fAttachmentsDescriptor.fResolve.isCompatible(desc.fResolve)) { |
| return false; |
| } |
| } |
| if (fAttachmentFlags & kStencil_AttachmentFlag) { |
| - if (fAttachmentsDescriptor.fStencil != desc.fStencil) { |
| + if (!fAttachmentsDescriptor.fStencil.isCompatible(desc.fStencil)) { |
| return false; |
| } |
| } |