-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathshell.html
72 lines (59 loc) · 2.01 KB
/
shell.html
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
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>webgpu</title>
<style>
body { background-color: black; }
canvas { position:absolute; top:0px; left:0px; border:none; margin:0; width: 100%; height: 100%; overflow: hidden; display: block; }
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script type='text/javascript'>
var Module = {
print: (function() {
return (text) => {console.log(text);
};
})(),
canvas: (function() {
return document.getElementById('canvas');
})(),
};
initWebGPU = async () => {
// Check to ensure the user agent supports WebGPU
if (!('gpu' in navigator)) {
const msg = '⚠️ WebGPU is not available on this browser.';
const pre = document.createElement('pre');
pre.style.color = '#f00';
pre.style.textAlign = 'center';
pre.textContent = msg;
document.body.appendChild(pre);
console.error(msg);
return false;
}
// Request an adapter
const adapter = await navigator.gpu.requestAdapter();
if (!adapter) {
console.error('No WebGPU adapters found.');
return false;
}
// Request a device
const device = await adapter.requestDevice();
device.lost.then((info) => {
console.error(`WebGPU device was lost: ${info.message}`);
device = null;
if (info.reason != 'destroyed') {
initWebGPU();
}
});
// Set WebGPU device in Module
Module.preinitializedWebGPUDevice = device;
return true;
}
initWebGPU();
</script>
{{{ SCRIPT }}}
</body>
</html>