[Beignet] [PATCH 1/2] Fix pitch parameter in clCreateImage2D
Zhigang Gong
zhigang.gong at linux.intel.com
Fri Apr 19 01:25:03 PDT 2013
A minor mistake here. The bpp is not bitsPerPixel here but bytesperpixel.
Other than that, LGTM. Thanks.
On Fri, Apr 19, 2013 at 08:12:58AM +0200, Simon Richter wrote:
>
> If the host_ptr is NULL, the pitch parameter must be 0.
>
> The pitch parameter gives the number of bytes per scanline. Specifying 0
> selects the minimum possible.
>
> Signed-off-by: Simon Richter <Simon.Richter at hogyros.de>
> ---
> src/cl_mem.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/cl_mem.c b/src/cl_mem.c
> index e89aafa..126b927 100644
> --- a/src/cl_mem.c
> +++ b/src/cl_mem.c
> @@ -284,9 +284,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) + 7) / 8;
should be : 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)
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list