Introduce helper class vk::StridedArrayProxy; use it on functions with parameters having the 'stride' attribute.

This commit is contained in:
asuessenbach
2022-09-12 16:53:44 +02:00
parent 833e6f576d
commit 34725b3192
13 changed files with 2093 additions and 1693 deletions

View File

@@ -0,0 +1,40 @@
template <typename T>
class StridedArrayProxy : protected ArrayProxy<T>
{
public:
using ArrayProxy<T>::ArrayProxy;
StridedArrayProxy( uint32_t count, T const * ptr, uint32_t stride ) VULKAN_HPP_NOEXCEPT
: ArrayProxy<T>( count, ptr )
, m_stride( stride )
{
VULKAN_HPP_ASSERT( sizeof( T ) <= stride );
}
using ArrayProxy<T>::begin;
const T * end() const VULKAN_HPP_NOEXCEPT
{
return reinterpret_cast<T const *>( static_cast<uint8_t const *>( begin() ) + size() * m_stride );
}
using ArrayProxy<T>::front;
const T & back() const VULKAN_HPP_NOEXCEPT
{
VULKAN_HPP_ASSERT( begin() && size() );
return *reinterpret_cast<T const *>( static_cast<uint8_t const *>( begin() ) + ( size() - 1 ) * m_stride );
}
using ArrayProxy<T>::empty;
using ArrayProxy<T>::size;
using ArrayProxy<T>::data;
uint32_t stride() const
{
return m_stride;
}
private:
uint32_t m_stride = sizeof( T );
};