1+ ///
2+ /// Class: GPU
3+ ///
4+ /// GPU.JS core class =D
5+ ///
16GPU = ( function ( ) {
27 var gl , canvas ;
38
@@ -37,6 +42,7 @@ GPU = (function() {
3742 this . endianness = endianness ( ) ;
3843
3944 this . functionBuilder = new functionBuilder ( ) ;
45+ this . functionBuilder . polyfillStandardFunctions ( ) ;
4046 }
4147
4248 GPU . prototype . getGl = function ( ) {
@@ -47,26 +53,31 @@ GPU = (function() {
4753 return this . canvas ;
4854 } ;
4955
56+ ///
57+ /// Function: createKernel
58+ ///
5059 /// The core GPU.js function
5160 ///
5261 /// The parameter object contains the following sub parameters
5362 ///
54- /// + ---------------+ ---------------+ ---------------------------------------------------------------------------+
63+ /// | ---------------| ---------------| ---------------------------------------------------------------------------|
5564 /// | Name | Default value | Description |
56- /// + ---------------+ ---------------+ ---------------------------------------------------------------------------+
65+ /// | ---------------| ---------------| ---------------------------------------------------------------------------|
5766 /// | dimensions | [1024] | Thread dimension array |
5867 /// | mode | null | CPU / GPU configuration mode, "auto" / null. Has the following modes. |
5968 /// | | | + null / "auto" : Attempts to build GPU mode, else fallbacks |
6069 /// | | | + "gpu" : Attempts to build GPU mode, else fallbacks |
6170 /// | | | + "cpu" : Forces JS fallback mode only |
62- /// + ---------------+ ---------------+ ---------------------------------------------------------------------------+
71+ /// | ---------------| ---------------| ---------------------------------------------------------------------------|
6372 ///
64- /// @param inputFunction The calling to perform the conversion
65- /// @param paramObj The parameter configuration object
73+ /// Parameters:
74+ /// inputFunction {JS Function} The calling to perform the conversion
75+ /// paramObj {Object} The parameter configuration object
6676 ///
67- /// @returns callable function to run
68- GPU . prototype . createKernel = function ( kernel , paramObj ) {
69-
77+ /// Returns:
78+ /// callable function to run
79+ ///
80+ function createKernel ( kernel , paramObj ) {
7081 //
7182 // basic parameters safety checks
7283 //
@@ -104,6 +115,26 @@ GPU = (function() {
104115 }
105116 }
106117 } ;
107-
118+ GPU . prototype . createKernel = createKernel ;
119+
120+ ///
121+ /// Function: addFunction
122+ ///
123+ /// Adds additional functions, that the kernel may call.
124+ ///
125+ /// Parameters:
126+ /// jsFunction - {JS Function} JS Function to do conversion
127+ /// paramTypeArray - {[String,...]} Parameter type array, assumes all parameters are "float" if null
128+ /// returnType - {String} The return type, assumes "float" if null
129+ ///
130+ /// Retuns:
131+ /// {GPU} returns itself
132+ ///
133+ function addFunction ( jsFunction , paramTypeArray , returnType ) {
134+ this . functionBuilder . addFunction ( null , jsFunction , paramTypeArray , returnType ) ;
135+ return this ;
136+ }
137+ GPU . prototype . addFunction = addFunction ;
138+
108139 return GPU ;
109140} ) ( ) ;
0 commit comments