Esempio n. 1
0
File: package.go Progetto: mantyr/cl
// see https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetSupportedImageFormats.html
func GetSupportedImageFormats(context Context, flags MemFlags, memObjectType MemObjectType, numEntries uint32, imageformats *ImageFormat, numImageFormat *uint32) ErrorCode {
	return ErrorCode(C.clGetSupportedImageFormats(context.clContext,
		C.cl_mem_flags(flags),
		C.cl_mem_object_type(memObjectType),
		C.cl_uint(numEntries),
		(*C.cl_image_format)(unsafe.Pointer(imageformats)),
		(*C.cl_uint)(numImageFormat)))
}
Esempio n. 2
0
File: image.go Progetto: xfong/gocl
func CLGetSupportedImageFormats(context CL_context,
	flags CL_mem_flags,
	image_type CL_mem_object_type,
	num_entries CL_uint,
	image_formats []CL_image_format,
	num_image_formats *CL_uint) CL_int {

	if (num_entries == 0 || image_formats == nil) && num_image_formats == nil {
		return CL_INVALID_VALUE
	} else {
		var c_num_image_formats C.cl_uint
		var c_errcode_ret C.cl_int

		if num_entries == 0 || image_formats == nil {
			c_errcode_ret = C.clGetSupportedImageFormats(context.cl_context,
				C.cl_mem_flags(flags),
				C.cl_mem_object_type(image_type),
				C.cl_uint(num_entries),
				nil,
				&c_num_image_formats)
		} else {
			c_image_formats := make([]C.cl_image_format, len(image_formats))
			c_errcode_ret = C.clGetSupportedImageFormats(context.cl_context,
				C.cl_mem_flags(flags),
				C.cl_mem_object_type(image_type),
				C.cl_uint(num_entries),
				&c_image_formats[0],
				&c_num_image_formats)
			if c_errcode_ret == C.CL_SUCCESS {
				for i := 0; i < len(image_formats); i++ {
					image_formats[i].Image_channel_data_type = CL_channel_type(c_image_formats[i].image_channel_data_type)
					image_formats[i].Image_channel_order = CL_channel_order(c_image_formats[i].image_channel_order)
				}
			}
		}

		if num_image_formats != nil {
			*num_image_formats = CL_uint(c_num_image_formats)
		}

		return CL_int(c_errcode_ret)
	}
}
Esempio n. 3
0
File: image.go Progetto: xfong/tmpCL
func (ctx *Context) GetSupportedImageFormats(flags MemFlag, imageType MemObjectType) ([]ImageFormat, error) {
	var formats [maxImageFormats]C.cl_image_format
	var nFormats C.cl_uint
	if err := C.clGetSupportedImageFormats(ctx.clContext, C.cl_mem_flags(flags), C.cl_mem_object_type(imageType), maxImageFormats, &formats[0], &nFormats); err != C.CL_SUCCESS {
		return nil, toError(err)
	}
	fmts := make([]ImageFormat, nFormats)
	for i, f := range formats[:nFormats] {
		fmts[i] = ImageFormat{
			ChannelOrder:    ChannelOrder(f.image_channel_order),
			ChannelDataType: ChannelDataType(f.image_channel_data_type),
		}
	}
	return fmts, nil
}