From 68f686215522296fbd203524aacbc60f05d59e88 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 19 Oct 2026 13:37:41 -0400 Subject: [PATCH 1/2] refactor(framebuffer)!: remove deprecated color texture getter --- BREAKING_CHANGES.md | 1 + Sources/Rendering/OpenGL/Convolution2DPass/index.js | 2 +- Sources/Rendering/OpenGL/ForwardPass/index.js | 2 +- Sources/Rendering/OpenGL/Framebuffer/index.d.ts | 7 ------- Sources/Rendering/OpenGL/Framebuffer/index.js | 3 --- Sources/Rendering/OpenGL/RadialDistortionPass/index.js | 2 +- Sources/Rendering/OpenGL/VolumeMapper/index.js | 2 +- 7 files changed, 5 insertions(+), 14 deletions(-) diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index fa5be5c8d8c..caf904fac01 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -3,6 +3,7 @@ - **TypeScript declarations**: expanded coverage and corrected types may expose build errors. Remove conflicting local declaration shims and fix code rejected by the new types. - **TypeScript libraries**: typed-array factories now declare BigInt support. Add `ES2020.BigInt` if your `lib` list does not include `ES2020` or later. Your `target` can stay unchanged. - **Accessor types**: `setXFrom` methods and setters that return no value now declare `void`. Getter types include `null` or `undefined` where applicable. +- **vtkOpenGLFramebuffer**: replace `getColorTexture()` with `getColorBuffers()[0]`. ## From 36.x to 37 diff --git a/Sources/Rendering/OpenGL/Convolution2DPass/index.js b/Sources/Rendering/OpenGL/Convolution2DPass/index.js index 10bf9197942..3cc834569c8 100644 --- a/Sources/Rendering/OpenGL/Convolution2DPass/index.js +++ b/Sources/Rendering/OpenGL/Convolution2DPass/index.js @@ -165,7 +165,7 @@ function vtkConvolution2DPass(publicAPI, model) { gl.scissor(0, 0, size[0], size[1]); // activate texture - const tex = model.framebuffer.getColorTexture(); + const tex = model.framebuffer.getColorBuffers()[0]; tex.activate(); model.convolutionShader.setUniformi('u_image', tex.getTextureUnit()); model.convolutionShader.setUniform2f( diff --git a/Sources/Rendering/OpenGL/ForwardPass/index.js b/Sources/Rendering/OpenGL/ForwardPass/index.js index 0437df6f669..b906a627317 100644 --- a/Sources/Rendering/OpenGL/ForwardPass/index.js +++ b/Sources/Rendering/OpenGL/ForwardPass/index.js @@ -113,7 +113,7 @@ function vtkForwardPass(publicAPI, model) { publicAPI.getZBufferTexture = () => { if (model.framebuffer) { - return model.framebuffer.getColorTexture(); + return model.framebuffer.getColorBuffers()[0]; } return null; }; diff --git a/Sources/Rendering/OpenGL/Framebuffer/index.d.ts b/Sources/Rendering/OpenGL/Framebuffer/index.d.ts index 1152ff72477..7a2ff57ad84 100644 --- a/Sources/Rendering/OpenGL/Framebuffer/index.d.ts +++ b/Sources/Rendering/OpenGL/Framebuffer/index.d.ts @@ -62,13 +62,6 @@ export interface vtkFramebuffer extends vtkObject { */ getColorBuffersByReference(): (Nullable | undefined)[]; - /** - * Get the texture attached as the first color buffer, if one is attached. - * - * @deprecated Use `getColorBuffers()[0]` instead. - */ - getColorTexture(): Nullable | undefined; - /** * Get the underlying WebGL framebuffer, or `null` before `create()`. */ diff --git a/Sources/Rendering/OpenGL/Framebuffer/index.js b/Sources/Rendering/OpenGL/Framebuffer/index.js index 1f732fe70a1..cc3dab0bfd5 100644 --- a/Sources/Rendering/OpenGL/Framebuffer/index.js +++ b/Sources/Rendering/OpenGL/Framebuffer/index.js @@ -310,9 +310,6 @@ function vtkFramebuffer(publicAPI, model) { publicAPI.releaseGraphicsResources, publicAPI.delete ); - - // For backwards compatibility. Use getColorBuffers()[0] going forward. - publicAPI.getColorTexture = () => model.colorBuffers[0]; } // ---------------------------------------------------------------------------- diff --git a/Sources/Rendering/OpenGL/RadialDistortionPass/index.js b/Sources/Rendering/OpenGL/RadialDistortionPass/index.js index 5a551a5d02c..0f798bd5700 100644 --- a/Sources/Rendering/OpenGL/RadialDistortionPass/index.js +++ b/Sources/Rendering/OpenGL/RadialDistortionPass/index.js @@ -133,7 +133,7 @@ function vtkRadialDistortionPass(publicAPI, model) { gl.scissor(0, 0, size[0], size[1]); // activate texture - const tex = model.framebuffer.getColorTexture(); + const tex = model.framebuffer.getColorBuffers()[0]; tex.activate(); model.copyShader.setUniformi('distTexture', tex.getTextureUnit()); diff --git a/Sources/Rendering/OpenGL/VolumeMapper/index.js b/Sources/Rendering/OpenGL/VolumeMapper/index.js index 58746db2170..696dbf0f200 100644 --- a/Sources/Rendering/OpenGL/VolumeMapper/index.js +++ b/Sources/Rendering/OpenGL/VolumeMapper/index.js @@ -1449,7 +1449,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { model.context.viewport(0, 0, size[0], size[1]); // activate texture - const tex = model.framebuffer.getColorTexture(); + const tex = model.framebuffer.getColorBuffers()[0]; tex.activate(); model.copyShader.setUniformi('texture', tex.getTextureUnit()); model.copyShader.setUniform2f('tfactor', model.fvp[0], model.fvp[1]); From d63f2b1be803cfed4b9c0757bf4abd076732472a Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Mon, 19 Oct 2026 14:02:31 -0400 Subject: [PATCH 2/2] perf(framebuffer): avoid copying color attachments during rendering --- Sources/Rendering/OpenGL/Convolution2DPass/index.js | 2 +- Sources/Rendering/OpenGL/ForwardPass/index.js | 2 +- .../OpenGL/Framebuffer/test/testReleaseGraphicsResources.js | 6 +++++- Sources/Rendering/OpenGL/RadialDistortionPass/index.js | 2 +- Sources/Rendering/OpenGL/VolumeMapper/index.js | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Sources/Rendering/OpenGL/Convolution2DPass/index.js b/Sources/Rendering/OpenGL/Convolution2DPass/index.js index 3cc834569c8..c5ab6c503de 100644 --- a/Sources/Rendering/OpenGL/Convolution2DPass/index.js +++ b/Sources/Rendering/OpenGL/Convolution2DPass/index.js @@ -165,7 +165,7 @@ function vtkConvolution2DPass(publicAPI, model) { gl.scissor(0, 0, size[0], size[1]); // activate texture - const tex = model.framebuffer.getColorBuffers()[0]; + const tex = model.framebuffer.getColorBuffersByReference()[0]; tex.activate(); model.convolutionShader.setUniformi('u_image', tex.getTextureUnit()); model.convolutionShader.setUniform2f( diff --git a/Sources/Rendering/OpenGL/ForwardPass/index.js b/Sources/Rendering/OpenGL/ForwardPass/index.js index b906a627317..a09f40f83cc 100644 --- a/Sources/Rendering/OpenGL/ForwardPass/index.js +++ b/Sources/Rendering/OpenGL/ForwardPass/index.js @@ -113,7 +113,7 @@ function vtkForwardPass(publicAPI, model) { publicAPI.getZBufferTexture = () => { if (model.framebuffer) { - return model.framebuffer.getColorBuffers()[0]; + return model.framebuffer.getColorBuffersByReference()[0]; } return null; }; diff --git a/Sources/Rendering/OpenGL/Framebuffer/test/testReleaseGraphicsResources.js b/Sources/Rendering/OpenGL/Framebuffer/test/testReleaseGraphicsResources.js index 908c2f7aebb..f4f3c714a4b 100644 --- a/Sources/Rendering/OpenGL/Framebuffer/test/testReleaseGraphicsResources.js +++ b/Sources/Rendering/OpenGL/Framebuffer/test/testReleaseGraphicsResources.js @@ -88,7 +88,11 @@ it.skipIf(__VTK_TEST_NO_WEBGL__)( // Removing one attachment must not shift the others off their slots. framebuffer.removeColorBuffer(0); - expect(framebuffer.getColorBuffers()[2]).toBe(texture2); + const colorBuffers = framebuffer.getColorBuffers(); + expect(colorBuffers[0]).toBeNull(); + expect(colorBuffers[1]).toBeUndefined(); + expect(colorBuffers[2]).toBe(texture2); + expect(framebuffer.getColorBuffersByReference()).toEqual(colorBuffers); expect(() => framebuffer.bind()).not.toThrow(); // recreating while bound must keep the caller on the new framebuffer diff --git a/Sources/Rendering/OpenGL/RadialDistortionPass/index.js b/Sources/Rendering/OpenGL/RadialDistortionPass/index.js index 0f798bd5700..bad898bb137 100644 --- a/Sources/Rendering/OpenGL/RadialDistortionPass/index.js +++ b/Sources/Rendering/OpenGL/RadialDistortionPass/index.js @@ -133,7 +133,7 @@ function vtkRadialDistortionPass(publicAPI, model) { gl.scissor(0, 0, size[0], size[1]); // activate texture - const tex = model.framebuffer.getColorBuffers()[0]; + const tex = model.framebuffer.getColorBuffersByReference()[0]; tex.activate(); model.copyShader.setUniformi('distTexture', tex.getTextureUnit()); diff --git a/Sources/Rendering/OpenGL/VolumeMapper/index.js b/Sources/Rendering/OpenGL/VolumeMapper/index.js index 696dbf0f200..19337469bcf 100644 --- a/Sources/Rendering/OpenGL/VolumeMapper/index.js +++ b/Sources/Rendering/OpenGL/VolumeMapper/index.js @@ -1449,7 +1449,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) { model.context.viewport(0, 0, size[0], size[1]); // activate texture - const tex = model.framebuffer.getColorBuffers()[0]; + const tex = model.framebuffer.getColorBuffersByReference()[0]; tex.activate(); model.copyShader.setUniformi('texture', tex.getTextureUnit()); model.copyShader.setUniform2f('tfactor', model.fvp[0], model.fvp[1]);