[Pkg-opencl-devel] [beignet] 14/66: Imported Upstream version 0.1+git20130419+9c11c18
Andreas Beckmann
anbe at moszumanska.debian.org
Fri Oct 31 07:27:03 UTC 2014
This is an automated email from the git hooks/post-receive script.
anbe pushed a commit to branch master
in repository beignet.
commit 9b9ec8074622b0915c454481be8bf73ddebf1651
Author: Simon Richter <sjr at debian.org>
Date: Fri Apr 19 14:14:39 2013 +0200
Imported Upstream version 0.1+git20130419+9c11c18
---
src/cl_api.c | 7 +++++--
src/cl_mem.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/cl_mem.h | 3 +++
3 files changed, 73 insertions(+), 3 deletions(-)
diff --git a/src/cl_api.c b/src/cl_api.c
index c39ef83..2d84ace 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -386,8 +386,11 @@ clGetMemObjectInfo(cl_mem memobj,
void * param_value,
size_t * param_value_size_ret)
{
- NOT_IMPLEMENTED;
- return 0;
+ return cl_get_mem_object_info(memobj,
+ param_name,
+ param_value_size,
+ param_value,
+ param_value_size_ret);
}
cl_int
diff --git a/src/cl_mem.c b/src/cl_mem.c
index e89aafa..4bbaee4 100644
--- a/src/cl_mem.c
+++ b/src/cl_mem.c
@@ -31,6 +31,66 @@
#include <assert.h>
#include <stdio.h>
+#define FIELD_SIZE(CASE,TYPE) \
+ case JOIN(CL_,CASE): \
+ if(param_value_size_ret) \
+ *param_value_size_ret = sizeof(TYPE); \
+ if(!param_value) \
+ return CL_SUCCESS; \
+ if(param_value_size < sizeof(TYPE)) \
+ return CL_INVALID_VALUE; \
+ break;
+
+LOCAL cl_int
+cl_get_mem_object_info(cl_mem mem,
+ cl_mem_info param_name,
+ size_t param_value_size,
+ void *param_value,
+ size_t *param_value_size_ret)
+{
+ switch(param_name)
+ {
+ FIELD_SIZE(MEM_TYPE, cl_mem_object_type);
+ FIELD_SIZE(MEM_FLAGS, cl_mem_flags);
+ FIELD_SIZE(MEM_SIZE, size_t);
+ FIELD_SIZE(MEM_HOST_PTR, void *);
+ FIELD_SIZE(MEM_MAP_COUNT, cl_uint);
+ FIELD_SIZE(MEM_REFERENCE_COUNT, cl_uint);
+ FIELD_SIZE(MEM_CONTEXT, cl_context);
+ default:
+ return CL_INVALID_VALUE;
+ }
+
+ switch(param_name)
+ {
+ case CL_MEM_TYPE:
+ *((cl_mem_object_type *)param_value) = mem->type;
+ break;
+ case CL_MEM_FLAGS:
+ *((cl_mem_flags *)param_value) = mem->flags;
+ break;
+ case CL_MEM_SIZE:
+ *((size_t *)param_value) = cl_buffer_get_size(mem->bo);
+ break;
+ case CL_MEM_HOST_PTR:
+ NOT_IMPLEMENTED;
+ break;
+ case CL_MEM_MAP_COUNT:
+ NOT_IMPLEMENTED;
+ break;
+ case CL_MEM_REFERENCE_COUNT:
+ NOT_IMPLEMENTED;
+ break;
+ case CL_MEM_CONTEXT:
+ NOT_IMPLEMENTED;
+ break;
+ }
+
+ return CL_SUCCESS;
+}
+
+#undef FIELD_SIZE
+
static cl_mem
cl_mem_allocate(cl_context ctx,
cl_mem_flags flags,
@@ -284,9 +344,13 @@ _cl_mem_new_image(cl_context ctx,
if (UNLIKELY(h == 0)) DO_IMAGE_ERROR;
if (image_type == CL_MEM_OBJECT_IMAGE2D) {
+ size_t min_pitch = bpp * w;
+ if (data && pitch == 0)
+ pitch = min_pitch;
if (UNLIKELY(w > ctx->device->image2d_max_width)) DO_IMAGE_ERROR;
if (UNLIKELY(h > ctx->device->image2d_max_height)) DO_IMAGE_ERROR;
- if (UNLIKELY(data && (bpp*w > pitch))) DO_IMAGE_ERROR;
+ if (UNLIKELY(data && min_pitch > pitch)) DO_IMAGE_ERROR;
+ if (UNLIKELY(!data && pitch != 0)) DO_IMAGE_ERROR;
/* Pick up tiling mode (we do only linear on SNB) */
if (cl_driver_get_ver(ctx->drv) != 6)
diff --git a/src/cl_mem.h b/src/cl_mem.h
index 8e7a2dd..836deb4 100644
--- a/src/cl_mem.h
+++ b/src/cl_mem.h
@@ -48,6 +48,9 @@ struct _cl_mem {
cl_image_tiling_t tiling; /* only IVB+ supports TILE_[X,Y] (image only) */
};
+/* Query information about a memory object */
+extern cl_int cl_get_mem_object_info(cl_mem, cl_mem_info, size_t, void *, size_t *);
+
/* Create a new memory object and initialize it with possible user data */
extern cl_mem cl_mem_new(cl_context, cl_mem_flags, size_t, void*, cl_int*);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opencl/beignet.git
More information about the Pkg-opencl-devel
mailing list