Esempio n. 1
0
func (im *Image) Info(param ImageInfo) (uint32, error) {
	var ret uint32
	if err := C.clGetImageInfo(im.id, C.cl_image_info(param), C.size_t(8), unsafe.Pointer(&ret), nil); err != C.CL_SUCCESS {
		return 0, Cl_error(err)
	}
	return ret, nil
}
Esempio n. 2
0
func (i *Image) Property(prop ImageProperty) Size {
	if value, ok := i.properties[prop]; ok {
		return value
	}

	var data C.size_t
	var length C.size_t

	if ret := C.clGetImageInfo(i.id, C.cl_image_info(prop), C.size_t(unsafe.Sizeof(data)), unsafe.Pointer(&data), &length); ret != C.CL_SUCCESS {
		return 0
	}

	i.properties[prop] = Size(data)
	return i.properties[prop]
}
Esempio n. 3
0
File: image.go Progetto: xfong/tmpCL
func (ip ImageInfoParam) toCl() C.cl_image_info {
	return C.cl_image_info(ip)
}
Esempio n. 4
0
File: package.go Progetto: mantyr/cl
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetImageInfo.html
func GetImageInfo(mem Mem, paramName ImageInfo, paramValueSize uint64, paramValue unsafe.Pointer, paramValueSizeRet *uint64) ErrorCode {
	return ErrorCode(C.clGetImageInfo(mem, C.cl_image_info(paramName), C.size_t(paramValueSize), paramValue, (*C.size_t)(paramValueSizeRet)))
}
Esempio n. 5
0
File: image.go Progetto: xfong/gocl
func CLGetImageInfo(image CL_mem,
	param_name CL_image_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.clGetImageInfo(image.cl_mem,
				C.cl_image_info(param_name),
				C.size_t(param_value_size),
				nil,
				&c_param_value_size_ret)
		} else {
			switch param_name {
			case CL_IMAGE_FORMAT:

				var value C.cl_image_format
				c_errcode_ret = C.clGetImageInfo(image.cl_mem,
					C.cl_image_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_image_format{CL_channel_order(value.image_channel_order),
					CL_channel_type(value.image_channel_data_type)}

			case CL_IMAGE_ELEMENT_SIZE,
				CL_IMAGE_ROW_PITCH,
				CL_IMAGE_SLICE_PITCH,
				CL_IMAGE_HEIGHT,
				CL_IMAGE_WIDTH,
				CL_IMAGE_DEPTH,
				CL_IMAGE_ARRAY_SIZE:

				var value C.size_t
				c_errcode_ret = C.clGetImageInfo(image.cl_mem,
					C.cl_image_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_size_t(value)

			case CL_IMAGE_BUFFER:

				var value C.cl_mem
				c_errcode_ret = C.clGetImageInfo(image.cl_mem,
					C.cl_image_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_mem{value}

			case CL_IMAGE_NUM_MIP_LEVELS,
				CL_IMAGE_NUM_SAMPLES:
				var value C.cl_uint
				c_errcode_ret = C.clGetImageInfo(image.cl_mem,
					C.cl_image_info(param_name),
					C.size_t(param_value_size),
					unsafe.Pointer(&value),
					&c_param_value_size_ret)

				*param_value = CL_uint(value)

			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)
	}
}