Spaces:
Sleeping
Sleeping
KasKniesmeijer
commited on
Commit
·
7c0f537
1
Parent(s):
bf55753
first commit
Browse files- index.html +16 -19
- src/main.js +21 -0
- style.css +13 -25
index.html
CHANGED
@@ -1,19 +1,16 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
</div>
|
18 |
-
</body>
|
19 |
-
</html>
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>WebGPU Hugging Face Space</title>
|
8 |
+
<link rel="stylesheet" href="styles.css">
|
9 |
+
</head>
|
10 |
+
|
11 |
+
<body>
|
12 |
+
<canvas id="webgpu-canvas"></canvas>
|
13 |
+
<script type="module" src="./src/main.js"></script>
|
14 |
+
</body>
|
15 |
+
|
16 |
+
</html>
|
|
|
|
|
|
src/main.js
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
async function initWebGPU() {
|
2 |
+
if (!navigator.gpu) {
|
3 |
+
document.body.innerHTML = "<p>Your browser does not support WebGPU.</p>";
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
|
7 |
+
const canvas = document.getElementById("webgpu-canvas");
|
8 |
+
const adapter = await navigator.gpu.requestAdapter();
|
9 |
+
const device = await adapter.requestDevice();
|
10 |
+
const context = canvas.getContext("webgpu");
|
11 |
+
|
12 |
+
context.configure({
|
13 |
+
device: device,
|
14 |
+
format: navigator.gpu.getPreferredCanvasFormat(),
|
15 |
+
alphaMode: "opaque",
|
16 |
+
});
|
17 |
+
|
18 |
+
console.log("WebGPU initialized successfully!");
|
19 |
+
}
|
20 |
+
|
21 |
+
initWebGPU();
|
style.css
CHANGED
@@ -1,28 +1,16 @@
|
|
1 |
body {
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
}
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
p {
|
12 |
-
color: rgb(107, 114, 128);
|
13 |
-
font-size: 15px;
|
14 |
-
margin-bottom: 10px;
|
15 |
-
margin-top: 5px;
|
16 |
-
}
|
17 |
-
|
18 |
-
.card {
|
19 |
-
max-width: 620px;
|
20 |
-
margin: 0 auto;
|
21 |
-
padding: 16px;
|
22 |
-
border: 1px solid lightgray;
|
23 |
-
border-radius: 16px;
|
24 |
-
}
|
25 |
-
|
26 |
-
.card p:last-child {
|
27 |
-
margin-bottom: 0;
|
28 |
-
}
|
|
|
1 |
body {
|
2 |
+
margin: 0;
|
3 |
+
display: flex;
|
4 |
+
justify-content: center;
|
5 |
+
align-items: center;
|
6 |
+
height: 100vh;
|
7 |
+
background: #222;
|
8 |
+
color: white;
|
9 |
+
font-family: Arial, sans-serif;
|
10 |
}
|
11 |
|
12 |
+
canvas {
|
13 |
+
width: 800px;
|
14 |
+
height: 600px;
|
15 |
+
border: 1px solid #fff;
|
16 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|