From 9fe2db1e4950f63aaaa575506486eab153ad448e Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 10 Apr 2024 11:19:28 -0700 Subject: Fix checking logic of entry point specialization arguments. (#3916) --- source/slang/slang-check-shader.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp index b8b83c094..591118385 100644 --- a/source/slang/slang-check-shader.cpp +++ b/source/slang/slang-check-shader.cpp @@ -1229,9 +1229,22 @@ namespace Slang DeclRef constraintDeclRef = astBuilder->getDirectDeclRef(constraintDecl.getDecl()); int argIndex = -1; int ii = 0; + + // Find the generic parameter type (T) that this constraint (T:IFoo) is applying to. + auto genericParamType = getSub(astBuilder, constraintDeclRef); + auto genParamDeclRefType = as(genericParamType); + if (!genParamDeclRefType) + { + continue; + } + auto genParamDeclRef = genParamDeclRefType->getDeclRef(); + + // Find the generic argument index of the corresponding generic parameter type in the + // generic parameter set. + // for (auto member : genericDeclRef.getDecl()->members) { - if (member == constraintDeclRef.getDecl()) + if (member == genParamDeclRef.getDecl()) { argIndex = ii; break; @@ -1243,7 +1256,6 @@ namespace Slang SLANG_ASSERT(!"generic parameter not found in generic decl"); continue; } - auto sub = as(args[argIndex].val); if (!sub) { -- cgit v1.2.3