26 using auto_const_t =
typename Base::template auto_const_t<U>;
28 auto_const_t<T>* m_data;
32 int m_pitch_bytes_area;
40 MUDA_GENERIC
Dense3DBase() MUDA_NOEXCEPT : m_data(
nullptr){};
46 int pitch_bytes_area) MUDA_NOEXCEPT
50 m_pitch_bytes(pitch_bytes),
51 m_pitch_bytes_area(pitch_bytes_area)
55 MUDA_GENERIC
auto as_const()
const MUDA_NOEXCEPT
57 return ConstViewer{m_data, m_offset, m_dim, m_pitch_bytes, m_pitch_bytes_area};
60 MUDA_GENERIC
operator ConstViewer()
const MUDA_NOEXCEPT
65 MUDA_GENERIC auto_const_t<T>& operator()(
int x,
int y,
int z) MUDA_NOEXCEPT
69 auto depth_begin =
reinterpret_cast<std::byte*
>(m_data) + x * m_pitch_bytes_area;
70 auto height_begin = depth_begin + y * m_pitch_bytes;
71 return *(
reinterpret_cast<T*
>(height_begin) + z);
74 MUDA_GENERIC auto_const_t<T>& operator()(
const int3& xyz) MUDA_NOEXCEPT
76 return operator()(xyz.x, xyz.y, xyz.z);
79 MUDA_GENERIC auto_const_t<T>* data() MUDA_NOEXCEPT {
return m_data; }
82 MUDA_GENERIC
const T& operator()(
int x,
int y,
int z)
const MUDA_NOEXCEPT
84 return remove_const(*
this)(x, y, z);
88 MUDA_GENERIC
const T& operator()(
const int3& xyz)
const MUDA_NOEXCEPT
90 return remove_const(*
this)(xyz.x, xyz.y, xyz.z);
93 MUDA_GENERIC auto_const_t<T>& flatten(
int i) MUDA_NOEXCEPT
95 if constexpr(DEBUG_VIEWER)
97 MUDA_KERNEL_ASSERT(i >= 0 && i < total_size(),
98 "Dense3D[%s:%s]: out of range, index=%d, total_size=%d. %s(%d)",
104 this->kernel_line());
106 auto area = m_dim.y * m_dim.z;
108 auto i_in_area = i % area;
109 auto y = i_in_area / m_dim.z;
110 auto i_in_width = i_in_area % m_dim.z;
112 return operator()(x, y, z);
116 MUDA_GENERIC
const T& flatten(
int i)
const MUDA_NOEXCEPT
118 return remove_const(*this).flatten(i);
121 MUDA_GENERIC
const T* data()
const MUDA_NOEXCEPT {
return m_data; }
124 MUDA_GENERIC
auto dim()
const MUDA_NOEXCEPT {
return m_dim; }
125 MUDA_GENERIC
int area()
const MUDA_NOEXCEPT {
return m_dim.y * m_dim.z; }
126 MUDA_GENERIC
int volume()
const MUDA_NOEXCEPT {
return total_size(); }
127 MUDA_GENERIC
int total_size()
const MUDA_NOEXCEPT
129 return m_dim.x * area();
131 MUDA_GENERIC
int pitch_bytes()
const MUDA_NOEXCEPT {
return m_pitch_bytes; }
132 MUDA_GENERIC
int pitch_bytes_area()
const MUDA_NOEXCEPT
134 return m_pitch_bytes_area;
136 MUDA_GENERIC
int total_bytes()
const MUDA_NOEXCEPT
138 return m_pitch_bytes_area * m_dim.x;
142 MUDA_INLINE MUDA_GENERIC
void check_range(
int x,
int y,
int z)
const MUDA_NOEXCEPT
144 if constexpr(DEBUG_VIEWER)
146 if(!(x >= 0 && x < m_dim.x && y >= 0 && y < m_dim.y && z >= 0
148 MUDA_KERNEL_ERROR(
"Dense3D[%s:%s]: out of range, index=(%d,%d,%d) dim=(%d,%d,%d). %s(%d)",
158 this->kernel_line());
162 MUDA_INLINE MUDA_GENERIC
void check()
const MUDA_NOEXCEPT
164 if constexpr(DEBUG_VIEWER)
165 if(m_data ==
nullptr)
166 MUDA_KERNEL_ERROR(
"Dense3D[%s:%s]: data is null. %s(%d)",
170 this->kernel_line());
219 return make_cdense_3d(data, make_int3(dimx, dimy, dimz));
225 return make_dense_3d(data, make_int3(dimx, dimy, dimz));