Commit 66a9f642 authored by David DeMarle's avatar David DeMarle
Browse files

improve benchmark and tests

command line arg "-EXT number" to control wavelet size
command line arg "-GL" to use OpenGL instead of OSPRay
reports wavelet build time too

Bring over another test and add -GL command lines to ease comparison
parent 635978d5
......@@ -17,6 +17,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestOSPRayVolumeRenderer.cxx
TestGPURayCastAdditive.cxx
TestGPURayCastCameraInside.cxx
TestGPURayCastCellData.cxx
TestGPURayCastCameraInsideSmallSpacing.cxx
TestGPURayCastMapperBenchmark.cxx
TestGPURayCastMapperSampleDistance.cxx
......
......@@ -36,7 +36,8 @@
#include "vtkDataArray.h"
#include "vtkOSPRayPass.h"
#include "vtkProperty.h"
#include "vtkSmartPointer.h"
#include "vtkOSPRayTestInteractor.h"
int TestGPURayCastAdditive(int argc,
char *argv[])
......@@ -88,7 +89,15 @@ int TestGPURayCastAdditive(int argc,
// intentional odd and NPOT width/height
renWin->SetSize(301,300);
vtkNew<vtkOSPRayPass> osprayPass;
ren1->SetPass(osprayPass.GetPointer());
vtkSmartPointer<vtkOSPRayTestInteractor> style =
vtkSmartPointer<vtkOSPRayTestInteractor>::New();
style->SetPipelineControlPoints((vtkOpenGLRenderer*)ren1, osprayPass.Get(), NULL);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetInteractorStyle(style);
iren->SetRenderWindow(renWin);
renWin->Delete();
......@@ -135,10 +144,6 @@ int TestGPURayCastAdditive(int argc,
volume->SetProperty(volumeProperty);
ren1->AddViewProp(volume);
// Attach OSPRay render pass
vtkNew<vtkOSPRayPass> osprayPass;
ren1->SetPass(osprayPass.GetPointer());
int valid = volumeMapper->IsRenderSupported(renWin,volumeProperty);
int retVal;
......
......@@ -914,6 +914,16 @@ int TestGPURayCastCameraInside(int argc, char *argv[])
{
cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl;
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
char* volumeFile = vtkTestUtilities::ExpandDataFileName(
argc, argv, "Data/ironProt.vtk");
vtkNew<vtkStructuredPointsReader> reader;
......@@ -961,7 +971,10 @@ int TestGPURayCastCameraInside(int argc, char *argv[])
// Attach OSPRay render pass
vtkSmartPointer<vtkOSPRayPass> osprayPass =
vtkSmartPointer<vtkOSPRayPass>::New();
ren->SetPass(osprayPass.GetPointer());
if (!useOSP)
{
ren->SetPass(osprayPass.GetPointer());
}
ren->AddVolume(volume.GetPointer());
ren->ResetCamera();
......
......@@ -1558,6 +1558,16 @@ int TestGPURayCastCameraInsideSmallSpacing(int argc, char *argv[])
{
cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl;
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
char* volumeFile = vtkTestUtilities::ExpandDataFileName(
argc, argv, "Data/ironProt.vtk");
vtkNew<vtkStructuredPointsReader> reader;
......@@ -1622,7 +1632,10 @@ int TestGPURayCastCameraInsideSmallSpacing(int argc, char *argv[])
// Attach OSPRay render pass
vtkSmartPointer<vtkOSPRayPass> osprayPass =
vtkSmartPointer<vtkOSPRayPass>::New();
ren->SetPass(osprayPass.GetPointer());
if (useOSP)
{
ren->SetPass(osprayPass.GetPointer());
}
ren->AddVolume(volume.GetPointer());
ren->ResetCamera();
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestGPURayCastVolumeUpdate.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// This test volume tests whether updating the volume MTime updates the ,
// geometry in the volume mapper.
#include <vtkColorTransferFunction.h>
#include <vtkDataArray.h>
#include <vtkGPUVolumeRayCastMapper.h>
#include <vtkImageData.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkNew.h>
#include <vtkOutlineFilter.h>
#include <vtkOSPRayPass.h>
#include <vtkPiecewiseFunction.h>
#include <vtkPointDataToCellData.h>
#include <vtkPolyDataMapper.h>
#include <vtkRegressionTestImage.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRTAnalyticSource.h>
#include <vtkSmartPointer.h>
#include <vtkTesting.h>
#include <vtkTestUtilities.h>
#include <vtkVolumeProperty.h>
#include <vtkXMLImageDataReader.h>
int TestGPURayCastCellData(int argc, char *argv[])
{
cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl;
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
double scalarRange[2];
vtkNew<vtkActor> outlineActor;
vtkNew<vtkPolyDataMapper> outlineMapper;
vtkNew<vtkGPUVolumeRayCastMapper> volumeMapper;
vtkNew<vtkXMLImageDataReader> reader;
char* volumeFile = vtkTestUtilities::ExpandDataFileName(
argc, argv, "Data/vase_1comp.vti");
reader->SetFileName(volumeFile);
delete[] volumeFile;
vtkNew<vtkPointDataToCellData> pointToCell;
pointToCell->SetInputConnection(reader->GetOutputPort());
volumeMapper->SetInputConnection(pointToCell->GetOutputPort());
// Add outline filter
vtkNew<vtkOutlineFilter> outlineFilter;
outlineFilter->SetInputConnection(pointToCell->GetOutputPort());
outlineMapper->SetInputConnection(outlineFilter->GetOutputPort());
outlineActor->SetMapper(outlineMapper.GetPointer());
volumeMapper->GetInput()->GetScalarRange(scalarRange);
volumeMapper->SetSampleDistance(0.1);
volumeMapper->SetAutoAdjustSampleDistances(0);
volumeMapper->SetBlendModeToComposite();
vtkNew<vtkRenderWindow> renWin;
renWin->SetMultiSamples(0);
renWin->SetSize(400, 400);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
vtkNew<vtkInteractorStyleTrackballCamera> style;
iren->SetInteractorStyle(style.GetPointer());
renWin->Render(); // make sure we have an OpenGL context.
vtkNew<vtkRenderer> ren;
ren->SetBackground(0.2, 0.2, 0.5);
renWin->AddRenderer(ren.GetPointer());
vtkNew<vtkPiecewiseFunction> scalarOpacity;
scalarOpacity->AddPoint(50, 0.0);
scalarOpacity->AddPoint(75, 1.0);
vtkNew<vtkVolumeProperty> volumeProperty;
volumeProperty->ShadeOn();
volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION);
volumeProperty->SetScalarOpacity(scalarOpacity.GetPointer());
vtkNew<vtkColorTransferFunction> colorTransferFunction;
colorTransferFunction->RemoveAllPoints();
colorTransferFunction->AddRGBPoint(scalarRange[0], 0.6, 0.4, 0.1);
volumeProperty->SetColor(colorTransferFunction.GetPointer());
vtkNew<vtkVolume> volume;
volume->SetMapper(volumeMapper.GetPointer());
volume->SetProperty(volumeProperty.GetPointer());
ren->AddVolume(volume.GetPointer());
ren->AddActor(outlineActor.GetPointer());
ren->ResetCamera();
vtkNew<vtkOSPRayPass> osprayPass;
if (useOSP)
{
ren->SetPass(osprayPass.GetPointer());
}
renWin->Render();
ren->ResetCamera();
iren->Initialize();
int retVal = vtkRegressionTestImage( renWin.GetPointer() );
if( retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
......@@ -36,11 +36,32 @@ int TestGPURayCastMapperBenchmark(int argc, char* argv[])
{
cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl;
bool useOSP = true;
int EXT=128;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
useOSP = false;
}
if (!strcmp(argv[i], "-EXT"))
{
EXT = atoi(argv[i+1]);
}
}
vtkNew<vtkRTAnalyticSource> wavelet;
wavelet->SetWholeExtent(-127, 128,
-127, 128,
-127, 128);
wavelet->SetWholeExtent(-(EXT-1), EXT,
-(EXT-1), EXT,
-(EXT-1), EXT);
wavelet->SetCenter(0.0, 0.0, 0.0);
vtkNew<vtkTimerLog> timer;
cerr << "Make data" << endl;
timer->StartTimer();
wavelet->Update();
timer->StopTimer();
double makeDataTime = timer->GetElapsedTime();
cerr << "Make data time: " << makeDataTime << endl;
vtkNew<vtkGPUVolumeRayCastMapper> volumeMapper;
volumeMapper->SetInputConnection(wavelet->GetOutputPort());
......@@ -64,7 +85,7 @@ int TestGPURayCastMapperBenchmark(int argc, char* argv[])
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->SetSize(900, 900);
// renderWindow->Render(); // make sure we have an OpenGL context.
renderWindow->Render(); // make sure we have an OpenGL context.
vtkNew<vtkRenderer> renderer;
renderer->AddVolume(volume.GetPointer());
......@@ -73,7 +94,10 @@ int TestGPURayCastMapperBenchmark(int argc, char* argv[])
// Attach OSPRay render pass
vtkNew<vtkOSPRayPass> osprayPass;
renderer->SetPass(osprayPass.GetPointer());
if (useOSP)
{
renderer->SetPass(osprayPass.GetPointer());
}
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renderWindow.GetPointer());
......@@ -84,7 +108,6 @@ int TestGPURayCastMapperBenchmark(int argc, char* argv[])
if (valid)
{
vtkNew<vtkTimerLog> timer;
timer->StartTimer();
renderWindow->Render();
timer->StopTimer();
......
......@@ -36,6 +36,15 @@
//----------------------------------------------------------------------------
int TestGPURayCastMapperSampleDistance(int argc, char* argv[])
{
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
vtkNew<vtkRTAnalyticSource> wavelet;
wavelet->SetWholeExtent(-127, 128,
-127, 128,
......@@ -75,7 +84,10 @@ int TestGPURayCastMapperSampleDistance(int argc, char* argv[])
// Attach OSPRay render pass
vtkNew<vtkOSPRayPass> osprayPass;
renderer->SetPass(osprayPass.GetPointer());
if (useOSP)
{
renderer->SetPass(osprayPass.GetPointer());
}
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renderWindow.GetPointer());
......
......@@ -41,6 +41,15 @@ int TestGPURayCastPerspectiveParallel(int argc,
char *argv[])
{
cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl;
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
// Create a spherical implicit function.
vtkSphere *shape=vtkSphere::New();
......@@ -125,7 +134,10 @@ int TestGPURayCastPerspectiveParallel(int argc,
// Attach OSPRay render pass
vtkNew<vtkOSPRayPass> osprayPass;
ren1->SetPass(osprayPass.GetPointer());
if (useOSP)
{
ren1->SetPass(osprayPass.GetPointer());
}
int valid=volumeMapper->IsRenderSupported(renWin,volumeProperty);
......
......@@ -44,6 +44,16 @@
int TestGPURayCastVolumeLightKit(int argc, char *argv[])
{
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
double scalarRange[2];
vtkNew<vtkGPUVolumeRayCastMapper> volumeMapper;
......@@ -99,7 +109,10 @@ int TestGPURayCastVolumeLightKit(int argc, char *argv[])
// Attach OSPRay render pass
vtkNew<vtkOSPRayPass> osprayPass;
ren->SetPass(osprayPass.GetPointer());
if (useOSP)
{
ren->SetPass(osprayPass.GetPointer());
}
renWin->Render();
ren->ResetCamera();
......
......@@ -44,6 +44,15 @@
int TestGPURayCastVolumePolyData(int argc, char *argv[])
{
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
double scalarRange[2];
vtkNew<vtkActor> outlineActor;
......@@ -129,7 +138,10 @@ int TestGPURayCastVolumePolyData(int argc, char *argv[])
// Attach OSPRay render pass
vtkNew<vtkOSPRayPass> osprayPass;
ren->SetPass(osprayPass.GetPointer());
if (useOSP)
{
ren->SetPass(osprayPass.GetPointer());
}
renWin->Render();
ren->ResetCamera();
......
......@@ -45,6 +45,16 @@
int TestGPURayCastVolumeRotation(int argc, char *argv[])
{
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
double scalarRange[2];
vtkNew<vtkActor> outlineActor;
......@@ -114,7 +124,10 @@ int TestGPURayCastVolumeRotation(int argc, char *argv[])
// Attach OSPRay render pass
vtkNew<vtkOSPRayPass> osprayPass;
ren->SetPass(osprayPass.GetPointer());
if (useOSP)
{
ren->SetPass(osprayPass.GetPointer());
}
ren->AddViewProp(volume.GetPointer());
ren->AddActor(outlineActor.GetPointer());
......
......@@ -47,6 +47,15 @@
int TestGPURayCastVolumeScale(int argc, char *argv[])
{
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
double scalarRange[2];
vtkNew<vtkActor> outlineActor;
......@@ -113,7 +122,10 @@ int TestGPURayCastVolumeScale(int argc, char *argv[])
// Attach OSPRay render pass
vtkNew<vtkOSPRayPass> osprayPass;
ren->SetPass(osprayPass.GetPointer());
if (useOSP)
{
ren->SetPass(osprayPass.GetPointer());
}
renWin->Render();
ren->ResetCamera();
......
......@@ -1247,6 +1247,15 @@ static const char * TestGPUVolumeRayCastMapperLog =
int TestGPUVolumeRayCastMapper(int argc, char *argv[])
{
cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl;
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
vtkNew<vtkRTAnalyticSource> wavelet;
wavelet->SetWholeExtent(-10, 10,
......@@ -1299,7 +1308,10 @@ int TestGPUVolumeRayCastMapper(int argc, char *argv[])
// Attach OSPRay render pass
vtkNew<vtkOSPRayPass> osprayPass;
renderer->SetPass(osprayPass.GetPointer());
if (useOSP)
{
renderer->SetPass(osprayPass.GetPointer());
}
volumeMapper->DebugOn();
......
......@@ -20,11 +20,11 @@
#include <vtkColorTransferFunction.h>
#include <vtkDataArray.h>
#include <vtkDataSetSurfaceFilter.h>
#include <vtkGPUVolumeRayCastMapper.h>
#include <vtkImageData.h>
#include <vtkImageReader.h>
#include <vtkImageShiftScale.h>
#include <vtkNew.h>
#include <vtkOSPRayVolumeMapper.h>
#include <vtkPlane.h>
#include <vtkPiecewiseFunction.h>
#include <vtkPlane.h>
......@@ -51,15 +51,14 @@ int TestOSPRayVolumeRenderer(int argc, char *argv[])
vtkNew<vtkActor> outlineActor;
vtkNew<vtkPolyDataMapper> outlineMapper;
vtkNew<vtkGPUVolumeRayCastMapper> volumeMapper;
//TODO: replace with OSPRayVolumeMapper when done
vtkNew<vtkOSPRayVolumeMapper> volumeMapper;
vtkNew<vtkXMLImageDataReader> reader;
const char* volumeFile = vtkTestUtilities::ExpandDataFileName(
argc, argv, "Data/vase_1comp.vti");
reader->SetFileName(volumeFile);
volumeMapper->SetInputConnection(reader->GetOutputPort());
volumeMapper->SetSampleDistance(0.01);
//volumeMapper->SetSampleDistance(0.01);
// Put inside an open box to evaluate composite order
vtkNew<vtkDataSetSurfaceFilter> outlineFilter;
......@@ -78,7 +77,7 @@ int TestOSPRayVolumeRenderer(int argc, char *argv[])
volumeMapper->GetInput()->GetScalarRange(scalarRange);
volumeMapper->SetBlendModeToComposite();
volumeMapper->SetAutoAdjustSampleDistances(1);
//volumeMapper->SetAutoAdjustSampleDistances(1);
vtkNew<vtkRenderWindow> renWin;
renWin->SetMultiSamples(0);
......@@ -120,10 +119,6 @@ int TestOSPRayVolumeRenderer(int argc, char *argv[])
volume->RotateX(90.0);
outlineActor->RotateX(90.0);
// Attach OSPRay render pass
//TODO: when OSPRayVolumeMapper works, don't use the pass
vtkNew<vtkOSPRayPass> osprayPass;
ren->SetPass(osprayPass.GetPointer());
ren->AddViewProp(volume.GetPointer());
ren->AddActor(outlineActor.GetPointer());
renWin->Render();
......
......@@ -52,13 +52,28 @@ VTK_MODULE_INIT(vtkRenderingOSPRay);
int TestSmartVolumeMapper(int argc,
char *argv[])
{
bool useOSP = true;
for (int i = 0; i < argc; i++)
{
if (!strcmp(argv[i], "-GL"))
{
cerr << "GL" << endl;
useOSP = false;
}
}
double scalarRange[2];
vtkNew<vtkActor> outlineActor;
vtkNew<vtkPolyDataMapper> outlineMapper;
vtkNew<vtkSmartVolumeMapper> volumeMapper;
//TODO: replace with OSPRayVolumeMapper when done
volumeMapper->SetRequestedRenderModeToOSPRay();
if (useOSP)
{
volumeMapper->SetRequestedRenderModeToOSPRay();
}
else
{
}
vtkNew<vtkXMLImageDataReader> reader;
const char* volumeFile = vtkTestUtilities::ExpandDataFileName(
......
Supports Markdown
0% or