From bd72dbae9295285d8e325c48772c5a36a651906b Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Fri, 13 Jun 2014 17:44:00 +0800 Subject: [PATCH] utests: use OpenCL 1.2 API for image related test cases. Signed-off-by: Zhigang Gong --- src/cl_khr_icd.c | 8 -------- utests/compiler_box_blur_image.cpp | 11 +++++++++-- utests/compiler_fill_gl_image.cpp | 2 +- utests/compiler_fill_image_3d.cpp | 13 ++++++++++++- utests/compiler_fill_image_3d_2.cpp | 13 ++++++++++++- utests/compiler_get_image_info.cpp | 12 +++++++++++- utests/compiler_movforphi_undef.cpp | 12 +++++++++--- utests/utest_helper.hpp | 12 ------------ 8 files changed, 54 insertions(+), 29 deletions(-) diff --git a/src/cl_khr_icd.c b/src/cl_khr_icd.c index f27ce4e..b23c29d 100644 --- a/src/cl_khr_icd.c +++ b/src/cl_khr_icd.c @@ -14,14 +14,6 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ -#include -#ifndef CL_VERSION_1_2 -#include -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 #include "cl_platform_id.h" diff --git a/utests/compiler_box_blur_image.cpp b/utests/compiler_box_blur_image.cpp index 351f08e..d94a97c 100644 --- a/utests/compiler_box_blur_image.cpp +++ b/utests/compiler_box_blur_image.cpp @@ -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; diff --git a/utests/compiler_fill_gl_image.cpp b/utests/compiler_fill_gl_image.cpp index 437fcf4..87d2fcd 100644 --- a/utests/compiler_fill_gl_image.cpp +++ b/utests/compiler_fill_gl_image.cpp @@ -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]); diff --git a/utests/compiler_fill_image_3d.cpp b/utests/compiler_fill_image_3d.cpp index 6a679fb..ec96e80 100644 --- a/utests/compiler_fill_image_3d.cpp +++ b/utests/compiler_fill_image_3d.cpp @@ -1,3 +1,4 @@ +#include #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]); diff --git a/utests/compiler_fill_image_3d_2.cpp b/utests/compiler_fill_image_3d_2.cpp index f5ff792..410ace8 100644 --- a/utests/compiler_fill_image_3d_2.cpp +++ b/utests/compiler_fill_image_3d_2.cpp @@ -1,3 +1,4 @@ +#include #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]); diff --git a/utests/compiler_get_image_info.cpp b/utests/compiler_get_image_info.cpp index 4454d03..3b9d132 100644 --- a/utests/compiler_get_image_info.cpp +++ b/utests/compiler_get_image_info.cpp @@ -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); diff --git a/utests/compiler_movforphi_undef.cpp b/utests/compiler_movforphi_undef.cpp index 31c7e89..3c5a456 100644 --- a/utests/compiler_movforphi_undef.cpp +++ b/utests/compiler_movforphi_undef.cpp @@ -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; diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp index 0ebad7b..de4d277 100644 --- a/utests/utest_helper.hpp +++ b/utests/utest_helper.hpp @@ -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) -- 2.7.4