correct the case that properties is NULL for clCreateContextFromType (#8)
authorguoyejun <yejun.guo@intel.com>
Tue, 13 Sep 2016 14:52:48 +0000 (22:52 +0800)
committerKedar Patil <kepatil@nvidia.com>
Tue, 13 Sep 2016 14:52:48 +0000 (20:22 +0530)
Handle properties==NULL in clCreateContextFromType

According to spec, for function clCreateContextFromType, properties can also be
NULL in which case the platform that is selected is implementation-defined,
while the current code returns CL_INVALID_PLATFORM.

icd.c

diff --git a/icd.c b/icd.c
index b060479e6f4f81b9ca470cfb534e854c7faeb098..c32a7841d7aeff643b942b1c1e7f9bac111aec2a 100644 (file)
--- a/icd.c
+++ b/icd.c
@@ -198,6 +198,12 @@ Done:
 
 void khrIcdContextPropertiesGetPlatform(const cl_context_properties *properties, cl_platform_id *outPlatform)
 {
+    if (properties == NULL && khrIcdVendors != NULL)
+    {
+        *outPlatform = khrIcdVendors[0].platform;
+        return;
+    }
+
     const cl_context_properties *property = (cl_context_properties *)NULL;
     *outPlatform = NULL;
     for (property = properties; property && property[0]; property += 2)