Merge pull request #271 from gpujs/270-falsey

fix, test, bump version number, and make.
This commit is contained in:
Robert Plummer 2018-03-01 15:58:18 -05:00 committed by GitHub
commit 71fa13b6bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 31 additions and 27 deletions

View File

@ -4,8 +4,8 @@
*
* GPU Accelerated JavaScript
*
* @version 1.0.3
* @date Wed Feb 28 2018 22:04:12 GMT-0500 (EST)
* @version 1.0.4
* @date Thu Mar 01 2018 15:56:51 GMT-0500 (EST)
*
* @license MIT
* The MIT License

4
bin/gpu-core.min.js vendored
View File

@ -4,8 +4,8 @@
*
* GPU Accelerated JavaScript
*
* @version 1.0.3
* @date Wed Feb 28 2018 22:04:12 GMT-0500 (EST)
* @version 1.0.4
* @date Thu Mar 01 2018 15:56:51 GMT-0500 (EST)
*
* @license MIT
* The MIT License

View File

@ -4,8 +4,8 @@
*
* GPU Accelerated JavaScript
*
* @version 1.0.3
* @date Wed Feb 28 2018 22:04:13 GMT-0500 (EST)
* @version 1.0.4
* @date Thu Mar 01 2018 15:56:51 GMT-0500 (EST)
*
* @license MIT
* The MIT License
@ -3211,12 +3211,10 @@ module.exports = function (_KernelBase) {
}, {
key: 'getUniformLocation',
value: function getUniformLocation(name) {
var location = this.programUniformLocationCache[name];
if (!location) {
location = this._webGl.getUniformLocation(this.program, name);
this.programUniformLocationCache[name] = location;
if (this.programUniformLocationCache.hasOwnProperty(name)) {
return this.programUniformLocationCache[name];
}
return location;
return this.programUniformLocationCache[name] = this._webGl.getUniformLocation(this.program, name);
}

10
bin/gpu.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -571,12 +571,10 @@ module.exports = function (_KernelBase) {
}, {
key: 'getUniformLocation',
value: function getUniformLocation(name) {
var location = this.programUniformLocationCache[name];
if (!location) {
location = this._webGl.getUniformLocation(this.program, name);
this.programUniformLocationCache[name] = location;
if (this.programUniformLocationCache.hasOwnProperty(name)) {
return this.programUniformLocationCache[name];
}
return location;
return this.programUniformLocationCache[name] = this._webGl.getUniformLocation(this.program, name);
}
/**

View File

@ -1,6 +1,6 @@
{
"name": "gpu.js",
"version": "1.0.3",
"version": "1.0.4",
"description": "GPU Accelerated JavaScript",
"main": "./dist/index.js",
"directories": {

View File

@ -532,12 +532,10 @@ module.exports = class WebGLKernel extends KernelBase {
*
*/
getUniformLocation(name) {
let location = this.programUniformLocationCache[name];
if (!location) {
location = this._webGl.getUniformLocation(this.program, name);
this.programUniformLocationCache[name] = location;
if (this.programUniformLocationCache.hasOwnProperty(name)) {
return this.programUniformLocationCache[name];
}
return location;
return this.programUniformLocationCache[name] = this._webGl.getUniformLocation(this.program, name);
}
/**

View File

@ -57,5 +57,6 @@
<script src="../src/issues/259-atan2.js"></script>
<script src="../src/issues/263-to-string.js"></script>
<script src="../src/issues/267-immutable-sub-kernels.js"></script>
<script src="../src/issues/270-cache.js"></script>
</body>
</html>

View File

@ -0,0 +1,9 @@
QUnit.test('Issue #270 WebGlKernel getUniformLocation caches falsey - gpu', () => {
const kernel = new GPU.WebGLKernel('', {});
kernel.programUniformLocationCache.test = false;
kernel._webGl = {};
kernel._webGl.getUniformLocation = () => {
throw new Error('tried to get getUniformLocation when falsey');
};
QUnit.assert.equal(kernel.getUniformLocation('test'), false);
});