-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhelper.mjs
45 lines (43 loc) · 1.75 KB
/
helper.mjs
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
const glslEmpty310es = `#version 310 es
void main() {}`;
const glslEmpty450 = `#version 450
void main() {}`;
const glslTextureSampler = `#version 310 es
layout(set = 0, binding = 0) uniform texture2D t;
layout(set = 0, binding = 1) uniform mediump sampler s;
void main() {}`;
export const testCases = [
['fragment', glslEmpty310es ], ['vertex', glslEmpty310es ], ['compute', glslEmpty310es ],
['fragment', glslEmpty450 ], ['vertex', glslEmpty450 ], ['compute', glslEmpty450 ],
['fragment', glslTextureSampler], ['vertex', glslTextureSampler], ['compute', glslTextureSampler],
];
export function runTest(glslang, type, glslcode) {
try {
{
const code = glslang.compileGLSL(glslcode, type, false, '1.3');
const result = glslang.compileGLSLZeroCopy(glslcode, type, false, '1.3');
console.log(code.length, result.data.toString());
result.free();
}
{
const code = glslang.compileGLSL(glslcode, type, true, '1.3');
const result = glslang.compileGLSLZeroCopy(glslcode, type, true, '1.3');
console.log(code.length, result.data.toString());
result.free();
}
{
const code = glslang.compileGLSL(glslcode, type, false, '1.0');
const result = glslang.compileGLSLZeroCopy(glslcode, type, false, '1.0');
console.log(code.length, result.data.toString());
result.free();
}
{
const code = glslang.compileGLSL(glslcode, type);
const result = glslang.compileGLSLZeroCopy(glslcode, type);
console.log(code.length, result.data.toString());
result.free();
}
} catch (ex) {
console.error(ex);
}
}