Add memoryless attachment support for vulkan dmsaa.
For this initial landing, we actually have the memoryless support
disabled because we need to update Chrome's vk memory allocator to
handle the new lazy flag added in this CL. Otherwise we will fail to
make dmsaa attachments and not draw anything.
I tested this on ARM and the it does look to keep the size of all the
lazy msaa attachments at 0. I test with both 4 and 8 sample counts. To
confirm the size check, I changed the store op on the msaa attachments
from discard to store and the reported memory size did grow.
Bug: skia:11809
Change-Id: I977f337b922cdbdbce16d67945369246e3547c17
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/451296
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrAttachment.cpp b/src/gpu/GrAttachment.cpp
index 08f1c73..29660589 100644
--- a/src/gpu/GrAttachment.cpp
+++ b/src/gpu/GrAttachment.cpp
@@ -22,7 +22,7 @@
// 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.
- if (!(fSupportedUsages & UsageFlags::kTexture)) {
+ if (!(fSupportedUsages & UsageFlags::kTexture) && fMemoryless == GrMemoryless::kNo) {
GrBackendFormat format = this->backendFormat();
SkImage::CompressionType compression = GrBackendFormatToCompressionType(format);
@@ -41,12 +41,14 @@
GrAttachment::UsageFlags requiredUsage,
int sampleCnt,
GrMipmapped mipmapped,
- GrProtected isProtected) {
+ GrProtected isProtected,
+ GrMemoryless memoryless) {
SkASSERT(!dimensions.isEmpty());
SkASSERT(static_cast<uint32_t>(isProtected) <= 1);
+ SkASSERT(static_cast<uint32_t>(memoryless) <= 1);
SkASSERT(static_cast<uint32_t>(requiredUsage) < (1u << 8));
- SkASSERT(static_cast<uint32_t>(sampleCnt) < (1u << (32 - 9)));
+ SkASSERT(static_cast<uint32_t>(sampleCnt) < (1u << (32 - 10)));
uint64_t formatKey = caps.computeFormatKey(format);
(*builder)[0] = dimensions.width();
@@ -54,8 +56,9 @@
(*builder)[2] = formatKey & 0xFFFFFFFF;
(*builder)[3] = (formatKey >> 32) & 0xFFFFFFFF;
(*builder)[4] = (static_cast<uint32_t>(isProtected) << 0) |
- (static_cast<uint32_t>(requiredUsage) << 1) |
- (static_cast<uint32_t>(sampleCnt) << 9);
+ (static_cast<uint32_t>(memoryless) << 1) |
+ (static_cast<uint32_t>(requiredUsage) << 2) |
+ (static_cast<uint32_t>(sampleCnt) << 10);
}
void GrAttachment::ComputeSharedAttachmentUniqueKey(const GrCaps& caps,
@@ -65,11 +68,13 @@
int sampleCnt,
GrMipmapped mipmapped,
GrProtected isProtected,
+ GrMemoryless memoryless,
GrUniqueKey* key) {
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
GrUniqueKey::Builder builder(key, kDomain, 5);
- build_key(&builder, caps, format, dimensions, requiredUsage, sampleCnt, mipmapped, isProtected);
+ build_key(&builder, caps, format, dimensions, requiredUsage, sampleCnt, mipmapped, isProtected,
+ memoryless);
}
void GrAttachment::ComputeScratchKey(const GrCaps& caps,
@@ -79,18 +84,26 @@
int sampleCnt,
GrMipmapped mipmapped,
GrProtected isProtected,
+ GrMemoryless memoryless,
GrScratchKey* key) {
static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResourceType();
GrScratchKey::Builder builder(key, kType, 5);
- build_key(&builder, caps, format, dimensions, requiredUsage, sampleCnt, mipmapped, isProtected);
+ build_key(&builder, caps, format, dimensions, requiredUsage, sampleCnt, mipmapped, isProtected,
+ memoryless);
}
void GrAttachment::computeScratchKey(GrScratchKey* key) const {
if (!SkToBool(fSupportedUsages & UsageFlags::kStencilAttachment)) {
auto isProtected = this->isProtected() ? GrProtected::kYes : GrProtected::kNo;
- ComputeScratchKey(*this->getGpu()->caps(), this->backendFormat(), this->dimensions(),
- fSupportedUsages, this->numSamples(), this->mipmapped(), isProtected,
+ ComputeScratchKey(*this->getGpu()->caps(),
+ this->backendFormat(),
+ this->dimensions(),
+ fSupportedUsages,
+ this->numSamples(),
+ this->mipmapped(),
+ isProtected,
+ fMemoryless,
key);
}
}