This repository has been archived by the owner on Aug 16, 2018. It is now read-only.
forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make tests es5 and add the kernel
.toString()
method, so we can hav…
…e the entire kernel, and nothing else.
- Loading branch information
1 parent
c5db5b0
commit 81275b5
Showing
14 changed files
with
388 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const utils = require('./utils'); | ||
module.exports = function alias(name, fn) { | ||
const fnString = fn.toString(); | ||
return new Function(`return function ${ name } (${ utils.getParamNamesFromString(fnString).join(', ') }) {${ utils.getFunctionBodyFromString(fnString) }}`)(); | ||
const fnString = fn.toString(); | ||
return new Function(`return function ${ name } (${ utils.getParamNamesFromString(fnString).join(', ') }) {${ utils.getFunctionBodyFromString(fnString) }}`)(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const utils = require('../../utils'); | ||
const kernelRunShortcut = require('../kernel-run-shortcut'); | ||
|
||
module.exports = function(cpuKernel, name) { | ||
return `() => { | ||
${ kernelRunShortcut.toString() }; | ||
const utils = { | ||
allPropertiesOf: function ${ utils.allPropertiesOf.toString() }, | ||
clone: function ${ utils.clone.toString() }, | ||
/*splitArray: function ${ utils.splitArray.toString() }, | ||
getArgumentType: function ${ utils.getArgumentType.toString() }, | ||
getDimensions: function ${ utils.getDimensions.toString() }, | ||
dimToTexSize: function ${ utils.dimToTexSize.toString() }, | ||
copyFlatten: function ${ utils.copyFlatten.toString() }, | ||
flatten: function ${ utils.flatten.toString() }, | ||
systemEndianness: '${ utils.systemEndianness }', | ||
initWebGl: function ${ utils.initWebGl.toString() }, | ||
isArray: function ${ utils.isArray.toString() }*/ | ||
}; | ||
class ${ name || 'Kernel' } { | ||
constructor() { | ||
this.argumentsLength = 0; | ||
this._canvas = null; | ||
this._webGl = null; | ||
this.built = false; | ||
this.program = null; | ||
this.paramNames = ${ JSON.stringify(cpuKernel.paramNames) }; | ||
this.paramTypes = ${ JSON.stringify(cpuKernel.paramTypes) }; | ||
this.texSize = ${ JSON.stringify(cpuKernel.texSize) }; | ||
this.dimensions = ${ JSON.stringify(cpuKernel.dimensions) }; | ||
this._kernelString = \`${ cpuKernel._kernelString }\`; | ||
this.run = function() { | ||
this.run = null; | ||
this.build(); | ||
return this.run.apply(this, arguments); | ||
}.bind(this); | ||
this.thread = { | ||
x: 0, | ||
y: 0, | ||
z: 0 | ||
}; | ||
this.runDimensions = { | ||
x: null, | ||
y: null, | ||
z: null | ||
}; | ||
} | ||
setCanvas(canvas) { this._canvas = canvas; return this; } | ||
setWebGl(webGl) { this._webGl = webGl; return this; } | ||
${ cpuKernel.build.toString() } | ||
run () { ${ cpuKernel.kernelString } } | ||
getKernelString() { return this._kernelString; } | ||
}; | ||
return kernelRunShortcut(new Kernel()); | ||
};`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.