LordXido commited on
Commit
16d758a
·
verified ·
1 Parent(s): f0ea7a1

Update gpu.js

Browse files
Files changed (1) hide show
  1. gpu.js +16 -1
gpu.js CHANGED
@@ -1,4 +1,4 @@
1
- export async function initGPU() {
2
  if (!navigator.gpu) {
3
  return { mode: "cpu" };
4
  }
@@ -7,5 +7,20 @@ export async function initGPU() {
7
  if (!adapter) return { mode: "cpu" };
8
 
9
  const device = await adapter.requestDevice();
 
10
  return { mode: "gpu", device };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
 
1
+ export async function initGPU(canvas) {
2
  if (!navigator.gpu) {
3
  return { mode: "cpu" };
4
  }
 
7
  if (!adapter) return { mode: "cpu" };
8
 
9
  const device = await adapter.requestDevice();
10
+
11
  return { mode: "gpu", device };
12
+ }
13
+
14
+ export async function createCompute(device, wgslSource) {
15
+ const module = device.createShaderModule({ code: wgslSource });
16
+
17
+ const pipeline = device.createComputePipeline({
18
+ layout: "auto",
19
+ compute: {
20
+ module,
21
+ entryPoint: "main"
22
+ }
23
+ });
24
+
25
+ return pipeline;
26
  }