forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Ensure arguments are targeted correctly
fix: Added a missing jsdoc
- Loading branch information
1 parent
e8a6f6d
commit 2d51ed6
Showing
9 changed files
with
170 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
const { assert, skip, test, module: describe, only } = require('qunit'); | ||
const { GPU } = require('../../src'); | ||
|
||
describe('issue #608 - rewritten arrays'); | ||
|
||
function testRewrittenArrays(mode) { | ||
const gpu = new GPU({ mode }); | ||
const kernel1 = gpu.createKernel(function (a, b) { | ||
return a[this.thread.y][this.thread.x]; | ||
}, { | ||
constants: { | ||
c: [21, 23] | ||
}, | ||
output: [2, 2] | ||
}); | ||
const kernel2 = gpu.createKernel(function (a, b) { | ||
return b[this.thread.y][this.thread.x]; | ||
}, { | ||
constants: { | ||
c: [21, 23] | ||
}, | ||
output: [2, 2] | ||
}); | ||
const kernel3 = gpu.createKernel(function (a, b) { | ||
return this.constants.c[this.thread.x]; | ||
}, { | ||
constants: { | ||
c: [21, 23] | ||
}, | ||
output: [2, 2] | ||
}); | ||
const a = [ | ||
[2, 3], | ||
[5, 7] | ||
]; | ||
const b = [ | ||
[11, 13], | ||
[17, 19] | ||
]; | ||
const cExpected = [ | ||
[21, 23], | ||
[21, 23] | ||
]; | ||
// testing twice to ensure constants are reset | ||
assert.deepEqual(kernel1(a, b).map(v => Array.from(v)), a); | ||
assert.deepEqual(kernel2(a, b).map(v => Array.from(v)), b); | ||
assert.deepEqual(kernel3(a, b).map(v => Array.from(v)), cExpected); | ||
|
||
assert.deepEqual(kernel1(a, b).map(v => Array.from(v)), a); | ||
assert.deepEqual(kernel2(a, b).map(v => Array.from(v)), b); | ||
assert.deepEqual(kernel3(a, b).map(v => Array.from(v)), cExpected); | ||
gpu.destroy(); | ||
} | ||
|
||
test('auto', () => { | ||
testRewrittenArrays(); | ||
}); | ||
|
||
test('gpu', () => { | ||
testRewrittenArrays('gpu'); | ||
}); | ||
|
||
(GPU.isWebGLSupported ? test : skip)('webgl', () => { | ||
testRewrittenArrays('webgl'); | ||
}); | ||
|
||
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => { | ||
testRewrittenArrays('webgl2'); | ||
}); | ||
|
||
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => { | ||
testRewrittenArrays('headlessgl'); | ||
}); | ||
|
||
test('cpu', () => { | ||
testRewrittenArrays('cpu'); | ||
}); |