@antv/g-webgpu 1.7.71 → 1.7.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/WebGPUContextService.d.ts +1 -1
- package/dist/WebGPUContextService.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +38 -46
- package/dist/index.js +38 -46
- package/dist/index.umd.js +898 -1793
- package/dist/index.umd.min.js +1 -1
- package/dist/pkg/glsl_wgsl_compiler.d.ts +48 -0
- package/dist/pkg/glsl_wgsl_compiler.js +223 -0
- package/dist/pkg/glsl_wgsl_compiler_bg.wasm +0 -0
- package/dist/pkg/package.json +17 -0
- package/package.json +7 -7
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} source
|
|
5
|
+
* @param {string} stage
|
|
6
|
+
* @param {boolean} validation_enabled
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export function glsl_compile(
|
|
10
|
+
source: string,
|
|
11
|
+
stage: string,
|
|
12
|
+
validation_enabled: boolean,
|
|
13
|
+
): string;
|
|
14
|
+
|
|
15
|
+
export type InitInput =
|
|
16
|
+
| RequestInfo
|
|
17
|
+
| URL
|
|
18
|
+
| Response
|
|
19
|
+
| BufferSource
|
|
20
|
+
| WebAssembly.Module;
|
|
21
|
+
|
|
22
|
+
export interface InitOutput {
|
|
23
|
+
readonly memory: WebAssembly.Memory;
|
|
24
|
+
readonly glsl_compile: (
|
|
25
|
+
a: number,
|
|
26
|
+
b: number,
|
|
27
|
+
c: number,
|
|
28
|
+
d: number,
|
|
29
|
+
e: number,
|
|
30
|
+
f: number,
|
|
31
|
+
) => void;
|
|
32
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
33
|
+
readonly __wbindgen_malloc: (a: number) => number;
|
|
34
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
|
|
35
|
+
readonly __wbindgen_free: (a: number, b: number) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
40
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
41
|
+
*
|
|
42
|
+
* @param {InitInput | Promise<InitInput>} module_or_path
|
|
43
|
+
*
|
|
44
|
+
* @returns {Promise<InitOutput>}
|
|
45
|
+
*/
|
|
46
|
+
export default function init(
|
|
47
|
+
module_or_path?: InitInput | Promise<InitInput>,
|
|
48
|
+
): Promise<InitOutput>;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
let cachedTextDecoder = new TextDecoder('utf-8', {
|
|
4
|
+
ignoreBOM: true,
|
|
5
|
+
fatal: true,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
cachedTextDecoder.decode();
|
|
9
|
+
|
|
10
|
+
let cachegetUint8Memory0 = null;
|
|
11
|
+
function getUint8Memory0() {
|
|
12
|
+
if (
|
|
13
|
+
cachegetUint8Memory0 === null ||
|
|
14
|
+
cachegetUint8Memory0.buffer !== wasm.memory.buffer
|
|
15
|
+
) {
|
|
16
|
+
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
17
|
+
}
|
|
18
|
+
return cachegetUint8Memory0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getStringFromWasm0(ptr, len) {
|
|
22
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const heap = new Array(32).fill(undefined);
|
|
26
|
+
|
|
27
|
+
heap.push(undefined, null, true, false);
|
|
28
|
+
|
|
29
|
+
let heap_next = heap.length;
|
|
30
|
+
|
|
31
|
+
function addHeapObject(obj) {
|
|
32
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
33
|
+
const idx = heap_next;
|
|
34
|
+
heap_next = heap[idx];
|
|
35
|
+
|
|
36
|
+
heap[idx] = obj;
|
|
37
|
+
return idx;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function getObject(idx) {
|
|
41
|
+
return heap[idx];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function dropObject(idx) {
|
|
45
|
+
if (idx < 36) return;
|
|
46
|
+
heap[idx] = heap_next;
|
|
47
|
+
heap_next = idx;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function takeObject(idx) {
|
|
51
|
+
const ret = getObject(idx);
|
|
52
|
+
dropObject(idx);
|
|
53
|
+
return ret;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let WASM_VECTOR_LEN = 0;
|
|
57
|
+
|
|
58
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
59
|
+
|
|
60
|
+
const encodeString =
|
|
61
|
+
typeof cachedTextEncoder.encodeInto === 'function'
|
|
62
|
+
? function (arg, view) {
|
|
63
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
64
|
+
}
|
|
65
|
+
: function (arg, view) {
|
|
66
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
67
|
+
view.set(buf);
|
|
68
|
+
return {
|
|
69
|
+
read: arg.length,
|
|
70
|
+
written: buf.length,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
75
|
+
if (realloc === undefined) {
|
|
76
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
77
|
+
const ptr = malloc(buf.length);
|
|
78
|
+
getUint8Memory0()
|
|
79
|
+
.subarray(ptr, ptr + buf.length)
|
|
80
|
+
.set(buf);
|
|
81
|
+
WASM_VECTOR_LEN = buf.length;
|
|
82
|
+
return ptr;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let len = arg.length;
|
|
86
|
+
let ptr = malloc(len);
|
|
87
|
+
|
|
88
|
+
const mem = getUint8Memory0();
|
|
89
|
+
|
|
90
|
+
let offset = 0;
|
|
91
|
+
|
|
92
|
+
for (; offset < len; offset++) {
|
|
93
|
+
const code = arg.charCodeAt(offset);
|
|
94
|
+
if (code > 0x7f) break;
|
|
95
|
+
mem[ptr + offset] = code;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (offset !== len) {
|
|
99
|
+
if (offset !== 0) {
|
|
100
|
+
arg = arg.slice(offset);
|
|
101
|
+
}
|
|
102
|
+
ptr = realloc(ptr, len, (len = offset + arg.length * 3));
|
|
103
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
104
|
+
const ret = encodeString(arg, view);
|
|
105
|
+
|
|
106
|
+
offset += ret.written;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
WASM_VECTOR_LEN = offset;
|
|
110
|
+
return ptr;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let cachegetInt32Memory0 = null;
|
|
114
|
+
function getInt32Memory0() {
|
|
115
|
+
if (
|
|
116
|
+
cachegetInt32Memory0 === null ||
|
|
117
|
+
cachegetInt32Memory0.buffer !== wasm.memory.buffer
|
|
118
|
+
) {
|
|
119
|
+
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
120
|
+
}
|
|
121
|
+
return cachegetInt32Memory0;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @param {string} source
|
|
125
|
+
* @param {string} stage
|
|
126
|
+
* @param {boolean} validation_enabled
|
|
127
|
+
* @returns {string}
|
|
128
|
+
*/
|
|
129
|
+
export function glsl_compile(source, stage, validation_enabled) {
|
|
130
|
+
try {
|
|
131
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
132
|
+
var ptr0 = passStringToWasm0(
|
|
133
|
+
source,
|
|
134
|
+
wasm.__wbindgen_malloc,
|
|
135
|
+
wasm.__wbindgen_realloc,
|
|
136
|
+
);
|
|
137
|
+
var len0 = WASM_VECTOR_LEN;
|
|
138
|
+
var ptr1 = passStringToWasm0(
|
|
139
|
+
stage,
|
|
140
|
+
wasm.__wbindgen_malloc,
|
|
141
|
+
wasm.__wbindgen_realloc,
|
|
142
|
+
);
|
|
143
|
+
var len1 = WASM_VECTOR_LEN;
|
|
144
|
+
wasm.glsl_compile(retptr, ptr0, len0, ptr1, len1, validation_enabled);
|
|
145
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
146
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
147
|
+
return getStringFromWasm0(r0, r1);
|
|
148
|
+
} finally {
|
|
149
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
150
|
+
wasm.__wbindgen_free(r0, r1);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function load(module, imports) {
|
|
155
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
156
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
157
|
+
try {
|
|
158
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
159
|
+
} catch (e) {
|
|
160
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
161
|
+
console.warn(
|
|
162
|
+
'`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n',
|
|
163
|
+
e,
|
|
164
|
+
);
|
|
165
|
+
} else {
|
|
166
|
+
throw e;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const bytes = await module.arrayBuffer();
|
|
172
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
173
|
+
} else {
|
|
174
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
175
|
+
|
|
176
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
177
|
+
return { instance, module };
|
|
178
|
+
} else {
|
|
179
|
+
return instance;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function init(input) {
|
|
185
|
+
if (typeof input === 'undefined') {
|
|
186
|
+
// input = new URL('glsl_wgsl_compiler_bg.wasm', import.meta.url);
|
|
187
|
+
}
|
|
188
|
+
const imports = {};
|
|
189
|
+
imports.wbg = {};
|
|
190
|
+
imports.wbg.__wbindgen_string_new = function (arg0, arg1) {
|
|
191
|
+
var ret = getStringFromWasm0(arg0, arg1);
|
|
192
|
+
return addHeapObject(ret);
|
|
193
|
+
};
|
|
194
|
+
imports.wbg.__wbindgen_object_drop_ref = function (arg0) {
|
|
195
|
+
takeObject(arg0);
|
|
196
|
+
};
|
|
197
|
+
imports.wbg.__wbg_log_fbd13631356d44e4 = function (arg0) {
|
|
198
|
+
console.log(getObject(arg0));
|
|
199
|
+
};
|
|
200
|
+
imports.wbg.__wbg_log_00fa6d531d56c191 = function (arg0, arg1) {
|
|
201
|
+
console.log(getObject(arg0), getObject(arg1));
|
|
202
|
+
};
|
|
203
|
+
imports.wbg.__wbindgen_throw = function (arg0, arg1) {
|
|
204
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
if (
|
|
208
|
+
typeof input === 'string' ||
|
|
209
|
+
(typeof Request === 'function' && input instanceof Request) ||
|
|
210
|
+
(typeof URL === 'function' && input instanceof URL)
|
|
211
|
+
) {
|
|
212
|
+
input = fetch(input);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const { instance, module } = await load(await input, imports);
|
|
216
|
+
|
|
217
|
+
wasm = instance.exports;
|
|
218
|
+
init.__wbindgen_wasm_module = module;
|
|
219
|
+
|
|
220
|
+
return wasm;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export default init;
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "glsl-wgsl-compiler",
|
|
3
|
+
"collaborators": [
|
|
4
|
+
"The wasm-bindgen Developers"
|
|
5
|
+
],
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"files": [
|
|
8
|
+
"glsl_wgsl_compiler_bg.wasm",
|
|
9
|
+
"glsl_wgsl_compiler.js",
|
|
10
|
+
"glsl_wgsl_compiler.d.ts"
|
|
11
|
+
],
|
|
12
|
+
"module": "glsl_wgsl_compiler.js",
|
|
13
|
+
"types": "glsl_wgsl_compiler.d.ts",
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"./snippets/*"
|
|
16
|
+
]
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g-webgpu",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.73",
|
|
4
4
|
"description": "A renderer implemented by WebGPU",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antv",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"sync": "tnpm sync"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@antv/g-plugin-device-renderer": "^1.7.
|
|
34
|
-
"@antv/g-plugin-dom-interaction": "^1.7.
|
|
35
|
-
"@antv/g-plugin-html-renderer": "^1.7.
|
|
36
|
-
"@antv/g-plugin-image-loader": "^1.1.
|
|
37
|
-
"@antv/g-plugin-webgpu-device": "^1.7.
|
|
33
|
+
"@antv/g-plugin-device-renderer": "^1.7.70",
|
|
34
|
+
"@antv/g-plugin-dom-interaction": "^1.7.52",
|
|
35
|
+
"@antv/g-plugin-html-renderer": "^1.7.56",
|
|
36
|
+
"@antv/g-plugin-image-loader": "^1.1.54",
|
|
37
|
+
"@antv/g-plugin-webgpu-device": "^1.7.51",
|
|
38
38
|
"@antv/util": "^3.3.1",
|
|
39
39
|
"@webgpu/types": "^0.1.6"
|
|
40
40
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "09b3114354c305562668f22159d9cc35d56c813a"
|
|
53
53
|
}
|