forked from Zyko0/go-opencl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpurego_types.go
133 lines (120 loc) · 2.75 KB
/
purego_types.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package pureCL
import (
"unsafe"
)
type ImageFormat struct {
ChannelOrder ImageChannelOrder
ChannelType ImageChannelType
}
type BufferData struct {
TypeSize uintptr
DataSize uintptr
Pointer unsafe.Pointer
}
type ImageData struct {
*BufferData
Origin [3]uint
Region [3]uint
RowPitch uint
SlicePitch uint
}
type (
// primitive types
Size uint
Status int32
Program uint
ProgramBuildInfo uint32
DeviceType uint32
PlatformInfo uint
Context uint
Platform uint
Device uint
DeviceInfo uint32
MemFlag uint32
ImageChannelOrder uint32
ImageChannelType uint32
CommandQueueProperties uint32
CommandQueue uint
Buffer uint
CommandQueueProperty uint32
MemInfo uint32
MapFlag uint32
Kernel uint
Event uint
// notify function types
CreateContextNotifyFuncType func(errinfo, privateInfo []byte, cb Size, userData []byte)
BuildProgramNotifyFuncType func(program Program, userData []byte)
// structs
KernelArg struct {
ptr unsafe.Pointer
size Size
}
// GL
GLEnum uint32
GLInt int32
GLUint uint32
CLGLObjectType uint32
CLGLTextureInfo uint32
// untested and unintergrateed
PipeProperties uint32
KernelWorkGroupInfo uint32
EventInfo uint32
EventCommandExecStatus uint32
ImageInfo uint32
DeviceAffinityDomain uint64
ContextProperty uint
ContextProperties struct {
Platform *Platform
// Interop
InteropUserSync *bool
// OpenGL
GLContextKHR *uint
// Windows
WGL_HDC_KHR *uint
}
DevicePartitionProperty struct {
Type uint32
Flags uint32
}
DevicePartition struct {
Properties []DevicePartitionProperty
AffinityDomain DeviceAffinityDomain
}
Sampler uint
MemObjectType uint32
MapPointer unsafe.Pointer
BufferRect struct {
Origin [3]Size
Region [3]Size
}
ImageDesc struct {
Type MemObjectType
Width Size
Height Size
Depth Size
ArraySize Size
RowPitch Size
SlisePitch Size
Buffer Buffer
NumMipLevel uint32
NumSamples uint32
}
)
func NewKernelArg[T any](arg *T) KernelArg {
return KernelArg{
ptr: unsafe.Pointer(arg),
size: Size(unsafe.Sizeof(*arg)),
}
}
func (k Kernel) SetArg(index uint, arg KernelArg) error {
if SetKernelArg == nil {
return Uninitialized("SetKernelArg")
}
return StatusToErr(SetKernelArg(k, uint32(index), arg.size, arg.ptr)) //TODO uint or uint32
}
func (k Kernel) Release() error {
if ReleaseKernel == nil {
return Uninitialized("ReleaseKernel")
}
return StatusToErr(ReleaseKernel(k))
}