forked from Zyko0/go-opencl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuffer.go
51 lines (43 loc) · 1.17 KB
/
buffer.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
package middleCL
import (
constants "github.com/opencl-pure/constantsCL"
pure "github.com/opencl-pure/pureCL"
"unsafe"
)
type Buffer struct {
B pure.Buffer
}
func (b *Buffer) getInfo(name pure.MemInfo) (uint, error) {
info := uint(0)
st := pure.GetMemObjectInfo(b.B, name, pure.Size(unsafe.Sizeof(info)), unsafe.Pointer(&info), nil)
if st != constants.CL_SUCCESS {
return 0, pure.StatusToErr(st)
}
return info, nil
}
func (b *Buffer) Size() (uint, error) {
return b.getInfo(pure.MemInfo(constants.CL_MEM_SIZE))
}
func (b *Buffer) Release() error {
return pure.StatusToErr(pure.ReleaseMemObject(b.B))
}
// GL
func (b *Buffer) GetGLObjectInfo() (pure.CLGLObjectType, error) {
var objectType pure.CLGLObjectType
st := pure.GetGLObjectInfo(b.B, &objectType, nil)
if st != constants.CL_SUCCESS {
return 0, pure.StatusToErr(st)
}
return objectType, nil
}
func (b *Buffer) GetGLTextureInfo(info pure.CLGLTextureInfo) (uint32, error) {
var results = []uint32{0}
st := pure.GetGLTextureInfo(
b.B, info, pure.Size(unsafe.Sizeof(&results[0])),
unsafe.Pointer(&results[0]), nil,
)
if st != constants.CL_SUCCESS {
return 0, pure.StatusToErr(st)
}
return results[0], nil
}