-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDekiRenderPassRegistry.cpp
More file actions
67 lines (54 loc) · 1.4 KB
/
DekiRenderPassRegistry.cpp
File metadata and controls
67 lines (54 loc) · 1.4 KB
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 "DekiRenderPassRegistry.h"
#include <unordered_map>
#include <string>
namespace DekiRenderPassRegistry {
static std::unordered_map<std::string, RenderPassInfo>& GetRegistry()
{
static std::unordered_map<std::string, RenderPassInfo> reg;
return reg;
}
static AutoAttachCallback& GetAutoAttachCallback()
{
static AutoAttachCallback cb;
return cb;
}
void Register(const char* name, RenderPassInfo info)
{
if (!name || !info.factory)
return;
GetRegistry()[name] = info;
// Late-attach for modules that load after DekiRendering_InitSystem already
// ran its scan. The callback is installed by DekiRendering_InitSystem.
if (info.autoAttach)
{
auto& cb = GetAutoAttachCallback();
if (cb) cb(name, info);
}
}
const RenderPassInfo* Get(const char* name)
{
if (!name || name[0] == '\0')
return nullptr;
auto& reg = GetRegistry();
auto it = reg.find(name);
if (it != reg.end())
return &it->second;
return nullptr;
}
void Unregister(const char* name)
{
if (!name)
return;
GetRegistry().erase(name);
}
void GetAllNames(std::vector<std::string>& outNames)
{
outNames.clear();
for (const auto& [name, info] : GetRegistry())
outNames.push_back(name);
}
void SetAutoAttachCallback(AutoAttachCallback cb)
{
GetAutoAttachCallback() = std::move(cb);
}
} // namespace DekiRenderPassRegistry