Bug fixes

This commit is contained in:
viziionary 2018-08-30 13:51:00 -05:00
parent 6662b1df53
commit de0da06cf4
7 changed files with 62 additions and 61 deletions

View File

@ -5,7 +5,7 @@
* GPU Accelerated JavaScript
*
* @version 1.6.0
* @date Thu Aug 30 2018 13:13:45 GMT-0500 (Central Daylight Time)
* @date Thu Aug 30 2018 13:50:04 GMT-0500 (Central Daylight Time)
*
* @license MIT
* The MIT License

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

@ -5,7 +5,7 @@
* GPU Accelerated JavaScript
*
* @version 1.6.0
* @date Thu Aug 30 2018 13:13:45 GMT-0500 (Central Daylight Time)
* @date Thu Aug 30 2018 13:50:04 GMT-0500 (Central Daylight Time)
*
* @license MIT
* The MIT License

View File

@ -5,7 +5,7 @@
* GPU Accelerated JavaScript
*
* @version 1.6.0
* @date Thu Aug 30 2018 13:13:46 GMT-0500 (Central Daylight Time)
* @date Thu Aug 30 2018 13:50:05 GMT-0500 (Central Daylight Time)
*
* @license MIT
* The MIT License
@ -4863,17 +4863,17 @@ module.exports = function (_KernelBase) {
}
if (!this.hardcodeConstants) {
this.setUniform3iv('user_' + name + 'Dim', dim);
this.setUniform2iv('user_' + name + 'Size', size);
this.setUniform3iv('constants_' + name + 'Dim', dim);
this.setUniform2iv('constants_' + name + 'Size', size);
}
this.setUniform1i('user_' + name + 'BitRatio', bitRatio);
this.setUniform1i('user_' + name, this.constantsLength);
this.setUniform1i('constants_' + name + 'BitRatio', bitRatio);
this.setUniform1i('constants_' + name, this.constantsLength);
break;
}
case 'Integer':
case 'Float':
{
this.setUniform1f('user_' + name, value);
this.setUniform1f('constants_' + name, value);
break;
}
case 'Input':
@ -4905,11 +4905,11 @@ module.exports = function (_KernelBase) {
}
if (!this.hardcodeConstants) {
this.setUniform3iv('user_' + name + 'Dim', _dim4);
this.setUniform2iv('user_' + name + 'Size', _size4);
this.setUniform3iv('constants_' + name + 'Dim', _dim4);
this.setUniform2iv('constants_' + name + 'Size', _size4);
}
this.setUniform1i('user_' + name + 'BitRatio', _bitRatio2);
this.setUniform1i('user_' + name, this.constantsLength);
this.setUniform1i('constants_' + name + 'BitRatio', _bitRatio2);
this.setUniform1i('constants_' + name, this.constantsLength);
break;
}
case 'HTMLImage':
@ -4930,9 +4930,9 @@ module.exports = function (_KernelBase) {
var srcFormat = gl.RGBA;
var srcType = gl.UNSIGNED_BYTE;
gl.texImage2D(gl.TEXTURE_2D, mipLevel, internalFormat, srcFormat, srcType, inputImage);
this.setUniform3iv('user_' + name + 'Dim', _dim5);
this.setUniform2iv('user_' + name + 'Size', _size5);
this.setUniform1i('user_' + name, this.constantsLength);
this.setUniform3iv('constants_' + name + 'Dim', _dim5);
this.setUniform2iv('constants_' + name + 'Size', _size5);
this.setUniform1i('constants_' + name, this.constantsLength);
break;
}
case 'Texture':
@ -4944,10 +4944,10 @@ module.exports = function (_KernelBase) {
gl.activeTexture(gl.TEXTURE0 + this.constantsLength);
gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture);
this.setUniform3iv('user_' + name + 'Dim', _dim6);
this.setUniform2iv('user_' + name + 'Size', _size6);
this.setUniform1i('user_' + name + 'BitRatio', 1);
this.setUniform1i('user_' + name, this.constantsLength);
this.setUniform3iv('constants_' + name + 'Dim', _dim6);
this.setUniform2iv('constants_' + name + 'Size', _size6);
this.setUniform1i('constants_' + name + 'BitRatio', 1);
this.setUniform1i('constants_' + name, this.constantsLength);
break;
}
default:
@ -5147,7 +5147,7 @@ module.exports = function (_KernelBase) {
result.push('const float constants_' + name + ' = ' + parseFloat(_value));
break;
case 'Texture':
result.push('uniform sampler2D constants_' + name, 'uniform ivec2 constants_' + name + 'Size', 'uniform ivec3 constants_' + name + 'Dim');
result.push('uniform sampler2D constants_' + name, 'uniform ivec2 constants_' + name + 'Size', 'uniform ivec3 constants_' + name + 'Dim', 'uniform ivec3 constants_' + name + 'BitRatio');
break;
default:
throw new Error('Unsupported constant ' + name + ' type ' + type);

12
bin/gpu.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -923,17 +923,17 @@ module.exports = function (_KernelBase) {
}
if (!this.hardcodeConstants) {
this.setUniform3iv('user_' + name + 'Dim', dim);
this.setUniform2iv('user_' + name + 'Size', size);
this.setUniform3iv('constants_' + name + 'Dim', dim);
this.setUniform2iv('constants_' + name + 'Size', size);
}
this.setUniform1i('user_' + name + 'BitRatio', bitRatio);
this.setUniform1i('user_' + name, this.constantsLength);
this.setUniform1i('constants_' + name + 'BitRatio', bitRatio);
this.setUniform1i('constants_' + name, this.constantsLength);
break;
}
case 'Integer':
case 'Float':
{
this.setUniform1f('user_' + name, value);
this.setUniform1f('constants_' + name, value);
break;
}
case 'Input':
@ -965,11 +965,11 @@ module.exports = function (_KernelBase) {
}
if (!this.hardcodeConstants) {
this.setUniform3iv('user_' + name + 'Dim', _dim4);
this.setUniform2iv('user_' + name + 'Size', _size4);
this.setUniform3iv('constants_' + name + 'Dim', _dim4);
this.setUniform2iv('constants_' + name + 'Size', _size4);
}
this.setUniform1i('user_' + name + 'BitRatio', _bitRatio2);
this.setUniform1i('user_' + name, this.constantsLength);
this.setUniform1i('constants_' + name + 'BitRatio', _bitRatio2);
this.setUniform1i('constants_' + name, this.constantsLength);
break;
}
case 'HTMLImage':
@ -991,9 +991,9 @@ module.exports = function (_KernelBase) {
var srcFormat = gl.RGBA; // format of data we are supplying
var srcType = gl.UNSIGNED_BYTE; // type of data we are supplying
gl.texImage2D(gl.TEXTURE_2D, mipLevel, internalFormat, srcFormat, srcType, inputImage);
this.setUniform3iv('user_' + name + 'Dim', _dim5);
this.setUniform2iv('user_' + name + 'Size', _size5);
this.setUniform1i('user_' + name, this.constantsLength);
this.setUniform3iv('constants_' + name + 'Dim', _dim5);
this.setUniform2iv('constants_' + name + 'Size', _size5);
this.setUniform1i('constants_' + name, this.constantsLength);
break;
}
case 'Texture':
@ -1005,10 +1005,10 @@ module.exports = function (_KernelBase) {
gl.activeTexture(gl.TEXTURE0 + this.constantsLength);
gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture);
this.setUniform3iv('user_' + name + 'Dim', _dim6);
this.setUniform2iv('user_' + name + 'Size', _size6);
this.setUniform1i('user_' + name + 'BitRatio', 1); // aways float32
this.setUniform1i('user_' + name, this.constantsLength);
this.setUniform3iv('constants_' + name + 'Dim', _dim6);
this.setUniform2iv('constants_' + name + 'Size', _size6);
this.setUniform1i('constants_' + name + 'BitRatio', 1); // aways float32
this.setUniform1i('constants_' + name, this.constantsLength);
break;
}
default:
@ -1345,7 +1345,7 @@ module.exports = function (_KernelBase) {
result.push('const float constants_' + name + ' = ' + parseFloat(_value));
break;
case 'Texture':
result.push('uniform sampler2D constants_' + name, 'uniform ivec2 constants_' + name + 'Size', 'uniform ivec3 constants_' + name + 'Dim');
result.push('uniform sampler2D constants_' + name, 'uniform ivec2 constants_' + name + 'Size', 'uniform ivec3 constants_' + name + 'Dim', 'uniform ivec3 constants_' + name + 'BitRatio');
break;
default:
throw new Error('Unsupported constant ' + name + ' type ' + type);

View File

@ -886,17 +886,17 @@ module.exports = class WebGLKernel extends KernelBase {
}
if (!this.hardcodeConstants) {
this.setUniform3iv(`user_${name}Dim`, dim);
this.setUniform2iv(`user_${name}Size`, size);
this.setUniform3iv(`constants_${name}Dim`, dim);
this.setUniform2iv(`constants_${name}Size`, size);
}
this.setUniform1i(`user_${name}BitRatio`, bitRatio);
this.setUniform1i(`user_${name}`, this.constantsLength);
this.setUniform1i(`constants_${name}BitRatio`, bitRatio);
this.setUniform1i(`constants_${name}`, this.constantsLength);
break;
}
case 'Integer':
case 'Float':
{
this.setUniform1f(`user_${name}`, value);
this.setUniform1f(`constants_${name}`, value);
break;
}
case 'Input':
@ -928,11 +928,11 @@ module.exports = class WebGLKernel extends KernelBase {
}
if (!this.hardcodeConstants) {
this.setUniform3iv(`user_${name}Dim`, dim);
this.setUniform2iv(`user_${name}Size`, size);
this.setUniform3iv(`constants_${name}Dim`, dim);
this.setUniform2iv(`constants_${name}Size`, size);
}
this.setUniform1i(`user_${name}BitRatio`, bitRatio);
this.setUniform1i(`user_${name}`, this.constantsLength);
this.setUniform1i(`constants_${name}BitRatio`, bitRatio);
this.setUniform1i(`constants_${name}`, this.constantsLength);
break;
}
case 'HTMLImage':
@ -959,9 +959,9 @@ module.exports = class WebGLKernel extends KernelBase {
srcFormat,
srcType,
inputImage);
this.setUniform3iv(`user_${name}Dim`, dim);
this.setUniform2iv(`user_${name}Size`, size);
this.setUniform1i(`user_${name}`, this.constantsLength);
this.setUniform3iv(`constants_${name}Dim`, dim);
this.setUniform2iv(`constants_${name}Size`, size);
this.setUniform1i(`constants_${name}`, this.constantsLength);
break;
}
case 'Texture':
@ -973,10 +973,10 @@ module.exports = class WebGLKernel extends KernelBase {
gl.activeTexture(gl.TEXTURE0 + this.constantsLength);
gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture);
this.setUniform3iv(`user_${name}Dim`, dim);
this.setUniform2iv(`user_${name}Size`, size);
this.setUniform1i(`user_${name}BitRatio`, 1); // aways float32
this.setUniform1i(`user_${name}`, this.constantsLength);
this.setUniform3iv(`constants_${name}Dim`, dim);
this.setUniform2iv(`constants_${name}Size`, size);
this.setUniform1i(`constants_${name}BitRatio`, 1); // aways float32
this.setUniform1i(`constants_${name}`, this.constantsLength);
break;
}
default:
@ -1329,7 +1329,8 @@ module.exports = class WebGLKernel extends KernelBase {
result.push(
`uniform sampler2D constants_${ name }`,
`uniform ivec2 constants_${ name }Size`,
`uniform ivec3 constants_${ name }Dim`
`uniform ivec3 constants_${ name }Dim`,
`uniform ivec3 constants_${ name }BitRatio`
);
break;
default:

View File

@ -10,7 +10,7 @@ console.log(texture);
const useTexture = gpu
.createKernel(
function() {
return constants.texture[this.thread.x];
return this.constants.texture[this.thread.x];
},
{
constants: { texture }