(output)
| 895 | } |
| 896 | |
| 897 | setOutput(output) { |
| 898 | const newOutput = this.toKernelOutput(output); |
| 899 | if (this.program) { |
| 900 | if (!this.dynamicOutput) { |
| 901 | throw new Error('Resizing a kernel with dynamicOutput: false is not possible'); |
| 902 | } |
| 903 | const newThreadDim = [newOutput[0], newOutput[1] || 1, newOutput[2] || 1]; |
| 904 | const newTexSize = utils.getKernelTextureSize({ |
| 905 | optimizeFloatMemory: this.optimizeFloatMemory, |
| 906 | precision: this.precision, |
| 907 | }, newThreadDim); |
| 908 | const oldTexSize = this.texSize; |
| 909 | if (oldTexSize) { |
| 910 | const oldPrecision = this.getVariablePrecisionString(oldTexSize, this.tactic); |
| 911 | const newPrecision = this.getVariablePrecisionString(newTexSize, this.tactic); |
| 912 | if (oldPrecision !== newPrecision) { |
| 913 | if (this.debug) { |
| 914 | console.warn('Precision requirement changed, asking GPU instance to recompile'); |
| 915 | } |
| 916 | this.switchKernels({ |
| 917 | type: 'outputPrecisionMismatch', |
| 918 | precision: newPrecision, |
| 919 | needed: output |
| 920 | }); |
| 921 | return; |
| 922 | } |
| 923 | } |
| 924 | this.output = newOutput; |
| 925 | this.threadDim = newThreadDim; |
| 926 | this.texSize = newTexSize; |
| 927 | const { context: gl } = this; |
| 928 | gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer); |
| 929 | this.updateMaxTexSize(); |
| 930 | this.framebuffer.width = this.texSize[0]; |
| 931 | this.framebuffer.height = this.texSize[1]; |
| 932 | gl.viewport(0, 0, this.maxTexSize[0], this.maxTexSize[1]); |
| 933 | this.canvas.width = this.maxTexSize[0]; |
| 934 | this.canvas.height = this.maxTexSize[1]; |
| 935 | if (this.texture) { |
| 936 | this.texture.delete(); |
| 937 | } |
| 938 | this.texture = null; |
| 939 | this._setupOutputTexture(); |
| 940 | if (this.mappedTextures && this.mappedTextures.length > 0) { |
| 941 | for (let i = 0; i < this.mappedTextures.length; i++) { |
| 942 | this.mappedTextures[i].delete(); |
| 943 | } |
| 944 | this.mappedTextures = null; |
| 945 | this._setupSubOutputTextures(); |
| 946 | } |
| 947 | } else { |
| 948 | this.output = newOutput; |
| 949 | } |
| 950 | return this; |
| 951 | } |
| 952 | renderValues() { |
| 953 | return this.formatValues( |
| 954 | this.transferValues(), |
nothing calls this directly
no test coverage detected