MCPcopy Create free account
hub / github.com/csyonghe/Spire / ResolveAttributes

Method ResolveAttributes

Source/SpireCore/ShaderCompiler.cpp:37–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 Dictionary<String, RefPtr<CodeGenBackend>> backends;
36
37 void ResolveAttributes(SymbolTable * symTable)
38 {
39 for (auto & shader : symTable->ShaderDependenceOrder)
40 {
41 auto comps = shader->GetComponentDependencyOrder();
42 for (auto & comp : comps)
43 {
44 for (auto & impl : comp->Implementations)
45 for (auto attrib : impl->SyntaxNode->GetLayoutAttributes())
46 {
47 try
48 {
49 if (attrib->GetValue().StartsWith("%"))
50 {
51 CoreLib::Text::TokenReader parser(attrib->GetValue().SubString(1, attrib->GetValue().Length() - 1));
52 auto compName = parser.ReadWord();
53 parser.Read(".");
54 auto compAttrib = parser.ReadWord();
55 RefPtr<ShaderComponentSymbol> compSym;
56 if (shader->Components.TryGetValue(compName, compSym))
57 {
58 for (auto & timpl : compSym->Implementations)
59 {
60 Token attribValue;
61 if (timpl->SyntaxNode->FindSimpleAttribute(compAttrib, attribValue))
62 attrib->Value = attribValue;
63 }
64 }
65 }
66 }
67 catch (Exception)
68 {
69 }
70 }
71 }
72 }
73 }
74
75 /* Generate a shader variant by applying mechanic choice rules and the choice file.
76 The choice file provides "preferred" definitions, as represented in ShaderComponentSymbol::Type::PinnedWorlds

Callers

nothing calls this directly

Calls 9

GetLayoutAttributesMethod · 0.80
StartsWithMethod · 0.80
SubStringMethod · 0.80
ReadWordMethod · 0.80
FindSimpleAttributeMethod · 0.80
LengthMethod · 0.45
ReadMethod · 0.45
TryGetValueMethod · 0.45

Tested by

no test coverage detected