Skip to content

Commit

Permalink
fix: Ensure arguments are targeted correctly
Browse files Browse the repository at this point in the history
fix: Added a missing jsdoc
  • Loading branch information
robertleeplummerjr authored and ammyk9 committed Aug 6, 2024
1 parent e8a6f6d commit 2d51ed6
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 242 deletions.
7 changes: 3 additions & 4 deletions dist/gpu-browser-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*
* GPU Accelerated JavaScript
*
* @version 2.10.5
* @date Thu Nov 12 2020 14:04:03 GMT-0500 (Eastern Standard Time)
* @version 2.10.6
* @date Wed Dec 02 2020 15:14:25 GMT-0500 (Eastern Standard Time)
*
* @license MIT
* The MIT License
Expand Down Expand Up @@ -2555,7 +2555,6 @@ class FunctionBuilder {
module.exports = {
FunctionBuilder
};

},{}],9:[function(require,module,exports){
const acorn = require('acorn');
const { utils } = require('../utils');
Expand Down Expand Up @@ -10381,7 +10380,7 @@ class WebGLKernel extends GLKernel {
return this.createTexture();
};
const onRequestIndex = () => {
return textureIndexes++;
return this.constantTextureCount + textureIndexes++;
};
const onUpdateValueMismatch = (constructor) => {
this.switchKernels({
Expand Down
6 changes: 3 additions & 3 deletions dist/gpu-browser-core.min.js

Large diffs are not rendered by default.

295 changes: 69 additions & 226 deletions dist/gpu-browser.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/gpu-browser.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gpu.js",
"version": "2.10.5",
"version": "2.10.6",
"description": "GPU Accelerated JavaScript",
"engines": {
"node": ">=8.0.0"
Expand Down
10 changes: 9 additions & 1 deletion src/backend/web-gl/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ class WebGLKernel extends GLKernel {
return testContext.getParameter(testContext.MAX_TEXTURE_SIZE);
}

/**
*
* @param type
* @param dynamic
* @param precision
* @param value
* @returns {KernelValue}
*/
static lookupKernelValueType(type, dynamic, precision, value) {
return lookupKernelValueType(type, dynamic, precision, value);
}
Expand Down Expand Up @@ -364,7 +372,7 @@ class WebGLKernel extends GLKernel {
return this.createTexture();
};
const onRequestIndex = () => {
return textureIndexes++;
return this.constantTextureCount + textureIndexes++;
};
const onUpdateValueMismatch = (constructor) => {
this.switchKernels({
Expand Down
1 change: 1 addition & 0 deletions test/all.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
<script type="module" src="issues/567-wrong-modulus.js"></script>
<script type="module" src="issues/585-inaccurate-lookups.js"></script>
<script type="module" src="issues/586-unable-to-resize.js"></script>
<script type="module" src="issues/608-rewritten-arrays.js"></script>
<script type="module" src="issues/91-create-kernel-map-array.js"></script>
<script type="module" src="issues/96-param-names.js"></script>
<script type="module" src="features/to-string/as-file.js"></script>
Expand Down
77 changes: 77 additions & 0 deletions test/issues/608-rewritten-arrays.js
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');
});

0 comments on commit 2d51ed6

Please sign in to comment.