Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

261 - webgl2 #262

Merged
merged 27 commits into from Mar 9, 2018
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ce8db7f
almost working 100%
robertleeplummerjr Feb 20, 2018
178d47b
closer to webgl2, still failing some tests when reusing or multiple t…
robertleeplummerjr Feb 25, 2018
fdf547c
getting some help on freenode, so made tests run using cdn's rather t…
robertleeplummerjr Feb 25, 2018
8d0145f
all tests but a couple to do with Floats running on chrome and firefox
robertleeplummerjr Feb 25, 2018
f440841
all tests now online, use `EXT_color_buffer_float`
robertleeplummerjr Feb 25, 2018
c668e16
Merge branch 'develop' into 261-webgl2
robertleeplummerjr Feb 26, 2018
e5d51fd
make and bump version number
robertleeplummerjr Feb 26, 2018
3c2369b
update documentation on Alpha
robertleeplummerjr Feb 26, 2018
9865a4b
Merge branch 'develop' into 261-webgl2
robertleeplummerjr Feb 28, 2018
fd3178c
fix up webgl2
robertleeplummerjr Feb 28, 2018
8ab9457
Merge branch 'develop' into 261-webgl2
robertleeplummerjr Mar 1, 2018
a7fad9c
Merge branch 'develop' into 261-webgl2
robertleeplummerjr Mar 1, 2018
f0d0630
make
robertleeplummerjr Mar 1, 2018
3b839b3
Merge branch 'develop' into 261-webgl2
robertleeplummerjr Mar 1, 2018
42882d7
Merge branch 'develop' into 261-webgl2
robertleeplummerjr Mar 1, 2018
1d99c94
Merge branch 'develop' into 261-webgl2
robertleeplummerjr Mar 3, 2018
c94ee12
merge latest from develop
robertleeplummerjr Mar 3, 2018
bdc0b6b
Merge branch '272-cached-uniform-setting' into 261-webgl2
robertleeplummerjr Mar 6, 2018
504735e
build
robertleeplummerjr Mar 6, 2018
ab7ab17
Merge branch 'develop' into 261-webgl2
robertleeplummerjr Mar 7, 2018
f0970cd
build
robertleeplummerjr Mar 7, 2018
0824151
moving to correct home
robertleeplummerjr Mar 8, 2018
36e4713
moving to correct home
robertleeplummerjr Mar 8, 2018
f84bee2
shrinking webgl2 to only what is needed, this broke a lot, but will r…
robertleeplummerjr Mar 8, 2018
01fa836
making both webgl's play nice together
robertleeplummerjr Mar 8, 2018
ed247f5
first build, getting ready to test
robertleeplummerjr Mar 8, 2018
af7060d
webgl1 and webgl2, together at last, and tested.
robertleeplummerjr Mar 9, 2018
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

webgl1 and webgl2, together at last, and tested.

  • Loading branch information
robertleeplummerjr committed Mar 9, 2018
commit af7060d88e65fe8f3591dcb53e25f999558ca054
@@ -5,7 +5,7 @@
* GPU Accelerated JavaScript
*
* @version 1.2.0
* @date Thu Mar 08 2018 14:35:39 GMT-0500 (EST)
* @date Thu Mar 08 2018 17:26:16 GMT-0500 (EST)
*
* @license MIT
* The MIT License

Some generated files are not rendered by default. Learn more.

@@ -5,7 +5,7 @@
* GPU Accelerated JavaScript
*
* @version 1.2.0
* @date Thu Mar 08 2018 14:35:39 GMT-0500 (EST)
* @date Thu Mar 08 2018 17:26:16 GMT-0500 (EST)
*
* @license MIT
* The MIT License
@@ -927,7 +927,16 @@ module.exports = function (_KernelBase) {
}

