Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2020-12-23 15:11:33 +00:00
|
|
|
#include "include/core/SkBitmap.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkSurface.h"
|
2020-07-06 14:56:46 +00:00
|
|
|
#include "include/core/SkTypes.h"
|
|
|
|
#include "include/gpu/GrDirectContext.h"
|
2020-10-14 15:23:11 +00:00
|
|
|
#include "src/gpu/GrDirectContextPriv.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tests/Test.h"
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
|
2018-09-11 20:39:11 +00:00
|
|
|
static SkBitmap read_pixels(sk_sp<SkSurface> surface, SkColor initColor) {
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
SkBitmap bmp;
|
|
|
|
bmp.allocN32Pixels(surface->width(), surface->height());
|
2018-09-11 20:39:11 +00:00
|
|
|
bmp.eraseColor(initColor);
|
2017-07-21 18:24:29 +00:00
|
|
|
if (!surface->readPixels(bmp, 0, 0)) {
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
SkDebugf("readPixels failed\n");
|
|
|
|
}
|
|
|
|
return bmp;
|
|
|
|
}
|
|
|
|
|
2020-07-23 17:54:35 +00:00
|
|
|
static sk_sp<SkSurface> make_surface(GrRecordingContext* rContext) {
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
SkImageInfo info = SkImageInfo::Make(50, 50, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
2020-07-23 17:54:35 +00:00
|
|
|
return SkSurface::MakeRenderTarget(rContext, SkBudgeted::kNo, info, 4,
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
kBottomLeft_GrSurfaceOrigin, nullptr);
|
|
|
|
}
|
|
|
|
|
2020-07-23 17:54:35 +00:00
|
|
|
static void test_bug_6653(GrDirectContext* dContext,
|
|
|
|
skiatest::Reporter* reporter,
|
|
|
|
const char* label) {
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
SkRect rect = SkRect::MakeWH(50, 50);
|
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor(SK_ColorWHITE);
|
|
|
|
paint.setStrokeWidth(5);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
// The one device that fails this test (Galaxy S6) does so in a flaky fashion. Trying many
|
|
|
|
// times makes it more likely to fail. Also, interacting with the phone (eg swiping between
|
|
|
|
// different home screens) while the test is running makes it fail close to 100%.
|
|
|
|
static const int kNumIterations = 50;
|
|
|
|
|
|
|
|
for (int i = 0; i < kNumIterations; ++i) {
|
2020-07-23 17:54:35 +00:00
|
|
|
auto s0 = make_surface(dContext);
|
2017-06-15 18:16:08 +00:00
|
|
|
if (!s0) {
|
|
|
|
// MSAA may not be supported
|
|
|
|
return;
|
|
|
|
}
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
|
2020-07-23 17:54:35 +00:00
|
|
|
auto s1 = make_surface(dContext);
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
s1->getCanvas()->clear(SK_ColorBLACK);
|
|
|
|
s1->getCanvas()->drawOval(rect, paint);
|
2018-09-11 20:39:11 +00:00
|
|
|
SkBitmap b1 = read_pixels(s1, SK_ColorBLACK);
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
s1 = nullptr;
|
|
|
|
|
|
|
|
// The bug requires that all three of the following surfaces are cleared to the same color
|
2020-07-23 17:54:35 +00:00
|
|
|
auto s2 = make_surface(dContext);
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
s2->getCanvas()->clear(SK_ColorBLUE);
|
2018-09-11 20:39:11 +00:00
|
|
|
SkBitmap b2 = read_pixels(s2, SK_ColorBLACK);
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
s2 = nullptr;
|
|
|
|
|
2020-07-23 17:54:35 +00:00
|
|
|
auto s3 = make_surface(dContext);
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
s3->getCanvas()->clear(SK_ColorBLUE);
|
2018-09-11 20:39:11 +00:00
|
|
|
SkBitmap b3 = read_pixels(s3, SK_ColorBLACK);
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
s0->getCanvas()->drawBitmap(b3, 0, 0);
|
|
|
|
s3 = nullptr;
|
|
|
|
|
2020-07-23 17:54:35 +00:00
|
|
|
auto s4 = make_surface(dContext);
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
s4->getCanvas()->clear(SK_ColorBLUE);
|
|
|
|
s4->getCanvas()->drawOval(rect, paint);
|
|
|
|
|
|
|
|
// When this fails, b4 will "succeed", but return an empty bitmap (containing just the
|
|
|
|
// clear color). Regardless, b5 will contain the oval that was just drawn, so diffing the
|
2018-09-11 20:39:11 +00:00
|
|
|
// two bitmaps tests for the failure case. Initialize the bitmaps to different colors so
|
|
|
|
// that if the readPixels doesn't work, this test will always fail.
|
|
|
|
SkBitmap b4 = read_pixels(s4, SK_ColorRED);
|
|
|
|
SkBitmap b5 = read_pixels(s4, SK_ColorGREEN);
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
|
|
|
|
bool match = true;
|
|
|
|
for (int y = 0; y < b4.height() && match; ++y) {
|
|
|
|
for (int x = 0; x < b4.width() && match; ++x) {
|
|
|
|
uint32_t pixelA = *b4.getAddr32(x, y);
|
|
|
|
uint32_t pixelB = *b5.getAddr32(x, y);
|
|
|
|
if (pixelA != pixelB) {
|
|
|
|
match = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-28 13:44:45 +00:00
|
|
|
REPORTER_ASSERT(reporter, match, label);
|
Unit test to demonstrate Galaxy S6 MSAA readPixels bug
After lots of tinkering, this is the smallest test case I've
found to reproduce the bug. Frequently, bitmap b4 will be
cleared to blue, but not contain the oval drawn right before.
Bitmap b5 will contain the oval, so the diff of the two
bitmaps will detect the error.
There may be something else that can be removed, but I
haven't found it.
Interesting note:
In the original version, all surfaces were cleared to
black. When I started trying to change the clear colors to
figure out if we were getting an old surface, the bug went
away. In particular, the first clear color is irrelevant,
but the last three clears must all be the same color. If
any are different, the bug doesn't occur.
Bug: skia:6653
Change-Id: Iacafcc140b60594fab208e82987b0f37416975f3
Reviewed-on: https://skia-review.googlesource.com/19817
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-06-15 17:25:10 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-27 14:02:00 +00:00
|
|
|
|
|
|
|
// Tests that readPixels returns up-to-date results. This has failed on several GPUs,
|
|
|
|
// from multiple vendors, in MSAA mode.
|
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(skbug6653, reporter, ctxInfo) {
|
2020-07-06 14:56:46 +00:00
|
|
|
auto ctx = ctxInfo.directContext();
|
2018-08-28 13:44:45 +00:00
|
|
|
test_bug_6653(ctx, reporter, "Default");
|
2018-08-27 14:02:00 +00:00
|
|
|
}
|
|
|
|
|