Commit e2c61e01 authored by Robert Maynard's avatar Robert Maynard

Update the HelloWorld example to use VTK-m runtime device adapter logic

parent 34165c8e
......@@ -32,19 +32,11 @@ if(TARGET OpenGL::GL AND
set(gl_libs OpenGL::GL GLEW::GLEW GLUT::GLUT)
add_executable(HelloWorld_SERIAL HelloWorld.cxx LoadShaders.h)
target_link_libraries(HelloWorld_SERIAL
PRIVATE vtkm_cont ${gl_libs})
if(TARGET vtkm::tbb)
add_executable(HelloWorld_TBB HelloWorldTBB.cxx LoadShaders.h)
target_link_libraries(HelloWorld_TBB
PRIVATE vtkm_cont ${gl_libs})
endif()
if(TARGET vtkm::cuda)
add_executable(HelloWorld_CUDA HelloWorld.cu LoadShaders.h)
target_link_libraries(HelloWorld_CUDA
PRIVATE vtkm_cont ${gl_libs})
add_executable(HelloWorld HelloWorld.cu LoadShaders.h)
else()
add_executable(HelloWorld HelloWorld.cxx LoadShaders.h)
endif()
target_link_libraries(HelloWorld PRIVATE vtkm_cont ${gl_libs})
endif()
......@@ -18,12 +18,6 @@
// this software.
//============================================================================
//We first check if VTKM_DEVICE_ADAPTER is defined, so that when TBB and CUDA
//includes this file we use the device adapter that they have set.
#ifndef VTKM_DEVICE_ADAPTER
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_SERIAL
#endif
// Must be included before any other GL includes:
#include <GL/glew.h>
......@@ -31,6 +25,7 @@
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/interop/TransferToOpenGL.h>
#include <vtkm/worklet/DispatcherMapField.h>
......@@ -53,7 +48,7 @@
#include "LoadShaders.h"
template <typename DeviceAdapter, typename T>
template <typename T>
struct HelloVTKMInterop
{
vtkm::Vec<vtkm::Int32, 2> Dims;
......@@ -64,7 +59,7 @@ struct HelloVTKMInterop
vtkm::interop::BufferState VBOState;
vtkm::interop::BufferState ColorState;
vtkm::cont::Timer<DeviceAdapter> Timer;
vtkm::cont::Timer<> Timer;
std::vector<vtkm::Vec<T, 3>> InputData;
vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>> InHandle;
......@@ -172,8 +167,8 @@ struct HelloVTKMInterop
GenerateSurfaceWorklet worklet(t);
DispatcherType(worklet).Invoke(this->InHandle, this->OutCoords, this->OutColors);
vtkm::interop::TransferToOpenGL(this->OutCoords, this->VBOState, DeviceAdapter());
vtkm::interop::TransferToOpenGL(this->OutColors, this->ColorState, DeviceAdapter());
vtkm::interop::TransferToOpenGL(this->OutCoords, this->VBOState);
vtkm::interop::TransferToOpenGL(this->OutColors, this->ColorState);
this->render();
if (t > 10)
{
......@@ -184,8 +179,7 @@ struct HelloVTKMInterop
};
//global static so that glut callback can access it
using DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
HelloVTKMInterop<DeviceAdapter, vtkm::Float32>* helloWorld = nullptr;
HelloVTKMInterop<vtkm::Float32>* helloWorld = nullptr;
// Render the output using simple OpenGL
void run()
......@@ -201,9 +195,8 @@ void idle()
int main(int argc, char** argv)
{
using DeviceAdapterTraits = vtkm::cont::DeviceAdapterTraits<DeviceAdapter>;
std::cout << "Running Hello World example on device adapter: " << DeviceAdapterTraits::GetName()
<< std::endl;
vtkm::cont::Initialize(argc, argv);
std::cout << "Running Hello World example: " << std::endl;
glewExperimental = GL_TRUE;
glutInit(&argc, argv);
......@@ -221,7 +214,7 @@ int main(int argc, char** argv)
std::cout << "glewInit failed\n";
}
HelloVTKMInterop<DeviceAdapter, vtkm::Float32> hw(width, height);
HelloVTKMInterop<vtkm::Float32> hw(width, height);
helloWorld = &hw;
glutDisplayFunc(run);
......
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt 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.
//
// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#define VTKM_DEVICE_ADAPTER VTKM_DEVICE_ADAPTER_TBB
#include "HelloWorld.cxx"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment