[Beignet] [PATCH OCL20 2/5] Runtime: Refine clGetSupportedImageFormats to support CL_MEM_FLAGS

Xiuli Pan xiuli.pan at intel.com
Fri Mar 4 02:05:21 UTC 2016


From: Pan Xiuli <xiuli.pan at intel.com>

sRGB writes are not supported now, and we should not return them
if any write was set as CL_MEM_FLAGS.

Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
 src/cl_api.c   | 1 +
 src/cl_image.c | 5 +++++
 src/cl_image.h | 1 +
 3 files changed, 7 insertions(+)

diff --git a/src/cl_api.c b/src/cl_api.c
index e18ff5c..1de1b13 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -986,6 +986,7 @@ clGetSupportedImageFormats(cl_context         ctx,
     goto error;
   }
   err = cl_image_get_supported_fmt(ctx,
+                                   flags,
                                    image_type,
                                    num_entries,
                                    image_formats,
diff --git a/src/cl_image.c b/src/cl_image.c
index 47298b6..d059304 100644
--- a/src/cl_image.c
+++ b/src/cl_image.c
@@ -228,6 +228,7 @@ static const size_t cl_image_type_n = SIZEOF32(cl_image_type);
 
 cl_int
 cl_image_get_supported_fmt(cl_context ctx,
+                           cl_mem_flags flags,
                            cl_mem_object_type image_type,
                            cl_uint num_entries,
                            cl_image_format *image_formats,
@@ -241,6 +242,10 @@ cl_image_get_supported_fmt(cl_context ctx,
       .image_channel_data_type = cl_image_type[j]
     };
     const uint32_t intel_fmt = cl_image_get_intel_format(&fmt);
+    if (cl_image_order[i] >= CL_sRGBA &&
+        ((flags & CL_MEM_WRITE_ONLY) || (flags & CL_MEM_READ_WRITE) ||
+         (flags & CL_MEM_KERNEL_READ_AND_WRITE)))
+      continue;
     if (intel_fmt == INTEL_UNSUPPORTED_FORMAT)
       continue;
     if (n < num_entries && image_formats) image_formats[n] = fmt;
diff --git a/src/cl_image.h b/src/cl_image.h
index ae74509..4f0d0f1 100644
--- a/src/cl_image.h
+++ b/src/cl_image.h
@@ -35,6 +35,7 @@ extern uint32_t cl_image_get_intel_format(const cl_image_format *fmt);
 
 /* Return the list of formats supported by the API */
 extern cl_int cl_image_get_supported_fmt(cl_context context,
+                                         cl_mem_flags flags,
                                          cl_mem_object_type image_type,
                                          cl_uint num_entries,
                                          cl_image_format *image_formats,
-- 
2.5.0



More information about the Beignet mailing list