utest: change the box_blur_image to be identical to box_blur.
authorZhigang Gong <zhigang.gong@intel.com>
Fri, 31 Oct 2014 02:04:50 +0000 (10:04 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Tue, 4 Nov 2014 11:15:20 +0000 (19:15 +0800)
Change box_blur_image to read integer type surface thus
it could be totally identical to the box_blur thus they
can share the same reference image.

Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
kernels/compiler_box_blur_image.cl
utests/compiler_box_blur_image.cpp

index 42f463b..69fa229 100644 (file)
@@ -6,13 +6,15 @@ __kernel void compiler_box_blur_image(__read_only image2d_t src,
                             CLK_FILTER_NEAREST;
   const int2 coord = (int2)(get_global_id(0), get_global_id(1));
   int2 offset;
-  float4 sum = 0;
+  uint4 sum = 0;
 
   for (offset.y = -1; offset.y <= 1; offset.y++) {
     for (offset.x = -1; offset.x <= 1; offset.x++) {
-      sum +=  read_imagef(src, sampler, coord + offset);
+      sum +=  read_imageui(src, sampler, coord + offset);
     }
   }
 
-  write_imagef(dst, coord, (1.0f/9.0f)*sum);
+  uint4 result = sum / 9;
+
+  write_imageui(dst, coord, result);
 }
index d94a97c..711f2b3 100644 (file)
@@ -15,7 +15,7 @@ static void compiler_box_blur_image()
   src = cl_read_bmp("lenna128x128.bmp", &w, &h);
 
   format.image_channel_order = CL_RGBA;
-  format.image_channel_data_type = CL_UNORM_INT8;
+  format.image_channel_data_type = CL_UNSIGNED_INT8;
   desc.image_type = CL_MEM_OBJECT_IMAGE2D;
   desc.image_width = w;
   desc.image_height = h;