forked from decred/gominer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image11.go
91 lines (74 loc) · 2.1 KB
/
image11.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package cl
/*
#cgo CFLAGS: -I CL
#cgo !darwin LDFLAGS: -lOpenCL
#cgo darwin LDFLAGS: -framework OpenCL
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
#ifdef __APPLE__
#include "OpenCL/opencl.h"
#else
#include "CL/opencl.h"
#endif
*/
import "C"
import "unsafe"
///////////////////////////////////////////////
//OpenCL 1.1 deprecated
///////////////////////////////////////////////
func CLCreateImage2D(context CL_context,
flags CL_mem_flags,
image_format *CL_image_format,
image_width CL_size_t,
image_height CL_size_t,
image_row_pitch CL_size_t,
host_ptr unsafe.Pointer,
errcode_ret *CL_int) CL_mem {
var c_image_format C.cl_image_format
var c_errcode_ret C.cl_int
var c_image C.cl_mem
c_image_format.image_channel_order = C.cl_channel_order(image_format.Image_channel_order)
c_image_format.image_channel_data_type = C.cl_channel_type(image_format.Image_channel_data_type)
c_image = C.clCreateImage2D(context.cl_context,
C.cl_mem_flags(flags),
&c_image_format,
C.size_t(image_width),
C.size_t(image_height),
C.size_t(image_row_pitch),
host_ptr,
&c_errcode_ret)
if errcode_ret != nil {
*errcode_ret = CL_int(c_errcode_ret)
}
return CL_mem{c_image}
}
func CLCreateImage3D(context CL_context,
flags CL_mem_flags,
image_format *CL_image_format,
image_width CL_size_t,
image_height CL_size_t,
image_depth CL_size_t,
image_row_pitch CL_size_t,
image_slice_pitch CL_size_t,
host_ptr unsafe.Pointer,
errcode_ret *CL_int) CL_mem {
var c_image_format C.cl_image_format
var c_errcode_ret C.cl_int
var c_image C.cl_mem
c_image_format.image_channel_order = C.cl_channel_order(image_format.Image_channel_order)
c_image_format.image_channel_data_type = C.cl_channel_type(image_format.Image_channel_data_type)
c_image = C.clCreateImage3D(context.cl_context,
C.cl_mem_flags(flags),
&c_image_format,
C.size_t(image_width),
C.size_t(image_height),
C.size_t(image_depth),
C.size_t(image_row_pitch),
C.size_t(image_slice_pitch),
host_ptr,
&c_errcode_ret)
if errcode_ret != nil {
*errcode_ret = CL_int(c_errcode_ret)
}
return CL_mem{c_image}
}