CLCREATESAMPLER(3clc)

๐Ÿ“ฆ
version 1.0~svn33624 ยท 3 versions
, in ubuntu jammy, ubuntu noble

๐Ÿ‘‘ 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's CL_TRUE, yep they're normalized; if it's CL_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 to CL_ADDRESS_MIRRORED_REPEAT, CL_ADDRESS_REPEAT, CL_ADDRESS_CLAMP_TO_EDGE, CL_ADDRESS_CLAMP, or CL_ADDRESS_NONE โญ
  • filter_mode โ€” the type of filter that must be applied when reading an image. This one can be CL_FILTER_NEAREST or CL_FILTER_LINEAR ๐ŸŒˆ
  • errcode_ret โ€” returns an appropriate error code. If errcode_ret is NULL, 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 โ€” if context is not a valid context ๐Ÿ˜ญ
  • CL_INVALID_VALUE โ€” if addressing_mode, filter_mode, or normalized_coords, or some combination of these argument values, are not valid ๐Ÿšฉ
  • CL_INVALID_OPERATION โ€” if images are not supported by any device associated with context (i.e. CL_DEVICE_IMAGE_SUPPORT specified in the table of OpenCL Device Queries for clGetDeviceInfo(3clc) is CL_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 ยฉ 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 ๐Ÿงš

  1. 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