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

Method run

src/backend/web-gl/kernel.js:615–675  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

613 }
614
615 run() {
616 const { kernelArguments, texSize, forceUploadKernelConstants, context: gl } = this;
617
618 gl.useProgram(this.program);
619 gl.scissor(0, 0, texSize[0], texSize[1]);
620 if (this.dynamicOutput) {
621 this.setUniform3iv('uOutputDim', new Int32Array(this.threadDim));
622 this.setUniform2iv('uTexSize', texSize);
623 }
624
625 this.setUniform2f('ratio', texSize[0] / this.maxTexSize[0], texSize[1] / this.maxTexSize[1]);
626
627 for (let i = 0; i < forceUploadKernelConstants.length; i++) {
628 const constant = forceUploadKernelConstants[i];
629 constant.updateValue(this.constants[constant.name]);
630 if (this.switchingKernels) return;
631 }
632 for (let i = 0; i < kernelArguments.length; i++) {
633 kernelArguments[i].updateValue(arguments[i]);
634 if (this.switchingKernels) return;
635 }
636
637 if (this.plugins) {
638 for (let i = 0; i < this.plugins.length; i++) {
639 const plugin = this.plugins[i];
640 if (plugin.onBeforeRun) {
641 plugin.onBeforeRun(this);
642 }
643 }
644 }
645
646 if (this.graphical) {
647 if (this.pipeline) {
648 gl.bindRenderbuffer(gl.RENDERBUFFER, null);
649 gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer);
650 if (this.immutable) {
651 this._replaceOutputTexture();
652 }
653 gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
654 return this.immutable ? this.texture.clone() : this.texture;
655 }
656 gl.bindRenderbuffer(gl.RENDERBUFFER, null);
657 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
658 gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
659 return;
660 }
661
662 gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer);
663 if (this.immutable) {
664 this._replaceOutputTexture();
665 }
666
667 if (this.subKernels !== null) {
668 if (this.immutable) {
669 this._replaceSubOutputTextures();
670 }
671 this.drawBuffers();
672 }

Callers 1

getIsFloatReadMethod · 0.45

Calls 8

setUniform3ivMethod · 0.95
setUniform2ivMethod · 0.95
setUniform2fMethod · 0.95
_replaceOutputTextureMethod · 0.95
drawBuffersMethod · 0.95
updateValueMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected