diff options
| author | Yong He <yonghe@outlook.com> | 2017-11-20 05:28:22 -0500 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2017-11-20 05:28:22 -0500 |
| commit | d6130baa8528c0a5b2e1b10b87fe02d8fc1a1b1a (patch) | |
| tree | 6aa5b2fe3a0fbfd8d2a02b38da9ca96f9fbd10ef /source/slang/ir.cpp | |
| parent | 3dff5a53a21ab2404918e772962004767024c0f3 (diff) | |
fixup global generic parameters
1. simplify RoundUpToAlignment()
2. add new a render-compute test case to cover the situation where the entry-point interface (parameter/return types of an entry-point function) is dependent on the global generic type.
3. initial fixes to get this test case to compile (but is not producing correct HLSL output yet)
Diffstat (limited to 'source/slang/ir.cpp')
| -rw-r--r-- | source/slang/ir.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index 2d3127a61..f5f52e08a 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -3103,10 +3103,22 @@ namespace Slang IRGlobalVar* cloneGlobalVar(IRSpecContext* context, IRGlobalVar* originalVar); IRFunc* cloneFunc(IRSpecContext* context, IRFunc* originalFunc); IRWitnessTable* cloneWitnessTable(IRSpecContext* context, IRWitnessTable* originalVar); + RefPtr<Substitutions> cloneSubstitutions( + IRSpecContext* context, + Substitutions* subst); RefPtr<Type> IRSpecContext::maybeCloneType(Type* originalType) { - return originalType->Substitute(subst).As<Type>(); + auto rsType = originalType->Substitute(subst).As<Type>(); + if (auto declRefType = rsType.As<DeclRefType>()) + { + if (subst) + { + auto newSubst = cloneSubstitutions(this, subst); + insertSubstAtBottom(declRefType->declRef.substitutions, newSubst); + } + } + return rsType; } IRValue* IRSpecContext::maybeCloneValue(IRValue* originalValue) @@ -3243,6 +3255,15 @@ namespace Slang newSubst->outer = cloneSubstitutions(context, subst->outer); return newSubst; } + else if (auto genTypeSubst = dynamic_cast<GlobalGenericParamSubstitution*>(subst)) + { + RefPtr<GlobalGenericParamSubstitution> newSubst = new GlobalGenericParamSubstitution(); + newSubst->actualType = genTypeSubst->actualType; + newSubst->paramDecl = genTypeSubst->paramDecl; + newSubst->witnessTables = genTypeSubst->witnessTables; + newSubst->outer = cloneSubstitutions(context, subst->outer); + return newSubst; + } else SLANG_UNREACHABLE("unimplemented cloneSubstitution"); UNREACHABLE_RETURN(nullptr); |
