aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-06-01 12:47:53 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-01 17:11:42 +0000
commitc2b5175e99c6451bdf34fa52900af39ee11a4a84 (patch)
tree50de247b5e1959a31cb06a8aa5a0649b5ff8a101 /tests
parent761d27c4d76bbd553c10cfe835d572b6fa33cf26 (diff)
Expand texturability testing to cover mip-mapped textures, and fix iOS
Don't allow creation of mip-mapped textures when caps says we don't support mip-mapping. Skip testing of mip-mapped resources in the resource size test, when creation will fail. For iOS devices with ES2, the APPLE BGRA8888 extension is more trouble than it's worth. Even though it lets the internal and external formats not match, it appears that the driver remembers the first external format, so subsequent attempts to upload with the other swizzle will fail. Up until now, creation of these textures was failing anyway, so now just make it more explicit that we don't support BGRA in this situation. Re-land of: https://skia-review.googlesource.com/18261 BUG=skia: Change-Id: I910ffab0aa735647dce910d9054696c385f94933 Reviewed-on: https://skia-review.googlesource.com/18382 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/GrSurfaceTest.cpp23
-rw-r--r--tests/ResourceCacheTest.cpp2
2 files changed, 24 insertions, 1 deletions
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 8c596d915b..85fc835bfe 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -17,6 +17,7 @@
#include "GrTest.h"
#include "GrTexture.h"
#include "GrSurfacePriv.h"
+#include "SkMipMap.h"
#include "Test.h"
// Tests that GrSurface::asTexture(), GrSurface::asRenderTarget(), and static upcasting of texture
@@ -99,6 +100,16 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
desc.fWidth = 64;
desc.fHeight = 64;
+ // Enough space for the first mip of our largest pixel config
+ const size_t pixelBufferSize = desc.fWidth * desc.fHeight *
+ GrBytesPerPixel(kRGBA_float_GrPixelConfig);
+ std::unique_ptr<char[]> pixelData(new char[pixelBufferSize]);
+ memset(pixelData.get(), 0, pixelBufferSize);
+
+ // We re-use the same mip level objects (with updated pointers and rowBytes) for each config
+ const int levelCount = SkMipMap::ComputeLevelCount(desc.fWidth, desc.fHeight) + 1;
+ std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[levelCount]);
+
for (GrPixelConfig config : configs) {
for (GrSurfaceOrigin origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
desc.fFlags = kNone_GrSurfaceFlags;
@@ -109,6 +120,18 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
sk_sp<GrSurface> tex = resourceProvider->createTexture(desc, SkBudgeted::kNo);
REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigTexturable(desc.fConfig));
+ size_t rowBytes = desc.fWidth * GrBytesPerPixel(desc.fConfig);
+ for (int i = 0; i < levelCount; ++i) {
+ texels[i].fPixels = pixelData.get();
+ texels[i].fRowBytes = rowBytes >> i;
+ }
+ sk_sp<GrTextureProxy> proxy = resourceProvider->createMipMappedTexture(
+ desc, SkBudgeted::kNo, texels.get(), levelCount);
+ REPORTER_ASSERT(reporter, SkToBool(proxy.get()) ==
+ (caps->isConfigTexturable(desc.fConfig) &&
+ caps->mipMapSupport() &&
+ !GrPixelConfigIsSint(desc.fConfig)));
+
desc.fFlags = kRenderTarget_GrSurfaceFlag;
tex = resourceProvider->createTexture(desc, SkBudgeted::kNo);
REPORTER_ASSERT(reporter, SkToBool(tex.get()) == caps->isConfigRenderable(config, false));
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 08f60ea1c5..460d4ee096 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -1714,7 +1714,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GPUMemorySize, reporter, ctxInfo) {
// Mipmapped versions
- {
+ if (context->caps()->mipMapSupport()) {
sk_sp<GrTextureProxy> proxy;
proxy = make_mipmap_proxy(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 0);