commit ab57856a5278c25748d8a2d261f31b8c29f146f9
Author: Simon Richter <Simon.Richter@hogyros.de>
Date:   Thu Apr 18 17:50:05 2013 +0200

    Fix pitch parameter in clCreateImage2D
    
    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.

Index: beignet-0.1+git20130418+0546d2e/src/cl_mem.c
===================================================================
--- beignet-0.1+git20130418+0546d2e.orig/src/cl_mem.c	2013-04-18 05:21:35.000000000 +0200
+++ beignet-0.1+git20130418+0546d2e/src/cl_mem.c	2013-04-18 17:54:09.970688265 +0200
@@ -284,9 +284,13 @@
   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)
