From 7ff1a690def7a61fc26a6d2856baf61ca19a9c60 Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Mon, 23 Nov 2020 17:17:31 -0700 Subject: [PATCH] Support ArrayHandleCompositeVector with 1 component When `ArrayHandleCompositeVector` has only 1 component, it is supposed to have a special template that uses the base value type rather than a `Vec` of that type. However, the `Storage` with the value type was missing. I'm not sure how we weren't getting compile errors before, but moving to the new buffer arrays seems to bring about the expected error. --- vtkm/cont/ArrayHandleCompositeVector.h | 21 +++++++++++++++++++-- vtkm/cont/Storage.h | 4 ++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/vtkm/cont/ArrayHandleCompositeVector.h b/vtkm/cont/ArrayHandleCompositeVector.h index e38960aab..c3e1341cd 100644 --- a/vtkm/cont/ArrayHandleCompositeVector.h +++ b/vtkm/cont/ArrayHandleCompositeVector.h @@ -248,8 +248,8 @@ class Storage(sizeof...(StorageTags) public: using ReadPortalType = vtkm::internal::ArrayPortalCompositeVector::ReadPortalType...>; - using WritePortalType = - vtkm::internal::ArrayPortalCompositeVector::ReadPortalType...>; + using WritePortalType = vtkm::internal::ArrayPortalCompositeVector< + typename StorageFor::WritePortalType...>; private: // Hoop to jump through to use Storage::ResizeBuffer in an initializer list. @@ -382,6 +382,23 @@ public: } }; +// Special degenerative case when there is only one array being composited +template +struct Storage> : Storage +{ + VTKM_CONT static std::vector CreateBuffers( + const vtkm::cont::ArrayHandle& array) + { + return vtkm::cont::internal::CreateBuffers(array); + } + + VTKM_CONT static vtkm::Tuple> GetArrayTuple( + const vtkm::cont::internal::Buffer* buffers) + { + return vtkm::cont::ArrayHandle(buffers); + } +}; + } // namespace internal template diff --git a/vtkm/cont/Storage.h b/vtkm/cont/Storage.h index a57dcf6a8..11e1c9a33 100644 --- a/vtkm/cont/Storage.h +++ b/vtkm/cont/Storage.h @@ -94,8 +94,12 @@ class Storage : public vtkm::cont::internal::UndefinedStorage { public: + // TODO: Deprecate these using PortalType = vtkm::cont::internal::detail::UndefinedArrayPortal; using PortalConstType = vtkm::cont::internal::detail::UndefinedArrayPortal; + + using ReadPortalType = vtkm::cont::internal::detail::UndefinedArrayPortal; + using WritePortalType = vtkm::cont::internal::detail::UndefinedArrayPortal; }; #else //VTKM_DOXYGEN_ONLY {