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
7
class
PL_RENDERERCORE_DLL
plConstantBufferStorageBase
8
{
9
protected
:
10
friend
class
plRenderContext
;
11
friend
class
plMemoryUtils
;
12
13
plConstantBufferStorageBase
(plUInt32 uiSizeInBytes);
14
~plConstantBufferStorageBase
();
15
16
public
:
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
24
protected
:
25
bool
m_bHasBeenModified =
false
;
26
plUInt32 m_uiLastHash = 0;
27
plGALBufferHandle
m_hGALConstantBuffer;
28
29
plArrayPtr<plUInt8>
m_Data;
30
};
31
32
template
<
typename
T>
33
class
plConstantBufferStorage
:
public
plConstantBufferStorageBase
34
{
35
public
:
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
51
using
plConstantBufferStorageId
=
plGenericId<24, 8>
;
52
53
class
plConstantBufferStorageHandle
54
{
55
PL_DECLARE_HANDLE_TYPE(
plConstantBufferStorageHandle
,
plConstantBufferStorageId
);
56
57
friend
class
plRenderContext
;
58
};
plArrayPtr
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition
ArrayPtr.h:37
plArrayPtr::GetCount
PL_ALWAYS_INLINE plUInt32 GetCount() const
Returns the number of elements in the array.
Definition
ArrayPtr.h:142
plArrayPtr::GetPtr
PL_ALWAYS_INLINE PointerType GetPtr() const
Returns the pointer to the array.
Definition
ArrayPtr.h:118
plConstantBufferStorageBase
Definition
ConstantBufferStorage.h:8
plConstantBufferStorageHandle
Definition
ConstantBufferStorage.h:54
plConstantBufferStorage
Definition
ConstantBufferStorage.h:34
plGALBufferHandle
Definition
RendererFoundationDLL.h:418
plGALCommandEncoder
Definition
CommandEncoder.h:11
plMemoryUtils
This class provides functions to work on raw memory.
Definition
MemoryUtils.h:26
plRenderContext
Definition
RenderContext.h:30
plGenericId< 24, 8 >
Code
Engine
RendererCore
Shader
ConstantBufferStorage.h
Generated by
1.11.0