func (s *Sampler) Info(param SamplerInfo) (uint32, error) { var ret uint32 var c_size_ret C.size_t if err := C.clGetSamplerInfo(s.id, C.cl_sampler_info(param), C.size_t(4), unsafe.Pointer(&ret), &c_size_ret); err != C.CL_SUCCESS { return 0, Cl_error(err) } return ret, nil }
func (s *Sampler) Property(prop SamplerProperty) interface{} { if value, ok := s.properties[prop]; ok { return value } var data interface{} var length C.size_t var ret C.cl_int switch prop { case SAMPLER_REFERENCE_COUNT: var val C.cl_uint ret = C.clGetSamplerInfo(s.id, C.cl_sampler_info(prop), C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), &length) data = val case SAMPLER_NORMALIZED_COORDS: var val C.cl_bool ret = C.clGetSamplerInfo(s.id, C.cl_sampler_info(prop), C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), &length) data = val == C.CL_TRUE case SAMPLER_ADDRESSING_MODE: var val C.cl_addressing_mode ret = C.clGetSamplerInfo(s.id, C.cl_sampler_info(prop), C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), &length) data = AddressingMode(ret) case SAMPLER_FILTER_MODE: var val C.cl_filter_mode ret = C.clGetSamplerInfo(s.id, C.cl_sampler_info(prop), C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), &length) data = FilterMode(ret) default: return nil } if ret != C.CL_SUCCESS { return nil } s.properties[prop] = data return s.properties[prop] }
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetSamplerInfo.html func GetSamplerInfo(sampler Sampler, paramName SamplerInfo, paramValueSize uint64, paramValue unsafe.Pointer, paramValueSizeRet *uint64) ErrorCode { return ErrorCode(C.clGetSamplerInfo(sampler, C.cl_sampler_info(paramName), C.size_t(paramValueSize), paramValue, (*C.size_t)(paramValueSizeRet))) }
func CLGetSamplerInfo(sampler CL_sampler, param_name CL_sampler_info, param_value_size CL_size_t, param_value *interface{}, param_value_size_ret *CL_size_t) CL_int { if (param_value_size == 0 || param_value == nil) && param_value_size_ret == nil { return CL_INVALID_VALUE } else { var c_param_value_size_ret C.size_t var c_errcode_ret C.cl_int if param_value_size == 0 || param_value == nil { c_errcode_ret = C.clGetSamplerInfo(sampler.cl_sampler, C.cl_sampler_info(param_name), C.size_t(param_value_size), nil, &c_param_value_size_ret) } else { switch param_name { case CL_SAMPLER_REFERENCE_COUNT: var value C.cl_uint c_errcode_ret = C.clGetSamplerInfo(sampler.cl_sampler, C.cl_sampler_info(param_name), C.size_t(param_value_size), unsafe.Pointer(&value), &c_param_value_size_ret) *param_value = CL_uint(value) case CL_SAMPLER_CONTEXT: var value C.cl_context c_errcode_ret = C.clGetSamplerInfo(sampler.cl_sampler, C.cl_sampler_info(param_name), C.size_t(param_value_size), unsafe.Pointer(&value), &c_param_value_size_ret) *param_value = CL_context{value} case CL_SAMPLER_FILTER_MODE: var value C.cl_filter_mode c_errcode_ret = C.clGetSamplerInfo(sampler.cl_sampler, C.cl_sampler_info(param_name), C.size_t(param_value_size), unsafe.Pointer(&value), &c_param_value_size_ret) *param_value = CL_filter_mode(value) case CL_SAMPLER_ADDRESSING_MODE: var value C.cl_addressing_mode c_errcode_ret = C.clGetSamplerInfo(sampler.cl_sampler, C.cl_sampler_info(param_name), C.size_t(param_value_size), unsafe.Pointer(&value), &c_param_value_size_ret) *param_value = CL_addressing_mode(value) case CL_SAMPLER_NORMALIZED_COORDS: var value C.cl_bool c_errcode_ret = C.clGetSamplerInfo(sampler.cl_sampler, C.cl_sampler_info(param_name), C.size_t(param_value_size), unsafe.Pointer(&value), &c_param_value_size_ret) *param_value = CL_bool(value) //TODO in CL.h, but not in spec? Why? //case CL_SAMPLER_MIP_FILTER_MODE, // CL_SAMPLER_LOD_MIN, // CL_SAMPLER_LOD_MAX: default: return CL_INVALID_VALUE } } if param_value_size_ret != nil { *param_value_size_ret = CL_size_t(c_param_value_size_ret) } return CL_int(c_errcode_ret) } }