Runtime: Only return the format allowed in the spec.
authorZhigang Gong <zhigang.gong@linux.intel.com>
Wed, 4 Sep 2013 07:04:03 +0000 (15:04 +0800)
committerZhigang Gong <zhigang.gong@linux.intel.com>
Wed, 4 Sep 2013 08:21:20 +0000 (16:21 +0800)
For the CL_INTENSITY and CL_LUMINANCE, it only supports
CL_UNORM_INT8,CL_UNORM_INT16, CL_SNORM_INT8, CL_SNORM_INT16,
CL_HALF_FLOAT or CL_FLOAT.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
src/cl_image.c

index 6ea104b..1fe8d08 100644 (file)
@@ -104,6 +104,12 @@ cl_image_get_intel_format(const cl_image_format *fmt)
     case CL_A:
     case CL_INTENSITY:
     case CL_LUMINANCE:
+      if ((order == CL_INTENSITY || order == CL_LUMINANCE)
+          && (type != CL_UNORM_INT8 && type != CL_UNORM_INT16
+              && type != CL_SNORM_INT8 && type != CL_SNORM_INT16
+              && type != CL_HALF_FLOAT && type != CL_FLOAT))
+        return INTEL_UNSUPPORTED_FORMAT;
+
       switch (type) {
         case CL_HALF_FLOAT:     return I965_SURFACEFORMAT_R16_FLOAT;
         case CL_FLOAT:          return I965_SURFACEFORMAT_R32_FLOAT;