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

Method setupConstants

src/backend/web-gl/kernel.js:427–476  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

425 }
426
427 setupConstants(args) {
428 const { context: gl } = this;
429 this.kernelConstants = [];
430 this.forceUploadKernelConstants = [];
431 let needsConstantTypes = this.constantTypes === null;
432 if (needsConstantTypes) {
433 this.constantTypes = {};
434 }
435 this.constantBitRatios = {};
436 let textureIndexes = 0;
437 for (const name in this.constants) {
438 const value = this.constants[name];
439 let type;
440 if (needsConstantTypes) {
441 type = utils.getVariableType(value, this.strictIntegers);
442 this.constantTypes[name] = type;
443 } else {
444 type = this.constantTypes[name];
445 }
446 const KernelValue = this.constructor.lookupKernelValueType(type, 'static', this.precision, value);
447 if (KernelValue === null) {
448 return this.requestFallback(args);
449 }
450 const kernelValue = new KernelValue(value, {
451 name,
452 type,
453 tactic: this.tactic,
454 origin: 'constants',
455 context: this.context,
456 checkContext: this.checkContext,
457 kernel: this,
458 strictIntegers: this.strictIntegers,
459 onRequestTexture: () => {
460 return this.createTexture();
461 },
462 onRequestIndex: () => {
463 return textureIndexes++;
464 },
465 onRequestContextHandle: () => {
466 return gl.TEXTURE0 + this.constantTextureCount++;
467 }
468 });
469 this.constantBitRatios[name] = kernelValue.bitRatio;
470 this.kernelConstants.push(kernelValue);
471 kernelValue.setup();
472 if (kernelValue.forceUploadEachRun) {
473 this.forceUploadKernelConstants.push(kernelValue);
474 }
475 }
476 }
477
478 build() {
479 if (this.built) return;

Callers 3

setupConstantsTestSuiteFunction · 0.95
buildMethod · 0.95
buildMethod · 0.45

Calls 5

createTextureMethod · 0.95
getVariableTypeMethod · 0.80
requestFallbackMethod · 0.80
lookupKernelValueTypeMethod · 0.45
setupMethod · 0.45

Tested by

no test coverage detected