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

Method _processArguments

src/backend/cpu/kernel.js:306–347  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

304 }
305
306 _processArguments() {
307 const result = [];
308 for (let i = 0; i < this.argumentTypes.length; i++) {
309 const variableName = `user_${this.argumentNames[i]}`;
310 switch (this.argumentTypes[i]) {
311 case 'HTMLCanvas':
312 case 'HTMLImage':
313 case 'HTMLVideo':
314 result.push(` ${variableName} = this._mediaTo2DArray(${variableName});\n`);
315 break;
316 case 'HTMLImageArray':
317 result.push(` ${variableName} = this._imageTo3DArray(${variableName});\n`);
318 break;
319 case 'Input':
320 result.push(` ${variableName} = ${variableName}.value;\n`);
321 break;
322 case 'ArrayTexture(1)':
323 case 'ArrayTexture(2)':
324 case 'ArrayTexture(3)':
325 case 'ArrayTexture(4)':
326 case 'NumberTexture':
327 case 'MemoryOptimizedNumberTexture':
328 result.push(`
329 if (${variableName}.toArray) {
330 if (!_this.textureCache) {
331 _this.textureCache = [];
332 _this.arrayCache = [];
333 }
334 const textureIndex = _this.textureCache.indexOf(${variableName});
335 if (textureIndex !== -1) {
336 ${variableName} = _this.arrayCache[textureIndex];
337 } else {
338 _this.textureCache.push(${variableName});
339 ${variableName} = ${variableName}.toArray();
340 _this.arrayCache.push(${variableName});
341 }
342 }`);
343 break;
344 }
345 }
346 return result.join('');
347 }
348
349 _mediaTo2DArray(media) {
350 const canvas = this.canvas;

Callers 1

getKernelStringMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected