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..46964d771fef6c5ced347e180a795c31f81c058f 100644 |
| --- a/src/gpu/vk/GrVkRenderPass.cpp |
| +++ b/src/gpu/vk/GrVkRenderPass.cpp |
| @@ -13,17 +13,31 @@ |
| #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, |
|
jvanverth1
2016/06/02 20:09:35
Nit: tabs
egdaniel
2016/06/02 20:50:26
Done.
|
| 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)); |
| + switch (layout) { |
| + case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: |
| + attachment->loadOp = desc.fLoadOp; |
| + attachment->storeOp = desc.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; |
| + break; |
| + default: |
| + SkFAIL("Unexpected attachment layout"); |
| + } |
| + |
| attachment->initialLayout = layout; |
| attachment->finalLayout = layout; |
| } |
| @@ -56,10 +70,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 +88,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 +102,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 +213,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; |
| } |
| } |