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

Function testArrayThenArray1D4

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

Source from the content-addressed store, hash-verified

4describe('internal: different texture cloning');
5
6function testArrayThenArray1D4(mode) {
7 const gpu = new GPU({ mode });
8 function createTextureOf(value, type) {
9 return (gpu.createKernel(function(value) {
10 return value[this.thread.x];
11 }, {
12 output: [1],
13 pipeline: true,
14 argumentTypes: { value: type }
15 }))(value);
16 }
17 const arrayTexture = createTextureOf([1], 'Array');
18 const arrayTextureClone = arrayTexture.clone();
19 const array4Texture = createTextureOf([[1,2,3,4]], 'Array1D(4)');
20 const array4TextureClone = array4Texture.clone();
21 assert.notEqual(arrayTextureClone, array4TextureClone);
22 assert.deepEqual(arrayTextureClone.toArray(), new Float32Array([1]));
23 assert.deepEqual(array4TextureClone.toArray(), [new Float32Array([1,2,3,4])]);
24 gpu.destroy();
25}
26
27test('Array then Array1D(4) auto', () => {
28 testArrayThenArray1D4();

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…