utests: use OpenCL 1.2 API for image related test cases.
authorZhigang Gong <zhigang.gong@intel.com>
Fri, 13 Jun 2014 09:44:00 +0000 (17:44 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Fri, 13 Jun 2014 09:49:36 +0000 (17:49 +0800)
Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
src/cl_khr_icd.c
utests/compiler_box_blur_image.cpp
utests/compiler_fill_gl_image.cpp
utests/compiler_fill_image_3d.cpp
utests/compiler_fill_image_3d_2.cpp
utests/compiler_get_image_info.cpp
utests/compiler_movforphi_undef.cpp
utests/utest_helper.hpp

index f27ce4e..b23c29d 100644 (file)
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
-#include <CL/cl.h>
-#ifndef CL_VERSION_1_2
-#include <cl_mem.h>
-typedef cl_uint             cl_kernel_arg_info;
-typedef cl_bitfield         cl_mem_migration_flags;
-#define cl_device_partition_property cl_device_partition_property_ext
-#define CL_API_SUFFIX__VERSION_1_2
-#endif
 #include <ocl_icd.h>
 
 #include "cl_platform_id.h"
index 351f08e..d94a97c 100644 (file)
@@ -4,6 +4,7 @@ static void compiler_box_blur_image()
 {
   int w, h;
   cl_image_format format = { };
+  cl_image_desc desc = { };
   size_t origin[3] = { };
   size_t region[3];
   int *src, *dst;
@@ -15,11 +16,17 @@ static void compiler_box_blur_image()
 
   format.image_channel_order = CL_RGBA;
   format.image_channel_data_type = CL_UNORM_INT8;
+  desc.image_type = CL_MEM_OBJECT_IMAGE2D;
+  desc.image_width = w;
+  desc.image_height = h;
+  desc.image_depth = 1;
+  desc.image_row_pitch = w*sizeof(uint32_t);
 
   /* Run the kernel */
-  OCL_CREATE_IMAGE2D(buf[0], CL_MEM_COPY_HOST_PTR, &format, w, h, w*sizeof(uint32_t), src);
+  OCL_CREATE_IMAGE(buf[0], CL_MEM_COPY_HOST_PTR, &format, &desc, src);
   free(src);
-  OCL_CREATE_IMAGE2D(buf[1], 0, &format, w, h, 0, NULL);
+  desc.image_row_pitch = 0;
+  OCL_CREATE_IMAGE(buf[1], 0, &format, &desc, NULL);
   OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
   OCL_SET_ARG(1, sizeof(cl_mem), &buf[1]);
   globals[0] = w;
index 437fcf4..87d2fcd 100644 (file)
@@ -46,7 +46,7 @@ static void compiler_fill_gl_image(void)
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, NULL);
 
   OCL_CREATE_KERNEL("test_fill_gl_image");
-  OCL_CREATE_GL_IMAGE2D(buf[0], 0, GL_TEXTURE_2D, 0, tex);
+  OCL_CREATE_GL_IMAGE(buf[0], 0, GL_TEXTURE_2D, 0, tex);
 
   // Run the kernel
   OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
index 6a679fb..ec96e80 100644 (file)
@@ -1,3 +1,4 @@
+#include <string.h>
 #include "utest_helper.hpp"
 
 static void compiler_fill_image_3d(void)
@@ -7,14 +8,24 @@ static void compiler_fill_image_3d(void)
   const size_t depth = 5;
   uint32_t color = 0x12345678;
   cl_image_format format;
+  cl_image_desc desc;
+
+  memset(&desc, 0x0, sizeof(cl_image_desc));
+  memset(&format, 0x0, sizeof(cl_image_format));
 
   format.image_channel_order = CL_RGBA;
   format.image_channel_data_type = CL_UNSIGNED_INT8;
+  desc.image_type = CL_MEM_OBJECT_IMAGE3D;
+  desc.image_width = w;
+  desc.image_height = h;
+  desc.image_depth = depth;
+  desc.image_row_pitch = 0;
+  desc.image_slice_pitch = 0;
 
   // Setup kernel and images
   OCL_CREATE_KERNEL("test_fill_image_3d");
 
-  OCL_CREATE_IMAGE3D(buf[0], 0, &format, w, h, depth, 0, 0, NULL);
+  OCL_CREATE_IMAGE(buf[0], 0, &format, &desc, NULL);
 
   // Run the kernel
   OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
index f5ff792..410ace8 100644 (file)
@@ -1,3 +1,4 @@
+#include <string.h>
 #include "utest_helper.hpp"
 
 static void compiler_fill_image_3d_2(void)
@@ -6,14 +7,24 @@ static void compiler_fill_image_3d_2(void)
   const size_t h = 512;
   const size_t depth = 5;
   cl_image_format format;
+  cl_image_desc desc;
+
+  memset(&desc, 0x0, sizeof(cl_image_desc));
+  memset(&format, 0x0, sizeof(cl_image_format));
 
   format.image_channel_order = CL_RGBA;
   format.image_channel_data_type = CL_UNSIGNED_INT8;
+  desc.image_type = CL_MEM_OBJECT_IMAGE3D;
+  desc.image_width = w;
+  desc.image_height = h;
+  desc.image_depth = depth;
+  desc.image_row_pitch = 0;
+  desc.image_slice_pitch = 0;
 
   // Setup kernel and images
   OCL_CREATE_KERNEL("test_fill_image_3d_2");
 
-  OCL_CREATE_IMAGE3D(buf[0], 0, &format, w, h, depth, 0, 0, NULL);
+  OCL_CREATE_IMAGE(buf[0], 0, &format, &desc, NULL);
 
   // Run the kernel
   OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
index 4454d03..3b9d132 100644 (file)
@@ -6,14 +6,24 @@ static void compiler_get_image_info(void)
   const size_t h = 512;
   const size_t depth = 3;
   cl_image_format format;
+  cl_image_desc desc;
 
   format.image_channel_order = CL_RGBA;
   format.image_channel_data_type = CL_UNSIGNED_INT8;
+  desc.image_type = CL_MEM_OBJECT_IMAGE3D;
+  desc.image_width = w;
+  desc.image_height = h;
+  desc.image_depth = depth;
+  desc.image_row_pitch = 0;
+  desc.image_slice_pitch = 0;
+  desc.num_mip_levels = 0;
+  desc.num_samples = 0;
+  desc.buffer = NULL;
 
   // Setup kernel and images
   OCL_CREATE_KERNEL("test_get_image_info");
 
-  OCL_CREATE_IMAGE3D(buf[0], 0, &format, w, h, depth, 0, 0, NULL);
+  OCL_CREATE_IMAGE(buf[0], 0, &format, &desc, NULL);
   OCL_CREATE_BUFFER(buf[1], 0, 32 * sizeof(int), NULL);
   OCL_CREATE_BUFFER(buf[2], 0, 32 * sizeof(int), NULL);
 
index 31c7e89..3c5a456 100644 (file)
@@ -6,6 +6,7 @@ static void compiler_movforphi_undef(void)
   const size_t h = 16;
   cl_sampler sampler;
   cl_image_format format;
+  cl_image_desc desc;
 
   // Setup kernel and images
   OCL_CREATE_KERNEL("test_movforphi_undef");
@@ -16,9 +17,14 @@ static void compiler_movforphi_undef(void)
 
   format.image_channel_order = CL_RGBA;
   format.image_channel_data_type = CL_UNSIGNED_INT8;
-  OCL_CREATE_IMAGE2D(buf[0], CL_MEM_COPY_HOST_PTR, &format, w, h, w * sizeof(uint32_t), buf_data[0]);
-
-  OCL_CREATE_IMAGE2D(buf[1], 0, &format, w, h, 0, NULL);
+  desc.image_type = CL_MEM_OBJECT_IMAGE2D;
+  desc.image_width = w;
+  desc.image_height = h;
+  desc.image_row_pitch = w * sizeof(uint32_t);
+  OCL_CREATE_IMAGE(buf[0], CL_MEM_COPY_HOST_PTR, &format, &desc, buf_data[0]);
+
+  desc.image_row_pitch = 0;
+  OCL_CREATE_IMAGE(buf[1], 0, &format, &desc, NULL);
   OCL_CREATE_SAMPLER(sampler, CL_ADDRESS_REPEAT, CL_FILTER_NEAREST);
   free(buf_data[0]);
   buf_data[0] = NULL;
index 0ebad7b..de4d277 100644 (file)
@@ -104,12 +104,6 @@ extern EGLSurface  eglSurface;
 #define OCL_CREATE_IMAGE(IMAGE, FLAGS, FORMAT, DESC, DATA) \
     OCL_CALL2(clCreateImage, IMAGE, ctx, FLAGS, FORMAT, DESC, DATA)
 
-#define OCL_CREATE_IMAGE2D(IMAGE, FLAGS, FORMAT, WIDTH, HEIGHT, PITCH, DATA) \
-    OCL_CALL2(clCreateImage2D, IMAGE, ctx, FLAGS, FORMAT, WIDTH, HEIGHT, PITCH, DATA)
-
-#define OCL_CREATE_IMAGE3D(IMAGE, FLAGS, FORMAT, WIDTH, HEIGHT, DEPTH, RPITCH, SPITCH, DATA) \
-    OCL_CALL2(clCreateImage3D, IMAGE, ctx, FLAGS, FORMAT, WIDTH, HEIGHT, DEPTH, RPITCH, SPITCH, DATA)
-
 #define OCL_READ_IMAGE(IMAGE, ORIGIN, REGION, DATA) \
     OCL_CALL(clEnqueueReadImage, queue, IMAGE, CL_TRUE, ORIGIN, REGION, 0, 0, DATA, 0, NULL, NULL)
 
@@ -119,12 +113,6 @@ extern EGLSurface  eglSurface;
 #define OCL_CREATE_GL_IMAGE(IMAGE, FLAGS, TARGET, LEVEL, TEXTURE) \
     OCL_CALL2(clCreateFromGLTexture, IMAGE, ctx, FLAGS, TARGET, LEVEL, TEXTURE)
 
-#define OCL_CREATE_GL_IMAGE2D(IMAGE, FLAGS, TARGET, LEVEL, TEXTURE) \
-    OCL_CALL2(clCreateFromGLTexture2D, IMAGE, ctx, FLAGS, TARGET, LEVEL, TEXTURE)
-
-#define OCL_CREATE_GL_IMAGE3D(IMAGE, FLAGS, TARGET, LEVEL, TEXTURE) \
-    OCL_CALL2(clCreateFromGLTexture3D, IMAGE, ctx, FLAGS, TARGET, LEVEL, TEXTURE)
-
 #define OCL_ENQUEUE_ACQUIRE_GL_OBJECTS(ID) \
     OCL_CALL(clEnqueueAcquireGLObjects, queue, 1, &buf[ID], 0, 0, 0)