-
-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VolumeMapper & OpenGLTexture: support updating image regions #3077
base: master
Are you sure you want to change the base?
Conversation
2928f9f
to
eda0053
Compare
I've pushed a new commit:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
50806bc
to
22fc452
Compare
This is now ready for any final reviews @sankhesh. All commits will be squashed prior to merging. A summary of the recent commits:
|
22fc452
to
c34bb70
Compare
c34bb70
to
fb9b67d
Compare
model.renderable.setUpdatedExtents([]); | ||
|
||
// Build the image scalar texture | ||
const dims = image.getDimensions(); | ||
model.openGLTexture.create3DFilterableFromDataArray( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider transitioning from positional arguments to object-based arguments. It would make it easier to track which arguments have default values and which ones need to be added. It wouldn't be a breaking change since this are not really public APIs that people use IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good idea to consider. Probably best to wrap up such a change with the next major version increment anyways to be safe from a public API standpoint (even if it's mostly used internally).
if (!model.openGLTexture) { | ||
model.openGLTexture = vtkOpenGLTexture.newInstance(); | ||
model.openGLTexture.setOpenGLRenderWindow(model._openGLRenderWindow); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code has changed and there will be conflicts here
Look at how shared textures are handled in the mappers to make sure you do not break the resource sharing or create memory leaks
); | ||
|
||
model._paramCache = { | ||
tex3dAllocated: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of tex3dAllocated
, as it is always true?
|
||
// It's possible for the texture parameters to change while | ||
// streaming, so check for such a change. | ||
const rebuildEntireTexture = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can create a newParamCache
object and call DeepEqual
between this newParamCache
and model._paramCache
. Then, if they are different, you just have to do model._paramCache = newParamCache;
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)
andgetUpdatedExtents()
. This property defines which extents need to be updated.This property acts as a "request" to update a set of extents. It is cleared after every successful render call.
Changes
setUpdatedExtents()
andgetUpdatedExtents()
create3D*
functionsPR and Code Checklist
npm run reformat
to have correctly formatted codeTesting