MCPcopy Index your code
hub / github.com/gpujs/gpu.js / readFromTextureKernels

Function readFromTextureKernels

test/features/read-from-texture.js:46–63  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

44});
45
46function readFromTextureKernels(mode) {
47 const gpu = new GPU({ mode });
48 function add(m, n) {
49 return m + n;
50 }
51 const kernels = gpu.createKernelMap({
52 addResult: add
53 }, function (a, b) {
54 return add(a[this.thread.x], b[this.thread.x]);
55 })
56 .setPipeline(true)
57 .setOutput([5]);
58 const result = kernels([1, 2, 3, 4, 5], [1, 2, 3, 4, 5]);
59 const textureResult = result.addResult;
60 assert.deepEqual(Array.from(result.result.toArray()), [2, 4, 6, 8, 10]);
61 assert.deepEqual(Array.from(textureResult.toArray()), [2, 4, 6, 8, 10]);
62 gpu.destroy();
63}
64
65(GPU.isKernelMapSupported ? test : skip)('Read from Texture auto', () => {
66 readFromTextureKernels();

Callers 1

Calls 6

createKernelMapMethod · 0.95
destroyMethod · 0.95
setPipelineMethod · 0.80
addFunction · 0.70
setOutputMethod · 0.45
toArrayMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…