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

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

Issue 2104353002: Add discard support to Vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment Created 4 years, 6 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/GrVkGpuCommandBuffer.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/GrVkGpuCommandBuffer.cpp
diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
index dc553e03772329aa4f03e9d75970a4acfd34ef4c..6c966b5fa941144b13f247c752bb089933b97764 100644
--- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp
+++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
@@ -118,6 +118,14 @@ void GrVkGpuCommandBuffer::onSubmit(const SkIRect& bounds) {
false);
}
+ if (GrVkImage* msaaImage = fRenderTarget->msaaImage()) {
+ msaaImage->setImageLayout(fGpu,
+ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
+ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
+ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
+ false);
+ }
+
for (int i = 0; i < fSampledImages.count(); ++i) {
fSampledImages[i]->setImageLayout(fGpu,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
@@ -130,6 +138,38 @@ void GrVkGpuCommandBuffer::onSubmit(const SkIRect& bounds) {
fRenderTarget, bounds);
}
+void GrVkGpuCommandBuffer::discard(GrRenderTarget* target) {
+ if (fIsEmpty) {
+ // We will change the render pass to do a clear load instead
+ GrVkRenderPass::LoadStoreOps vkColorOps(VK_ATTACHMENT_LOAD_OP_DONT_CARE,
+ VK_ATTACHMENT_STORE_OP_STORE);
+ GrVkRenderPass::LoadStoreOps vkStencilOps(VK_ATTACHMENT_LOAD_OP_DONT_CARE,
+ VK_ATTACHMENT_STORE_OP_STORE);
+ GrVkRenderPass::LoadStoreOps vkResolveOps(VK_ATTACHMENT_LOAD_OP_DONT_CARE,
+ VK_ATTACHMENT_STORE_OP_STORE);
+
+ const GrVkRenderPass* oldRP = fRenderPass;
+
+ GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(target);
+ const GrVkResourceProvider::CompatibleRPHandle& rpHandle =
+ vkRT->compatibleRenderPassHandle();
+ if (rpHandle.isValid()) {
+ fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
+ vkColorOps,
+ vkResolveOps,
+ vkStencilOps);
+ } else {
+ fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
+ vkColorOps,
+ vkResolveOps,
+ vkStencilOps);
+ }
+
+ SkASSERT(fRenderPass->isCompatible(*oldRP));
+ oldRP->unref(fGpu);
+ }
+}
+
void GrVkGpuCommandBuffer::onClearStencilClip(GrRenderTarget* target,
const SkIRect& rect,
bool insideClip) {
« no previous file with comments | « src/gpu/vk/GrVkGpuCommandBuffer.h ('k') | src/gpu/vk/GrVkRenderTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698