* 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"
{
int w, h;
cl_image_format format = { };
+ cl_image_desc desc = { };
size_t origin[3] = { };
size_t region[3];
int *src, *dst;
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;
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]);
+#include <string.h>
#include "utest_helper.hpp"
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]);
+#include <string.h>
#include "utest_helper.hpp"
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]);
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);
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");
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;
#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)
#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)