Skip to content

VolumeMapper & OpenGLTexture: support updating image regions#3077

Merged
floryst merged 1 commit intomasterfrom
streaming-textures
Mar 14, 2025
Merged

VolumeMapper & OpenGLTexture: support updating image regions#3077
floryst merged 1 commit intomasterfrom
streaming-textures

Conversation

@floryst
Copy link
Copy Markdown
Contributor

@floryst floryst commented Jun 4, 2024

Context

When updating a 3D texture, the entire texture is uploaded to the GPU. If a volume is incrementally updated (e.g. slice-by-slice), then there is a lot of unchanged data being uploaded at every update.

This changeset lets the VolumeMapper specify image regions that have updated. Internally, this tells vtkOpenGLTexture to only update those regions via texSubImage3D.

This change can also be applied to other mappers that use the 3D textures, e.g. the ImageResliceMapper.

Results

The volume mapper now has the following methods: setUpdatedExtents(extents) and getUpdatedExtents(). This property defines which extents need to be updated.

const extent = [20, 49, 20, 49, 20, 49];
volumeMapper.setUpdatedExtents([...volumeMapper.getUpdatedExtents(), extent]);

This property acts as a "request" to update a set of extents. It is cleared after every successful render call.

Changes

  • Documentation and TypeScript definitions were updated to match those changes
  • vtkVolumeMapper and vtkImageResliceMapper: setUpdatedExtents() and getUpdatedExtents()
  • vtkOpenGLTexture: support updated extents in create3D* functions

PR and Code Checklist

  • semantic-release commit messages
  • Run npm run reformat to have correctly formatted code

Testing

  • This change adds or fixes unit tests
  • Tested environment:
    • vtk.js:
    • OS:
    • Browser:

@floryst
Copy link
Copy Markdown
Contributor Author

floryst commented Jun 4, 2024

@sankhesh @finetjul it would be good to do a review of the API, since this is an initial draft at a working API.Some initial thoughts:

  • Maybe add a addRegionsToUpdate method
  • Should the regions be user-cleared or cleared after every render call

@floryst floryst force-pushed the streaming-textures branch 2 times, most recently from 2928f9f to eda0053 Compare June 4, 2024 21:22
Comment thread Sources/Rendering/Core/VolumeMapper/index.d.ts Outdated
Comment thread Sources/Rendering/Core/VolumeMapper/index.d.ts Outdated
Comment thread Sources/Rendering/OpenGL/Texture/index.js Outdated
Comment thread Sources/Rendering/OpenGL/Texture/index.js Outdated
Comment thread Sources/Rendering/OpenGL/Texture/index.js
Comment thread Sources/Rendering/OpenGL/Texture/index.js Outdated
@floryst
Copy link
Copy Markdown
Contributor Author

floryst commented Jun 5, 2024

I've pushed a new commit:

  • rename "region" to "extent" and use the existing Extent type
  • minor perf improvements to the extent handling (not measured)

Copy link
Copy Markdown
Member

@finetjul finetjul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@floryst floryst force-pushed the streaming-textures branch from 50806bc to 22fc452 Compare June 11, 2024 17:06
@floryst floryst marked this pull request as ready for review June 11, 2024 17:06
@floryst
Copy link
Copy Markdown
Contributor Author

floryst commented Jun 11, 2024

This is now ready for any final reviews @sankhesh. All commits will be squashed prior to merging.

A summary of the recent commits:

  • Add updatedExtents support for the vtkImageResliceMapper
  • Add a test for vtkOpenGLVolumeMapper and fix an updatedExtents-related bug in vtkOpenGLTexture

@floryst floryst force-pushed the streaming-textures branch from 22fc452 to c34bb70 Compare June 11, 2024 18:18
@floryst floryst force-pushed the streaming-textures branch from c34bb70 to fb9b67d Compare June 18, 2024 15:21
@floryst floryst requested a review from sankhesh June 25, 2024 14:29
Comment thread Sources/Rendering/OpenGL/ImageResliceMapper/index.js
@finetjul finetjul requested a review from bruyeret August 5, 2024 06:53
Comment thread Sources/Rendering/OpenGL/ImageResliceMapper/index.js Outdated
Comment thread Sources/Rendering/OpenGL/Texture/index.js Outdated
Comment thread Sources/Rendering/OpenGL/Texture/index.js
Copy link
Copy Markdown
Member

@finetjul finetjul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Collaborator

@sankhesh sankhesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@floryst floryst force-pushed the streaming-textures branch from 6f7ecc4 to d030714 Compare March 11, 2025 19:41
@floryst
Copy link
Copy Markdown
Contributor Author

floryst commented Mar 12, 2025

I'll merge this once #3221 goes in, since I need to rebase and handle conflicts anyways.

@floryst floryst added this pull request to the merge queue Mar 13, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Mar 13, 2025
vtkVolumeMapper, vtkImageCPRMapper, and vtkImageResliceMapper all now
support updating sub-image extents, reducing the GPU upload overhead
when part of the image has updated.
@floryst floryst force-pushed the streaming-textures branch from fa6efd1 to ac64b76 Compare March 14, 2025 15:19
@floryst floryst added this pull request to the merge queue Mar 14, 2025
@floryst floryst removed this pull request from the merge queue due to a manual request Mar 14, 2025
@floryst floryst added this pull request to the merge queue Mar 14, 2025
@sedghi
Copy link
Copy Markdown
Contributor

sedghi commented Mar 14, 2025

@floryst Could we perhaps release a minor version with the installation fix before merging this larger change?

#3231
#3226

Merged via the queue into master with commit 0f13c25 Mar 14, 2025
2 checks passed
@floryst
Copy link
Copy Markdown
Contributor Author

floryst commented Mar 14, 2025

Oh I saw your comment a little too late, sorry. I'll get a fix out for that.

@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 32.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Automated label label Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Automated label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants