forked from megayuchi/D3D12Lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConstantBufferManager.cpp
52 lines (45 loc) · 1.27 KB
/
ConstantBufferManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "pch.h"
#include "typedef.h"
#include "SimpleConstantBufferPool.h"
#include "ConstantBufferManager.h"
CONSTANT_BUFFER_PROPERTY g_pConstBufferPropList[] =
{
CONSTANT_BUFFER_TYPE_DEFAULT, sizeof(CONSTANT_BUFFER_DEFAULT),
CONSTANT_BUFFER_TYPE_SPRITE, sizeof(CONSTANT_BUFFER_SPRITE)
};
CConstantBufferManager::CConstantBufferManager()
{
}
BOOL CConstantBufferManager::Initialize(ID3D12Device* pD3DDevice, DWORD dwMaxCBVNum)
{
for (DWORD i = 0; i < CONSTANT_BUFFER_TYPE_COUNT; i++)
{
m_ppConstantBufferPool[i] = new CSimpleConstantBufferPool;
m_ppConstantBufferPool[i]->Initialize(pD3DDevice, (CONSTANT_BUFFER_TYPE)i, AlignConstantBufferSize(g_pConstBufferPropList[i].Size), dwMaxCBVNum);
}
return TRUE;
}
void CConstantBufferManager::Reset()
{
for (DWORD i = 0; i < CONSTANT_BUFFER_TYPE_COUNT; i++)
{
m_ppConstantBufferPool[i]->Reset();
}
}
CSimpleConstantBufferPool* CConstantBufferManager::GetConstantBufferPool(CONSTANT_BUFFER_TYPE type)
{
if (type >= CONSTANT_BUFFER_TYPE_COUNT)
__debugbreak();
return m_ppConstantBufferPool[type];
}
CConstantBufferManager::~CConstantBufferManager()
{
for (DWORD i = 0; i < CONSTANT_BUFFER_TYPE_COUNT; i++)
{
if (m_ppConstantBufferPool[i])
{
delete m_ppConstantBufferPool[i];
m_ppConstantBufferPool[i] = nullptr;
}
}
}