CLCREATESAMPLER(3clc)
๐ CLCREATESAMPLER โ okay bestie, let's build a sampler ๐
Welcome to the OpenCL Manual, section 3clc โ this is the page for clCreateSampler, and yes it's giving very much "image-reading era" โจ
๐ธ NAME ๐ธ
clCreateSampler โ literally just creates a sampler object, no cap ๐ซถ
cl_sampler clCreateSampler(cl_context context,
cl_bool normalized_coords,
cl_addressing_mode addressing_mode,
cl_filter_mode filter_mode,
cl_int *errcode_ret);
๐ PARAMETERS ๐
contextโ has to be a valid OpenCL context, periodt. No fake contexts allowed ๐normalized_coordsโ decides whether the image coords you're giving are normalized or not. If it'sCL_TRUE, yep they're normalized; if it'sCL_FALSE, nope they're not ๐addressing_modeโ tells you how out-of-range image coordinates get handled when you're reading from an image. You can set it toCL_ADDRESS_MIRRORED_REPEAT,CL_ADDRESS_REPEAT,CL_ADDRESS_CLAMP_TO_EDGE,CL_ADDRESS_CLAMP, orCL_ADDRESS_NONEโญfilter_modeโ the type of filter that must be applied when reading an image. This one can beCL_FILTER_NEARESTorCL_FILTER_LINEAR๐errcode_retโ returns an appropriate error code. Iferrcode_retisNULL, then no error code gets returned. That's it, that's the deal ๐คท
๐ฆ NOTES ๐ฆ
A sampler object is basically the vibe guide for how to sample an image when that image gets read in the kernel, bestie. The built-in functions that read from an image inside a kernel take a sampler as an argument. And those sampler arguments to the image read function? They can be sampler objects you made with OpenCL functions and passed as argument values to the kernel โ OR they can be samplers declared inside a kernel. This section is all about the first way: making sampler objects with OpenCL functions ๐
If you wanna know more about working with samplers, go check out sampler_t(3clc) โ it's linked down below, iykyk ๐
๐ ERRORS ๐
So here's the tea: you get a valid non-zero sampler object back and errcode_ret is set to CL_SUCCESS if the sampler object got created successfully. Otherwise? You get a NULL value, and one of these error values lands in errcode_ret:
CL_INVALID_CONTEXTโ ifcontextis not a valid context ๐ญCL_INVALID_VALUEโ ifaddressing_mode,filter_mode, ornormalized_coords, or some combination of these argument values, are not valid ๐ฉCL_INVALID_OPERATIONโ if images are not supported by any device associated withcontext(i.e.CL_DEVICE_IMAGE_SUPPORTspecified in the table of OpenCL Device Queries forclGetDeviceInfo(3clc)isCL_FALSE) ๐CL_OUT_OF_RESOURCESโ if there's a failure to allocate resources required by the OpenCL implementation on the device ๐ฎ๐จCL_OUT_OF_HOST_MEMORYโ if there's a failure to allocate resources required by the OpenCL implementation on the host ๐ซ
โญ SPECIFICATION โญ
OpenCL Specification[1]
๐ SEE ALSO ๐
clRetainSampler(3clc), clReleaseSampler(3clc), clGetSamplerInfo(3clc), classDiagram(3clc) sampler_t(3clc)
๐ AUTHORS ๐
The Khronos Group ๐
๐ COPYRIGHT ๐
Copyright ยฉ 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
๐ง NOTES ๐ง
- OpenCL Specification โ page 128, section 5.5.1 - Creating Sampler Objects ๐
That's the whole page, bestie โ go forth and sample some images ๐ โจ
Brought to you by The Khronos Group, dated 01/14/2021, from the CLCREATESAMPLER(3clc) page of the OpenCL Manual. ๐ซถ๐ธ
๐ฆ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 ยท other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 ยท other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms