mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Remove use of deprecated features in TransferToOpenGL
The `TransferToOpenGL` function was using a deprecated method to determine on which device an `ArrayHandle` was installed. Update the function to use the replacement methods.
This commit is contained in:
parent
0df578eb84
commit
e36d908a49
@ -26,23 +26,6 @@ namespace vtkm
|
||||
namespace interop
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
struct TransferToOpenGL
|
||||
{
|
||||
template <typename DeviceAdapterTag, typename ValueType, typename StorageTag>
|
||||
VTKM_CONT bool operator()(DeviceAdapterTag,
|
||||
const vtkm::cont::ArrayHandle<ValueType, StorageTag>& handle,
|
||||
BufferState& state) const
|
||||
{
|
||||
vtkm::interop::internal::TransferToOpenGL<ValueType, DeviceAdapterTag> toGL(state);
|
||||
toGL.Transfer(handle);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// \brief Manages transferring an ArrayHandle to opengl .
|
||||
///
|
||||
/// \c TransferToOpenGL manages to transfer the contents of an ArrayHandle
|
||||
@ -80,18 +63,30 @@ template <typename ValueType, typename StorageTag>
|
||||
VTKM_CONT void TransferToOpenGL(const vtkm::cont::ArrayHandle<ValueType, StorageTag>& handle,
|
||||
BufferState& state)
|
||||
{
|
||||
|
||||
vtkm::cont::DeviceAdapterId devId = handle.GetDeviceAdapterId();
|
||||
bool success = vtkm::cont::TryExecuteOnDevice(devId, detail::TransferToOpenGL{}, handle, state);
|
||||
// First, try to transfer data that already exists on a device.
|
||||
bool success = vtkm::cont::TryExecute([&](auto device) {
|
||||
if (handle.IsOnDevice(device))
|
||||
{
|
||||
TransferToOpenGL(handle, state, device);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!success)
|
||||
{
|
||||
//Generally we are here because the devId is undefined
|
||||
//or for some reason the last executed device is now disabled
|
||||
success = vtkm::cont::TryExecute(detail::TransferToOpenGL{}, handle, state);
|
||||
// Generally, we are here because the array is not already on a device
|
||||
// or for some reason the transfer failed on that device. Try any device.
|
||||
success = vtkm::cont::TryExecute([&](auto device) {
|
||||
TransferToOpenGL(handle, state, device);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
if (!success)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Unknown device id.");
|
||||
throw vtkm::cont::ErrorBadValue("Failed to transfer array to OpenGL on any device.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user