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
File: image.go Progetto: xfong/tmpCL
func (image_desc *ImageDescription) GetFormat() (*ImageFormat, error) {
	var tmpFormat C.cl_image_format
	err := C.clGetImageInfo(image_desc.Buffer.clMem, ImageInfoFormat.toCl(), C.size_t(unsafe.Sizeof(tmpFormat)), (unsafe.Pointer)(&tmpFormat), nil)
	if toError(err) != nil {
		return nil, toError(err)
	}
	return &ImageFormat{ChannelOrder: (ChannelOrder)(tmpFormat.image_channel_order), ChannelDataType: (ChannelDataType)(tmpFormat.image_channel_data_type)}, toError(err)
}
Esempio n. 3
0
File: image.go Progetto: xfong/tmpCL
//////////////// Basic Functions ////////////////
func getImageInfoInt(memobj *MemObject, param_name ImageInfoParam) (int, error) {
	var val C.size_t
	err := C.clGetImageInfo(memobj.clMem, param_name.toCl(), C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), nil)
	if toError(err) != nil {
		return -1, toError(err)
	}
	return int(val), toError(err)
}
Esempio n. 4
0
File: dx9ms.go Progetto: xfong/tmpCL
func (image_desc *ImageDescription) GetDX9MediaPlane() (int, error) {
	if image_desc.Buffer != nil {
		var val C.cl_uint
		err := C.clGetImageInfo(image_desc.Buffer.clMem, C.CL_IMAGE_DX9_MEDIA_PLANE_KHR, (C.size_t)(unsafe.Sizeof(val)), unsafe.Pointer(&val), nil)
		if toError(err) != nil {
			return -1, toError(err)
		}
		return int(val), nil
	}
	return -1, toError(C.CL_INVALID_MEM_OBJECT)
}
Esempio n. 5
0
File: d3d10.go Progetto: xfong/tmpCL
func (image_desc *ImageDescription) GetD3D10Subresource() (*C.ID3D10Resource, error) {
	if image_desc.Buffer != nil {
		var val C.ID3D10Resource
		err := C.clGetImageInfo(image_desc.Buffer.clMem, C.CL_IMAGE_D3D10_SUBRESOURCE_KHR, (C.size_t)(unsafe.Sizeof(val)), unsafe.Pointer(&val), nil)
		if toError(err) != nil {
			return nil, toError(err)
		}
		return &val, nil
	}
	return nil, toError(C.CL_INVALID_MEM_OBJECT)
}
Esempio n. 6
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. 7
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. 8
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)
	}
}