-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.d.ts
110 lines (95 loc) · 2.02 KB
/
index.d.ts
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
export = blink
export as namespace blink
declare namespace blink {
/**
* Environment related objects.
*/
const context: WebGLRenderingContext
const device: {
glslVersion: string
maxColorAttachments: number
maxTextureSize: number
maxTextureUnits: number
renderer: string
vendor: string
unmaskedRenderer?: string
unmaskedVendor?: string
}
/**
* blink.js version
*/
const VERSION: {
major: number
minor: number
patch: number
toString(): string
}
/**
* Constants.
*/
type DataType = {
name: string
bytes: number
integer: boolean
unsigned: boolean
}
const FLOAT: DataType
const INT32: DataType
const INT16: DataType
const INT8: DataType
const UINT32: DataType
const UINT16: DataType
const UINT8: DataType
type WrapMode = number
const CLAMP: WrapMode
const MIRROR: WrapMode
const REPEAT: WrapMode
/**
* Generic Buffer Descriptor.
* Though perhaps unnecessarily complex, it does force either `alloc` or `data` to be present.
*/
type TypedArray = Float32Array
| Int32Array | Int16Array | Int8Array
| Uint32Array | Uint16Array | Uint8Array | Uint8ClampedArray
interface BufferDescriptorBase {
type?: DataType
vector?: number
wrap?: WrapMode
}
interface BufferDescriptorAlloc extends BufferDescriptorBase {
alloc: number
}
interface BufferDescriptorData<T extends TypedArray> extends BufferDescriptorBase {
data: T
}
type BufferDescriptor<T extends TypedArray> = BufferDescriptorAlloc | BufferDescriptorData<T>
/**
* Buffers.
*/
class Buffer<T extends TypedArray> {
readonly data: T
constructor(descriptor: BufferDescriptor<T>)
copy(): Buffer<T>
delete()
}
class DeviceBuffer<T extends TypedArray> {
constructor(descriptor: BufferDescriptor<T>)
copy(): DeviceBuffer<T>
delete()
toDevice(data: T)
toHost(data?: T): T
toHostAsync?(data?: T): Promise<T>
}
/**
* Kernel.
*/
interface InputOutput {
in?: object
out: object
}
class Kernel {
constructor(io: InputOutput, source: string)
delete()
exec(uniforms?: object)
}
}