Add proper support for IndexType and uint32 indices
This commit is contained in:
@@ -180,6 +180,15 @@ namespace Nz
|
||||
|
||||
constexpr std::size_t ImageTypeCount = static_cast<std::size_t>(ImageType::Max) + 1;
|
||||
|
||||
enum class IndexType
|
||||
{
|
||||
U8,
|
||||
U16,
|
||||
U32,
|
||||
|
||||
Max = U32
|
||||
};
|
||||
|
||||
enum class NodeType
|
||||
{
|
||||
Default, // Node
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
IndexBuffer() = default;
|
||||
IndexBuffer(bool largeIndices, std::shared_ptr<Buffer> buffer);
|
||||
IndexBuffer(bool largeIndices, std::shared_ptr<Buffer> buffer, UInt64 offset, UInt64 size);
|
||||
IndexBuffer(bool largeIndices, UInt64 indexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData = nullptr);
|
||||
IndexBuffer(IndexType indexType, std::shared_ptr<Buffer> buffer);
|
||||
IndexBuffer(IndexType indexType, std::shared_ptr<Buffer> buffer, UInt64 offset, UInt64 size);
|
||||
IndexBuffer(IndexType indexType, UInt64 indexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData = nullptr);
|
||||
IndexBuffer(const IndexBuffer&) = default;
|
||||
IndexBuffer(IndexBuffer&&) noexcept = default;
|
||||
~IndexBuffer() = default;
|
||||
@@ -31,11 +31,10 @@ namespace Nz
|
||||
inline const std::shared_ptr<Buffer>& GetBuffer() const;
|
||||
inline UInt64 GetEndOffset() const;
|
||||
inline UInt64 GetIndexCount() const;
|
||||
inline IndexType GetIndexType() const;
|
||||
inline UInt64 GetStride() const;
|
||||
inline UInt64 GetStartOffset() const;
|
||||
|
||||
inline bool HasLargeIndices() const;
|
||||
|
||||
inline bool IsValid() const;
|
||||
|
||||
inline void* Map(UInt64 startIndex, UInt64 length);
|
||||
@@ -52,10 +51,10 @@ namespace Nz
|
||||
|
||||
private:
|
||||
std::shared_ptr<Buffer> m_buffer;
|
||||
IndexType m_indexType;
|
||||
UInt32 m_indexCount;
|
||||
UInt64 m_endOffset;
|
||||
UInt64 m_startOffset;
|
||||
bool m_largeIndices;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,27 @@ namespace Nz
|
||||
return m_indexCount;
|
||||
}
|
||||
|
||||
inline IndexType IndexBuffer::GetIndexType() const
|
||||
{
|
||||
return m_indexType;
|
||||
}
|
||||
|
||||
inline UInt64 IndexBuffer::GetStride() const
|
||||
{
|
||||
return (m_largeIndices) ? sizeof(UInt32) : sizeof(UInt16);
|
||||
switch (m_indexType)
|
||||
{
|
||||
case IndexType::U8:
|
||||
return sizeof(UInt8);
|
||||
|
||||
case IndexType::U16:
|
||||
return sizeof(UInt16);
|
||||
|
||||
case IndexType::U32:
|
||||
return sizeof(UInt32);
|
||||
}
|
||||
|
||||
NazaraError("invalid index size");
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline UInt64 IndexBuffer::GetStartOffset() const
|
||||
@@ -33,11 +51,6 @@ namespace Nz
|
||||
return m_startOffset;
|
||||
}
|
||||
|
||||
inline bool IndexBuffer::HasLargeIndices() const
|
||||
{
|
||||
return m_largeIndices;
|
||||
}
|
||||
|
||||
inline bool IndexBuffer::IsValid() const
|
||||
{
|
||||
return m_buffer != nullptr;
|
||||
|
||||
Reference in New Issue
Block a user