Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
robertleeplummerjr committed Mar 20, 2020
2 parents 772eaec + 16bf2f9 commit fdedd6f
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 108 deletions.
85 changes: 39 additions & 46 deletions dist/gpu-browser-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* GPU Accelerated JavaScript
*
* @version 2.8.5
* @date Fri Mar 20 2020 08:27:36 GMT-0400 (Eastern Daylight Time)
* @date Fri Mar 20 2020 08:38:27 GMT-0400 (Eastern Daylight Time)
*
* @license MIT
* The MIT License
Expand Down Expand Up @@ -1490,7 +1490,6 @@ class CPUKernel extends Kernel {
}

build() {
if (this.built) return;
this.setupConstants();
this.setupArguments(arguments);
this.validateSettings(arguments);
Expand Down Expand Up @@ -6526,6 +6525,7 @@ class Kernel {

static getSignature(kernel, argumentTypes) {
throw new Error(`"getSignature" not implemented on ${ this.name }`);
return argumentTypes.length > 0 ? ':' + argumentTypes.join(',') : '';
}

functionToIGPUFunction(source, settings = {}) {
Expand Down Expand Up @@ -10105,7 +10105,6 @@ class WebGLKernel extends GLKernel {
}

build() {
if (this.built) return;
this.initExtensions();
this.validateSettings(arguments);
this.setupConstants(arguments);
Expand Down Expand Up @@ -11002,7 +11001,6 @@ float integerCorrectionModulo(float number, float divisor) {
}

destroy(removeCanvasReferences) {
if (!this.context) return;
if (this.buffer) {
this.context.deleteBuffer(this.buffer);
}
Expand Down Expand Up @@ -11061,10 +11059,6 @@ float integerCorrectionModulo(float number, float divisor) {
this.destroyExtensions();
delete this.context;
delete this.canvas;
if (!this.gpu) return;
const i = this.gpu.kernels.indexOf(this);
if (i === -1) return;
this.gpu.kernels.splice(i, 1);
}

destroyExtensions() {
Expand Down Expand Up @@ -13210,15 +13204,15 @@ class GPU {
return result;
}

function onRequestSwitchKernel(reasons, args, _kernel) {
if (_kernel.debug) {
function onRequestSwitchKernel(reasons, args, kernel) {
if (kernel.debug) {
console.warn('Switching kernels');
}
let newOutput = null;
if (_kernel.signature && !switchableKernels[_kernel.signature]) {
switchableKernels[_kernel.signature] = _kernel;
if (kernel.signature && !switchableKernels[kernel.signature]) {
switchableKernels[kernel.signature] = kernel;
}
if (_kernel.dynamicOutput) {
if (kernel.dynamicOutput) {
for (let i = reasons.length - 1; i >= 0; i--) {
const reason = reasons[i];
if (reason.type === 'outputPrecisionMismatch') {
Expand All @@ -13227,42 +13221,42 @@ class GPU {
}
}

const Constructor = _kernel.constructor;
const argumentTypes = Constructor.getArgumentTypes(_kernel, args);
const signature = Constructor.getSignature(_kernel, argumentTypes);
const Constructor = kernel.constructor;
const argumentTypes = Constructor.getArgumentTypes(kernel, args);
const signature = Constructor.getSignature(kernel, argumentTypes);
const existingKernel = switchableKernels[signature];
if (existingKernel) {
return existingKernel;
}

const newKernel = switchableKernels[signature] = new Constructor(source, {
argumentTypes,
constantTypes: _kernel.constantTypes,
graphical: _kernel.graphical,
loopMaxIterations: _kernel.loopMaxIterations,
constants: _kernel.constants,
dynamicOutput: _kernel.dynamicOutput,
dynamicArgument: _kernel.dynamicArguments,
context: _kernel.context,
canvas: _kernel.canvas,
output: newOutput || _kernel.output,
precision: _kernel.precision,
pipeline: _kernel.pipeline,
immutable: _kernel.immutable,
optimizeFloatMemory: _kernel.optimizeFloatMemory,
fixIntegerDivisionAccuracy: _kernel.fixIntegerDivisionAccuracy,
functions: _kernel.functions,
nativeFunctions: _kernel.nativeFunctions,
injectedNative: _kernel.injectedNative,
subKernels: _kernel.subKernels,
strictIntegers: _kernel.strictIntegers,
debug: _kernel.debug,
gpu: _kernel.gpu,
constantTypes: kernel.constantTypes,
graphical: kernel.graphical,
loopMaxIterations: kernel.loopMaxIterations,
constants: kernel.constants,
dynamicOutput: kernel.dynamicOutput,
dynamicArgument: kernel.dynamicArguments,
context: kernel.context,
canvas: kernel.canvas,
output: newOutput || kernel.output,
precision: kernel.precision,
pipeline: kernel.pipeline,
immutable: kernel.immutable,
optimizeFloatMemory: kernel.optimizeFloatMemory,
fixIntegerDivisionAccuracy: kernel.fixIntegerDivisionAccuracy,
functions: kernel.functions,
nativeFunctions: kernel.nativeFunctions,
injectedNative: kernel.injectedNative,
subKernels: kernel.subKernels,
strictIntegers: kernel.strictIntegers,
debug: kernel.debug,
gpu: kernel.gpu,
validate,
returnType: _kernel.returnType,
onIstanbulCoverageVariable: _kernel.onIstanbulCoverageVariable,
removeIstanbulCoverage: _kernel.removeIstanbulCoverage,
tactic: _kernel.tactic,
returnType: kernel.returnType,
onIstanbulCoverageVariable: kernel.onIstanbulCoverageVariable,
removeIstanbulCoverage: kernel.removeIstanbulCoverage,
tactic: kernel.tactic,
onRequestFallback,
onRequestSwitchKernel,
});
Expand All @@ -13284,18 +13278,17 @@ class GPU {
onRequestSwitchKernel
}, settingsCopy);

const kernel = new this.Kernel(source, mergedSettings);
const kernelRun = kernelRunShortcut(kernel);
const kernelRun = kernelRunShortcut(new this.Kernel(source, mergedSettings));

if (!this.canvas) {
this.canvas = kernel.canvas;
this.canvas = kernelRun.canvas;
}

if (!this.context) {
this.context = kernel.context;
this.context = kernelRun.context;
}

this.kernels.push(kernel);
this.kernels.push(kernelRun);

return kernelRun;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/gpu-browser-core.min.js

Large diffs are not rendered by default.

85 changes: 39 additions & 46 deletions dist/gpu-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* GPU Accelerated JavaScript
*
* @version 2.8.5
* @date Fri Mar 20 2020 08:27:36 GMT-0400 (Eastern Daylight Time)
* @date Fri Mar 20 2020 08:38:27 GMT-0400 (Eastern Daylight Time)
*
* @license MIT
* The MIT License
Expand Down Expand Up @@ -5943,7 +5943,6 @@ class CPUKernel extends Kernel {
}

build() {
if (this.built) return;
this.setupConstants();
this.setupArguments(arguments);
this.validateSettings(arguments);
Expand Down Expand Up @@ -10979,6 +10978,7 @@ class Kernel {

static getSignature(kernel, argumentTypes) {
throw new Error(`"getSignature" not implemented on ${ this.name }`);
return argumentTypes.length > 0 ? ':' + argumentTypes.join(',') : '';
}

functionToIGPUFunction(source, settings = {}) {
Expand Down Expand Up @@ -14558,7 +14558,6 @@ class WebGLKernel extends GLKernel {
}

build() {
if (this.built) return;
this.initExtensions();
this.validateSettings(arguments);
this.setupConstants(arguments);
Expand Down Expand Up @@ -15455,7 +15454,6 @@ float integerCorrectionModulo(float number, float divisor) {
}

destroy(removeCanvasReferences) {
if (!this.context) return;
if (this.buffer) {
this.context.deleteBuffer(this.buffer);
}
Expand Down Expand Up @@ -15514,10 +15512,6 @@ float integerCorrectionModulo(float number, float divisor) {
this.destroyExtensions();
delete this.context;
delete this.canvas;
if (!this.gpu) return;
const i = this.gpu.kernels.indexOf(this);
if (i === -1) return;
this.gpu.kernels.splice(i, 1);
}

destroyExtensions() {
Expand Down Expand Up @@ -17663,15 +17657,15 @@ class GPU {
return result;
}

function onRequestSwitchKernel(reasons, args, _kernel) {
if (_kernel.debug) {
function onRequestSwitchKernel(reasons, args, kernel) {
if (kernel.debug) {
console.warn('Switching kernels');
}
let newOutput = null;
if (_kernel.signature && !switchableKernels[_kernel.signature]) {
switchableKernels[_kernel.signature] = _kernel;
if (kernel.signature && !switchableKernels[kernel.signature]) {
switchableKernels[kernel.signature] = kernel;
}
if (_kernel.dynamicOutput) {
if (kernel.dynamicOutput) {
for (let i = reasons.length - 1; i >= 0; i--) {
const reason = reasons[i];
if (reason.type === 'outputPrecisionMismatch') {
Expand All @@ -17680,42 +17674,42 @@ class GPU {
}
}

const Constructor = _kernel.constructor;
const argumentTypes = Constructor.getArgumentTypes(_kernel, args);
const signature = Constructor.getSignature(_kernel, argumentTypes);
const Constructor = kernel.constructor;
const argumentTypes = Constructor.getArgumentTypes(kernel, args);
const signature = Constructor.getSignature(kernel, argumentTypes);
const existingKernel = switchableKernels[signature];
if (existingKernel) {
return existingKernel;
}

const newKernel = switchableKernels[signature] = new Constructor(source, {
argumentTypes,
constantTypes: _kernel.constantTypes,
graphical: _kernel.graphical,
loopMaxIterations: _kernel.loopMaxIterations,
constants: _kernel.constants,
dynamicOutput: _kernel.dynamicOutput,
dynamicArgument: _kernel.dynamicArguments,
context: _kernel.context,
canvas: _kernel.canvas,
output: newOutput || _kernel.output,
precision: _kernel.precision,
pipeline: _kernel.pipeline,
immutable: _kernel.immutable,
optimizeFloatMemory: _kernel.optimizeFloatMemory,
fixIntegerDivisionAccuracy: _kernel.fixIntegerDivisionAccuracy,
functions: _kernel.functions,
nativeFunctions: _kernel.nativeFunctions,
injectedNative: _kernel.injectedNative,
subKernels: _kernel.subKernels,
strictIntegers: _kernel.strictIntegers,
debug: _kernel.debug,
gpu: _kernel.gpu,
constantTypes: kernel.constantTypes,
graphical: kernel.graphical,
loopMaxIterations: kernel.loopMaxIterations,
constants: kernel.constants,
dynamicOutput: kernel.dynamicOutput,
dynamicArgument: kernel.dynamicArguments,
context: kernel.context,
canvas: kernel.canvas,
output: newOutput || kernel.output,
precision: kernel.precision,
pipeline: kernel.pipeline,
immutable: kernel.immutable,
optimizeFloatMemory: kernel.optimizeFloatMemory,
fixIntegerDivisionAccuracy: kernel.fixIntegerDivisionAccuracy,
functions: kernel.functions,
nativeFunctions: kernel.nativeFunctions,
injectedNative: kernel.injectedNative,
subKernels: kernel.subKernels,
strictIntegers: kernel.strictIntegers,
debug: kernel.debug,
gpu: kernel.gpu,
validate,
returnType: _kernel.returnType,
onIstanbulCoverageVariable: _kernel.onIstanbulCoverageVariable,
removeIstanbulCoverage: _kernel.removeIstanbulCoverage,
tactic: _kernel.tactic,
returnType: kernel.returnType,
onIstanbulCoverageVariable: kernel.onIstanbulCoverageVariable,
removeIstanbulCoverage: kernel.removeIstanbulCoverage,
tactic: kernel.tactic,
onRequestFallback,
onRequestSwitchKernel,
});
Expand All @@ -17737,18 +17731,17 @@ class GPU {
onRequestSwitchKernel
}, settingsCopy);

const kernel = new this.Kernel(source, mergedSettings);
const kernelRun = kernelRunShortcut(kernel);
const kernelRun = kernelRunShortcut(new this.Kernel(source, mergedSettings));

if (!this.canvas) {
this.canvas = kernel.canvas;
this.canvas = kernelRun.canvas;
}

if (!this.context) {
this.context = kernel.context;
this.context = kernelRun.context;
}

this.kernels.push(kernel);
this.kernels.push(kernelRun);

return kernelRun;
}
Expand Down
4 changes: 2 additions & 2 deletions dist/gpu-browser.min.js

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fdedd6f

Please sign in to comment.