[Beignet] [PATCH OCL2.0 1/6] Runtime: Add clCreateSamplerWithProperties
Xiuli Pan
xiuli.pan at intel.com
Tue Mar 1 00:39:59 UTC 2016
From: Pan Xiuli <xiuli.pan at intel.com>
Add api clCreateSamplerWithProperties
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
src/cl_api.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/cl_khr_icd.c | 2 +-
2 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/src/cl_api.c b/src/cl_api.c
index 840d57f..0592416 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -999,6 +999,68 @@ error:
return sampler;
}
+cl_sampler
+clCreateSamplerWithProperties(cl_context context,
+ const cl_sampler_properties *sampler_properties,
+ cl_int * errcode_ret)
+{
+ cl_sampler sampler = NULL;
+ cl_int err = CL_SUCCESS;
+ CHECK_CONTEXT (context);
+ cl_bool normalized = 0xFFFFFFFF;
+ cl_addressing_mode addressing = 0xFFFFFFFF;
+ cl_filter_mode filter = 0xFFFFFFFF;
+ if(sampler_properties)
+ {
+ cl_ulong sam_type;
+ cl_ulong sam_val;
+ for(cl_uint i = 0;(sam_type = sampler_properties[i++])!=0;i++)
+ {
+ sam_val = sampler_properties[i];
+ switch(sam_type)
+ {
+ case CL_SAMPLER_NORMALIZED_COORDS:
+ if(normalized != 0xFFFFFFFF)
+ err = CL_INVALID_VALUE;
+ else if(sam_val == CL_TRUE || sam_val == CL_FALSE)
+ normalized = sam_val;
+ else
+ err = CL_INVALID_VALUE;
+ break;
+ case CL_SAMPLER_ADDRESSING_MODE:
+ if(addressing != 0xFFFFFFFF)
+ err = CL_INVALID_VALUE;
+ else if(sam_val == CL_ADDRESS_MIRRORED_REPEAT || sam_val == CL_ADDRESS_REPEAT ||
+ sam_val == CL_ADDRESS_CLAMP_TO_EDGE || sam_val == CL_ADDRESS_CLAMP ||
+ sam_val == CL_ADDRESS_NONE)
+ addressing = sam_val;
+ else
+ err = CL_INVALID_VALUE;
+ break;
+ case CL_SAMPLER_FILTER_MODE:
+ if(filter != 0xFFFFFFFF)
+ err = CL_INVALID_VALUE;
+ else if(sam_val == CL_FILTER_LINEAR || sam_val == CL_FILTER_NEAREST)
+ filter = sam_val;
+ else
+ err = CL_INVALID_VALUE;
+ break;
+ default:
+ err = CL_INVALID_VALUE;
+ break;
+ }
+ }
+ }
+ if(normalized == 0xFFFFFFFF) normalized = CL_TRUE;
+ if(addressing == 0xFFFFFFFF) addressing = CL_ADDRESS_CLAMP;
+ if(filter == 0xFFFFFFFF) filter = CL_FILTER_NEAREST;
+ sampler = cl_sampler_new(context, normalized, addressing, filter, &err);
+error:
+ if (errcode_ret)
+ *errcode_ret = err;
+ return sampler;
+}
+
cl_int
clRetainSampler(cl_sampler sampler)
{
diff --git a/src/cl_khr_icd.c b/src/cl_khr_icd.c
index a8dd3e0..459f763 100644
--- a/src/cl_khr_icd.c
+++ b/src/cl_khr_icd.c
@@ -182,7 +182,7 @@ struct _cl_icd_dispatch const cl_khr_icd_dispatch = {
(void *) clEnqueueSVMMemFill,
(void *) clEnqueueSVMMap,
(void *) clEnqueueSVMUnmap,
- (void *) NULL /* clCreateSamplerWithProperties */,
+ (void *) clCreateSamplerWithProperties,
clSetKernelArgSVMPointer,
#endif
};
--
2.5.0
More information about the Beignet
mailing list