Skip to content
/ VTK Public
forked from Kitware/VTK

[slicer-v9.2.20230607-1ff325c54-2] Backports related to Rendering & VR#46

Merged
jcfr merged 55 commits intoslicer-v9.2.20230607-1ff325c54-2from
slicer-v9.2.20230607-1ff325c54-2-backports
Dec 18, 2023
Merged

[slicer-v9.2.20230607-1ff325c54-2] Backports related to Rendering & VR#46
jcfr merged 55 commits intoslicer-v9.2.20230607-1ff325c54-2from
slicer-v9.2.20230607-1ff325c54-2-backports

Conversation

@jcfr
Copy link
Member

@jcfr jcfr commented Dec 17, 2023

Testing

Build of the VTK branch Build of CTK Build of Slicer Run Slicer
overload / Windows ✅(*)
computron / macOS ✅(*)
metroplex / Linux ✅(*)

(*) A performance regression was identified while exercising the volume rendering module. Running git bisect (see #46 (comment)) helped identify Kitware@cff3d9a60 (vtkRenderer: Fix prop picking in GetZ method) as the culprit.

List of changes related to Rendering & VR

Slicer specific

  • [SlicerVirtualReality] ENH: Update OpenVR json binding to map right and left trigger with triggeraction

Backports

Features

VR/OpenVR/OpenXR

  • XR: Move device pose update in interactor (MR-10742)

  • Overrideable vr interactions MR-10735

  • vtkModule: use FILE_SETs for header files (MR-10555)

  • Add volume clipping to vtkVRInteractorStyle (MR-10555)

  • OpenXR: Add missing EndInitialize in QueryInstanceVersion (MR-10550)

  • OpenXRRemoting: Streamline integration as plugin (MR-10449)

  • XR: Improve OpenXR instance management (MR-10543)

    • Add a utility function to query OpenXR instance version (Kitware/VTK@b46651d)

    • Enable switching from remoting XR runtime to default XR runtime dynamically (Kitware/VTK@d32293b)

      • Revert the following commit to allow integrating the next two commits, the corresponding functionality is integrated in a subsequent backport:
        • Revert: [Backport MR-10449] OpenXRRemoting: Streamline integration as plugin (abbbb1b)
  • OpenXR: Generalize XrCheck and downgrade action suggestion to a debug output (MR-10450)

    • OpenXRRemoting: Using XrCheckOutput (Kitware/VTK@8eee120)

      • Revert the following commits as corresponding equivalent changes integrated afterward:
        • Revert: [Backport MR-10450] OpenXR: Improve XrCheckOutput API fixing constness of level parameter (259459f)
        • Revert: [Backport MR-10450] OpenXRRemoting: Fix windows build using XrCheckOutput instead of XrCheckError (5c31352)
  • Move teleportation to interaction modes (MR-10546)

  • Add teleportation to VR (MR-10509)

  • VR Renderer: Add cross markers at tip of controllers (MR-10478)

  • OpenXR: Support depth buffer composition layer (MR-10596)

  • vtkWin32OpenGLDXRenderWindow: Fix missing include (MR-10730)

  • Split vtkWin32OpenGLDXRenderWindow initialization (MR-10484)

Rendering

jspanchu and others added 30 commits December 17, 2023 01:53
- The last few triangle's edges were not visible because the PrimitiveIDOffset in the shader overflowed and went past the end of the EdgeValues texture buffer. As a result, the edge equation's z component was garbage or 0.
- Resize and fill the edge values vector with placeholder elements to fix out of bounds access in geometry shader.
- This fix is borrowed from the vtkOpenGLBatchedPolyDataMapper code.

(cherry picked from commit Kitware/VTK@13e28a9)
VTK !8186 added support for using multitexturing with
InterpolateScalarsBeforeMappingOn to allow for blending interpolated
scalars with texture coloring.
This commit extends this support to the "actortexture" and "albedoTex"
textures that can be respectively set with vtkActor::SetTexture() and
vtkActor::GetProperty()->SetBaseColorTexture().

When turning on InterpolateScalarsBeforeMapping, the mapper internally
creates a texture with the associated texture coordinates.
This commit adds a specific attribute for those tcoords to avoid overriding
the existing polydata tcoords.

Merge-request: vtk/vtk!10271
(cherry picked from commit Kitware/VTK@7996928)
…data mapper

Backport fix from Kitware/VTK@79969286

Merge-request: vtk/vtk!10271
(cherry picked from commit Kitware/VTK@9925fd1)
… polydata mapper

Backport fix from Kitware/VTK@79969286

Merge-request: vtk/vtk!10271
(cherry picked from commit Kitware/VTK@00a170c)
TestBlockOpacity is using vtkCompositePolyDataMapper2 that was deprecated
for 9.3.
Remove this test here as it won't pass after the fix introduced in
7996928.
Backporting 7996928 to fix the TestBlockOpacity is easy, but there is no
point in fixing the deprecated class. The functionality is still tested
with vtkCompositePolyDataMapper in Rendering/Core.

Merge-request: vtk/vtk!10271
(cherry picked from commit Kitware/VTK@cc2498c)
Merge-request: vtk/vtk!10343
(cherry picked from commit Kitware/VTK@0d1d852)
Merge-request: vtk/vtk!10343
(cherry picked from commit Kitware/VTK@28ecc8b)
Merge-request: vtk/vtk!10343
(cherry picked from commit Kitware/VTK@f58faae)
Merge-request: vtk/vtk!10341
(cherry picked from commit Kitware/VTK@7676b6a)
Merge-request: vtk/vtk!10341
(cherry picked from commit Kitware/VTK@b61cc84)
Render surface with edges uses a geometry shader to draw a triangle
strip at the edges of polygons. Apart from calculating the edge
equation, it was offsetting the vertex positions to accommodate wide
lines. However, this would lead to overlapping inner edges. This change
removes this offset.

Merge-request: vtk/vtk!10403
(cherry picked from commit Kitware/VTK@2fe546c)
Merge-request: vtk/vtk!10435
(cherry picked from commit Kitware/VTK@3755243)
Supports using multivolume with IndependentComponentOff.
As in the single-input volume approach, the first three components are
used directly as RGB colors without being mapped through the color
transfer function.

Merge-request: vtk/vtk!10477
(cherry picked from commit Kitware/VTK@bf461af)
Merge-request: vtk/vtk!10477
(cherry picked from commit Kitware/VTK@97ba1fb)
Add changelog.

Merge-request: vtk/vtk!10477
(cherry picked from commit Kitware/VTK@9db07b4)
…unction

Merge-request: vtk/vtk!10477
(cherry picked from commit Kitware/VTK@129c55c)
Merge-request: vtk/vtk!10541
(cherry picked from commit Kitware/VTK@6dc5382)
…entTranslucentPass.

Merge-request: vtk/vtk!10603
(cherry picked from commit Kitware/VTK@fb22318)
Merge-request: vtk/vtk!10636
(cherry picked from commit Kitware/VTK@9d6f627)
Merge-request: vtk/vtk!10636
(cherry picked from commit Kitware/VTK@9162959)
…o report errors

Merge-request: vtk/vtk!10646
(cherry picked from commit Kitware/VTK@3bd2e83)
Enable overriding the default depth mask value for volumes.
Read the value of the existing DepthMaskOverride property key to alter
the value of the depth mask if needed.

Merge-request: vtk/vtk!10642
(cherry picked from commit Kitware/VTK@1995c65)
…cement

Add a tag for shader replacement in computeLighting.
This can be used to store variable as global variables when using shader
replacement.

Merge-request: vtk/vtk!10645
(cherry picked from commit Kitware/VTK@2e94e80)
Merge-request: vtk/vtk!10705
(cherry picked from commit Kitware/VTK@d43ab15)
…ture

Merge-request: vtk/vtk!10644
(cherry picked from commit Kitware/VTK@0f2025f)
…ys efficiently

Expose virtual functions called for each prop in the PreRender and
PostRender functions of vtkOpenGLRenderPass. This allows for accessing
information keys without having to iterate again over the array of filtered
props.

Merge-request: vtk/vtk!10725
(cherry picked from commit Kitware/VTK@44e8f26)
AlexyPellegrini and others added 12 commits December 17, 2023 16:24
…ntime dynamically

The default OpenXRManagerConnection ensure that XR_RUNTIME_JSON
environment variable is unset in Initialize.
This enable multiple version queries or OpenXR render windows to use
different OpenXR runtimes.

Merge-request: vtk/vtk!10543
(cherry picked from commit Kitware/VTK@d32293b)
This doesn't need a full vtkOpenXRManager initialization, this function
instantiates an independent xrInstance to query the version.

Merge-request: vtk/vtk!10543
(cherry picked from commit Kitware/VTK@b46651d)
To support scenario where OpenXRRemoting library and companion files
provided by the "microsoft.holographic.remoting.openxr" package are not
distributed along side the application executable, this commit updates
the heuristic looking up for "RemotingXR.json" to first consider the
vtkRenderingOpenXRRemoting library directory.

Merge-request: vtk/vtk!10449
(cherry picked from commit Kitware/VTK@7c0474c)
Fix ForEachNonWidgetProp

Merge-request: vtk/vtk!10555
(cherry picked from commit Kitware/VTK@2904bb8)
It is included by `vtkVRRenderWindow.h`.

Merge-request: vtk/vtk!10621
(cherry picked from commit Kitware/VTK@d79eba4)
Merge-request: vtk/vtk!10735
(cherry picked from commit Kitware/VTK@dd2a56a)
Merge-request: vtk/vtk!10735
(cherry picked from commit Kitware/VTK@d1699eb)
This enables interactor styles to override controller pose, in events such
as PositionProp or Move3D events, but still getting access to the up to
date value in said events.

Merge-request: vtk/vtk!10742
(cherry picked from commit Kitware/VTK@a155740)
Merge-request: vtk/vtk!10307
(cherry picked from commit Kitware/VTK@28e580e)
This new option is off by default, but when turned on, renders the
scalar bar title vertically rather than horizontally.

Merge-request: vtk/vtk!10306
(cherry picked from commit Kitware/VTK@fa6552e)
…nd left trigger with triggeraction

This is required to support using the trigger button for complex gesture.
See vtkVirtualRealityViewInteractor::SetGestureButtonToTrigger()

Co-authored-by: Lucas Gandel <lucas.gandel@kitware.com>
@jcfr
Copy link
Member Author

jcfr commented Dec 17, 2023

@jcfr
Copy link
Member Author

jcfr commented Dec 17, 2023

Volume rendering seems much slower with these backports ... I am not yet1 sure if a performance regression was introduced and later fixed in a commit I did not integrate.

Footnotes

  1. I will do a local experimental build against VTK master to confirm this.

@jcfr
Copy link
Member Author

jcfr commented Dec 18, 2023

After running a bisect, I ended up identifying the faulty commit as being d8cacb2 introduced in upstream as Kitware@cff3d9a through MR-10391 and intended to fix VTK issue 18503.

image

@jcfr jcfr merged commit 2e91328 into slicer-v9.2.20230607-1ff325c54-2 Dec 18, 2023
@lassoan
Copy link

lassoan commented Dec 18, 2023

Great detective work @jcfr. Make sure the VTK team is aware of the issue - they would probably want to revert the commit or do further investigation (and for this the test that you created for the bisect could be very useful).

@jcfr
Copy link
Member Author

jcfr commented Dec 18, 2023

the test that you created for the bisect could be very useful

The process was manual. Enabling the volume rendering of MRHead (with MR-Default preset) and interacting with the 3D view was slow on my workstation.

This is likely explained by how we make sure of vtkWorldPointPicker::Pick, see more details at Slicer/Slicer#7487 (comment)

@jcfr jcfr deleted the slicer-v9.2.20230607-1ff325c54-2-backports branch December 18, 2023 05:22
@jcfr
Copy link
Member Author

jcfr commented Dec 18, 2023

@lassoan As the original contributor of vtkMRMLThreeDViewInteractorStyle::QuickPick and vtkMRMLInteractionEventData::SetAccuratePicker in Slicer/Slicer@364ff7b, it would be great if you could review VTK issue 185031 and its associated MR-103912. This help us building a case for either reverting or updating the vtkRenderer API.

One potential approach is to consider adding a boolean parameter to the existing vtkRenderer::GetZ() method. Alternatively, we could also introduced a new method like vtkRenderer::GetAccurateZ().

Footnotes

  1. https://gitlab.kitware.com/vtk/vtk/-/issues/18503

  2. https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10391

@jcfr
Copy link
Member Author

jcfr commented Dec 18, 2023

@lassoan @pieper

Also, since in itself this branch is ready for integration, I would appreciate an approval.

Since the commit introducing the "regression" as been identified and reverted, we will work on addressing the vtkRenderer::GetZ issue later.

@lassoan
Copy link

lassoan commented Dec 18, 2023

I've posted to the VTK merge request here: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10391#note_1459483
Should we reopen the issue or enter a new issue as well (as a comment in a closed MR is very easy to ignore)?

@lassoan
Copy link

lassoan commented Dec 18, 2023

Also, since in itself this branch is ready for integration, I would appreciate an approval.

Approved. Reviewing 55 commits in detail would be very time consuming, so I only had a quick look at the commit headlines. I was just wondering why do we manage so many backported changes. Could we use a more recent VTK release and have maybe just a couple of Slicer-specific patches?

@jcfr
Copy link
Member Author

jcfr commented Dec 18, 2023

I was just wondering why do we manage so many backported changes.

Considering the end of the year & the fact I have to integrate some of the recent Rendering changes along with the one related to OpenXR & OpenXRRemoting, it was easier to select the few commits specific to rendering and VR/XR.

In a nutshell, I preferred to only introduce selected "critical" changes and avoid to deal with side effects of VTK build-system updates and alike (yet).

Could we use a more recent VTK release and have maybe just a couple of Slicer-specific patches?

This will be done earlier next year.

To clarify, the only Slicer specific changes are these ones and beside of 2e91328 introduced few days ago and specific to SlicerVirtualReality, there is nothing Slicer specific to review.

  • 2e91328 - [SlicerVirtualReality] ENH: Update OpenVR json binding to map right and left trigger with triggeraction
  • 6d0bf9e - [SlicerSMTK] vtkm: Use github.com/KitwareMedical/vtk-m: Update diy install rules, support TBB_DIR
  • 4d6dfb2 - [SlicerSMTK] COMP: Add support for specifying vtk-m library install components
  • 8b22157 - [Slicer] COMP: Remove FindTBB and expect VTK to be configured with TBB_DIR
  • c82e337 - [Slicer] BUG: Update vtkPythonUtil to disable relative import causing crash for Slicer modules
  • aea1f44 - [Slicer] COMP: Remove custom FindOpenGL to ensure OpenGL_GL_PREFERENCE is considered

.. from which these one have already been integrated upstream through MR-10400:

  • 0227875 - [SlicerVirtualReality] BUG: Ensure a valid OpenVR pose is returned
  • c6189a4 - [SlicerVirtualReality] ENH: Re-introduce OpenVR API for retrieving last OpenVR pose

and this one was just to avoid a false positive:

  • a3ab617 - [Slicer] COMP: Empty commit to workaround CTest false positive

@jcfr
Copy link
Member Author

jcfr commented Dec 18, 2023

Reviewing 55 commits in detail would be very time consuming

Agreed.

And, as you mentioned, having a quick look is the way to go.

To put things in perspective, when I update VTK or ITK, I also go through the list of changes introduced between version doing a cursory review. As you noted, looking at each one of them in details would not be feasible.

This set of backported changes is not much different from a regular version update. The advantage in this case is that it allowed to fairly efficiently identify a regression through git bisect.

@lassoan
Copy link

lassoan commented Dec 18, 2023

All sounds good, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.