Interop now works when device adapter isn't known.
Additionally the Interop calls now pass the ArrayHandle by const ref.
This commit is contained in:
parent
9747a89a1b
commit
7c2c1d5fbc
@ -46,7 +46,8 @@ struct TransferToOpenGL
|
||||
BufferState& state) const
|
||||
{
|
||||
vtkm::interop::internal::TransferToOpenGL<ValueType, DeviceAdapterTag> toGL(state);
|
||||
return toGL.Transfer(handle);
|
||||
toGL.Transfer(handle);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -64,7 +65,7 @@ struct TransferToOpenGL
|
||||
///
|
||||
///
|
||||
template <typename ValueType, class StorageTag, class DeviceAdapterTag>
|
||||
VTKM_CONT void TransferToOpenGL(vtkm::cont::ArrayHandle<ValueType, StorageTag> handle,
|
||||
VTKM_CONT void TransferToOpenGL(const vtkm::cont::ArrayHandle<ValueType, StorageTag>& handle,
|
||||
BufferState& state,
|
||||
DeviceAdapterTag)
|
||||
{
|
||||
@ -86,17 +87,17 @@ VTKM_CONT void TransferToOpenGL(vtkm::cont::ArrayHandle<ValueType, StorageTag> h
|
||||
/// This function will throw exceptions if the transfer wasn't possible
|
||||
///
|
||||
template <typename ValueType, typename StorageTag>
|
||||
VTKM_CONT void TransferToOpenGL(vtkm::cont::ArrayHandle<ValueType, StorageTag> handle,
|
||||
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, TransferToOpenGL, handle, state);
|
||||
bool success = vtkm::cont::TryExecuteOnDevice(devId, detail::TransferToOpenGL{}, handle, state);
|
||||
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(TransferToOpenGL, handle, state);
|
||||
success = vtkm::cont::TryExecute(detail::TransferToOpenGL{}, handle, state);
|
||||
}
|
||||
if (!success)
|
||||
{
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <vtkm/cont/ErrorExecution.h>
|
||||
|
||||
#include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h>
|
||||
#include <vtkm/cont/cuda/internal/MakeThrustIterator.h>
|
||||
|
||||
#include <vtkm/interop/internal/TransferToOpenGL.h>
|
||||
|
||||
@ -157,7 +156,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename StorageTag>
|
||||
VTKM_CONT void Transfer(vtkm::cont::ArrayHandle<ValueType, StorageTag>& handle) const
|
||||
VTKM_CONT void Transfer(const vtkm::cont::ArrayHandle<ValueType, StorageTag>& handle) const
|
||||
{
|
||||
//make a buffer for the handle if the user has forgotten too
|
||||
if (!glIsBuffer(*this->State.GetHandle()))
|
||||
@ -192,20 +191,10 @@ public:
|
||||
this->Resource->Map();
|
||||
|
||||
ValueType* beginPointer = this->Resource->GetMappedPoiner<ValueType>(size);
|
||||
auto deviceMemory = vtkm::cont::make_ArrayHandle(beginPointer, size);
|
||||
|
||||
//get the device pointers
|
||||
auto portal = handle.PrepareForInput(DeviceAdapterTag());
|
||||
|
||||
//Copy the data into memory that opengl owns, since we can't
|
||||
//give memory from cuda to opengl
|
||||
|
||||
//Perhaps a direct call to thrust copy should be wrapped in a vtkm
|
||||
//compatble function
|
||||
::thrust::copy(ThrustCudaPolicyPerThread,
|
||||
vtkm::cont::cuda::internal::IteratorBegin(portal),
|
||||
vtkm::cont::cuda::internal::IteratorEnd(portal),
|
||||
thrust::cuda::pointer<ValueType>(beginPointer));
|
||||
cudaStreamSynchronize(cudaStreamPerThread);
|
||||
//Do a device to device memory copy
|
||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>::Copy(handle, deviceMemory);
|
||||
|
||||
//unmap the resource
|
||||
this->Resource->UnMap();
|
||||
|
@ -95,7 +95,7 @@ namespace detail
|
||||
{
|
||||
|
||||
template <class ValueType, class StorageTag, class DeviceAdapterTag>
|
||||
VTKM_CONT void CopyFromHandle(vtkm::cont::ArrayHandle<ValueType, StorageTag>& handle,
|
||||
VTKM_CONT void CopyFromHandle(const vtkm::cont::ArrayHandle<ValueType, StorageTag>& handle,
|
||||
vtkm::interop::BufferState& state,
|
||||
DeviceAdapterTag)
|
||||
{
|
||||
@ -145,7 +145,7 @@ VTKM_CONT void CopyFromHandle(vtkm::cont::ArrayHandle<ValueType, StorageTag>& ha
|
||||
|
||||
template <class ValueType, class DeviceAdapterTag>
|
||||
VTKM_CONT void CopyFromHandle(
|
||||
vtkm::cont::ArrayHandle<ValueType, vtkm::cont::StorageTagBasic>& handle,
|
||||
const vtkm::cont::ArrayHandle<ValueType, vtkm::cont::StorageTagBasic>& handle,
|
||||
vtkm::interop::BufferState& state,
|
||||
DeviceAdapterTag)
|
||||
{
|
||||
@ -196,7 +196,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename StorageTag>
|
||||
VTKM_CONT void Transfer(vtkm::cont::ArrayHandle<ValueType, StorageTag>& handle) const
|
||||
VTKM_CONT void Transfer(const vtkm::cont::ArrayHandle<ValueType, StorageTag>& handle) const
|
||||
{
|
||||
//make a buffer for the handle if the user has forgotten too
|
||||
if (!glIsBuffer(*this->State.GetHandle()))
|
||||
|
Loading…
Reference in New Issue
Block a user