Plasma Engine  2.0
Loading...
Searching...
No Matches
ProcessingStream.h
1#pragma once
2
3#include <Foundation/Basics.h>
4#include <Foundation/Strings/HashedString.h>
5
7class PL_FOUNDATION_DLL plProcessingStream
8{
9public:
12 enum class DataType : plUInt8
13 {
14 Half, // plFloat16
15 Half2, // 2x plFloat16
16 Half3, // 3x plFloat16
17 Half4, // 4x plFloat16
18
19 Float, // float
20 Float2, // 2x float, e.g. plVec2
21 Float3, // 3x float, e.g. plVec3
22 Float4, // 4x float, e.g. plVec4
23
24 Byte,
25 Byte2,
26 Byte3,
27 Byte4,
28
29 Short,
30 Short2,
31 Short3,
32 Short4,
33
34 Int,
35 Int2,
36 Int3,
37 Int4,
38
39 Count
40 };
41
43 plProcessingStream(const plHashedString& sName, DataType type, plUInt16 uiStride, plUInt16 uiAlignment);
44 plProcessingStream(const plHashedString& sName, plArrayPtr<plUInt8> data, DataType type, plUInt16 uiStride);
45 plProcessingStream(const plHashedString& sName, plArrayPtr<plUInt8> data, DataType type);
47
49 template <typename T>
50 const T* GetData() const
51 {
52 return static_cast<const T*>(GetData());
53 }
54
56 const void* GetData() const { return m_pData; }
57
59 template <typename T>
60 T* GetWritableData() const
61 {
62 return static_cast<T*>(GetWritableData());
63 }
64
66 void* GetWritableData() const { return m_pData; }
67
68 plUInt64 GetDataSize() const { return m_uiDataSize; }
69
71 const plHashedString& GetName() const { return m_sName; }
72
74 plUInt16 GetAlignment() const { return m_uiAlignment; }
75
77 DataType GetDataType() const { return m_Type; }
78
80 plUInt16 GetElementSize() const { return m_uiTypeSize; }
81
83 plUInt16 GetElementStride() const { return m_uiStride; }
84
85 static plUInt16 GetDataTypeSize(DataType type);
86 static plStringView GetDataTypeName(DataType type);
87
88protected:
89 friend class plProcessingStreamGroup;
90
91 void SetSize(plUInt64 uiNumElements);
92 void FreeData();
93
94 void* m_pData = nullptr;
95 plUInt64 m_uiDataSize = 0; // in bytes
96
97 plUInt16 m_uiAlignment = 0;
98 plUInt16 m_uiTypeSize = 0;
99 plUInt16 m_uiStride = 0;
100 DataType m_Type;
101 bool m_bExternalMemory = false;
102
103 plHashedString m_sName;
104};
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
A stream group encapsulates the streams and the corresponding data processors.
Definition ProcessingStreamGroup.h:25
A single stream in a stream group holding contiguous data of a given type.
Definition ProcessingStream.h:8
T * GetWritableData() const
Returns a non-const pointer to the data casted to the type T, note that no type check is done!
Definition ProcessingStream.h:60
void * GetWritableData() const
Returns a non-const pointer to the start of the data block.
Definition ProcessingStream.h:66
const void * GetData() const
Returns a const pointer to the start of the data block.
Definition ProcessingStream.h:56
const T * GetData() const
Returns a const pointer to the data casted to the type T, note that no type check is done!
Definition ProcessingStream.h:50
plUInt16 GetElementStride() const
Returns the stride between two elements of the stream in bytes.
Definition ProcessingStream.h:83
plUInt16 GetAlignment() const
Returns the alignment which was used to allocate the stream.
Definition ProcessingStream.h:74
DataType
The data types which can be stored in the stream. When adding new data types the GetDataTypeSize() of...
Definition ProcessingStream.h:13
DataType GetDataType() const
Returns the data type of the stream.
Definition ProcessingStream.h:77
plUInt16 GetElementSize() const
Returns the size of one stream element in bytes.
Definition ProcessingStream.h:80
const plHashedString & GetName() const
Returns the name of the stream.
Definition ProcessingStream.h:71
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34