diff options
author | Yang Rong <rong.r.yang@intel.com> | 2014-05-28 17:02:26 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-05-28 16:09:18 +0800 |
commit | fd93252cfa7114759f53ba4e9119ce126181cbc4 (patch) | |
tree | 5ed84a84453007999de271c2d9ca192e7707e23f | |
parent | 71f96a67578ce1ccb56e045b7913913073a5d42e (diff) |
Return CL_IMAGE_FORMAT_NOT_SUPPORTED if image_format is not supported.
And move the function cl_image_byte_per_pixel call before cl_image_get_supported_fmt
to return correct error code when format invalid.
Signed-off-by: Yang Rong <rong.r.yang@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r-- | src/cl_image.c | 3 | ||||
-rw-r--r-- | src/cl_mem.c | 8 | ||||
-rw-r--r-- | src/intel/intel_driver.c | 4 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src/cl_image.c b/src/cl_image.c index f89bcaeb..ced97899 100644 --- a/src/cl_image.c +++ b/src/cl_image.c @@ -28,6 +28,9 @@ cl_image_byte_per_pixel(const cl_image_format *fmt, uint32_t *bpp) { assert(bpp); + if(fmt == NULL) + return CL_INVALID_IMAGE_FORMAT_DESCRIPTOR; + const uint32_t type = fmt->image_channel_data_type; const uint32_t order = fmt->image_channel_order; switch (type) { diff --git a/src/cl_mem.c b/src/cl_mem.c index 9e7bfc92..6369ba97 100644 --- a/src/cl_mem.c +++ b/src/cl_mem.c @@ -561,7 +561,7 @@ _cl_mem_new_image(cl_context ctx, /* Only a sub-set of the formats are supported */ intel_fmt = cl_image_get_intel_format(fmt); if (UNLIKELY(intel_fmt == INTEL_UNSUPPORTED_FORMAT)) { - err = CL_INVALID_IMAGE_FORMAT_DESCRIPTOR; + err = CL_IMAGE_FORMAT_NOT_SUPPORTED; goto error; } @@ -1347,14 +1347,16 @@ LOCAL cl_mem cl_mem_new_libva_image(cl_context ctx, struct _cl_mem_image *image = NULL; uint32_t intel_fmt, bpp; + /* Get the size of each pixel */ + if (UNLIKELY((err = cl_image_byte_per_pixel(&fmt, &bpp)) != CL_SUCCESS)) + goto error; + intel_fmt = cl_image_get_intel_format(&fmt); if (intel_fmt == INTEL_UNSUPPORTED_FORMAT) { err = CL_IMAGE_FORMAT_NOT_SUPPORTED; goto error; } - cl_image_byte_per_pixel(&fmt, &bpp); - mem = cl_mem_allocate(CL_MEM_IMAGE_TYPE, ctx, 0, 0, 0, &err); if (mem == NULL || err != CL_SUCCESS) { err = CL_OUT_OF_HOST_MEMORY; diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c index aa313446..d2a477d4 100644 --- a/src/intel/intel_driver.c +++ b/src/intel/intel_driver.c @@ -563,10 +563,12 @@ intel_alloc_buffer_from_texture_egl(cl_context ctx, unsigned int target, region.tiling = get_cl_tiling(region.tiling); if (cl_get_clformat_from_texture(region.gl_format, &cl_format) != 0) goto error; + + if (cl_image_byte_per_pixel(&cl_format, &bpp) != CL_SUCCESS) + goto error; intel_fmt = cl_image_get_intel_format(&cl_format); if (intel_fmt == INTEL_UNSUPPORTED_FORMAT) goto error; - cl_image_byte_per_pixel(&cl_format, &bpp); cl_mem_object_type image_type; if (get_mem_type_from_target(target, &image_type) != 0) goto error; |