Plasma Engine  2.0
Loading...
Searching...
No Matches
ConstantBufferStorage.h
1#pragma once
2
3#include <Foundation/Containers/DynamicArray.h>
4#include <RendererCore/RendererCoreDLL.h>
5#include <RendererFoundation/RendererFoundationDLL.h>
6
7class PL_RENDERERCORE_DLL plConstantBufferStorageBase
8{
9protected:
10 friend class plRenderContext;
11 friend class plMemoryUtils;
12
13 plConstantBufferStorageBase(plUInt32 uiSizeInBytes);
15
16public:
17 plArrayPtr<plUInt8> GetRawDataForWriting();
18 plArrayPtr<const plUInt8> GetRawDataForReading() const;
19
20 void UploadData(plGALCommandEncoder* pCommandEncoder);
21
22 PL_ALWAYS_INLINE plGALBufferHandle GetGALBufferHandle() const { return m_hGALConstantBuffer; }
23
24protected:
25 bool m_bHasBeenModified = false;
26 plUInt32 m_uiLastHash = 0;
27 plGALBufferHandle m_hGALConstantBuffer;
28
30};
31
32template <typename T>
34{
35public:
36 PL_FORCE_INLINE T& GetDataForWriting()
37 {
38 plArrayPtr<plUInt8> rawData = GetRawDataForWriting();
39 PL_ASSERT_DEV(rawData.GetCount() == sizeof(T), "Invalid data size");
40 return *reinterpret_cast<T*>(rawData.GetPtr());
41 }
42
43 PL_FORCE_INLINE const T& GetDataForReading() const
44 {
45 plArrayPtr<const plUInt8> rawData = GetRawDataForReading();
46 PL_ASSERT_DEV(rawData.GetCount() == sizeof(T), "Invalid data size");
47 return *reinterpret_cast<const T*>(rawData.GetPtr());
48 }
49};
50
52
54{
56
57 friend class plRenderContext;
58};
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
PL_ALWAYS_INLINE plUInt32 GetCount() const
Returns the number of elements in the array.
Definition ArrayPtr.h:142
PL_ALWAYS_INLINE PointerType GetPtr() const
Returns the pointer to the array.
Definition ArrayPtr.h:118
Definition ConstantBufferStorage.h:8
Definition ConstantBufferStorage.h:54
Definition ConstantBufferStorage.h:34
Definition RendererFoundationDLL.h:418
Definition CommandEncoder.h:11
This class provides functions to work on raw memory.
Definition MemoryUtils.h:26
Definition RenderContext.h:30