From 44b61204d9f5681b9474db017577d56f42a32d66 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Thu, 1 Mar 2018 10:49:26 -0500 Subject: Add 1010102 support to Ganesh Adds gl1010102, gles1010102, vk1010102, and mtl1010102 configs to DM. This uses the same saveLayer approach as CPU, switching to 8888 so that we have enough alpha precision. Change-Id: I9f5b63747ec01031c8db97dadfc42f77e4863ccb Reviewed-on: https://skia-review.googlesource.com/110500 Reviewed-by: Brian Salomon Commit-Queue: Brian Osman --- tests/GrSurfaceTest.cpp | 1 + tests/ImageGeneratorTest.cpp | 2 ++ tests/ProxyTest.cpp | 5 +++-- tests/ReadWriteAlphaTest.cpp | 15 +++++++++++---- tests/SpecialSurfaceTest.cpp | 15 +++++++++------ tests/SurfaceTest.cpp | 14 ++++++++++---- tests/TestConfigParsing.cpp | 6 +++++- 7 files changed, 41 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index eb975852d1..a645f99c3e 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -92,6 +92,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { kBGRA_8888_GrPixelConfig, kSRGBA_8888_GrPixelConfig, kSBGRA_8888_GrPixelConfig, + kRGBA_1010102_GrPixelConfig, kRGBA_float_GrPixelConfig, kRG_float_GrPixelConfig, kAlpha_half_GrPixelConfig, diff --git a/tests/ImageGeneratorTest.cpp b/tests/ImageGeneratorTest.cpp index 8a7f0decec..574c8e8728 100644 --- a/tests/ImageGeneratorTest.cpp +++ b/tests/ImageGeneratorTest.cpp @@ -90,10 +90,12 @@ DEF_TEST(PictureImageGenerator, reporter) { { kRGBA_8888_SkColorType, kPremul_SkAlphaType, kRGBA_8888_SkColorType == kN32_SkColorType }, { kBGRA_8888_SkColorType, kPremul_SkAlphaType, kBGRA_8888_SkColorType == kN32_SkColorType }, { kRGBA_F16_SkColorType, kPremul_SkAlphaType, true }, + { kRGBA_1010102_SkColorType, kPremul_SkAlphaType, true }, { kRGBA_8888_SkColorType, kUnpremul_SkAlphaType, false }, { kBGRA_8888_SkColorType, kUnpremul_SkAlphaType, false }, { kRGBA_F16_SkColorType, kUnpremul_SkAlphaType, false }, + { kRGBA_1010102_SkColorType, kUnpremul_SkAlphaType, false }, }; auto colorspace = SkColorSpace::MakeSRGB(); diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index f48e2a090f..6ad8199849 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -104,7 +104,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) { for (auto widthHeight : { 100, 128, 1048576 }) { for (auto config : { kAlpha_8_GrPixelConfig, kRGB_565_GrPixelConfig, - kRGBA_8888_GrPixelConfig }) { + kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig }) { for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) { for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) { for (auto numSamples : {1, 4, 16, 128}) { @@ -196,7 +196,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { return; } for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) { - for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType }) { + for (auto colorType : { kAlpha_8_SkColorType, kRGBA_8888_SkColorType, + kRGBA_1010102_SkColorType }) { for (auto numSamples : {1, 4}) { GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, caps); SkASSERT(kUnknown_GrPixelConfig != config); diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp index 68a3ee0983..ba1022c689 100644 --- a/tests/ReadWriteAlphaTest.cpp +++ b/tests/ReadWriteAlphaTest.cpp @@ -25,11 +25,17 @@ static const int X_SIZE = 13; static const int Y_SIZE = 13; static void validate_alpha_data(skiatest::Reporter* reporter, int w, int h, const uint8_t* actual, - size_t actualRowBytes, const uint8_t* expected, SkString extraMsg) { + size_t actualRowBytes, const uint8_t* expected, SkString extraMsg, + GrPixelConfig config) { for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { uint8_t a = actual[y * actualRowBytes + x]; uint8_t e = expected[y * w + x]; + if (kRGBA_1010102_GrPixelConfig == config) { + // This config only preserves two bits of alpha + a >>= 6; + e >>= 6; + } if (e != a) { ERRORF(reporter, "Failed alpha readback. Expected: 0x%02x, Got: 0x%02x at (%d,%d), %s", @@ -99,7 +105,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { SkString msg; msg.printf("rb:%d A8", SkToU32(rowBytes)); validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes, - alphaData, msg); + alphaData, msg, kAlpha_8_GrPixelConfig); // Now try writing to a single channel surface (if we could create one). if (surf) { @@ -136,7 +142,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { static const GrPixelConfig kRGBAConfigs[] { kRGBA_8888_GrPixelConfig, kBGRA_8888_GrPixelConfig, - kSRGBA_8888_GrPixelConfig + kSRGBA_8888_GrPixelConfig, + kRGBA_1010102_GrPixelConfig, }; for (int y = 0; y < Y_SIZE; ++y) { @@ -200,7 +207,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { SkString msg; msg.printf("rt:%d, rb:%d 8888", rt, SkToU32(rowBytes)); validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes, - alphaData, msg); + alphaData, msg, config); } } } diff --git a/tests/SpecialSurfaceTest.cpp b/tests/SpecialSurfaceTest.cpp index a336cf669d..40de08de85 100644 --- a/tests/SpecialSurfaceTest.cpp +++ b/tests/SpecialSurfaceTest.cpp @@ -80,12 +80,15 @@ DEF_TEST(SpecialSurface_Raster2, reporter) { #if SK_SUPPORT_GPU DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu1, reporter, ctxInfo) { - sk_sp surf(SkSpecialSurface::MakeRenderTarget(ctxInfo.grContext(), - kSmallerSize, kSmallerSize, - kRGBA_8888_GrPixelConfig, - nullptr)); - - test_surface(surf, reporter, 0); + for (auto config : { kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig }) { + if (!ctxInfo.grContext()->caps()->isConfigRenderable(config)) { + continue; + } + sk_sp surf(SkSpecialSurface::MakeRenderTarget(ctxInfo.grContext(), + kSmallerSize, kSmallerSize, + config, nullptr)); + test_surface(surf, reporter, 0); + } } #endif diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index ab91061094..35b72a972e 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -932,6 +932,7 @@ static void test_surface_creation_and_snapshot_with_color_space( skiatest::Reporter* reporter, const char* prefix, bool f16Support, + bool supports1010102, std::function(const SkImageInfo&)> surfaceMaker) { auto srgbColorSpace = SkColorSpace::MakeSRGB(); @@ -960,6 +961,7 @@ static void test_surface_creation_and_snapshot_with_color_space( { kRGBA_F16_SkColorType, oddColorSpace, false, "F16-odd" }, { kRGB_565_SkColorType, srgbColorSpace, false, "565-srgb" }, { kAlpha_8_SkColorType, srgbColorSpace, false, "A8-srgb" }, + { kRGBA_1010102_SkColorType, nullptr, true, "1010102-nullptr" }, }; for (auto& testConfig : testConfigs) { @@ -970,7 +972,8 @@ static void test_surface_creation_and_snapshot_with_color_space( // For some GPU contexts (eg ANGLE), we don't have f16 support, so we should fail to create // any surface of that type: bool shouldWork = testConfig.fShouldWork && - (f16Support || kRGBA_F16_SkColorType != testConfig.fColorType); + (f16Support || kRGBA_F16_SkColorType != testConfig.fColorType) && + (supports1010102 || kRGBA_1010102_SkColorType != testConfig.fColorType); auto surface(surfaceMaker(info)); REPORTER_ASSERT(reporter, SkToBool(surface) == shouldWork, fullTestName.c_str()); @@ -990,7 +993,8 @@ DEF_TEST(SurfaceCreationWithColorSpace, reporter) { return SkSurface::MakeRaster(info); }; - test_surface_creation_and_snapshot_with_color_space(reporter, "raster", true, surfaceMaker); + test_surface_creation_and_snapshot_with_color_space(reporter, "raster", true, true, + surfaceMaker); } #if SK_SUPPORT_GPU @@ -998,11 +1002,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter, GrContext* context = ctxInfo.grContext(); bool f16Support = context->caps()->isConfigRenderable(kRGBA_half_GrPixelConfig); + bool supports1010102 = context->caps()->isConfigRenderable(kRGBA_1010102_GrPixelConfig); auto surfaceMaker = [context](const SkImageInfo& info) { return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info); }; - test_surface_creation_and_snapshot_with_color_space(reporter, "gpu", f16Support, surfaceMaker); + test_surface_creation_and_snapshot_with_color_space(reporter, "gpu", f16Support, + supports1010102, surfaceMaker); std::vector backendTextures; auto wrappedSurfaceMaker = [ context, &backendTextures ](const SkImageInfo& info) { @@ -1028,7 +1034,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter, }; test_surface_creation_and_snapshot_with_color_space(reporter, "wrapped", f16Support, - wrappedSurfaceMaker); + supports1010102, wrappedSurfaceMaker); context->flush(); diff --git a/tests/TestConfigParsing.cpp b/tests/TestConfigParsing.cpp index ec69235ccc..6ff1fd830f 100644 --- a/tests/TestConfigParsing.cpp +++ b/tests/TestConfigParsing.cpp @@ -110,7 +110,8 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) { "mtl", "gl4444", "gl565", - "gltestthreading" + "gltestthreading", + "gl1010102", }); SkCommandLineConfigArray configs; @@ -200,6 +201,9 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) { REPORTER_ASSERT(reporter, configs[35]->asConfigGpu()->getAlphaType() == kOpaque_SkAlphaType); REPORTER_ASSERT(reporter, configs[36]->asConfigGpu()); REPORTER_ASSERT(reporter, configs[36]->asConfigGpu()->getTestThreading()); + REPORTER_ASSERT(reporter, configs[37]->asConfigGpu()); + REPORTER_ASSERT(reporter, configs[37]->asConfigGpu()->getColorType() == + kRGBA_1010102_SkColorType); #endif } -- cgit v1.2.3