* @desc Setup on inherit sub-output textures
()
| 759 | * @desc Setup on inherit sub-output textures |
| 760 | */ |
| 761 | _setupSubOutputTextures() { |
| 762 | const gl = this.context; |
| 763 | if (this.mappedTextures) { |
| 764 | // here we inherit from an already existing kernel, so go ahead and just bind textures to the framebuffer |
| 765 | for (let i = 0; i < this.subKernels.length; i++) { |
| 766 | gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i + 1, gl.TEXTURE_2D, this.mappedTextures[i].texture, 0); |
| 767 | } |
| 768 | return; |
| 769 | } |
| 770 | const texSize = this.texSize; |
| 771 | this.drawBuffersMap = [gl.COLOR_ATTACHMENT0]; |
| 772 | this.mappedTextures = []; |
| 773 | for (let i = 0; i < this.subKernels.length; i++) { |
| 774 | const texture = this.createTexture(); |
| 775 | this.drawBuffersMap.push(gl.COLOR_ATTACHMENT0 + i + 1); |
| 776 | gl.activeTexture(gl.TEXTURE0 + this.constantTextureCount + this.argumentTextureCount + i); |
| 777 | gl.bindTexture(gl.TEXTURE_2D, texture); |
| 778 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); |
| 779 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); |
| 780 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); |
| 781 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); |
| 782 | if (this.precision === 'single') { |
| 783 | gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); |
| 784 | } else { |
| 785 | gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); |
| 786 | } |
| 787 | gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i + 1, gl.TEXTURE_2D, texture, 0); |
| 788 | |
| 789 | this.mappedTextures.push(new this.TextureConstructor({ |
| 790 | texture, |
| 791 | size: texSize, |
| 792 | dimensions: this.threadDim, |
| 793 | output: this.output, |
| 794 | context: this.context, |
| 795 | internalFormat: this.getInternalFormat(), |
| 796 | textureFormat: this.getTextureFormat(), |
| 797 | kernel: this, |
| 798 | })); |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | setUniform1f(name, value) { |
| 803 | if (this.uniform1fCache.hasOwnProperty(name)) { |
no test coverage detected