13 #include <cuda_runtime.h> 14 #include <cuda_runtime_api.h> 16 #include <muda/viewer/dense.h> 17 #include <muda/buffer/buffer_3d_view.h> 25 friend class BufferLaunch;
26 friend class NDReshaper;
29 size_t m_pitch_bytes = 0;
30 size_t m_pitch_bytes_area = 0;
31 Extent3D m_extent = Extent3D::Zero();
32 Extent3D m_capacity = Extent3D::Zero();
37 DeviceBuffer3D(
const Extent3D& n);
40 DeviceBuffer3D(
const DeviceBuffer3D<T>& other);
41 DeviceBuffer3D(DeviceBuffer3D&& other) MUDA_NOEXCEPT;
42 DeviceBuffer3D& operator=(
const DeviceBuffer3D<T>& other);
43 DeviceBuffer3D& operator=(DeviceBuffer3D<T>&& other);
45 DeviceBuffer3D(CBuffer3DView<T> other);
46 DeviceBuffer3D& operator=(CBuffer3DView<T> other);
48 void copy_to(std::vector<T>& host)
const;
49 void copy_from(
const std::vector<T>& host);
51 void resize(Extent3D new_size);
52 void resize(Extent3D new_size,
const T& value);
53 void reserve(Extent3D new_capacity);
56 void fill(
const T& v);
58 Dense3D<T> viewer() MUDA_NOEXCEPT {
return view().viewer(); }
59 CDense3D<T> cviewer() const MUDA_NOEXCEPT {
return view().viewer(); }
61 Buffer3DView<T> view(Offset3D offset, Extent3D extent = {}) MUDA_NOEXCEPT
63 return view().subview(offset, extent);
65 Buffer3DView<T> view() MUDA_NOEXCEPT
67 return Buffer3DView<T>{
68 m_data, m_pitch_bytes, m_pitch_bytes_area, Offset3D::Zero(), m_extent};
70 operator Buffer3DView<T>() MUDA_NOEXCEPT {
return view(); }
72 CBuffer3DView<T> view(Offset3D offset, Extent3D extent = {})
const MUDA_NOEXCEPT
74 return view().subview(offset, extent);
77 CBuffer3DView<T> view() const MUDA_NOEXCEPT
79 return CBuffer3DView<T>{
80 m_data, m_pitch_bytes, m_pitch_bytes_area, Offset3D::Zero(), m_extent};
82 operator CBuffer3DView<T>()
const MUDA_NOEXCEPT {
return view(); }
86 auto extent() const MUDA_NOEXCEPT {
return m_extent; }
87 auto capacity() const MUDA_NOEXCEPT {
return m_capacity; }
88 auto pitch_bytes() const MUDA_NOEXCEPT {
return m_pitch_bytes; }
89 auto pitch_bytes_area() const MUDA_NOEXCEPT {
return m_pitch_bytes_area; }
90 auto total_size() const MUDA_NOEXCEPT
92 return m_extent.width() * m_extent.height() * m_extent.depth();
94 T* data() MUDA_NOEXCEPT {
return m_data; }
95 const T* data() const MUDA_NOEXCEPT {
return m_data; }
99 #include "details/device_buffer_3d.inl"