mirror of
https://github.com/gpujs/gpu.js.git
synced 2026-01-18 16:04:10 +00:00
process images in reverse y on cpu
bump version number
This commit is contained in:
parent
cfd3c777d9
commit
33a7dca5df
@ -4,8 +4,8 @@
|
||||
*
|
||||
* GPU Accelerated JavaScript
|
||||
*
|
||||
* @version 1.4.0
|
||||
* @date Tue Jun 05 2018 20:28:34 GMT-0400 (EDT)
|
||||
* @version 1.4.1
|
||||
* @date Fri Jun 08 2018 16:41:34 GMT-0400 (EDT)
|
||||
*
|
||||
* @license MIT
|
||||
* The MIT License
|
||||
|
||||
4
bin/gpu-core.min.js
vendored
4
bin/gpu-core.min.js
vendored
@ -4,8 +4,8 @@
|
||||
*
|
||||
* GPU Accelerated JavaScript
|
||||
*
|
||||
* @version 1.4.0
|
||||
* @date Tue Jun 05 2018 20:28:34 GMT-0400 (EDT)
|
||||
* @version 1.4.1
|
||||
* @date Fri Jun 08 2018 16:41:34 GMT-0400 (EDT)
|
||||
*
|
||||
* @license MIT
|
||||
* The MIT License
|
||||
|
||||
47
bin/gpu.js
47
bin/gpu.js
@ -4,8 +4,8 @@
|
||||
*
|
||||
* GPU Accelerated JavaScript
|
||||
*
|
||||
* @version 1.4.0
|
||||
* @date Tue Jun 05 2018 20:28:35 GMT-0400 (EDT)
|
||||
* @version 1.4.1
|
||||
* @date Fri Jun 08 2018 16:41:35 GMT-0400 (EDT)
|
||||
*
|
||||
* @license MIT
|
||||
* The MIT License
|
||||
@ -1033,7 +1033,7 @@ module.exports = function (_KernelBase) {
|
||||
var pixelsData = this._canvasCtx.getImageData(0, 0, image.width, image.height).data;
|
||||
var imageArray = new Array(image.height);
|
||||
var index = 0;
|
||||
for (var y = 0; y < image.height; y++) {
|
||||
for (var y = image.height; y >= 0; y--) {
|
||||
imageArray[y] = new Array(image.width);
|
||||
for (var x = 0; x < image.width; x++) {
|
||||
imageArray[y][x] = [pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255];
|
||||
@ -3492,7 +3492,8 @@ module.exports = function (_KernelBase) {
|
||||
this.setUniform1i('user_' + name, this.argumentsLength);
|
||||
break;
|
||||
}
|
||||
case 'Number':
|
||||
case 'Integer':
|
||||
case 'Float':
|
||||
{
|
||||
this.setUniform1f('user_' + name, value);
|
||||
break;
|
||||
@ -3687,15 +3688,15 @@ module.exports = function (_KernelBase) {
|
||||
}, paramDim);
|
||||
|
||||
result.push('uniform highp sampler2D user_' + paramName, 'highp vec2 user_' + paramName + 'Size = vec2(' + paramSize[0] + '.0, ' + paramSize[1] + '.0)', 'highp vec3 user_' + paramName + 'Dim = vec3(' + paramDim[0] + '.0, ' + paramDim[1] + '.0, ' + paramDim[2] + '.0)');
|
||||
} else if (paramType === 'Number' && Number.isInteger(param)) {
|
||||
} else if (paramType === 'Integer') {
|
||||
result.push('highp float user_' + paramName + ' = ' + param + '.0');
|
||||
} else if (paramType === 'Number') {
|
||||
} else if (paramType === 'Float') {
|
||||
result.push('highp float user_' + paramName + ' = ' + param);
|
||||
}
|
||||
} else {
|
||||
if (paramType === 'Array' || paramType === 'Texture' || paramType === 'Input' || paramType === 'HTMLImage') {
|
||||
result.push('uniform highp sampler2D user_' + paramName, 'uniform highp vec2 user_' + paramName + 'Size', 'uniform highp vec3 user_' + paramName + 'Dim');
|
||||
} else if (paramType === 'Number') {
|
||||
} else if (paramType === 'Integer' || paramType === 'Float') {
|
||||
result.push('uniform highp float user_' + paramName);
|
||||
} else {
|
||||
throw new Error('Param type ' + paramType + ' not supported in WebGL, only WebGL2');
|
||||
@ -3713,12 +3714,17 @@ module.exports = function (_KernelBase) {
|
||||
if (this.constants) {
|
||||
for (var name in this.constants) {
|
||||
if (!this.constants.hasOwnProperty(name)) continue;
|
||||
var value = parseFloat(this.constants[name]);
|
||||
|
||||
if (Number.isInteger(value)) {
|
||||
result.push('const float constants_' + name + ' = ' + parseInt(value) + '.0');
|
||||
} else {
|
||||
result.push('const float constants_' + name + ' = ' + parseFloat(value));
|
||||
var value = this.constants[name];
|
||||
var type = utils.getArgumentType(value);
|
||||
switch (type) {
|
||||
case 'Integer':
|
||||
result.push('const float constants_' + name + ' = ' + parseInt(value) + '.0');
|
||||
break;
|
||||
case 'Float':
|
||||
result.push('const float constants_' + name + ' = ' + parseFloat(value));
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unsupported constant ' + name + ' type ' + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3736,7 +3742,6 @@ module.exports = function (_KernelBase) {
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
result.push('highp float ' + names[i] + ' = 0.0');
|
||||
}
|
||||
|
||||
} else {
|
||||
result.push('highp float kernelResult = 0.0');
|
||||
}
|
||||
@ -5119,7 +5124,8 @@ module.exports = function (_WebGLKernel) {
|
||||
this.setUniform1i('user_' + name, this.argumentsLength);
|
||||
break;
|
||||
}
|
||||
case 'Number':
|
||||
case 'Integer':
|
||||
case 'Float':
|
||||
{
|
||||
this.setUniform1f('user_' + name, value);
|
||||
break;
|
||||
@ -5276,9 +5282,9 @@ module.exports = function (_WebGLKernel) {
|
||||
}, paramDim);
|
||||
|
||||
result.push('uniform highp sampler2D user_' + paramName, 'highp vec2 user_' + paramName + 'Size = vec2(' + paramSize[0] + '.0, ' + paramSize[1] + '.0)', 'highp vec3 user_' + paramName + 'Dim = vec3(' + paramDim[0] + '.0, ' + paramDim[1] + '.0, ' + paramDim[2] + '.0)');
|
||||
} else if (paramType === 'Number' && Number.isInteger(param)) {
|
||||
} else if (paramType === 'Integer') {
|
||||
result.push('highp float user_' + paramName + ' = ' + param + '.0');
|
||||
} else if (paramType === 'Number') {
|
||||
} else if (paramType === 'Float') {
|
||||
result.push('highp float user_' + paramName + ' = ' + param);
|
||||
}
|
||||
} else {
|
||||
@ -5286,7 +5292,7 @@ module.exports = function (_WebGLKernel) {
|
||||
result.push('uniform highp sampler2D user_' + paramName, 'uniform highp vec2 user_' + paramName + 'Size', 'uniform highp vec3 user_' + paramName + 'Dim');
|
||||
} else if (paramType === 'HTMLImageArray') {
|
||||
result.push('uniform highp sampler2DArray user_' + paramName, 'uniform highp vec2 user_' + paramName + 'Size', 'uniform highp vec3 user_' + paramName + 'Dim');
|
||||
} else if (paramType === 'Number') {
|
||||
} else if (paramType === 'Integer' || paramType === 'Float') {
|
||||
result.push('uniform highp float user_' + paramName);
|
||||
}
|
||||
}
|
||||
@ -6201,7 +6207,10 @@ var Utils = function (_UtilsCore) {
|
||||
}
|
||||
return 'Array';
|
||||
} else if (typeof arg === 'number') {
|
||||
return 'Number';
|
||||
if (Number.isInteger(arg)) {
|
||||
return 'Integer';
|
||||
}
|
||||
return 'Float';
|
||||
} else if (arg instanceof Texture) {
|
||||
return 'Texture';
|
||||
} else if (arg instanceof Input) {
|
||||
|
||||
18
bin/gpu.min.js
vendored
18
bin/gpu.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/backend/cpu/kernel.js
vendored
2
dist/backend/cpu/kernel.js
vendored
@ -354,7 +354,7 @@ module.exports = function (_KernelBase) {
|
||||
var pixelsData = this._canvasCtx.getImageData(0, 0, image.width, image.height).data;
|
||||
var imageArray = new Array(image.height);
|
||||
var index = 0;
|
||||
for (var y = 0; y < image.height; y++) {
|
||||
for (var y = image.height; y >= 0; y--) {
|
||||
imageArray[y] = new Array(image.width);
|
||||
for (var x = 0; x < image.width; x++) {
|
||||
imageArray[y][x] = [pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255];
|
||||
|
||||
36
dist/backend/web-gl/kernel.js
vendored
36
dist/backend/web-gl/kernel.js
vendored
@ -729,7 +729,8 @@ module.exports = function (_KernelBase) {
|
||||
this.setUniform1i('user_' + name, this.argumentsLength);
|
||||
break;
|
||||
}
|
||||
case 'Number':
|
||||
case 'Integer':
|
||||
case 'Float':
|
||||
{
|
||||
this.setUniform1f('user_' + name, value);
|
||||
break;
|
||||
@ -1031,15 +1032,15 @@ module.exports = function (_KernelBase) {
|
||||
}, paramDim);
|
||||
|
||||
result.push('uniform highp sampler2D user_' + paramName, 'highp vec2 user_' + paramName + 'Size = vec2(' + paramSize[0] + '.0, ' + paramSize[1] + '.0)', 'highp vec3 user_' + paramName + 'Dim = vec3(' + paramDim[0] + '.0, ' + paramDim[1] + '.0, ' + paramDim[2] + '.0)');
|
||||
} else if (paramType === 'Number' && Number.isInteger(param)) {
|
||||
} else if (paramType === 'Integer') {
|
||||
result.push('highp float user_' + paramName + ' = ' + param + '.0');
|
||||
} else if (paramType === 'Number') {
|
||||
} else if (paramType === 'Float') {
|
||||
result.push('highp float user_' + paramName + ' = ' + param);
|
||||
}
|
||||
} else {
|
||||
if (paramType === 'Array' || paramType === 'Texture' || paramType === 'Input' || paramType === 'HTMLImage') {
|
||||
result.push('uniform highp sampler2D user_' + paramName, 'uniform highp vec2 user_' + paramName + 'Size', 'uniform highp vec3 user_' + paramName + 'Dim');
|
||||
} else if (paramType === 'Number') {
|
||||
} else if (paramType === 'Integer' || paramType === 'Float') {
|
||||
result.push('uniform highp float user_' + paramName);
|
||||
} else {
|
||||
throw new Error('Param type ' + paramType + ' not supported in WebGL, only WebGL2');
|
||||
@ -1063,12 +1064,17 @@ module.exports = function (_KernelBase) {
|
||||
if (this.constants) {
|
||||
for (var name in this.constants) {
|
||||
if (!this.constants.hasOwnProperty(name)) continue;
|
||||
var value = parseFloat(this.constants[name]);
|
||||
|
||||
if (Number.isInteger(value)) {
|
||||
result.push('const float constants_' + name + ' = ' + parseInt(value) + '.0');
|
||||
} else {
|
||||
result.push('const float constants_' + name + ' = ' + parseFloat(value));
|
||||
var value = this.constants[name];
|
||||
var type = utils.getArgumentType(value);
|
||||
switch (type) {
|
||||
case 'Integer':
|
||||
result.push('const float constants_' + name + ' = ' + parseInt(value) + '.0');
|
||||
break;
|
||||
case 'Float':
|
||||
result.push('const float constants_' + name + ' = ' + parseFloat(value));
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unsupported constant ' + name + ' type ' + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1096,16 +1102,6 @@ module.exports = function (_KernelBase) {
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
result.push('highp float ' + names[i] + ' = 0.0');
|
||||
}
|
||||
|
||||
/* this is v2 prep
|
||||
result.push('highp float kernelResult = 0.0');
|
||||
result.push('layout(location = 0) out highp float fradData0 = 0.0');
|
||||
for (let i = 0; i < names.length; i++) {
|
||||
result.push(
|
||||
`highp float ${ names[i] } = 0.0`,
|
||||
`layout(location = ${ i + 1 }) out highp float fragData${ i + 1 } = 0.0`
|
||||
);
|
||||
}*/
|
||||
} else {
|
||||
result.push('highp float kernelResult = 0.0');
|
||||
}
|
||||
|
||||
9
dist/backend/web-gl2/kernel.js
vendored
9
dist/backend/web-gl2/kernel.js
vendored
@ -318,7 +318,8 @@ module.exports = function (_WebGLKernel) {
|
||||
this.setUniform1i('user_' + name, this.argumentsLength);
|
||||
break;
|
||||
}
|
||||
case 'Number':
|
||||
case 'Integer':
|
||||
case 'Float':
|
||||
{
|
||||
this.setUniform1f('user_' + name, value);
|
||||
break;
|
||||
@ -510,9 +511,9 @@ module.exports = function (_WebGLKernel) {
|
||||
}, paramDim);
|
||||
|
||||
result.push('uniform highp sampler2D user_' + paramName, 'highp vec2 user_' + paramName + 'Size = vec2(' + paramSize[0] + '.0, ' + paramSize[1] + '.0)', 'highp vec3 user_' + paramName + 'Dim = vec3(' + paramDim[0] + '.0, ' + paramDim[1] + '.0, ' + paramDim[2] + '.0)');
|
||||
} else if (paramType === 'Number' && Number.isInteger(param)) {
|
||||
} else if (paramType === 'Integer') {
|
||||
result.push('highp float user_' + paramName + ' = ' + param + '.0');
|
||||
} else if (paramType === 'Number') {
|
||||
} else if (paramType === 'Float') {
|
||||
result.push('highp float user_' + paramName + ' = ' + param);
|
||||
}
|
||||
} else {
|
||||
@ -520,7 +521,7 @@ module.exports = function (_WebGLKernel) {
|
||||
result.push('uniform highp sampler2D user_' + paramName, 'uniform highp vec2 user_' + paramName + 'Size', 'uniform highp vec3 user_' + paramName + 'Dim');
|
||||
} else if (paramType === 'HTMLImageArray') {
|
||||
result.push('uniform highp sampler2DArray user_' + paramName, 'uniform highp vec2 user_' + paramName + 'Size', 'uniform highp vec3 user_' + paramName + 'Dim');
|
||||
} else if (paramType === 'Number') {
|
||||
} else if (paramType === 'Integer' || paramType === 'Float') {
|
||||
result.push('uniform highp float user_' + paramName);
|
||||
}
|
||||
}
|
||||
|
||||
7
dist/core/utils.js
vendored
7
dist/core/utils.js
vendored
@ -314,7 +314,7 @@ var Utils = function (_UtilsCore) {
|
||||
*
|
||||
* @param {Object} arg - The argument object to evaluate type
|
||||
*
|
||||
* @returns {String} Argument type Array/Number/Texture/Unknown
|
||||
* @returns {String} Argument type Array/Number/Float/Texture/Unknown
|
||||
*
|
||||
*/
|
||||
|
||||
@ -327,7 +327,10 @@ var Utils = function (_UtilsCore) {
|
||||
}
|
||||
return 'Array';
|
||||
} else if (typeof arg === 'number') {
|
||||
return 'Number';
|
||||
if (Number.isInteger(arg)) {
|
||||
return 'Integer';
|
||||
}
|
||||
return 'Float';
|
||||
} else if (arg instanceof Texture) {
|
||||
return 'Texture';
|
||||
} else if (arg instanceof Input) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gpu.js",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"description": "GPU Accelerated JavaScript",
|
||||
"main": "./dist/index.js",
|
||||
"directories": {
|
||||
|
||||
@ -384,7 +384,7 @@ ${ this.subKernelOutputVariableNames === null
|
||||
const pixelsData = this._canvasCtx.getImageData(0, 0, image.width, image.height).data;
|
||||
const imageArray = new Array(image.height);
|
||||
let index = 0;
|
||||
for (let y = 0; y < image.height; y++) {
|
||||
for (let y = image.height; y >= 0; y--) {
|
||||
imageArray[y] = new Array(image.width);
|
||||
for (let x = 0; x < image.width; x++) {
|
||||
imageArray[y][x] = [pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255, pixelsData[index++] / 255];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user