## C Specification

To create a sampler object, call the function

cl_sampler clCreateSampler(
cl_context context,
cl_bool normalized_coords,
cl_filter_mode filter_mode,
cl_int* errcode_ret);

## Parameters

• context must be a valid OpenCL context.

• normalized_coords has the same interpretation as CL_​SAMPLER_​NORMALIZED_​COORDS in the sampler creation properties table.

• addressing_mode has the same interpretation as CL_​SAMPLER_​ADDRESSING_​MODE in the sampler creation properties table.

• filter_mode has the same interpretation as CL_​SAMPLER_​FILTER_​MODE in the sampler creation properties table.

• errcode_ret will return an appropriate error code. If errcode_ret is NULL, no error code is returned.

## Description

clCreateSampler returns a valid non-zero sampler object and errcode_ret is set to CL_​SUCCESS if the sampler object is created successfully. Otherwise, it returns a NULL value with one of the following error values returned in errcode_ret:

• CL_​INVALID_​CONTEXT if context is not a valid context.

• CL_​INVALID_​VALUE if addressing_mode, filter_mode, normalized_coords or a combination of these arguements 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 Device Queries table is CL_​FALSE).

• CL_​OUT_​OF_​RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

• CL_​OUT_​OF_​HOST_​MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

## Document Notes

This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.