MCPcopy Index your code
hub / github.com/gpujs/gpu.js / constructor

Method constructor

src/gpu.js:113–141  ·  view source on GitHub ↗

* Creates an instance of GPU. * @param {IGPUSettings} [settings] - Settings to set mode, and other properties * @constructor

(settings)

Source from the content-addressed store, hash-verified

111 * @constructor
112 */
113 constructor(settings) {
114 settings = settings || {};
115 this.canvas = settings.canvas || null;
116 this.context = settings.context || null;
117 this.mode = settings.mode;
118 this.Kernel = null;
119 this.kernels = [];
120 this.functions = [];
121 this.nativeFunctions = [];
122 this.injectedNative = null;
123 if (this.mode === 'dev') return;
124 this.chooseKernel();
125 // add functions from settings
126 if (settings.functions) {
127 for (let i = 0; i < settings.functions.length; i++) {
128 this.addFunction(settings.functions[i]);
129 }
130 }
131
132 // add native functions from settings
133 if (settings.nativeFunctions) {
134 for (const p in settings.nativeFunctions) {
135 if (!settings.nativeFunctions.hasOwnProperty(p)) continue;
136 const s = settings.nativeFunctions[p];
137 const { name, source } = s;
138 this.addNativeFunction(name, source, s);
139 }
140 }
141 }
142
143 /**
144 * Choose kernel type and save on .Kernel property of GPU

Callers 1

cloneFunction · 0.45

Calls 3

chooseKernelMethod · 0.95
addFunctionMethod · 0.95
addNativeFunctionMethod · 0.95

Tested by

no test coverage detected