Have GrVkRenderTarget only use GrVkAttachments and not derive from GrVkImage.
This change moves the color and resolve attachments used in a
GrVkRenderTarget to be a GrVkAttachment. These along with the msaa
attachment now mean that GrVkRenderTarget no longer needs to derive from
a GrVkImage.
There are a couple ugly things in this CL since GrVkTexture still is a
GrVkImage since we can't share attachments between GrVkRT and GrVkTex.
But when that gets updated in the follow on CL things will look much nicer.
Bug: skia:10727
Change-Id: I2f12674d7517c6d6dea389e2d1fb7296028bcc85
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/379576
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrAttachment.cpp b/src/gpu/GrAttachment.cpp
index 6db517d..04edf57 100644
--- a/src/gpu/GrAttachment.cpp
+++ b/src/gpu/GrAttachment.cpp
@@ -14,13 +14,28 @@
#include "src/gpu/GrGpu.h"
size_t GrAttachment::onGpuMemorySize() const {
- GrBackendFormat format = this->backendFormat();
- SkImage::CompressionType compression = GrBackendFormatToCompressionType(format);
+ // The GrTexture[RenderTarget] is built up by a bunch of attachments each of which are their
+ // own GrGpuResource. Ideally the GrRenderTarget would not be a GrGpuResource and the GrTexture
+ // would just merge with the new GrSurface/Attachment world. Then we could just depend on each
+ // attachment to give its own size since we don't have GrGpuResources owning other
+ // GrGpuResources. Until we get to that point we need to live in some hybrid world. We will let
+ // the msaa and stencil attachments track their own size because they do get cached separately.
+ // For all GrTexture* based things we will continue to to use the GrTexture* to report size and
+ // the owned attachments will have no size and be uncached.
+ // TODO: Once we start using texture attachments this check really should be !texture. However,
+ // until then in GrVkTextureRenderTarget we make a wrapped attachment to use for the render
+ // target which duplicates the GrTexture. These will be merged once we use texture attachments.
+ if ((fSupportedUsages & UsageFlags::kStencilAttachment) ||
+ ((fSupportedUsages & UsageFlags::kColorAttachment) && fSampleCnt > 1)) {
+ GrBackendFormat format = this->backendFormat();
+ SkImage::CompressionType compression = GrBackendFormatToCompressionType(format);
- uint64_t size = GrNumBlocks(compression, this->dimensions());
- size *= GrBackendFormatBytesPerBlock(this->backendFormat());
- size *= this->numSamples();
- return size;
+ uint64_t size = GrNumBlocks(compression, this->dimensions());
+ size *= GrBackendFormatBytesPerBlock(this->backendFormat());
+ size *= this->numSamples();
+ return size;
+ }
+ return 0;
}
static void build_key(GrResourceKey::Builder* builder,