Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Unified Diff: src/gpu/vk/GrVkRenderPass.cpp

Issue 1977403002: Refactor creation of GrVkRenderPasses to make them move general (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: review nits Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/vk/GrVkRenderPass.h ('k') | src/gpu/vk/GrVkRenderTarget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkRenderPass.cpp
diff --git a/src/gpu/vk/GrVkRenderPass.cpp b/src/gpu/vk/GrVkRenderPass.cpp
index 1aedab4cfa985dd35fcef1d7ec173f9129cd576d..c56bafa92daa367c547d95adbf4b36961255103e 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,
- VkImageLayout layout) {
+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));
+ 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;
}
}
« no previous file with comments | « src/gpu/vk/GrVkRenderPass.h ('k') | src/gpu/vk/GrVkRenderTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698