Move FP texture test buffers to heap.
This is a speculative fix for the crashing N5 bots. It looks like the bots are
always failing in or around FloatingPointTextureTest.
It looks like sometimes they're hitting a SIGBUS, which I suspect is stack
overflow. FloatingPointTextureTest allocates ~320K on the stack, which may
be too much. This CL moves those buffers to the heap. For consistency I did
the same with the half-float tests, though they're only using ~1/8th the stack.
It looks like sometimes the bots are failing to malloc. I don't understand that,
and this CL doesn't address that directly. But it's possible this is still a stack
overflow, just trashing RAM and causing arbitrary mayhem instead of a SIGBUS.
I have no idea why this is a problem only on the N5. I have been unable to
reproduce this locally, neither with a K N5 nor an L N5, but the bots are pretty
reliable.
NOTREECHECKS=true
BUG=skia:
Review URL: https://codereview.chromium.org/871623002
diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp
index 346c737..15f2e2e 100644
--- a/tests/FloatingPointTextureTest.cpp
+++ b/tests/FloatingPointTextureTest.cpp
@@ -28,8 +28,10 @@
static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H);
DEF_GPUTEST(FloatingPointTextureTest, reporter, factory) {
- float controlPixelData[FP_CONTROL_ARRAY_SIZE];
- float readBuffer[FP_CONTROL_ARRAY_SIZE];
+ SkTDArray<float> controlPixelData, readBuffer;
+ controlPixelData.setCount(FP_CONTROL_ARRAY_SIZE);
+ readBuffer.setCount(FP_CONTROL_ARRAY_SIZE);
+
for (int i = 0; i < FP_CONTROL_ARRAY_SIZE; i += 4) {
controlPixelData[i] = FLT_MIN;
controlPixelData[i + 1] = FLT_MAX;
@@ -70,8 +72,8 @@
}
// write square
- fpTexture->writePixels(0, 0, DEV_W, DEV_H, desc.fConfig, controlPixelData, 0);
- fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer, 0);
+ fpTexture->writePixels(0, 0, DEV_W, DEV_H, desc.fConfig, controlPixelData.begin(), 0);
+ fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer.begin(), 0);
for (int j = 0; j < FP_CONTROL_ARRAY_SIZE; ++j) {
REPORTER_ASSERT(reporter, readBuffer[j] == controlPixelData[j]);
}
@@ -82,8 +84,10 @@
static const int HALF_CONTROL_ARRAY_SIZE = DEV_W * DEV_H;
DEF_GPUTEST(HalfFloatTextureTest, reporter, factory) {
- SkHalf controlPixelData[HALF_CONTROL_ARRAY_SIZE];
- SkHalf readBuffer[HALF_CONTROL_ARRAY_SIZE];
+ SkTDArray<SkHalf> controlPixelData, readBuffer;
+ controlPixelData.setCount(HALF_CONTROL_ARRAY_SIZE);
+ readBuffer.setCount(HALF_CONTROL_ARRAY_SIZE);
+
for (int i = 0; i < HALF_CONTROL_ARRAY_SIZE; i += 4) {
controlPixelData[i] = SK_HalfMin;
controlPixelData[i + 1] = SK_HalfMax;
@@ -124,8 +128,8 @@
}
// write square
- fpTexture->writePixels(0, 0, DEV_W, DEV_H, desc.fConfig, controlPixelData, 0);
- fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer, 0);
+ fpTexture->writePixels(0, 0, DEV_W, DEV_H, desc.fConfig, controlPixelData.begin(), 0);
+ fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer.begin(), 0);
for (int j = 0; j < HALF_CONTROL_ARRAY_SIZE; ++j) {
REPORTER_ASSERT(reporter, readBuffer[j] == controlPixelData[j]);
}