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

Method _setupOutputTexture

src/backend/web-gl2/kernel.js:278–311  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

276 }
277
278 _setupOutputTexture() {
279 const gl = this.context;
280 if (this.texture) {
281 // here we inherit from an already existing kernel, so go ahead and just bind textures to the framebuffer
282 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture.texture, 0);
283 return;
284 }
285 gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer);
286 const texture = gl.createTexture();
287 const texSize = this.texSize;
288 gl.activeTexture(gl.TEXTURE0 + this.constantTextureCount + this.argumentTextureCount);
289 gl.bindTexture(gl.TEXTURE_2D, texture);
290 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
291 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
292 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
293 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
294 const format = this.getInternalFormat();
295 if (this.precision === 'single') {
296 gl.texStorage2D(gl.TEXTURE_2D, 1, format, texSize[0], texSize[1]);
297 } else {
298 gl.texImage2D(gl.TEXTURE_2D, 0, format, texSize[0], texSize[1], 0, format, gl.UNSIGNED_BYTE, null);
299 }
300 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
301 this.texture = new this.TextureConstructor({
302 texture,
303 size: texSize,
304 dimensions: this.threadDim,
305 output: this.output,
306 context: this.context,
307 internalFormat: this.getInternalFormat(),
308 textureFormat: this.getTextureFormat(),
309 kernel: this,
310 });
311 }
312
313 _setupSubOutputTextures() {
314 const gl = this.context;

Callers

nothing calls this directly

Calls 3

getInternalFormatMethod · 0.95
getTextureFormatMethod · 0.95
createTextureMethod · 0.80

Tested by

no test coverage detected