Skip to content

Commit e3fd163

Browse files
fix: Ensure arguments are targeted correctly
fix: Added a missing jsdoc
1 parent d489f1d commit e3fd163

File tree

9 files changed

+170
-242
lines changed

9 files changed

+170
-242
lines changed

dist/gpu-browser-core.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* GPU Accelerated JavaScript
66
*
7-
* @version 2.10.5
8-
* @date Thu Nov 12 2020 14:04:03 GMT-0500 (Eastern Standard Time)
7+
* @version 2.10.6
8+
* @date Wed Dec 02 2020 15:14:25 GMT-0500 (Eastern Standard Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -2555,7 +2555,6 @@ class FunctionBuilder {
25552555
module.exports = {
25562556
FunctionBuilder
25572557
};
2558-
25592558
},{}],9:[function(require,module,exports){
25602559
const acorn = require('acorn');
25612560
const { utils } = require('../utils');
@@ -10381,7 +10380,7 @@ class WebGLKernel extends GLKernel {
1038110380
return this.createTexture();
1038210381
};
1038310382
const onRequestIndex = () => {
10384-
return textureIndexes++;
10383+
return this.constantTextureCount + textureIndexes++;
1038510384
};
1038610385
const onUpdateValueMismatch = (constructor) => {
1038710386
this.switchKernels({

dist/gpu-browser-core.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gpu-browser.js

Lines changed: 69 additions & 226 deletions
Large diffs are not rendered by default.

dist/gpu-browser.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gpu.js",
3-
"version": "2.10.5",
3+
"version": "2.10.6",
44
"description": "GPU Accelerated JavaScript",
55
"engines": {
66
"node": ">=8.0.0"

src/backend/web-gl/kernel.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ class WebGLKernel extends GLKernel {
9898
return testContext.getParameter(testContext.MAX_TEXTURE_SIZE);
9999
}
100100

101+
/**
102+
*
103+
* @param type
104+
* @param dynamic
105+
* @param precision
106+
* @param value
107+
* @returns {KernelValue}
108+
*/
101109
static lookupKernelValueType(type, dynamic, precision, value) {
102110
return lookupKernelValueType(type, dynamic, precision, value);
103111
}
@@ -364,7 +372,7 @@ class WebGLKernel extends GLKernel {
364372
return this.createTexture();
365373
};
366374
const onRequestIndex = () => {
367-
return textureIndexes++;
375+
return this.constantTextureCount + textureIndexes++;
368376
};
369377
const onUpdateValueMismatch = (constructor) => {
370378
this.switchKernels({

test/all.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@
180180
<script type="module" src="issues/567-wrong-modulus.js"></script>
181181
<script type="module" src="issues/585-inaccurate-lookups.js"></script>
182182
<script type="module" src="issues/586-unable-to-resize.js"></script>
183+
<script type="module" src="issues/608-rewritten-arrays.js"></script>
183184
<script type="module" src="issues/91-create-kernel-map-array.js"></script>
184185
<script type="module" src="issues/96-param-names.js"></script>
185186
<script type="module" src="features/to-string/as-file.js"></script>

test/issues/608-rewritten-arrays.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const { assert, skip, test, module: describe, only } = require('qunit');
2+
const { GPU } = require('../../src');
3+
4+
describe('issue #608 - rewritten arrays');
5+
6+
function testRewrittenArrays(mode) {
7+
const gpu = new GPU({ mode });
8+
const kernel1 = gpu.createKernel(function (a, b) {
9+
return a[this.thread.y][this.thread.x];
10+
}, {
11+
constants: {
12+
c: [21, 23]
13+
},
14+
output: [2, 2]
15+
});
16+
const kernel2 = gpu.createKernel(function (a, b) {
17+
return b[this.thread.y][this.thread.x];
18+
}, {
19+
constants: {
20+
c: [21, 23]
21+
},
22+
output: [2, 2]
23+
});
24+
const kernel3 = gpu.createKernel(function (a, b) {
25+
return this.constants.c[this.thread.x];
26+
}, {
27+
constants: {
28+
c: [21, 23]
29+
},
30+
output: [2, 2]
31+
});
32+
const a = [
33+
[2, 3],
34+
[5, 7]
35+
];
36+
const b = [
37+
[11, 13],
38+
[17, 19]
39+
];
40+
const cExpected = [
41+
[21, 23],
42+
[21, 23]
43+
];
44+
// testing twice to ensure constants are reset
45+
assert.deepEqual(kernel1(a, b).map(v => Array.from(v)), a);
46+
assert.deepEqual(kernel2(a, b).map(v => Array.from(v)), b);
47+
assert.deepEqual(kernel3(a, b).map(v => Array.from(v)), cExpected);
48+
49+
assert.deepEqual(kernel1(a, b).map(v => Array.from(v)), a);
50+
assert.deepEqual(kernel2(a, b).map(v => Array.from(v)), b);
51+
assert.deepEqual(kernel3(a, b).map(v => Array.from(v)), cExpected);
52+
gpu.destroy();
53+
}
54+
55+
test('auto', () => {
56+
testRewrittenArrays();
57+
});
58+
59+
test('gpu', () => {
60+
testRewrittenArrays('gpu');
61+
});
62+
63+
(GPU.isWebGLSupported ? test : skip)('webgl', () => {
64+
testRewrittenArrays('webgl');
65+
});
66+
67+
(GPU.isWebGL2Supported ? test : skip)('webgl2', () => {
68+
testRewrittenArrays('webgl2');
69+
});
70+
71+
(GPU.isHeadlessGLSupported ? test : skip)('headlessgl', () => {
72+
testRewrittenArrays('headlessgl');
73+
});
74+
75+
test('cpu', () => {
76+
testRewrittenArrays('cpu');
77+
});

0 commit comments

Comments
 (0)