Round up DMSAA attachments to pow2 if supported.
Change-Id: I03f5ea649209b9894753c981872edbd7d718288c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408643
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index e1e911d..51154a4 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -23,7 +23,7 @@
fReuseScratchTextures = true;
fReuseScratchBuffers = true;
fGpuTracingSupport = false;
- fOversizedStencilSupport = false;
+ fOversizedAttachmentSupport = false;
fTextureBarrierSupport = false;
fSampleLocationsSupport = false;
fMultisampleDisableSupport = false;
@@ -193,7 +193,7 @@
writer->appendBool("Reuse Scratch Textures", fReuseScratchTextures);
writer->appendBool("Reuse Scratch Buffers", fReuseScratchBuffers);
writer->appendBool("Gpu Tracing Support", fGpuTracingSupport);
- writer->appendBool("Oversized Stencil Support", fOversizedStencilSupport);
+ writer->appendBool("Oversized Attachment Support", fOversizedAttachmentSupport);
writer->appendBool("Texture Barrier Support", fTextureBarrierSupport);
writer->appendBool("Sample Locations Support", fSampleLocationsSupport);
writer->appendBool("Multisample disable support", fMultisampleDisableSupport);
diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h
index 33bbdf2..9d0dbaa 100644
--- a/src/gpu/GrCaps.h
+++ b/src/gpu/GrCaps.h
@@ -48,7 +48,7 @@
bool mipmapSupport() const { return fMipmapSupport; }
bool gpuTracingSupport() const { return fGpuTracingSupport; }
- bool oversizedStencilSupport() const { return fOversizedStencilSupport; }
+ bool oversizedAttachmentSupport() const { return fOversizedAttachmentSupport; }
bool textureBarrierSupport() const { return fTextureBarrierSupport; }
bool sampleLocationsSupport() const { return fSampleLocationsSupport; }
bool multisampleDisableSupport() const { return fMultisampleDisableSupport; }
@@ -504,7 +504,7 @@
bool fReuseScratchTextures : 1;
bool fReuseScratchBuffers : 1;
bool fGpuTracingSupport : 1;
- bool fOversizedStencilSupport : 1;
+ bool fOversizedAttachmentSupport : 1;
bool fTextureBarrierSupport : 1;
bool fSampleLocationsSupport : 1;
bool fMultisampleDisableSupport : 1;
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 38738a5..b4d486f 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -516,7 +516,7 @@
GrUniqueKey sbKey;
#if 0
- if (this->caps()->oversizedStencilSupport()) {
+ if (this->caps()->oversizedAttachmentSupport()) {
width = SkNextPow2(width);
height = SkNextPow2(height);
}
@@ -548,6 +548,7 @@
stencil->numSamples() == num_stencil_samples(rt, useMSAASurface, *this->caps()));
return stencil != nullptr;
}
+
sk_sp<GrAttachment> GrResourceProvider::getDiscardableMSAAAttachment(SkISize dimensions,
const GrBackendFormat& format,
int sampleCnt,
@@ -560,6 +561,10 @@
return nullptr;
}
+ if (this->caps()->oversizedAttachmentSupport()) {
+ dimensions = MakeApprox(dimensions);
+ }
+
if (!fCaps->validateSurfaceParams(
dimensions, format, GrRenderable::kYes, sampleCnt, GrMipmapped::kNo)) {
return nullptr;
@@ -578,6 +583,7 @@
if (msaaAttachment) {
return msaaAttachment;
}
+
msaaAttachment = this->makeMSAAAttachment(dimensions, format, sampleCnt, isProtected);
if (msaaAttachment) {
this->assignUniqueKeyToResource(key, msaaAttachment.get());
diff --git a/src/gpu/d3d/GrD3DCaps.cpp b/src/gpu/d3d/GrD3DCaps.cpp
index 9bd72bf..a7cf162 100644
--- a/src/gpu/d3d/GrD3DCaps.cpp
+++ b/src/gpu/d3d/GrD3DCaps.cpp
@@ -31,7 +31,7 @@
fNPOTTextureTileSupport = true; // available in feature level 10_0 and up
fReuseScratchTextures = true; //TODO: figure this out
fGpuTracingSupport = false; //TODO: figure this out
- fOversizedStencilSupport = false; //TODO: figure this out
+ fOversizedAttachmentSupport = false; //TODO: figure this out
fDrawInstancedSupport = true;
fNativeDrawIndirectSupport = true;
@@ -213,7 +213,7 @@
fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag | kAsyncRead_MapFlag;
- fOversizedStencilSupport = true;
+ fOversizedAttachmentSupport = true;
fTwoSidedStencilRefsAndMasksMustMatch = true;
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index e2f43a4..aa3dc7a 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -589,18 +589,18 @@
// ARB allows mixed size FBO attachments, EXT does not.
if (version >= GR_GL_VER(3, 0) ||
ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
- fOversizedStencilSupport = true;
+ fOversizedAttachmentSupport = true;
} else {
SkASSERT(ctxInfo.hasExtension("GL_EXT_framebuffer_object"));
}
} else if (GR_IS_GR_GL_ES(standard)) {
// ES 3.0 supports mixed size FBO attachments, 2.0 does not.
- fOversizedStencilSupport = version >= GR_GL_VER(3, 0);
+ fOversizedAttachmentSupport = version >= GR_GL_VER(3, 0);
} else if (GR_IS_GR_WEBGL(standard)) {
// WebGL 1.0 has some constraints for FBO attachments:
// https://www.khronos.org/registry/webgl/specs/1.0/index.html#6.6
// These constraints "no longer apply in WebGL 2"
- fOversizedStencilSupport = version >= GR_GL_VER(2, 0);
+ fOversizedAttachmentSupport = version >= GR_GL_VER(2, 0);
}
if (GR_IS_GR_GL(standard)) {
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index 486f046..617a929 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -320,7 +320,7 @@
// Buffers are always fully mapped.
fMapBufferFlags = kCanMap_MapFlag | kAsyncRead_MapFlag;
- fOversizedStencilSupport = true;
+ fOversizedAttachmentSupport = true;
fMipmapSupport = true; // always available in Metal
fNPOTTextureTileSupport = true; // always available in Metal
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 223b361..a1a9e94 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -44,7 +44,6 @@
fNPOTTextureTileSupport = true; // always available in Vulkan
fReuseScratchTextures = true; //TODO: figure this out
fGpuTracingSupport = false; //TODO: figure this out
- fOversizedStencilSupport = false; //TODO: figure this out
fDrawInstancedSupport = true;
fSemaphoreSupport = true; // always available in Vulkan
@@ -644,7 +643,7 @@
fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag | kAsyncRead_MapFlag;
- fOversizedStencilSupport = true;
+ fOversizedAttachmentSupport = true;
if (extensions.hasExtension(VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME, 2) &&
this->supportsPhysicalDeviceProperties2()) {