-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeshFactory.cpp
67 lines (54 loc) · 1.67 KB
/
MeshFactory.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "D3D12FrameWork/MeshFactory.h"
#include "D3D12FrameWork/GraphicPipelineStateObject.h"
namespace D3D12FrameWork{
MeshFactory* MeshFactory::m_instance = nullptr;
MeshFactory*
MeshFactory::CreateMesh(
std::string_view _meshName,
IPipelineStateObject* _pso
) {
auto const& inputDesc = _pso->GetInputDesc();
auto tmpMB = std::make_unique<MeshBuffer>();
if (!tmpMB->Init(inputDesc)) {
assert(false);
return nullptr;
}
auto const meshName = std::string(_meshName.data());
auto& mbMap = m_psoMeshBuffMap[_pso->GetName().data()].RPBuffs;
if (mbMap.count(meshName)) {
assert(false);
return nullptr;
}
mbMap[meshName].reset(tmpMB.release());
return this;
}
MeshBufferController
MeshFactory::MeshController(
std::string_view _matName,
class IPipelineStateObject const* _pso) {
auto psoName = _pso->GetName().data();
if(!m_psoMeshBuffMap.count(psoName)||
!m_psoMeshBuffMap[psoName].RPBuffs.count(_matName.data())) {
assert(false);
}
return MeshBufferController(*m_psoMeshBuffMap[psoName].RPBuffs[_matName.data()].get(),
m_pRefDev);
}
unqPtr<class MeshSet>
MeshFactory::CreateMeshSet(
std::string_view const _meshName,
IPipelineStateObject const* _pso
) {
auto psoName = std::string(_pso->GetName().data());
if (!m_psoMeshBuffMap.count(psoName)) {
throw std::runtime_error("指定されたpsoで使用されるMesh一つも登録されていません.");
}
auto& mbMap = m_psoMeshBuffMap[psoName].RPBuffs;
if (!mbMap.count(_meshName.data())) {
throw std::runtime_error("未作成のMesh");
}
auto* meshBuff = mbMap[_meshName.data()].get();
auto ret = std::make_unique<MeshSet>(meshBuff, m_pRefDev);
return ret;
}
}