-
Notifications
You must be signed in to change notification settings - Fork 1
/
buffer.go
37 lines (31 loc) · 823 Bytes
/
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
package wasmgpu
import "syscall/js"
// GPUBufferDescriptor as described:
// https://gpuweb.github.io/gpuweb/#gpubufferdescriptor
type GPUBufferDescriptor struct {
Size GPUSize64
Usage GPUBufferUsageFlags
}
// ToJS converts this type to one that can be passed as an argument
// to JavaScript.
func (g GPUBufferDescriptor) ToJS() any {
return map[string]any{
"size": g.Size.ToJS(),
"usage": g.Usage.ToJS(),
}
}
// GPUBuffer as described:
// https://gpuweb.github.io/gpuweb/#gpubuffer
type GPUBuffer struct {
jsValue js.Value
}
// ToJS converts this type to one that can be passed as an argument
// to JavaScript.
func (g GPUBuffer) ToJS() any {
return g.jsValue
}
// Destroy as described:
// https://gpuweb.github.io/gpuweb/#dom-gpubuffer-destroy
func (g GPUBuffer) Destroy() {
g.jsValue.Call("destroy")
}