var prototypes = builder.getPrototypes();
var kernel = prototypes.shift();
var kernel = null;
if (prototypes.length > 1) {
prototypes = prototypes.filter(function (fn) {
if (/^function/.test(fn)) return fn;
kernel = fn;
return false;
});
} else {
kernel = prototypes.shift();
}
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) {
return ' var ' + name + ' = null;\n';
}).join('')) + '\n return function (' + this.paramNames.map(function (paramName) {
@@ -4303,19 +4312,25 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
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; }

var WebGLRunner = require('../web-gl/runner');
var WebGL2FunctionBuilder = require('./function-builder');
var WebGL2Kernel = require('./kernel');

module.exports = function (_WebGLRunner) {
_inherits(WebGL2Runner, _WebGLRunner);
_inherits(WebGL2Runner, _WebGLRunner);

function WebGL2Runner() {
_classCallCheck(this, WebGL2Runner);
function WebGL2Runner(settings) {
_classCallCheck(this, WebGL2Runner);

return _possibleConstructorReturn(this, (WebGL2Runner.__proto__ || Object.getPrototypeOf(WebGL2Runner)).apply(this, arguments));
}
var _this = _possibleConstructorReturn(this, (WebGL2Runner.__proto__ || Object.getPrototypeOf(WebGL2Runner)).call(this, new WebGL2FunctionBuilder(), settings));

return WebGL2Runner;
_this.Kernel = WebGL2Kernel;
_this.kernel = null;
return _this;
}

return WebGL2Runner;
}(WebGLRunner);
},{"../web-gl/runner":15}],23:[function(require,module,exports){
},{"../web-gl/runner":15,"./function-builder":19,"./kernel":21}],23:[function(require,module,exports){
"use strict";

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) {

var GPU = require('../index');
var x = new GPU({
mode: 'webgl-validator'
mode: 'webgl2-validator'
}).createKernel(function () {
return 1;
}, {
@@ -9960,12 +9975,7 @@ pp$8.readEscapedChar = function(inTemplate) {
this.pos += octalStr.length - 1;
ch = this.input.charCodeAt(this.pos);
if ((octalStr !== "0" || ch == 56 || ch == 57) && (this.strict || inTemplate)) {
this.invalidStringToken(
this.pos - 1 - octalStr.length,
inTemplate
? "Octal literal in template string"
: "Octal literal in strict mode"
);
this.invalidStringToken(this.pos - 1 - octalStr.length, "Octal literal in strict mode");
}
return String.fromCharCode(octal)
}
@@ -10024,7 +10034,7 @@ pp$8.readWord = function() {
};


var version = "5.5.3";
var version = "5.5.0";


function parse(input, options) {

Large diffs are not rendered by default.

@@ -226,7 +226,16 @@ module.exports = function (_KernelBase) {
}

var prototypes = builder.getPrototypes();
var kernel = prototypes.shift();
var kernel = null;
if (prototypes.length > 1) {
prototypes = prototypes.filter(function (fn) {
if (/^function/.test(fn)) return fn;
kernel = fn;
return false;
});
} else {
kernel = prototypes.shift();
}
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) {
return ' var ' + name + ' = null;\n';
}).join('')) + '\n return function (' + this.paramNames.map(function (paramName) {
@@ -0,0 +1,33 @@
'use strict';

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

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; }

var FunctionBuilderBase = require('../function-builder-base');
var WebGLFunctionNode = require('./function-node');

/**
* @class WebGLFunctionBuilder
*
* @extends FunctionBuilderBase
*
* @desc Builds webGl functions (shaders) from JavaScript function Strings
*
*/
module.exports = function (_FunctionBuilderBase) {
_inherits(WebGL2FunctionBuilder, _FunctionBuilderBase);

function WebGL2FunctionBuilder() {
_classCallCheck(this, WebGL2FunctionBuilder);

var _this = _possibleConstructorReturn(this, (WebGL2FunctionBuilder.__proto__ || Object.getPrototypeOf(WebGL2FunctionBuilder)).call(this));

_this.Node = WebGLFunctionNode;
return _this;
}

return WebGL2FunctionBuilder;
}(FunctionBuilderBase);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.