(function (GPU) { function clone(obj) { if(obj === null || typeof(obj) !== 'object' || 'isActiveClone' in obj) return obj; var temp = obj.constructor(); // changed for(var key in obj) { if(Object.prototype.hasOwnProperty.call(obj, key)) { obj.isActiveClone = null; temp[key] = clone(obj[key]); delete obj.isActiveClone; } } return temp; } function getArgumentType(arg) { if (Array.isArray(arg)) { return 'Array'; } else if (typeof arg == "number") { return 'Number'; } else if (arg instanceof GPUTexture) { return 'Texture'; } else { return 'Unknown'; } } /// JS fallback transformation, basically pure JS /// /// @param inputFunction The calling to perform the conversion /// @param opt The parameter object /// /// @returns callable function if converted, else returns null GPU.prototype._backendFallback = function(kernel, opt) { var gpu = this; function ret() { if (!opt.dimensions || opt.dimensions.length === 0) { if (arguments.length != 1) { throw "Auto dimensions only supported for kernels with only one input"; } var argType = getArgumentType(arguments[0]); if (argType == "Array") { opt.dimensions = getDimensions(argType); } else if (argType == "Texture") { opt.dimensions = arguments[0].dimensions; } else { throw "Auto dimensions not supported for input type: " + argType; } } var kernelArgs = []; for (var i=0; i