|
5 | 5 | * GPU Accelerated JavaScript
|
6 | 6 | *
|
7 | 7 | * @version 1.2.0
|
8 |
| - * @date Thu Mar 08 2018 14:35:39 GMT-0500 (EST) |
| 8 | + * @date Thu Mar 08 2018 17:26:16 GMT-0500 (EST) |
9 | 9 | *
|
10 | 10 | * @license MIT
|
11 | 11 | * The MIT License
|
@@ -927,7 +927,16 @@ module.exports = function (_KernelBase) {
|
927 | 927 | }
|
928 | 928 |
|
929 | 929 | var prototypes = builder.getPrototypes();
|
930 |
| - var kernel = prototypes.shift(); |
| 930 | + var kernel = null; |
| 931 | + if (prototypes.length > 1) { |
| 932 | + prototypes = prototypes.filter(function (fn) { |
| 933 | + if (/^function/.test(fn)) return fn; |
| 934 | + kernel = fn; |
| 935 | + return false; |
| 936 | + }); |
| 937 | + } else { |
| 938 | + kernel = prototypes.shift(); |
| 939 | + } |
931 | 940 | var kernelString = this._kernelString = '\n\t\tvar LOOP_MAX = ' + this._getLoopMaxString() + ';\n\t\tvar _this = this;\n ' + (this.subKernelOutputVariableNames === null ? '' : this.subKernelOutputVariableNames.map(function (name) {
|
932 | 941 | return ' var ' + name + ' = null;\n';
|
933 | 942 | }).join('')) + '\n return function (' + this.paramNames.map(function (paramName) {
|
@@ -4303,19 +4312,25 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
|
4303 | 4312 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
4304 | 4313 |
|
4305 | 4314 | var WebGLRunner = require('../web-gl/runner');
|
| 4315 | +var WebGL2FunctionBuilder = require('./function-builder'); |
| 4316 | +var WebGL2Kernel = require('./kernel'); |
4306 | 4317 |
|
4307 | 4318 | module.exports = function (_WebGLRunner) {
|
4308 |
| - _inherits(WebGL2Runner, _WebGLRunner); |
| 4319 | + _inherits(WebGL2Runner, _WebGLRunner); |
4309 | 4320 |
|
4310 |
| - function WebGL2Runner() { |
4311 |
| - _classCallCheck(this, WebGL2Runner); |
| 4321 | + function WebGL2Runner(settings) { |
| 4322 | + _classCallCheck(this, WebGL2Runner); |
4312 | 4323 |
|
4313 |
| - return _possibleConstructorReturn(this, (WebGL2Runner.__proto__ || Object.getPrototypeOf(WebGL2Runner)).apply(this, arguments)); |
4314 |
| - } |
| 4324 | + var _this = _possibleConstructorReturn(this, (WebGL2Runner.__proto__ || Object.getPrototypeOf(WebGL2Runner)).call(this, new WebGL2FunctionBuilder(), settings)); |
4315 | 4325 |
|
4316 |
| - return WebGL2Runner; |
| 4326 | + _this.Kernel = WebGL2Kernel; |
| 4327 | + _this.kernel = null; |
| 4328 | + return _this; |
| 4329 | + } |
| 4330 | + |
| 4331 | + return WebGL2Runner; |
4317 | 4332 | }(WebGLRunner);
|
4318 |
| -},{"../web-gl/runner":15}],23:[function(require,module,exports){ |
| 4333 | +},{"../web-gl/runner":15,"./function-builder":19,"./kernel":21}],23:[function(require,module,exports){ |
4319 | 4334 | "use strict";
|
4320 | 4335 |
|
4321 | 4336 | module.exports = "#version 300 es\n__HEADER__;\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nconst float LOOP_MAX = __LOOP_MAX__;\n#define EPSILON 0.0000001;\n\n__CONSTANTS__;\n\nin highp vec2 vTexCoord;\n\nvec2 integerMod(vec2 x, float y) {\n vec2 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec3 integerMod(vec3 x, float y) {\n vec3 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec4 integerMod(vec4 x, vec4 y) {\n vec4 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nhighp float integerMod(highp float x, highp float y) {\n highp float res = floor(mod(x, y));\n return res * (res > floor(y) - 1.0 ? 0.0 : 1.0);\n}\n\nhighp int integerMod(highp int x, highp int y) {\n return int(integerMod(float(x), float(y)));\n}\n\n// Here be dragons!\n// DO NOT OPTIMIZE THIS CODE\n// YOU WILL BREAK SOMETHING ON SOMEBODY'S MACHINE\n// LEAVE IT AS IT IS, LEST YOU WASTE YOUR OWN TIME\nconst vec2 MAGIC_VEC = vec2(1.0, -256.0);\nconst vec4 SCALE_FACTOR = vec4(1.0, 256.0, 65536.0, 0.0);\nconst vec4 SCALE_FACTOR_INV = vec4(1.0, 0.00390625, 0.0000152587890625, 0.0); // 1, 1/256, 1/65536\nhighp float decode32(highp vec4 rgba) {\n __DECODE32_ENDIANNESS__;\n rgba *= 255.0;\n vec2 gte128;\n gte128.x = rgba.b >= 128.0 ? 1.0 : 0.0;\n gte128.y = rgba.a >= 128.0 ? 1.0 : 0.0;\n float exponent = 2.0 * rgba.a - 127.0 + dot(gte128, MAGIC_VEC);\n float res = exp2(round(exponent));\n rgba.b = rgba.b - 128.0 * gte128.x;\n res = dot(rgba, SCALE_FACTOR) * exp2(round(exponent-23.0)) + res;\n res *= gte128.y * -2.0 + 1.0;\n return res;\n}\n\nhighp vec4 encode32(highp float f) {\n highp float F = abs(f);\n highp float sign = f < 0.0 ? 1.0 : 0.0;\n highp float exponent = floor(log2(F));\n highp float mantissa = (exp2(-exponent) * F);\n // exponent += floor(log2(mantissa));\n vec4 rgba = vec4(F * exp2(23.0-exponent)) * SCALE_FACTOR_INV;\n rgba.rg = integerMod(rgba.rg, 256.0);\n rgba.b = integerMod(rgba.b, 128.0);\n rgba.a = exponent*0.5 + 63.5;\n rgba.ba += vec2(integerMod(exponent+127.0, 2.0), sign) * 128.0;\n rgba = floor(rgba);\n rgba *= 0.003921569; // 1/255\n __ENCODE32_ENDIANNESS__;\n return rgba;\n}\n// Dragons end here\n\nhighp float index;\nhighp vec3 threadId;\n\nhighp vec3 indexTo3D(highp float idx, highp vec3 texDim) {\n highp float z = floor(idx / (texDim.x * texDim.y));\n idx -= z * texDim.x * texDim.y;\n highp float y = floor(idx / texDim.x);\n highp float x = integerMod(idx, texDim.x);\n return vec3(x, y, z);\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float z, highp float y, highp float x) {\n highp vec3 xyz = vec3(x, y, z);\n xyz = floor(xyz + 0.5);\n __GET_WRAPAROUND__;\n highp float index = round(xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z));\n __GET_TEXTURE_CHANNEL__;\n highp float w = round(texSize.x);\n vec2 st = vec2(integerMod(index, w), float(int(index) / int(w))) + 0.5;\n __GET_TEXTURE_INDEX__;\n highp vec4 texel = texture(tex, st / texSize);\n __GET_RESULT__;\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float y, highp float x) {\n return get(tex, texSize, texDim, 0.0, y, x);\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float x) {\n return get(tex, texSize, texDim, 0.0, 0.0, x);\n}\n\nhighp vec4 actualColor;\nvoid color(float r, float g, float b, float a) {\n actualColor = vec4(r,g,b,a);\n}\n\nvoid color(float r, float g, float b) {\n color(r,g,b,1.0);\n}\n\n__MAIN_PARAMS__;\n__MAIN_CONSTANTS__;\n__KERNEL__;\n\nvoid main(void) {\n index = floor(vTexCoord.s * float(uTexSize.x)) + floor(vTexCoord.t * float(uTexSize.y)) * uTexSize.x;\n __MAIN_RESULT__;\n}";
|
@@ -5097,7 +5112,7 @@ var Utils = function (_UtilsCore) {
|
5097 | 5112 |
|
5098 | 5113 | var GPU = require('../index');
|
5099 | 5114 | var x = new GPU({
|
5100 |
| - mode: 'webgl-validator' |
| 5115 | + mode: 'webgl2-validator' |
5101 | 5116 | }).createKernel(function () {
|
5102 | 5117 | return 1;
|
5103 | 5118 | }, {
|
@@ -9960,12 +9975,7 @@ pp$8.readEscapedChar = function(inTemplate) {
|
9960 | 9975 | this.pos += octalStr.length - 1;
|
9961 | 9976 | ch = this.input.charCodeAt(this.pos);
|
9962 | 9977 | if ((octalStr !== "0" || ch == 56 || ch == 57) && (this.strict || inTemplate)) {
|
9963 |
| - this.invalidStringToken( |
9964 |
| - this.pos - 1 - octalStr.length, |
9965 |
| - inTemplate |
9966 |
| - ? "Octal literal in template string" |
9967 |
| - : "Octal literal in strict mode" |
9968 |
| - ); |
| 9978 | + this.invalidStringToken(this.pos - 1 - octalStr.length, "Octal literal in strict mode"); |
9969 | 9979 | }
|
9970 | 9980 | return String.fromCharCode(octal)
|
9971 | 9981 | }
|
@@ -10024,7 +10034,7 @@ pp$8.readWord = function() {
|
10024 | 10034 | };
|
10025 | 10035 |
|
10026 | 10036 |
|
10027 |
| -var version = "5.5.3"; |
| 10037 | +var version = "5.5.0"; |
10028 | 10038 |
|
10029 | 10039 |
|
10030 | 10040 | function parse(input, options) {
|
|
0 commit comments