Spaces:
Running
Running
Update gpu.js
Browse files
gpu.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
if (!navigator.gpu) {
|
| 3 |
-
console.warn("WebGPU
|
| 4 |
-
return null;
|
| 5 |
}
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
GPUBufferUsage.COPY_DST
|
| 18 |
-
});
|
| 19 |
-
|
| 20 |
-
return { device, buffer };
|
| 21 |
}
|
|
|
|
| 1 |
+
// gpu.js — v9.2 hardened
|
| 2 |
+
export async function initGPU() {
|
| 3 |
if (!navigator.gpu) {
|
| 4 |
+
console.warn("[GPU] WebGPU unavailable — CPU fallback engaged");
|
| 5 |
+
return { mode: "cpu", device: null };
|
| 6 |
}
|
| 7 |
|
| 8 |
+
try {
|
| 9 |
+
const adapter = await navigator.gpu.requestAdapter();
|
| 10 |
+
if (!adapter) throw new Error("No GPU adapter");
|
| 11 |
|
| 12 |
+
const device = await adapter.requestDevice();
|
| 13 |
+
console.log("[GPU] WebGPU initialized");
|
| 14 |
+
return { mode: "gpu", device };
|
| 15 |
+
} catch (e) {
|
| 16 |
+
console.error("[GPU] Initialization failed:", e);
|
| 17 |
+
return { mode: "cpu", device: null };
|
| 18 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
}
|