Skip to content

Commit 3bf22d7

Browse files
Merge branch 'develop'
2 parents 5e13509 + 6c30071 commit 3bf22d7

File tree

9 files changed

+75
-18
lines changed

9 files changed

+75
-18
lines changed

bin/gpu-core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* GPU Accelerated JavaScript
66
*
7-
* @version 1.6.1
8-
* @date Sun Sep 02 2018 12:23:56 GMT-0400 (EDT)
7+
* @version 1.6.2
8+
* @date Sun Sep 02 2018 13:35:51 GMT-0400 (EDT)
99
*
1010
* @license MIT
1111
* The MIT License

bin/gpu-core.min.js

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

bin/gpu.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* GPU Accelerated JavaScript
66
*
7-
* @version 1.6.1
8-
* @date Sun Sep 02 2018 12:23:57 GMT-0400 (EDT)
7+
* @version 1.6.2
8+
* @date Sun Sep 02 2018 13:35:52 GMT-0400 (EDT)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -2467,7 +2467,7 @@ module.exports = function (_FunctionNodeBase) {
24672467
if (!inGetParams) {
24682468
retArr.push('.0');
24692469
}
2470-
} else if (this.isState('in-get-call-parameters')) {
2470+
} else if (inGetParams) {
24712471
retArr.pop();
24722472
retArr.push('int(');
24732473
retArr.push(ast.value);
@@ -2481,6 +2481,11 @@ module.exports = function (_FunctionNodeBase) {
24812481
}, {
24822482
key: 'astBinaryExpression',
24832483
value: function astBinaryExpression(ast, retArr) {
2484+
var inGetParams = this.isState('in-get-call-parameters');
2485+
if (inGetParams) {
2486+
this.pushState('not-in-get-call-parameters');
2487+
retArr.push('int');
2488+
}
24842489
retArr.push('(');
24852490

24862491
if (ast.operator === '%') {
@@ -2511,6 +2516,10 @@ module.exports = function (_FunctionNodeBase) {
25112516

25122517
retArr.push(')');
25132518

2519+
if (inGetParams) {
2520+
this.popState('not-in-get-call-parameters');
2521+
}
2522+
25142523
return retArr;
25152524
}
25162525

bin/gpu.min.js

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

dist/backend/web-gl/function-node.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ module.exports = function (_FunctionNodeBase) {
234234
if (!inGetParams) {
235235
retArr.push('.0');
236236
}
237-
} else if (this.isState('in-get-call-parameters')) {
237+
} else if (inGetParams) {
238238
// or cast to an int as we are addressing an input array
239239
retArr.pop();
240240
retArr.push('int(');
@@ -261,6 +261,11 @@ module.exports = function (_FunctionNodeBase) {
261261
}, {
262262
key: 'astBinaryExpression',
263263
value: function astBinaryExpression(ast, retArr) {
264+
var inGetParams = this.isState('in-get-call-parameters');
265+
if (inGetParams) {
266+
this.pushState('not-in-get-call-parameters');
267+
retArr.push('int');
268+
}
264269
retArr.push('(');
265270

266271
if (ast.operator === '%') {
@@ -291,6 +296,10 @@ module.exports = function (_FunctionNodeBase) {
291296

292297
retArr.push(')');
293298

299+
if (inGetParams) {
300+
this.popState('not-in-get-call-parameters');
301+
}
302+
294303
return retArr;
295304
}
296305

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": "1.6.1",
3+
"version": "1.6.2",
44
"description": "GPU Accelerated JavaScript",
55
"main": "./dist/index.js",
66
"directories": {

src/backend/web-gl/function-node.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ module.exports = class WebGLFunctionNode extends FunctionNodeBase {
235235
if (!inGetParams) {
236236
retArr.push('.0');
237237
}
238-
} else if (this.isState('in-get-call-parameters')) {
238+
} else if (inGetParams) {
239239
// or cast to an int as we are addressing an input array
240240
retArr.pop();
241241
retArr.push('int(');
@@ -259,6 +259,11 @@ module.exports = class WebGLFunctionNode extends FunctionNodeBase {
259259
* @returns {Array} the append retArr
260260
*/
261261
astBinaryExpression(ast, retArr) {
262+
const inGetParams = this.isState('in-get-call-parameters');
263+
if (inGetParams) {
264+
this.pushState('not-in-get-call-parameters');
265+
retArr.push('int');
266+
}
262267
retArr.push('(');
263268

264269
if (ast.operator === '%') {
@@ -289,6 +294,10 @@ module.exports = class WebGLFunctionNode extends FunctionNodeBase {
289294

290295
retArr.push(')');
291296

297+
if (inGetParams) {
298+
this.popState('not-in-get-call-parameters');
299+
}
300+
292301
return retArr;
293302
}
294303

test/all.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,6 @@
7171
<script src="issues/335-missing-z-index-issue.js"></script>
7272
<script src="issues/346-uint8array-converted.js"></script>
7373
<script src="issues/349-division-by-factors-of-3.js"></script>
74+
<script src="issues/357-modulus-issue.js"></script>
7475
</body>
7576
</html>

test/issues/357-modulus-issue.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(function() {
2+
function testModKernel(mode) {
3+
var gpu = new GPU({mode});
4+
var nValues = 100;
5+
6+
var myFunc3 = gpu.createKernel(function(x) {
7+
return x[this.thread.x % 3];
8+
}).setOutput([nValues]);
9+
10+
var input = [1, 2, 3];
11+
myFunc3(input);
12+
13+
var expected = new Float32Array(nValues);
14+
for (var i = 0; i < nValues; i++) {
15+
expected[i] = input[i % 3];
16+
}
17+
QUnit.assert.deepEqual(myFunc3([1, 2, 3]), expected);
18+
// QUnit.assert.ok()
19+
gpu.destroy();
20+
}
21+
22+
QUnit.test('Issue #357 - modulus issue (webgl)', function() {
23+
testModKernel('webgl')
24+
});
25+
26+
QUnit.test('Issue #357 - modulus issue (webgl2)', function() {
27+
testModKernel('webgl2')
28+
})
29+
})();

0 commit comments

Comments
 (0)