[Beignet] [PATCH 1/2] [opencl-2.0] clCreateSampler replaced by clCreateSamplerWithProperties.

xionghu.luo at intel.com xionghu.luo at intel.com
Thu Mar 19 01:14:30 PDT 2015


From: Luo Xionghu <xionghu.luo at intel.com>

api ungrade for opencl-2.0.
set sampler normalized_coords default value per spec.
---
 src/cl_api.c     | 27 ++++++++++++++++++++++-----
 src/cl_khr_icd.c |  2 +-
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/cl_api.c b/src/cl_api.c
index 3e72deb..cd4020e 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -753,15 +753,31 @@ error:
 }
 
 cl_sampler
-clCreateSampler(cl_context         context,
-                cl_bool            normalized,
-                cl_addressing_mode addressing,
-                cl_filter_mode     filter,
-                cl_int *           errcode_ret)
+clCreateSamplerWithProperties(cl_context                      context,
+                              const cl_sampler_properties *   normalized_coords,
+                              cl_int *                        errcode_ret)
 {
   cl_sampler sampler = NULL;
   cl_int err = CL_SUCCESS;
   CHECK_CONTEXT (context);
+  cl_bool normalized = CL_TRUE;
+  cl_addressing_mode addressing = CL_ADDRESS_CLAMP;
+  cl_filter_mode filter = CL_FILTER_NEAREST;
+
+  while(*normalized_coords) {
+    switch (*normalized_coords) {
+    case CL_SAMPLER_NORMALIZED_COORDS:
+      normalized = *(normalized_coords + 1);
+      break;
+    case CL_SAMPLER_ADDRESSING_MODE:
+      addressing = *(normalized_coords + 1);
+      break;
+    case CL_SAMPLER_FILTER_MODE:
+      filter = *(normalized_coords + 1);
+      break;
+    }
+    normalized_coords += 2;
+  }
   sampler = cl_sampler_new(context, normalized, addressing, filter, &err);
 error:
   if (errcode_ret)
@@ -769,6 +785,7 @@ error:
   return sampler;
 }
 
+
 cl_int
 clRetainSampler(cl_sampler sampler)
 {
diff --git a/src/cl_khr_icd.c b/src/cl_khr_icd.c
index 8715bbd..703d875 100644
--- a/src/cl_khr_icd.c
+++ b/src/cl_khr_icd.c
@@ -68,7 +68,7 @@ struct _cl_icd_dispatch const cl_khr_icd_dispatch = {
   clGetSupportedImageFormats,
   clGetMemObjectInfo,
   clGetImageInfo,
-  clCreateSampler,
+  clCreateSamplerWithProperties,
   clRetainSampler,
   clReleaseSampler,
   clGetSamplerInfo,
-- 
1.9.1



More information about the Beignet mailing list