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

Function imageArrayTest

test/features/image-array.js:28–51  ·  view source on GitHub ↗
(mode, done)

Source from the content-addressed store, hash-verified

26}
27
28function imageArrayTest(mode, done) {
29 const gpu = new GPU({
30 mode
31 });
32 const imageKernel = gpu.createKernel(function(images) {
33 const pixel = images[this.thread.z][this.thread.y][this.thread.x];
34 this.color(pixel[0], pixel[1], pixel[2], pixel[3]);
35 }, {
36 graphical: true,
37 output : [138, 91]
38 });
39 getImages(function(images) {
40 imageKernel(images);
41 const pixels = imageKernel.getPixels();
42 assert.equal(pixels.length, 50232);
43 // way too large to test the whole picture, just test the first pixel
44 assert.equal(pixels[0], 147);
45 assert.equal(pixels[1], 168);
46 assert.equal(pixels[2], 251);
47 assert.equal(pixels[3], 255);
48 gpu.destroy();
49 done(imageKernel);
50 });
51}
52
53(typeof Image !== 'undefined' ? test : skip)('image array auto', t => {
54 imageArrayTest(null, t.async());

Callers 1

image-array.jsFile · 0.85

Calls 5

createKernelMethod · 0.95
destroyMethod · 0.95
getImagesFunction · 0.85
colorMethod · 0.65
getPixelsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…