Don't create lazy proxys if their width/height is greater than max tex size
Bug: skia:
Change-Id: I53508c4e3bbd4c315be4b29a66716e0c5e7f25bf
Reviewed-on: https://skia-review.googlesource.com/121161
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index b65c3df..a4b8d61 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -257,6 +257,10 @@
},
desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, surfaceFlags, fit, budgeted);
+ if (!proxy) {
+ return nullptr;
+ }
+
if (fResourceProvider) {
// In order to reuse code we always create a lazy proxy. When we aren't in DDL mode however
// we're better off instantiating the proxy immediately here.
@@ -354,6 +358,10 @@
desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kYes, SkBackingFit::kExact,
SkBudgeted::kYes);
+ if (!proxy) {
+ return nullptr;
+ }
+
if (fResourceProvider) {
// In order to reuse code we always create a lazy proxy. When we aren't in DDL mode however
// we're better off instantiating the proxy immediately here.
@@ -539,6 +547,11 @@
LazyInstantiationType lazyType) {
SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) ||
(desc.fWidth > 0 && desc.fHeight > 0));
+
+ if (desc.fWidth > fCaps->maxTextureSize() || desc.fHeight > fCaps->maxTextureSize()) {
+ return nullptr;
+ }
+
surfaceFlags |= GrInternalSurfaceFlags::kNoPendingIO;
#ifdef SK_DEBUG
@@ -566,6 +579,11 @@
SkBackingFit fit, SkBudgeted budgeted) {
SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) ||
(desc.fWidth > 0 && desc.fHeight > 0));
+
+ if (desc.fWidth > fCaps->maxRenderTargetSize() || desc.fHeight > fCaps->maxRenderTargetSize()) {
+ return nullptr;
+ }
+
SkASSERT(SkToBool(kRenderTarget_GrSurfaceFlag & desc.fFlags));
surfaceFlags |= GrInternalSurfaceFlags::kNoPendingIO;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index e162d83..1cf60d8 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -4346,6 +4346,10 @@
return GrBackendTexture(); // invalid
}
+ if (w > this->caps()->maxTextureSize() || h > this->caps()->maxTextureSize()) {
+ return GrBackendTexture(); // invalid
+ }
+
// Currently we don't support uploading pixel data when mipped.
if (pixels && GrMipMapped::kYes == mipMapped) {
return GrBackendTexture(); // invalid
@@ -4433,6 +4437,9 @@
GrBackendRenderTarget GrGLGpu::createTestingOnlyBackendRenderTarget(int w, int h,
GrColorType colorType,
GrSRGBEncoded srgbEncoded) {
+ if (w > this->caps()->maxRenderTargetSize() || h > this->caps()->maxRenderTargetSize()) {
+ return GrBackendRenderTarget(); // invalid
+ }
this->handleDirtyContext();
auto config = GrColorTypeToPixelConfig(colorType, srgbEncoded);
GrGLenum colorBufferFormat;
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 0011a78..481232e 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -1555,6 +1555,10 @@
GrBackendRenderTarget GrVkGpu::createTestingOnlyBackendRenderTarget(int w, int h, GrColorType ct,
GrSRGBEncoded srgbEncoded) {
+ if (w > this->caps()->maxRenderTargetSize() || h > this->caps()->maxRenderTargetSize()) {
+ return GrBackendRenderTarget();
+ }
+
this->handleDirtyContext();
GrVkImageInfo info;
auto config = GrColorTypeToPixelConfig(ct, srgbEncoded);
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index 2b2b716..c048ea6 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -233,6 +233,7 @@
desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, GrInternalSurfaceFlags::kNone,
SkBackingFit::kExact, SkBudgeted::kNo, lazyType);
+ REPORTER_ASSERT(reporter, proxy.get());
REPORTER_ASSERT(reporter, 0 == testCount);
if (doInstantiate) {
@@ -281,6 +282,8 @@
desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, SkBackingFit::kExact,
SkBudgeted::kNo);
+ SkASSERT(fLazyProxy.get());
+
this->setBounds(SkRect::MakeIWH(kSize, kSize),
HasAABloat::kNo, IsZeroArea::kNo);
}
@@ -425,6 +428,8 @@
desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, GrInternalSurfaceFlags::kNone,
SkBackingFit::kExact, SkBudgeted::kNo, lazyType);
+ REPORTER_ASSERT(reporter, lazyProxy.get());
+
rtc->priv().testingOnly_addDrawOp(skstd::make_unique<LazyUninstantiateTestOp>(lazyProxy));
ctx->flush();