[Beignet] [PATCH] Refine mem.h and improve the related macro defination.
junyan.he at inbox.com
junyan.he at inbox.com
Mon Dec 19 09:21:51 UTC 2016
From: Junyan He <junyan.he at intel.com>
Signed-off-by: Junyan He <junyan.he at intel.com>
---
src/cl_api_mem.c | 70 ++++-----
src/cl_cmrt.cpp | 4 +-
src/cl_command_queue.c | 2 +-
src/cl_enqueue.c | 4 +-
src/cl_kernel.c | 6 +-
src/cl_mem.c | 71 ++++++---
src/cl_mem.h | 417 ++++++++++++++++++++++---------------------------
src/cl_mem_gl.c | 2 +-
src/cl_utils.h | 4 +-
9 files changed, 276 insertions(+), 304 deletions(-)
diff --git a/src/cl_api_mem.c b/src/cl_api_mem.c
index de18684..1222070 100644
--- a/src/cl_api_mem.c
+++ b/src/cl_api_mem.c
@@ -71,54 +71,54 @@ clGetMemObjectInfo(cl_mem memobj,
break;
case CL_MEM_HOST_PTR: {
ptr = 0;
- if (memobj->type == CL_MEM_IMAGE_TYPE) {
+ if (!CL_OBJECT_IS_BUFFER(memobj)) {
ptr = (size_t)memobj->host_ptr;
} else {
- struct _cl_mem_buffer *buf = (struct _cl_mem_buffer *)memobj;
+ cl_mem_buffer buf = cl_mem_to_buffer(memobj);
ptr = (size_t)memobj->host_ptr + buf->sub_offset;
}
src_ptr = &ptr;
src_size = sizeof(size_t);
break;
}
- case CL_MEM_USES_SVM_POINTER: {
+ case CL_MEM_USES_SVM_POINTER:
src_ptr = &memobj->is_svm;
src_size = sizeof(memobj->is_svm);
- }
+ break;
case CL_MEM_MAP_COUNT:
src_ptr = &memobj->map_ref;
src_size = sizeof(cl_uint);
break;
- case CL_MEM_REFERENCE_COUNT: {
+ case CL_MEM_REFERENCE_COUNT:
ref = CL_OBJECT_GET_REF(memobj);
src_ptr = &ref;
src_size = sizeof(cl_int);
break;
- }
case CL_MEM_CONTEXT:
src_ptr = &memobj->ctx;
src_size = sizeof(cl_context);
break;
case CL_MEM_ASSOCIATED_MEMOBJECT: {
parent = NULL;
- if (memobj->type == CL_MEM_SUBBUFFER_TYPE) {
- struct _cl_mem_buffer *buf = (struct _cl_mem_buffer *)memobj;
+ if (CL_OBJECT_IS_SUB_BUFFER(memobj)) {
+ cl_mem_buffer buf = cl_mem_to_buffer(memobj);
parent = (cl_mem)(buf->parent);
- } else if (memobj->type == CL_MEM_IMAGE_TYPE) {
- parent = memobj;
- } else if (memobj->type == CL_MEM_BUFFER1D_IMAGE_TYPE) {
- struct _cl_mem_buffer1d_image* image_buffer = (struct _cl_mem_buffer1d_image*)memobj;
+ } else if (CL_OBJECT_IS_BUFFER1D_IMAGE(memobj)) {
+ cl_mem_buffer1d_image image_buffer = cl_mem_to_buffer1d_image(memobj);
parent = image_buffer->descbuffer;
- } else
+ } else if (CL_OBJECT_IS_IMAGE(memobj)) {
+ parent = memobj;
+ } else {
parent = NULL;
+ }
src_ptr = &parent;
src_size = sizeof(cl_mem);
break;
}
case CL_MEM_OFFSET: {
offset = 0;
- if (memobj->type == CL_MEM_SUBBUFFER_TYPE) {
- struct _cl_mem_buffer *buf = (struct _cl_mem_buffer *)memobj;
+ if (CL_OBJECT_IS_SUB_BUFFER(memobj)) {
+ cl_mem_buffer buf = cl_mem_to_buffer(memobj);
offset = buf->sub_offset;
}
src_ptr = &offset;
@@ -142,14 +142,14 @@ clGetImageInfo(cl_mem memobj,
{
const void *src_ptr = NULL;
size_t src_size = 0;
- struct _cl_mem_image *image;
+ cl_mem_image image;
size_t height, depth, array_sz;
cl_uint value;
- if (!CL_OBJECT_IS_MEM(memobj)) {
+ if (!CL_OBJECT_IS_IMAGE(memobj)) {
return CL_INVALID_MEM_OBJECT;
}
- image = cl_mem_image(memobj);
+ image = cl_mem_to_image(memobj);
switch (param_name) {
case CL_IMAGE_FORMAT:
@@ -169,8 +169,8 @@ clGetImageInfo(cl_mem memobj,
src_size = sizeof(size_t);
break;
case CL_IMAGE_WIDTH:
- if (memobj->type == CL_MEM_BUFFER1D_IMAGE_TYPE) {
- struct _cl_mem_buffer1d_image *buffer1d_image = (struct _cl_mem_buffer1d_image *)image;
+ if (CL_OBJECT_IS_BUFFER1D_IMAGE(memobj)) {
+ cl_mem_buffer1d_image buffer1d_image = cl_mem_to_buffer1d_image(memobj);
src_ptr = &buffer1d_image->size;
} else {
src_ptr = &image->w;
@@ -179,8 +179,8 @@ clGetImageInfo(cl_mem memobj,
break;
case CL_IMAGE_HEIGHT: {
height = 0;
- if (memobj->type != CL_MEM_BUFFER1D_IMAGE_TYPE) {
- height = IS_1D_IMAGE(image) ? 0 : image->h;
+ if (!CL_OBJECT_IS_BUFFER1D_IMAGE(memobj)) {
+ height = CL_OBJECT_IS_IMAGE_1D(image) ? 0 : image->h;
}
src_ptr = &height;
src_size = sizeof(size_t);
@@ -188,14 +188,14 @@ clGetImageInfo(cl_mem memobj,
}
case CL_IMAGE_DEPTH: {
depth = 0;
- depth = IS_3D_IMAGE(image) ? image->depth : 0;
+ depth = CL_OBJECT_IS_IMAGE_3D(image) ? image->depth : 0;
src_ptr = &depth;
src_size = sizeof(size_t);
break;
}
case CL_IMAGE_ARRAY_SIZE: {
array_sz = 0;
- array_sz = IS_IMAGE_ARRAY(image) ? image->depth : 0;
+ array_sz = CL_OBJECT_IS_IMAGE_ARRAY(image) ? image->depth : 0;
src_ptr = &array_sz;
src_size = sizeof(size_t);
break;
@@ -992,9 +992,9 @@ clEnqueueCopyBuffer(cl_command_queue command_queue,
}
/* Check sub overlap */
- if (src_buffer->type == CL_MEM_SUBBUFFER_TYPE && dst_buffer->type == CL_MEM_SUBBUFFER_TYPE) {
- struct _cl_mem_buffer *src_b = (struct _cl_mem_buffer *)src_buffer;
- struct _cl_mem_buffer *dst_b = (struct _cl_mem_buffer *)dst_buffer;
+ if (CL_OBJECT_IS_SUB_BUFFER(src_buffer) && CL_OBJECT_IS_SUB_BUFFER(dst_buffer)) {
+ cl_mem_buffer src_b = cl_mem_to_buffer(src_buffer);
+ cl_mem_buffer dst_b = cl_mem_to_buffer(dst_buffer);
size_t src_sub_offset = src_b->sub_offset;
size_t dst_sub_offset = dst_b->sub_offset;
if ((src_offset + src_sub_offset <= dst_offset + dst_sub_offset &&
@@ -1515,7 +1515,7 @@ clEnqueueMapImage(cl_command_queue command_queue,
break;
}
- image = cl_mem_image(mem);
+ image = cl_mem_to_image(mem);
err = check_image_region(image, pregion, region);
if (err != CL_SUCCESS) {
@@ -1699,7 +1699,7 @@ clEnqueueReadImage(cl_command_queue command_queue,
break;
}
- image = cl_mem_image(mem);
+ image = cl_mem_to_image(mem);
err = check_image_region(image, pregion, region);
if (err != CL_SUCCESS) {
@@ -1852,7 +1852,7 @@ clEnqueueWriteImage(cl_command_queue command_queue,
break;
}
- image = cl_mem_image(mem);
+ image = cl_mem_to_image(mem);
err = check_image_region(image, pregion, region);
if (err != CL_SUCCESS) {
@@ -2010,8 +2010,8 @@ clEnqueueCopyImage(cl_command_queue command_queue,
break;
}
- src_image = cl_mem_image(src_mem);
- dst_image = cl_mem_image(dst_mem);
+ src_image = cl_mem_to_image(src_mem);
+ dst_image = cl_mem_to_image(dst_mem);
err = check_image_region(src_image, pregion, region);
if (err != CL_SUCCESS) {
@@ -2147,7 +2147,7 @@ clEnqueueCopyImageToBuffer(cl_command_queue command_queue,
break;
}
- src_image = cl_mem_image(src_mem);
+ src_image = cl_mem_to_image(src_mem);
err = check_image_region(src_image, pregion, region);
if (err != CL_SUCCESS) {
@@ -2260,7 +2260,7 @@ clEnqueueCopyBufferToImage(cl_command_queue command_queue,
break;
}
- dst_image = cl_mem_image(dst_mem);
+ dst_image = cl_mem_to_image(dst_mem);
err = check_image_region(dst_image, pregion, region);
if (err != CL_SUCCESS) {
@@ -2369,7 +2369,7 @@ clEnqueueFillImage(cl_command_queue command_queue,
break;
}
- image = cl_mem_image(mem);
+ image = cl_mem_to_image(mem);
err = check_image_region(image, pregion, region);
if (err != CL_SUCCESS) {
diff --git a/src/cl_cmrt.cpp b/src/cl_cmrt.cpp
index f653844..5c178a1 100644
--- a/src/cl_cmrt.cpp
+++ b/src/cl_cmrt.cpp
@@ -210,8 +210,8 @@ static bool CreateCmrtMemory(cl_mem mem)
osResource.bo_size = mem->size;
osResource.bo_flags = DRM_BO_HANDLE;
osResource.bo = (drm_intel_bo*)mem->bo;
- if (IS_IMAGE(mem)) {
- _cl_mem_image* image = cl_mem_image(mem);
+ if (CL_OBJECT_IS_IMAGE(mem)) {
+ cl_mem_image image = cl_mem_to_image(mem);
if (CL_MEM_OBJECT_IMAGE2D != image->image_type)
return CL_INVALID_ARG_VALUE;
osResource.format = GetCmrtFormat(image);
diff --git a/src/cl_command_queue.c b/src/cl_command_queue.c
index cab0c19..5957062 100644
--- a/src/cl_command_queue.c
+++ b/src/cl_command_queue.c
@@ -134,7 +134,7 @@ cl_command_queue_bind_image(cl_command_queue queue, cl_kernel k, cl_gpgpu gpgpu,
struct _cl_mem_image *image;
assert(interp_kernel_get_arg_type(k->opaque, id) == GBE_ARG_IMAGE);
- image = cl_mem_image(k->args[id].mem);
+ image = cl_mem_to_image(k->args[id].mem);
set_image_info(k->curbe, &k->images[i], image);
if(*max_bti < k->images[i].idx)
*max_bti = k->images[i].idx;
diff --git a/src/cl_enqueue.c b/src/cl_enqueue.c
index 59605f9..0d84675 100644
--- a/src/cl_enqueue.c
+++ b/src/cl_enqueue.c
@@ -38,9 +38,7 @@ cl_enqueue_read_buffer(enqueue_data *data, cl_int status)
if (status != CL_COMPLETE)
return err;
- assert(mem->type == CL_MEM_BUFFER_TYPE ||
- mem->type == CL_MEM_SUBBUFFER_TYPE);
- struct _cl_mem_buffer *buffer = (struct _cl_mem_buffer *)mem;
+ cl_mem_buffer buffer = cl_mem_to_buffer(mem);
//cl_buffer_get_subdata sometime is very very very slow in linux kernel, in skl and chv,
//and it is randomly. So temporary disable it, use map/copy/unmap to read.
//Should re-enable it after find root cause.
diff --git a/src/cl_kernel.c b/src/cl_kernel.c
index 4366147..7920c9e 100644
--- a/src/cl_kernel.c
+++ b/src/cl_kernel.c
@@ -170,7 +170,7 @@ cl_kernel_set_arg(cl_kernel k, cl_uint index, size_t sz, const void *value)
if(value != NULL)
mem = *(cl_mem*)value;
if(arg_type == GBE_ARG_PIPE) {
- _cl_mem_pipe* pipe= cl_mem_pipe(mem);
+ const cl_mem_pipe pipe= cl_mem_to_pipe(mem);
size_t type_size = (size_t)interp_kernel_get_arg_info(k->opaque, index,5);
if(pipe->packet_size != type_size)
return CL_INVALID_ARG_VALUE;
@@ -179,8 +179,8 @@ cl_kernel_set_arg(cl_kernel k, cl_uint index, size_t sz, const void *value)
if(CL_SUCCESS != cl_mem_is_valid(mem, ctx))
return CL_INVALID_MEM_OBJECT;
- if (UNLIKELY((arg_type == GBE_ARG_IMAGE && !IS_IMAGE(mem))
- || (arg_type != GBE_ARG_IMAGE && IS_IMAGE(mem))))
+ if (UNLIKELY((arg_type == GBE_ARG_IMAGE && !CL_OBJECT_IS_IMAGE(mem))
+ || (arg_type != GBE_ARG_IMAGE && CL_OBJECT_IS_IMAGE(mem))))
return CL_INVALID_ARG_VALUE;
}
}
diff --git a/src/cl_mem.c b/src/cl_mem.c
index d105bff..dcb912b 100644
--- a/src/cl_mem.c
+++ b/src/cl_mem.c
@@ -50,6 +50,31 @@
#define MAX_TILING_SIZE 128 * MB
+inline static void
+cl_mem_image_init(struct _cl_mem_image *image, size_t w, size_t h,
+ cl_mem_object_type image_type,
+ size_t depth, cl_image_format fmt,
+ uint32_t intel_fmt, uint32_t bpp,
+ size_t row_pitch, size_t slice_pitch,
+ cl_image_tiling_t tiling,
+ size_t tile_x, size_t tile_y,
+ size_t offset)
+{
+ image->w = w;
+ image->h = h;
+ image->image_type = image_type;
+ image->depth = depth;
+ image->fmt = fmt;
+ image->intel_fmt = intel_fmt;
+ image->bpp = bpp;
+ image->row_pitch = row_pitch;
+ image->slice_pitch = slice_pitch;
+ image->tiling = tiling;
+ image->tile_x = tile_x;
+ image->tile_y = tile_y;
+ image->offset = offset;
+}
+
LOCAL cl_mem_object_type
cl_get_mem_object_type(cl_mem mem)
{
@@ -60,7 +85,7 @@ cl_get_mem_object_type(cl_mem mem)
case CL_MEM_IMAGE_TYPE:
case CL_MEM_GL_IMAGE_TYPE:
{
- struct _cl_mem_image *image = cl_mem_image(mem);
+ cl_mem_image image = cl_mem_to_image(mem);
return image->image_type;
}
default:
@@ -87,7 +112,7 @@ cl_get_pipe_info(cl_mem mem,
if(mem->type != CL_MEM_PIPE_TYPE)
return CL_INVALID_MEM_OBJECT;
- pipe = cl_mem_pipe(mem);
+ pipe = cl_mem_to_pipe(mem);
switch(param_name)
{
@@ -151,7 +176,7 @@ cl_mem_allocate(enum cl_mem_type type,
mem->is_svm = 0;
mem->cmrt_mem = NULL;
if (mem->type == CL_MEM_IMAGE_TYPE) {
- cl_mem_image(mem)->is_image_from_buffer = 0;
+ cl_mem_to_image(mem)->is_image_from_buffer = 0;
}
if (sz != 0) {
@@ -230,7 +255,7 @@ cl_mem_allocate(enum cl_mem_type type,
}
// if the image if created from buffer, should use the bo directly to share same bo.
mem->bo = buffer->bo;
- cl_mem_image(mem)->is_image_from_buffer = 1;
+ cl_mem_to_image(mem)->is_image_from_buffer = 1;
bufCreated = 1;
}
@@ -240,7 +265,7 @@ cl_mem_allocate(enum cl_mem_type type,
if(type == CL_MEM_IMAGE_TYPE && buffer != NULL) {
// if the image if created from buffer, should use the bo directly to share same bo.
mem->bo = buffer->bo;
- cl_mem_image(mem)->is_image_from_buffer = 1;
+ cl_mem_to_image(mem)->is_image_from_buffer = 1;
} else
mem->bo = cl_buffer_alloc(bufmgr, "CL memory object", sz, alignment);
#endif
@@ -531,7 +556,7 @@ cl_mem cl_mem_new_pipe(cl_context ctx,
ptr[6] = 0; //packet num
cl_mem_unmap(mem);
- pipe = cl_mem_pipe(mem);
+ pipe = cl_mem_to_pipe(mem);
pipe->flags = flags;
pipe->packet_size = packet_size;
pipe->max_packets = max_packets;
@@ -963,20 +988,20 @@ _cl_mem_new_image(cl_context ctx,
//SKL need use tiling's aligned_h to calc slice_pitch and IVB to BDW need CL_NO_TILE's aligned_h to calc.
aligned_slice_pitch = aligned_pitch * ALIGN(h, cl_buffer_get_tiling_align(ctx, tiling, 2));
- cl_mem_image_init(cl_mem_image(mem), w, h, image_type, depth, *fmt,
+ cl_mem_image_init(cl_mem_to_image(mem), w, h, image_type, depth, *fmt,
intel_fmt, bpp, aligned_pitch, aligned_slice_pitch, tiling,
0, 0, 0);
/* Copy the data if required */
if (flags & CL_MEM_COPY_HOST_PTR && data)
- cl_mem_copy_image(cl_mem_image(mem), pitch, slice_pitch, data);
+ cl_mem_copy_image(cl_mem_to_image(mem), pitch, slice_pitch, data);
if (flags & CL_MEM_USE_HOST_PTR && data) {
mem->host_ptr = data;
- cl_mem_image(mem)->host_row_pitch = pitch;
- cl_mem_image(mem)->host_slice_pitch = slice_pitch;
+ cl_mem_to_image(mem)->host_row_pitch = pitch;
+ cl_mem_to_image(mem)->host_slice_pitch = slice_pitch;
if (!enableUserptr)
- cl_mem_copy_image(cl_mem_image(mem), pitch, slice_pitch, data);
+ cl_mem_copy_image(cl_mem_to_image(mem), pitch, slice_pitch, data);
}
exit:
@@ -1140,9 +1165,9 @@ _cl_mem_new_image_from_buffer(cl_context ctx,
/* Now point to the right offset if buffer is a SUB_BUFFER. */
if (buffer->flags & CL_MEM_USE_HOST_PTR)
image->host_ptr = buffer->host_ptr + offset;
- cl_mem_image(image)->offset = offset;
+ cl_mem_to_image(image)->offset = offset;
cl_mem_add_ref(buffer);
- cl_mem_image(image)->buffer_1d = buffer;
+ cl_mem_to_image(image)->buffer_1d = buffer;
return image;
error:
@@ -1236,14 +1261,14 @@ cl_mem_delete(cl_mem mem)
}
/* iff we are a image, delete the 1d buffer if has. */
- if (IS_IMAGE(mem)) {
- if (cl_mem_image(mem)->buffer_1d) {
- assert(cl_mem_image(mem)->image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER ||
- cl_mem_image(mem)->image_type == CL_MEM_OBJECT_IMAGE2D);
- cl_mem_delete(cl_mem_image(mem)->buffer_1d);
- if(cl_mem_image(mem)->image_type == CL_MEM_OBJECT_IMAGE2D && cl_mem_image(mem)->is_image_from_buffer == 1)
+ if (CL_OBJECT_IS_IMAGE(mem)) {
+ if (cl_mem_to_image(mem)->buffer_1d) {
+ assert(cl_mem_to_image(mem)->image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER ||
+ cl_mem_to_image(mem)->image_type == CL_MEM_OBJECT_IMAGE2D);
+ cl_mem_delete(cl_mem_to_image(mem)->buffer_1d);
+ if(cl_mem_to_image(mem)->image_type == CL_MEM_OBJECT_IMAGE2D && cl_mem_to_image(mem)->is_image_from_buffer == 1)
{
- cl_mem_image(mem)->buffer_1d = NULL;
+ cl_mem_to_image(mem)->buffer_1d = NULL;
mem->bo = NULL;
}
}
@@ -2147,7 +2172,7 @@ cl_mem_map_auto(cl_mem mem, int write)
if (!mem->is_userptr)
assert(mem->offset == 0);
- if (IS_IMAGE(mem) && cl_mem_image(mem)->tiling != CL_NO_TILE)
+ if (CL_OBJECT_IS_IMAGE(mem) && cl_mem_to_image(mem)->tiling != CL_NO_TILE)
return cl_mem_map_gtt(mem);
else {
if (mem->is_userptr) {
@@ -2246,7 +2271,7 @@ LOCAL cl_mem cl_mem_new_libva_image(cl_context ctx,
if (mem == NULL || err != CL_SUCCESS)
goto error;
- image = cl_mem_image(mem);
+ image = cl_mem_to_image(mem);
mem->bo = cl_buffer_get_image_from_libva(ctx, bo_name, image);
if (mem->bo == NULL) {
@@ -2346,7 +2371,7 @@ LOCAL cl_mem cl_mem_new_image_from_fd(cl_context ctx,
if (mem == NULL || err != CL_SUCCESS)
goto error;
- image = cl_mem_image(mem);
+ image = cl_mem_to_image(mem);
mem->bo = cl_buffer_get_image_from_fd(ctx, fd, image_sz, image);
if (mem->bo == NULL) {
diff --git a/src/cl_mem.h b/src/cl_mem.h
index dbe4bec..93161e5 100644
--- a/src/cl_mem.h
+++ b/src/cl_mem.h
@@ -31,44 +31,44 @@
#endif
#ifndef CL_VERSION_1_2
-#define CL_MEM_OBJECT_IMAGE1D 0x10F4
-#define CL_MEM_OBJECT_IMAGE1D_ARRAY 0x10F5
-#define CL_MEM_OBJECT_IMAGE1D_BUFFER 0x10F6
-#define CL_MEM_OBJECT_IMAGE2D_ARRAY 0x10F3
+#define CL_MEM_OBJECT_IMAGE1D 0x10F4
+#define CL_MEM_OBJECT_IMAGE1D_ARRAY 0x10F5
+#define CL_MEM_OBJECT_IMAGE1D_BUFFER 0x10F6
+#define CL_MEM_OBJECT_IMAGE2D_ARRAY 0x10F3
typedef struct _cl_image_desc {
- cl_mem_object_type image_type;
- size_t image_width;
- size_t image_height;
- size_t image_depth;
- size_t image_array_size;
- size_t image_row_pitch;
- size_t image_slice_pitch;
- cl_uint num_mip_levels;
- cl_uint num_samples;
- cl_mem buffer;
+ cl_mem_object_type image_type;
+ size_t image_width;
+ size_t image_height;
+ size_t image_depth;
+ size_t image_array_size;
+ size_t image_row_pitch;
+ size_t image_slice_pitch;
+ cl_uint num_mip_levels;
+ cl_uint num_samples;
+ cl_mem buffer;
} cl_image_desc;
#endif
typedef enum cl_image_tiling {
CL_NO_TILE = 0,
- CL_TILE_X = 1,
- CL_TILE_Y = 2
+ CL_TILE_X = 1,
+ CL_TILE_Y = 2
} cl_image_tiling_t;
typedef struct _cl_mapped_ptr {
- void * ptr;
- void * v_ptr;
+ void *ptr;
+ void *v_ptr;
size_t size;
- size_t origin[3]; /* mapped origin */
- size_t region[3]; /* mapped region */
-}cl_mapped_ptr;
+ size_t origin[3]; /* mapped origin */
+ size_t region[3]; /* mapped region */
+} cl_mapped_ptr;
typedef struct _cl_mem_dstr_cb {
- list_head node; /* Mem callback list node */
- void (CL_CALLBACK *pfn_notify)(cl_mem memobj, void *user_data);
+ list_head node; /* Mem callback list node */
+ void(CL_CALLBACK *pfn_notify)(cl_mem memobj, void *user_data);
void *user_data;
} _cl_mem_dstr_cb;
-typedef _cl_mem_dstr_cb* cl_mem_dstr_cb;
+typedef _cl_mem_dstr_cb *cl_mem_dstr_cb;
/* Used for buffers and images */
enum cl_mem_type {
@@ -80,291 +80,240 @@ enum cl_mem_type {
CL_MEM_GL_IMAGE_TYPE,
CL_MEM_BUFFER1D_IMAGE_TYPE
};
-#define IS_IMAGE(mem) (mem->type >= CL_MEM_IMAGE_TYPE)
-#define IS_GL_IMAGE(mem) (mem->type == CL_MEM_GL_IMAGE_TYPE)
-typedef struct _cl_mem {
+typedef struct _cl_mem {
_cl_base_object base;
enum cl_mem_type type;
- cl_buffer bo; /* Data in GPU memory */
- size_t size; /* original request size, not alignment size, used in constant buffer */
- cl_context ctx; /* Context it belongs to */
- cl_mem_flags flags; /* Flags specified at the creation time */
- void * host_ptr; /* Pointer of the host mem specified by CL_MEM_ALLOC_HOST_PTR, CL_MEM_USE_HOST_PTR */
- cl_mapped_ptr* mapped_ptr;/* Store the mapped addresses and size by caller. */
- int mapped_ptr_sz; /* The array size of mapped_ptr. */
- int map_ref; /* The mapped count. */
- uint8_t mapped_gtt; /* This object has mapped gtt, for unmap. */
- list_head dstr_cb_head; /* All destroy callbacks. */
- uint8_t is_userptr; /* CL_MEM_USE_HOST_PTR is enabled */
- cl_bool is_svm; /* This object is svm */
- size_t offset; /* offset of host_ptr to the page beginning, only for CL_MEM_USE_HOST_PTR*/
-
- uint8_t cmrt_mem_type; /* CmBuffer, CmSurface2D, ... */
- void* cmrt_mem;
+ cl_buffer bo; /* Data in GPU memory */
+ size_t size; /* original request size, not alignment size, used in constant buffer */
+ cl_context ctx; /* Context it belongs to */
+ cl_mem_flags flags; /* Flags specified at the creation time */
+ void *host_ptr; /* Pointer of the host mem specified by CL_MEM_ALLOC_HOST_PTR, CL_MEM_USE_HOST_PTR */
+ cl_mapped_ptr *mapped_ptr; /* Store the mapped addresses and size by caller. */
+ int mapped_ptr_sz; /* The array size of mapped_ptr. */
+ int map_ref; /* The mapped count. */
+ uint8_t mapped_gtt; /* This object has mapped gtt, for unmap. */
+ list_head dstr_cb_head; /* All destroy callbacks. */
+ uint8_t is_userptr; /* CL_MEM_USE_HOST_PTR is enabled */
+ cl_bool is_svm; /* This object is svm */
+ size_t offset; /* offset of host_ptr to the page beginning, only for CL_MEM_USE_HOST_PTR*/
+
+ uint8_t cmrt_mem_type; /* CmBuffer, CmSurface2D, ... */
+ void *cmrt_mem;
} _cl_mem;
#define CL_OBJECT_MEM_MAGIC 0x381a27b9ee6504dfLL
-#define CL_OBJECT_IS_MEM(obj) ((obj && \
- ((cl_base_object)obj)->magic == CL_OBJECT_MEM_MAGIC && \
- CL_OBJECT_GET_REF(obj) >= 1))
-#define CL_OBJECT_IS_IMAGE(mem) ((mem && \
- ((cl_base_object)mem)->magic == CL_OBJECT_MEM_MAGIC && \
- CL_OBJECT_GET_REF(mem) >= 1 && \
- mem->type >= CL_MEM_IMAGE_TYPE))
-#define CL_OBJECT_IS_BUFFER(mem) ((mem && \
- ((cl_base_object)mem)->magic == CL_OBJECT_MEM_MAGIC && \
- CL_OBJECT_GET_REF(mem) >= 1 && \
- mem->type < CL_MEM_IMAGE_TYPE))
+#define CL_OBJECT_IS_MEM(obj) ((obj && \
+ ((cl_base_object)obj)->magic == CL_OBJECT_MEM_MAGIC && \
+ CL_OBJECT_GET_REF(obj) >= 1))
-typedef struct _cl_mem_pipe {
+typedef struct _cl_mem_buffer {
_cl_mem base;
- cl_svm_mem_flags flags; /* Flags specified at the creation time */
- uint32_t packet_size;
- uint32_t max_packets;
-} _cl_mem_pipe;
-
-typedef struct _cl_mem_svm {
- _cl_mem base;
- cl_svm_mem_flags flags; /* Flags specified at the creation time */
-} _cl_mem_svm;
+ struct _cl_mem_buffer *subs; /* Sub buf objects. */
+ size_t sub_offset; /* The sub start offset. */
+ struct _cl_mem_buffer *sub_prev, *sub_next; /* We chain the sub memory buffers together */
+ pthread_mutex_t sub_lock; /* Sub buffers list lock*/
+ struct _cl_mem_buffer *parent; /* Point to the parent buffer if is sub-buffer */
+} _cl_mem_buffer;
+typedef _cl_mem_buffer *cl_mem_buffer;
+
+#define CL_OBJECT_IS_BUFFER(mem) ((mem && \
+ ((cl_base_object)mem)->magic == CL_OBJECT_MEM_MAGIC && \
+ CL_OBJECT_GET_REF(mem) >= 1 && \
+ ((cl_mem)mem)->type <= CL_MEM_SUBBUFFER_TYPE))
+#define CL_OBJECT_IS_SUB_BUFFER(mem) ((mem && \
+ ((cl_base_object)mem)->magic == CL_OBJECT_MEM_MAGIC && \
+ CL_OBJECT_GET_REF(mem) >= 1 && \
+ ((cl_mem)mem)->type == CL_MEM_SUBBUFFER_TYPE))
+inline static cl_mem_buffer cl_mem_to_buffer(cl_mem mem)
+{
+ assert(CL_OBJECT_IS_BUFFER(mem));
+ return (cl_mem_buffer)mem;
+}
-struct _cl_mem_image {
+typedef struct _cl_mem_image {
_cl_mem base;
- cl_image_format fmt; /* only for images */
- uint32_t intel_fmt; /* format to provide in the surface state */
- size_t bpp; /* number of bytes per pixel */
- cl_mem_object_type image_type; /* only for images 1D/2D...*/
- size_t w, h, depth; /* only for images (depth is only for 3D images) */
+ cl_image_format fmt; /* only for images */
+ uint32_t intel_fmt; /* format to provide in the surface state */
+ size_t bpp; /* number of bytes per pixel */
+ cl_mem_object_type image_type; /* only for images 1D/2D...*/
+ size_t w, h, depth; /* only for images (depth is only for 3D images) */
size_t row_pitch, slice_pitch;
size_t host_row_pitch, host_slice_pitch;
- cl_image_tiling_t tiling; /* only IVB+ supports TILE_[X,Y] (image only) */
- size_t tile_x, tile_y; /* tile offset, used for mipmap images. */
- size_t offset; /* offset for dri_bo, used when it's reloc. */
- cl_mem buffer_1d; /* if the image is created from buffer, it point to the buffer.*/
- uint8_t is_image_from_buffer; /* IMAGE from Buffer*/
-};
+ cl_image_tiling_t tiling; /* only IVB+ supports TILE_[X,Y] (image only) */
+ size_t tile_x, tile_y; /* tile offset, used for mipmap images. */
+ size_t offset; /* offset for dri_bo, used when it's reloc. */
+ cl_mem buffer_1d; /* if the image is created from buffer, it point to the buffer.*/
+ uint8_t is_image_from_buffer; /* IMAGE from Buffer*/
+} _cl_mem_image;
+typedef _cl_mem_image *cl_mem_image;
+
+#define CL_OBJECT_IS_IMAGE(mem) ((mem && \
+ ((cl_base_object)mem)->magic == CL_OBJECT_MEM_MAGIC && \
+ CL_OBJECT_GET_REF(mem) >= 1 && \
+ ((cl_mem)mem)->type >= CL_MEM_IMAGE_TYPE))
+#define CL_OBJECT_IS_IMAGE_1D(image) (CL_OBJECT_IS_IMAGE((cl_mem)image) && \
+ (((cl_mem_image)image)->image_type == CL_MEM_OBJECT_IMAGE1D || \
+ ((cl_mem_image)image)->image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY || \
+ ((cl_mem_image)image)->image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER))
+#define CL_OBJECT_IS_IMAGE_2D(image) (CL_OBJECT_IS_IMAGE((cl_mem)image) && \
+ (((cl_mem_image)image)->image_type == CL_MEM_OBJECT_IMAGE2D || \
+ ((cl_mem_image)image)->image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY))
+#define CL_OBJECT_IS_IMAGE_3D(image) (CL_OBJECT_IS_IMAGE((cl_mem)image) && \
+ ((cl_mem_image)image)->image_type == CL_MEM_OBJECT_IMAGE3D)
+#define CL_OBJECT_IS_IMAGE_ARRAY(image) (CL_OBJECT_IS_IMAGE((cl_mem)image) && \
+ (((cl_mem_image)image)->image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY || \
+ ((cl_mem_image)image)->image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY))
+inline static cl_mem_image cl_mem_to_image(cl_mem mem)
+{
+ assert(CL_OBJECT_IS_IMAGE(mem));
+ return (cl_mem_image)mem;
+}
-struct _cl_mem_gl_image {
+typedef struct _cl_mem_gl_image {
struct _cl_mem_image base;
int fd;
#if defined(HAS_GL_EGL)
EGLImage egl_image;
#endif
-};
+} _cl_mem_gl_image;
+typedef _cl_mem_gl_image *cl_mem_gl_image;
+#define CL_OBJECT_IS_GL_IMAGE(mem) ((mem && \
+ ((cl_base_object)mem)->magic == CL_OBJECT_MEM_MAGIC && \
+ CL_OBJECT_GET_REF(mem) >= 1 && \
+ ((cl_mem)mem)->type == CL_MEM_GL_IMAGE_TYPE))
+inline static cl_mem_gl_image cl_mem_to_gl_image(cl_mem mem)
+{
+ assert(CL_OBJECT_IS_GL_IMAGE(mem));
+ return (cl_mem_gl_image)mem;
+}
-struct _cl_mem_buffer1d_image {
+typedef struct _cl_mem_buffer1d_image {
struct _cl_mem_image base;
uint32_t size;
- _cl_mem * descbuffer;
-};
-
-#define IS_1D_IMAGE(image) (image->image_type == CL_MEM_OBJECT_IMAGE1D || \
- image->image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY || \
- image->image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER)
-
-#define IS_2D_IMAGE(image) (image->image_type == CL_MEM_OBJECT_IMAGE2D || \
- image->image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY)
-
-#define IS_3D_IMAGE(image) (image->image_type == CL_MEM_OBJECT_IMAGE3D)
-
-#define IS_IMAGE_ARRAY(image) (image->image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY || \
- image->image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY)
-
-inline static void
-cl_mem_image_init(struct _cl_mem_image *image, size_t w, size_t h,
- cl_mem_object_type image_type,
- size_t depth, cl_image_format fmt,
- uint32_t intel_fmt, uint32_t bpp,
- size_t row_pitch, size_t slice_pitch,
- cl_image_tiling_t tiling,
- size_t tile_x, size_t tile_y,
- size_t offset)
+ _cl_mem *descbuffer;
+} _cl_mem_buffer1d_image;
+typedef _cl_mem_buffer1d_image *cl_mem_buffer1d_image;
+#define CL_OBJECT_IS_BUFFER1D_IMAGE(mem) ((mem && \
+ ((cl_base_object)mem)->magic == CL_OBJECT_MEM_MAGIC && \
+ CL_OBJECT_GET_REF(mem) >= 1 && \
+ ((cl_mem)mem)->type == CL_MEM_BUFFER1D_IMAGE_TYPE))
+inline static cl_mem_buffer1d_image cl_mem_to_buffer1d_image(cl_mem mem)
{
- image->w = w;
- image->h = h;
- image->image_type = image_type;
- image->depth = depth;
- image->fmt = fmt;
- image->intel_fmt = intel_fmt;
- image->bpp = bpp;
- image->row_pitch = row_pitch;
- image->slice_pitch = slice_pitch;
- image->tiling = tiling;
- image->tile_x = tile_x;
- image->tile_y = tile_y;
- image->offset = offset;
+ assert(CL_OBJECT_IS_BUFFER1D_IMAGE(mem));
+ return (cl_mem_buffer1d_image)mem;
}
-struct _cl_mem_buffer {
+typedef struct _cl_mem_pipe {
_cl_mem base;
- struct _cl_mem_buffer* subs; /* Sub buf objects. */
- size_t sub_offset; /* The sub start offset. */
- struct _cl_mem_buffer* sub_prev, *sub_next;/* We chain the sub memory buffers together */
- pthread_mutex_t sub_lock; /* Sub buffers list lock*/
- struct _cl_mem_buffer* parent; /* Point to the parent buffer if is sub-buffer */
-};
-
-inline static struct _cl_mem_image *
-cl_mem_image(cl_mem mem)
-{
- assert(IS_IMAGE(mem));
- return (struct _cl_mem_image *)mem;
-}
+ cl_svm_mem_flags flags; /* Flags specified at the creation time */
+ uint32_t packet_size;
+ uint32_t max_packets;
+} _cl_mem_pipe;
+typedef _cl_mem_pipe *cl_mem_pipe;
-inline static struct _cl_mem_gl_image *
-cl_mem_gl_image(cl_mem mem)
+#define CL_OBJECT_IS_PIPE(mem) ((mem && \
+ ((cl_base_object)mem)->magic == CL_OBJECT_MEM_MAGIC && \
+ CL_OBJECT_GET_REF(mem) >= 1 && \
+ ((cl_mem)mem)->type == CL_MEM_PIPE_TYPE))
+inline static cl_mem_pipe cl_mem_to_pipe(cl_mem mem)
{
- assert(IS_GL_IMAGE(mem));
- return (struct _cl_mem_gl_image*)mem;
+ assert(CL_OBJECT_IS_PIPE(mem));
+ return (cl_mem_pipe)mem;
}
-inline static struct _cl_mem_pipe *
-cl_mem_pipe(cl_mem mem)
+typedef struct _cl_mem_svm {
+ _cl_mem base;
+ cl_svm_mem_flags flags; /* Flags specified at the creation time */
+} _cl_mem_svm;
+typedef _cl_mem_svm *cl_mem_svm;
+#define CL_OBJECT_IS_SVM(mem) ((mem && \
+ ((cl_base_object)mem)->magic == CL_OBJECT_MEM_MAGIC && \
+ CL_OBJECT_GET_REF(mem) >= 1 && \
+ ((cl_mem)mem)->type == CL_MEM_SVM_TYPE))
+inline static cl_mem_svm cl_mem_to_svm(cl_mem mem)
{
- assert(mem->type == CL_MEM_PIPE_TYPE);
- return (struct _cl_mem_pipe *)mem;
+ assert(CL_OBJECT_IS_SVM(mem));
+ return (cl_mem_svm)mem;
}
/* Query information about a memory object */
extern cl_mem_object_type cl_get_mem_object_type(cl_mem mem);
-
/* Query whether mem is in buffers */
extern cl_int cl_mem_is_valid(cl_mem mem, cl_context ctx);
-
/* Create a new memory object and initialize it with possible user data */
-extern cl_mem cl_mem_new_buffer(cl_context, cl_mem_flags, size_t, void*, cl_int*);
-
+extern cl_mem cl_mem_new_buffer(cl_context, cl_mem_flags, size_t, void *, cl_int *);
/* Create a new sub memory object */
extern cl_mem cl_mem_new_sub_buffer(cl_mem, cl_mem_flags, cl_buffer_create_type, const void *, cl_int *);
-
extern cl_mem cl_mem_new_pipe(cl_context, cl_mem_flags, cl_uint, cl_uint, cl_int *);
/* Query information about a pipe object */
extern cl_int cl_get_pipe_info(cl_mem, cl_mem_info, size_t, void *, size_t *);
-
-void* cl_mem_svm_allocate(cl_context, cl_svm_mem_flags, size_t, unsigned int);
-void cl_mem_svm_delete(cl_context, void *svm_pointer);
-
+extern void *cl_mem_svm_allocate(cl_context, cl_svm_mem_flags, size_t, unsigned int);
+extern void cl_mem_svm_delete(cl_context, void *svm_pointer);
/* Idem but this is an image */
-extern cl_mem
-cl_mem_new_image(cl_context context,
- cl_mem_flags flags,
- const cl_image_format *image_format,
- const cl_image_desc *image_desc,
- void *host_ptr,
- cl_int *errcode_ret);
-
+extern cl_mem cl_mem_new_image(cl_context context, cl_mem_flags flags, const cl_image_format *image_format,
+ const cl_image_desc *image_desc, void *host_ptr, cl_int *errcode_ret);
/* Unref the object and delete it if no more reference */
extern void cl_mem_delete(cl_mem);
-
/* Destroy egl image. */
extern void cl_mem_gl_delete(struct _cl_mem_gl_image *);
-
/* Add one more reference to this object */
extern void cl_mem_add_ref(cl_mem);
-
/* api clEnqueueCopyBuffer help function */
extern cl_int cl_mem_copy(cl_command_queue queue, cl_event event, cl_mem src_buf, cl_mem dst_buf,
- size_t src_offset, size_t dst_offset, size_t cb);
-
-extern cl_int cl_mem_fill(cl_command_queue queue, cl_event e, const void * pattern, size_t pattern_size,
- cl_mem buffer, size_t offset, size_t size);
-
-extern cl_int cl_image_fill(cl_command_queue queue, const void * pattern, struct _cl_mem_image*,
- const size_t *, const size_t *);
-
+ size_t src_offset, size_t dst_offset, size_t cb);
+extern cl_int cl_mem_fill(cl_command_queue queue, cl_event e, const void *pattern, size_t pattern_size,
+ cl_mem buffer, size_t offset, size_t size);
+extern cl_int cl_image_fill(cl_command_queue queue, const void *pattern, struct _cl_mem_image *,
+ const size_t *, const size_t *);
/* api clEnqueueCopyBufferRect help function */
extern cl_int cl_mem_copy_buffer_rect(cl_command_queue, cl_event event, cl_mem, cl_mem,
- const size_t *, const size_t *, const size_t *,
- size_t, size_t, size_t, size_t);
-
+ const size_t *, const size_t *, const size_t *,
+ size_t, size_t, size_t, size_t);
/* api clEnqueueCopyImage help function */
-extern cl_int cl_mem_kernel_copy_image(cl_command_queue, cl_event event, struct _cl_mem_image*,
- struct _cl_mem_image*, const size_t *, const size_t *, const size_t *);
-
+extern cl_int cl_mem_kernel_copy_image(cl_command_queue, cl_event event, struct _cl_mem_image *,
+ struct _cl_mem_image *, const size_t *, const size_t *, const size_t *);
/* api clEnqueueCopyImageToBuffer help function */
-extern cl_int cl_mem_copy_image_to_buffer(cl_command_queue, cl_event, struct _cl_mem_image*, cl_mem,
+extern cl_int cl_mem_copy_image_to_buffer(cl_command_queue, cl_event, struct _cl_mem_image *, cl_mem,
const size_t *, const size_t, const size_t *);
-
/* api clEnqueueCopyBufferToImage help function */
-extern cl_int cl_mem_copy_buffer_to_image(cl_command_queue, cl_event, cl_mem, struct _cl_mem_image*,
+extern cl_int cl_mem_copy_buffer_to_image(cl_command_queue, cl_event, cl_mem, struct _cl_mem_image *,
const size_t, const size_t *, const size_t *);
-
/* Directly map a memory object */
extern void *cl_mem_map(cl_mem, int);
-
/* Unmap a memory object */
extern cl_int cl_mem_unmap(cl_mem);
-
/* Directly map a memory object in GTT mode */
extern void *cl_mem_map_gtt(cl_mem);
-
/* Directly map a memory object in GTT mode, with out waiting gpu idle */
extern void *cl_mem_map_gtt_unsync(cl_mem);
-
/* Unmap a memory object in GTT mode */
extern cl_int cl_mem_unmap_gtt(cl_mem);
-
/* Directly map a memory object - tiled images are mapped in GTT mode */
extern void *cl_mem_map_auto(cl_mem, int);
-
/* Unmap a memory object - tiled images are unmapped in GTT mode */
extern cl_int cl_mem_unmap_auto(cl_mem);
-
/* Pin/unpin the buffer in memory (you must be root) */
extern cl_int cl_mem_pin(cl_mem);
extern cl_int cl_mem_unpin(cl_mem);
-
-extern cl_mem
-cl_mem_allocate(enum cl_mem_type type,
- cl_context ctx,
- cl_mem_flags flags,
- size_t sz,
- cl_int is_tiled,
- void *host_ptr,
- cl_mem buffer,
- cl_int *errcode);
-
-void
-cl_mem_copy_image_region(const size_t *origin, const size_t *region,
- void *dst, size_t dst_row_pitch, size_t dst_slice_pitch,
- const void *src, size_t src_row_pitch, size_t src_slice_pitch,
- const struct _cl_mem_image *image, cl_bool offset_dst, cl_bool offset_src);
-
-void
-cl_mem_copy_image_to_image(const size_t *dst_origin,const size_t *src_origin, const size_t *region,
- const struct _cl_mem_image *dst_image, const struct _cl_mem_image *src_image);
-
-extern cl_mem cl_mem_new_libva_buffer(cl_context ctx,
- unsigned int bo_name,
- cl_int *errcode);
-
-extern cl_mem cl_mem_new_libva_image(cl_context ctx,
- unsigned int bo_name, size_t offset,
- size_t width, size_t height,
- cl_image_format fmt,
- size_t row_pitch,
- cl_int *errcode);
-
-extern cl_int cl_mem_get_fd(cl_mem mem, int* fd);
-
-extern cl_mem cl_mem_new_buffer_from_fd(cl_context ctx,
- int fd,
- int buffer_sz,
- cl_int* errcode);
-
-extern cl_mem cl_mem_new_image_from_fd(cl_context ctx,
- int fd, int image_sz,
- size_t offset,
- size_t width, size_t height,
- cl_image_format fmt,
- size_t row_pitch,
- cl_int *errcode);
-
+extern cl_mem cl_mem_allocate(enum cl_mem_type type, cl_context ctx, cl_mem_flags flags,
+ size_t sz, cl_int is_tiled, void *host_ptr, cl_mem buffer, cl_int *errcode);
+extern void cl_mem_copy_image_region(const size_t *origin, const size_t *region,
+ void *dst, size_t dst_row_pitch, size_t dst_slice_pitch,
+ const void *src, size_t src_row_pitch, size_t src_slice_pitch,
+ const struct _cl_mem_image *image, cl_bool offset_dst, cl_bool offset_src);
+extern void cl_mem_copy_image_to_image(const size_t *dst_origin, const size_t *src_origin, const size_t *region,
+ const struct _cl_mem_image *dst_image, const struct _cl_mem_image *src_image);
+extern cl_mem cl_mem_new_libva_buffer(cl_context ctx, unsigned int bo_name, cl_int *errcode);
+extern cl_mem cl_mem_new_libva_image(cl_context ctx, unsigned int bo_name, size_t offset,
+ size_t width, size_t height, cl_image_format fmt,
+ size_t row_pitch, cl_int *errcode);
+extern cl_int cl_mem_get_fd(cl_mem mem, int *fd);
+extern cl_mem cl_mem_new_buffer_from_fd(cl_context ctx, int fd, int buffer_sz, cl_int *errcode);
+extern cl_mem cl_mem_new_image_from_fd(cl_context ctx, int fd, int image_sz, size_t offset, size_t width,
+ size_t height, cl_image_format fmt, size_t row_pitch, cl_int *errcode);
extern cl_int cl_mem_record_map_mem(cl_mem mem, void *ptr, void **mem_ptr, size_t offset,
- size_t size, const size_t *origin, const size_t *region);
-
+ size_t size, const size_t *origin, const size_t *region);
extern cl_int cl_mem_set_destructor_callback(cl_mem memobj,
- void(CL_CALLBACK *pfn_notify)(cl_mem, void *), void *user_data);
+ void(CL_CALLBACK *pfn_notify)(cl_mem, void *), void *user_data);
#endif /* __CL_MEM_H__ */
-
diff --git a/src/cl_mem_gl.c b/src/cl_mem_gl.c
index fdad067..89c546f 100644
--- a/src/cl_mem_gl.c
+++ b/src/cl_mem_gl.c
@@ -68,7 +68,7 @@ cl_mem_new_gl_texture(cl_context ctx,
goto error;
mem->bo = cl_buffer_alloc_from_texture(ctx, texture_target, miplevel,
- texture, cl_mem_image(mem));
+ texture, cl_mem_to_image(mem));
if (UNLIKELY(mem->bo == NULL)) {
err = CL_MEM_OBJECT_ALLOCATION_FAILURE;
goto error;
diff --git a/src/cl_utils.h b/src/cl_utils.h
index 829b774..6ff815f 100644
--- a/src/cl_utils.h
+++ b/src/cl_utils.h
@@ -158,13 +158,13 @@ do { \
#define CHECK_IMAGE(MEM, IMAGE) \
CHECK_MEM(MEM); \
do { \
- if (UNLIKELY(!IS_IMAGE(MEM))) { \
+ if (UNLIKELY(!CL_OBJECT_IS_IMAGE(MEM))) { \
err = CL_INVALID_MEM_OBJECT; \
goto error; \
} \
} while (0); \
struct _cl_mem_image *IMAGE; \
-IMAGE = cl_mem_image(MEM); \
+IMAGE = cl_mem_to_image(MEM); \
#define FIXUP_IMAGE_REGION(IMAGE, PREGION, REGION) \
const size_t *REGION; \
--
2.7.4
More information about the Beignet
mailing list