vtkMultiVolume remove and add again will slow render
version:VTK-9.3.0.rc1
repeat step:
- add a vtkMultiVolume to window, e.g. m_pRender->AddViewProp(prop)
- remove it, e.g. m_pRender->RemoveViewProp(prop);
- add the vtkMultiVolume to window again, e.g. m_pRender->AddViewProp(prop)
- do some render, it will render slow than do some render at step 1.
I compare the code difference, it's difference is as below:
void vtkOpenGLGPUVolumeRayCastMapper::GPURender(vtkRenderer* ren, vtkVolume* vol){
...
// when at step 3,
// below NeedToInitializeResources is always true, this->Impl->InitializationTime.ModifiedTime is always 0
// so this->Impl->UpdateInputs(ren, vol) will always Initialize Resources, and it slow render.
this->Impl->NeedToInitializeResources =
(this->Impl->ReleaseResourcesTime.GetMTime() > this->Impl->InitializationTime.GetMTime());
this->ComputeReductionFactor(vol->GetAllocatedRenderTime());
if (!this->Impl->SharedDepthTextureObject)
{
this->Impl->CaptureDepthTexture(ren);
}
vtkMTimeType renderPassTime = this->GetRenderPassStageMTime(vol);
const auto multiVol = vtkMultiVolume::SafeDownCast(vol);
this->Impl->MultiVolume = multiVol && this->GetInputCount() > 1 ? multiVol : nullptr;
this->Impl->ClearRemovedInputs(renWin);
if (!this->Impl->UpdateInputs(ren, vol))
{
return;
}
}
Edited by hgyxb ll