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

Function testArray1D4ThenArray

test/internal/different-texture-cloning.js:43–62  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

41});
42
43function testArray1D4ThenArray(mode) {
44 const gpu = new GPU({ mode });
45 function createTextureOf(value, type) {
46 return (gpu.createKernel(function(value) {
47 return value[this.thread.x];
48 }, {
49 output: [1],
50 pipeline: true,
51 argumentTypes: { value: type }
52 }))(value);
53 }
54 const array4Texture = createTextureOf([[1,2,3,4]], 'Array1D(4)');
55 const array4TextureClone = array4Texture.clone();
56 const arrayTexture = createTextureOf([1], 'Array');
57 const arrayTextureClone = arrayTexture.clone();
58 assert.notEqual(array4TextureClone, arrayTextureClone);
59 assert.deepEqual(array4TextureClone.toArray(), [new Float32Array([1,2,3,4])]);
60 assert.deepEqual(arrayTextureClone.toArray(), new Float32Array([1]));
61 gpu.destroy();
62}
63
64test('Array1D(4) then Array auto', () => {
65 testArray1D4ThenArray();

Callers 1

Calls 4

destroyMethod · 0.95
createTextureOfFunction · 0.85
cloneMethod · 0.45
toArrayMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…