Index: experimental/skpdiff/SkDifferentPixelsMetric_opencl.cpp |
diff --git a/experimental/skpdiff/SkDifferentPixelsMetric_opencl.cpp b/experimental/skpdiff/SkDifferentPixelsMetric_opencl.cpp |
index 61fb63813bcabbbcedbe5575796c3876f24573e1..f2a02c1c1823972793a9af7685910e6d46ec4d06 100644 |
--- a/experimental/skpdiff/SkDifferentPixelsMetric_opencl.cpp |
+++ b/experimental/skpdiff/SkDifferentPixelsMetric_opencl.cpp |
@@ -22,7 +22,6 @@ static const char kDifferentPixelsKernelSource[] = |
" int2 coord = (int2)(get_global_id(0), get_global_id(1)); \n" |
" uint4 baselinePixel = read_imageui(baseline, gInSampler, coord); \n" |
" uint4 testPixel = read_imageui(test, gInSampler, coord); \n" |
- " int4 pixelCompare = baselinePixel == testPixel; \n" |
" if (baselinePixel.x != testPixel.x || \n" |
" baselinePixel.y != testPixel.y || \n" |
" baselinePixel.z != testPixel.z || \n" |
@@ -120,9 +119,12 @@ int SkDifferentPixelsMetric::queueDiff(SkBitmap* baseline, SkBitmap* test) { |
diff->result *= (double)diff->numDiffPixels; |
diff->result = (1.0 - diff->result); |
- diff->poi = SkNEW_ARRAY(SkIPoint, diff->numDiffPixels); |
- clEnqueueReadBuffer(fCommandQueue, diff->poiBuffer, CL_TRUE, 0, |
+ // Reading a buffer of size zero can cause issues on some (Mac) OpenCL platforms. |
+ if (diff->numDiffPixels > 0) { |
+ diff->poi = SkNEW_ARRAY(SkIPoint, diff->numDiffPixels); |
+ clEnqueueReadBuffer(fCommandQueue, diff->poiBuffer, CL_TRUE, 0, |
sizeof(SkIPoint) * diff->numDiffPixels, diff->poi, 0, NULL, NULL); |
+ } |
// Release all the buffers created |
clReleaseMemObject(diff->poiBuffer); |