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

Method _setupOutputTexture

src/backend/web-gl/kernel.js:709–741  ·  view source on GitHub ↗

* @desc Setup output texture

()

Source from the content-addressed store, hash-verified

707 * @desc Setup output texture
708 */
709 _setupOutputTexture() {
710 const gl = this.context;
711 const texSize = this.texSize;
712 if (this.texture) {
713 // here we inherit from an already existing kernel, so go ahead and just bind textures to the framebuffer
714 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture.texture, 0);
715 return;
716 }
717 const texture = this.createTexture();
718 gl.activeTexture(gl.TEXTURE0 + this.constantTextureCount + this.argumentTextureCount);
719 gl.bindTexture(gl.TEXTURE_2D, texture);
720 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
721 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
722 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
723 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
724 const format = this.getInternalFormat();
725 if (this.precision === 'single') {
726 gl.texImage2D(gl.TEXTURE_2D, 0, format, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null);
727 } else {
728 gl.texImage2D(gl.TEXTURE_2D, 0, format, texSize[0], texSize[1], 0, format, gl.UNSIGNED_BYTE, null);
729 }
730 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
731 this.texture = new this.TextureConstructor({
732 texture,
733 size: texSize,
734 dimensions: this.threadDim,
735 output: this.output,
736 context: this.context,
737 internalFormat: this.getInternalFormat(),
738 textureFormat: this.getTextureFormat(),
739 kernel: this,
740 });
741 }
742
743 /**
744 *

Callers 2

buildMethod · 0.95
setOutputMethod · 0.45

Calls 3

createTextureMethod · 0.95
getInternalFormatMethod · 0.95
getTextureFormatMethod · 0.95

Tested by

no test coverage detected