30 #include "_ccl_abstract_wrapper.h"
58 struct ccl_sampler_basic_properties {
61 cl_bool normalized_coords;
64 cl_addressing_mode addressing_mode;
67 cl_filter_mode filter_mode;
89 static struct ccl_sampler_basic_properties
90 ccl_sampler_get_basic_properties(
91 const cl_sampler_properties *sampler_properties) {
94 struct ccl_sampler_basic_properties sbp =
95 { CL_TRUE, CL_ADDRESS_CLAMP, CL_FILTER_NEAREST };
98 if (sampler_properties != NULL) {
99 for (guint i = 0; sampler_properties[i] != 0; i = i + 2) {
101 switch (sampler_properties[i]) {
102 case CL_SAMPLER_NORMALIZED_COORDS:
103 sbp.normalized_coords = (cl_bool) sampler_properties[i + 1];
105 case CL_SAMPLER_ADDRESSING_MODE:
106 sbp.addressing_mode =
107 (cl_addressing_mode) sampler_properties[i + 1];
109 case CL_SAMPLER_FILTER_MODE:
111 (cl_filter_mode) sampler_properties[i + 1];
158 NULL, (ccl_wrapper_release_cl_object) clReleaseSampler, NULL);
183 cl_addressing_mode addressing_mode, cl_filter_mode filter_mode,
186 const cl_sampler_properties sp[] = {
187 CL_SAMPLER_NORMALIZED_COORDS, normalized_coords,
188 CL_SAMPLER_ADDRESSING_MODE, addressing_mode,
189 CL_SAMPLER_FILTER_MODE, filter_mode,
230 const cl_sampler_properties *sampler_properties,
CCLErr** err) {
233 g_return_val_if_fail((err) == NULL || *(err) == NULL, NULL);
235 g_return_val_if_fail(ctx != NULL, NULL);
244 #ifdef CL_VERSION_2_0
249 CCLErr* err_internal = NULL;
256 if (ocl_ver >= 200) {
258 sampler = clCreateSamplerWithProperties(
262 struct ccl_sampler_basic_properties sbp =
263 ccl_sampler_get_basic_properties(sampler_properties);
264 CCL_BEGIN_IGNORE_DEPRECATIONS
266 sbp.normalized_coords, sbp.addressing_mode, sbp.filter_mode,
268 CCL_END_IGNORE_DEPRECATIONS
274 struct ccl_sampler_basic_properties sbp =
275 ccl_sampler_get_basic_properties(sampler_properties);
277 sbp.normalized_coords, sbp.addressing_mode, sbp.filter_mode,
284 CL_SUCCESS != ocl_status, ocl_status, error_handler,
285 "%s: unable to create sampler (OpenCL error %d: %s).",
286 CCL_STRD, ocl_status,
ccl_err(ocl_status));
292 g_assert(err == NULL || *err == NULL);
298 g_assert(err == NULL || *err != NULL);
CCLSampler * ccl_sampler_new_full(CCLContext *ctx, const cl_sampler_properties *sampler_properties, CCLErr **err)
Create a new sampler wrapper object using a list of properties.
#define CCL_OCL_ERROR
Resolves to error category identifying string, in this case an error in the OpenCL library...
#define ccl_if_err_create_goto(err, quark, error_condition, error_code, label, msg,...)
If error is detected (error_code != no_error_code), create an error object (CCLErr) and go to the spe...
#define ccl_context_unwrap(ctx)
Get the OpenCL context object.
Useful definitions used internally by cf4ocl.
The context wrapper class.
#define ccl_if_err_propagate_goto(err_dest, err_src, label)
Same as ccl_if_err_goto(), but rethrows error in a source CCLErr object to a new destination CCLErr o...
const char * ccl_err(int code)
Convert OpenCL error code to a readable string.
cl_uint ccl_context_get_opencl_version(CCLContext *ctx, CCLErr **err)
Get the OpenCL version of the platform associated with this context.
Definition of a wrapper class and its methods for OpenCL sampler objects.
void ccl_sampler_destroy(CCLSampler *smplr)
Decrements the reference count of the wrapper object.
CCLSampler * ccl_sampler_new(CCLContext *ctx, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, CCLErr **err)
Create a new sampler wrapper object by specifying a basic set of sampler properties.
Base class for all OpenCL wrappers.
GError CCLErr
Error handling class.
CCLSampler * ccl_sampler_new_wrap(cl_sampler sampler)
Get the sampler wrapper for the given OpenCL sampler.