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

Method build

src/backend/cpu/kernel.js:138–176  ·  view source on GitHub ↗

* @desc Builds the Kernel, by generating the kernel * string using thread dimensions, and arguments * supplied to the kernel. * * If the graphical flag is enabled, canvas is used.

()

Source from the content-addressed store, hash-verified

136 * <p>If the graphical flag is enabled, canvas is used.</p>
137 */
138 build() {
139 if (this.built) return;
140 this.setupConstants();
141 this.setupArguments(arguments);
142 this.validateSettings(arguments);
143 this.translateSource();
144
145 if (this.graphical) {
146 const {
147 canvas,
148 output
149 } = this;
150 if (!canvas) {
151 throw new Error('no canvas available for using graphical output');
152 }
153 const width = output[0];
154 const height = output[1] || 1;
155 canvas.width = width;
156 canvas.height = height;
157 this._imageData = this.context.createImageData(width, height);
158 this._colorData = new Uint8ClampedArray(width * height * 4);
159 }
160
161 const kernelString = this.getKernelString();
162 this.kernelString = kernelString;
163
164 if (this.debug) {
165 console.log('Function output:');
166 console.log(kernelString);
167 }
168
169 try {
170 this.run = new Function([], kernelString).bind(this)();
171 } catch (e) {
172 console.error('An error occurred compiling the javascript: ', e);
173 }
174 this.buildSignature(arguments);
175 this.built = true;
176 }
177
178 color(r, g, b, a) {
179 if (typeof a === 'undefined') {

Callers 1

getIsFloatReadMethod · 0.45

Calls 6

validateSettingsMethod · 0.95
translateSourceMethod · 0.95
getKernelStringMethod · 0.95
buildSignatureMethod · 0.80
setupConstantsMethod · 0.45
setupArgumentsMethod · 0.45

Tested by

no test coverage detected