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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
// slang-entry-point.cpp
#include "slang-entry-point.h"
#include "slang-compiler.h"
#include "slang-mangle.h"
namespace Slang
{
//
// EntryPoint
//
ISlangUnknown* EntryPoint::getInterface(const Guid& guid)
{
if (guid == slang::IEntryPoint::getTypeGuid())
return static_cast<slang::IEntryPoint*>(this);
return Super::getInterface(guid);
}
RefPtr<EntryPoint> EntryPoint::create(
Linkage* linkage,
DeclRef<FuncDecl> funcDeclRef,
Profile profile)
{
RefPtr<EntryPoint> entryPoint =
new EntryPoint(linkage, funcDeclRef.getName(), profile, funcDeclRef);
entryPoint->m_mangledName = getMangledName(linkage->getASTBuilder(), funcDeclRef);
return entryPoint;
}
RefPtr<EntryPoint> EntryPoint::createDummyForPassThrough(
Linkage* linkage,
Name* name,
Profile profile)
{
RefPtr<EntryPoint> entryPoint = new EntryPoint(linkage, name, profile, DeclRef<FuncDecl>());
return entryPoint;
}
RefPtr<EntryPoint> EntryPoint::createDummyForDeserialize(
Linkage* linkage,
Name* name,
Profile profile,
String mangledName)
{
RefPtr<EntryPoint> entryPoint = new EntryPoint(linkage, name, profile, DeclRef<FuncDecl>());
entryPoint->m_mangledName = mangledName;
return entryPoint;
}
EntryPoint::EntryPoint(Linkage* linkage, Name* name, Profile profile, DeclRef<FuncDecl> funcDeclRef)
: ComponentType(linkage), m_name(name), m_profile(profile), m_funcDeclRef(funcDeclRef)
{
// Collect any specialization parameters used by the entry point
//
_collectShaderParams();
}
Module* EntryPoint::getModule()
{
return Slang::getModule(getFuncDecl());
}
Index EntryPoint::getSpecializationParamCount()
{
return m_genericSpecializationParams.getCount() + m_existentialSpecializationParams.getCount();
}
SpecializationParam const& EntryPoint::getSpecializationParam(Index index)
{
auto genericParamCount = m_genericSpecializationParams.getCount();
if (index < genericParamCount)
{
return m_genericSpecializationParams[index];
}
else
{
return m_existentialSpecializationParams[index - genericParamCount];
}
}
Index EntryPoint::getRequirementCount()
{
// The only requirement of an entry point is the module that contains it.
//
// TODO: We will eventually want to support the case of an entry
// point nested in a `struct` type, in which case there should be
// a single requirement representing that outer type (so that multiple
// entry points nested under the same type can share the storage
// for parameters at that scope).
// Note: the defensive coding is here because the
// "dummy" entry points we create for pass-through
// compilation will not have an associated module.
//
if (const auto module = getModule())
{
return 1;
}
return 0;
}
RefPtr<ComponentType> EntryPoint::getRequirement(Index index)
{
SLANG_UNUSED(index);
SLANG_ASSERT(index == 0);
SLANG_ASSERT(getModule());
return getModule();
}
String EntryPoint::getEntryPointMangledName(Index index)
{
SLANG_UNUSED(index);
SLANG_ASSERT(index == 0);
return m_mangledName;
}
String EntryPoint::getEntryPointNameOverride(Index index)
{
SLANG_UNUSED(index);
SLANG_ASSERT(index == 0);
return m_name ? m_name->text : "";
}
void EntryPoint::acceptVisitor(
ComponentTypeVisitor* visitor,
SpecializationInfo* specializationInfo)
{
visitor->visitEntryPoint(this, as<EntryPointSpecializationInfo>(specializationInfo));
}
void EntryPoint::buildHash(DigestBuilder<SHA1>& builder)
{
SLANG_UNUSED(builder);
}
List<Module*> const& EntryPoint::getModuleDependencies()
{
if (auto module = getModule())
return module->getModuleDependencies();
static List<Module*> empty;
return empty;
}
List<SourceFile*> const& EntryPoint::getFileDependencies()
{
if (const auto module = getModule())
return getModule()->getFileDependencies();
static List<SourceFile*> empty;
return empty;
}
} // namespace Slang
|