From 42f49937ffa69c82e333e886952eed027e12340e Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 16 Aug 2022 17:11:54 -0700 Subject: Add gfx interface definition in Slang. (#2364) * Add gfx interface definition in Slang. - add gfx interface definitons in Slang. - fix slang compiler to correctly type-check `out` interface argument. - modify gfx interface to be fully COM compatible - add convenient ShaderProgram creation methods to gfx. * Fix compile errors and warnings. * Update project files * Fix cuda. * Properly implement queryInterface in command encoder impls. Co-authored-by: Yong He --- source/slang/slang-check-decl.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-check-decl.cpp') diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 22567c889..f2a339643 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -3063,10 +3063,37 @@ namespace Slang InheritanceDecl* inheritanceDecl, ContainerDecl* parentDecl) { + auto superType = inheritanceDecl->base.type; + if( auto declRefType = as(subType) ) { auto declRef = declRefType->declRef; + if (auto superDeclRefType = as(superType)) + { + auto superTypeDecl = superDeclRefType->declRef.getDecl(); + if (superTypeDecl->findModifier()) + { + // A struct cannot implement a COM Interface. + if (auto classDecl = as(superTypeDecl)) + { + // OK. + SLANG_UNUSED(classDecl); + } + else if (auto subInterfaceDecl = as(superTypeDecl)) + { + if (!subInterfaceDecl->findModifier()) + { + getSink()->diagnose(inheritanceDecl, Diagnostics::interfaceInheritingComMustBeCom); + } + } + else if (auto structDecl = as(superTypeDecl)) + { + getSink()->diagnose(inheritanceDecl, Diagnostics::structCannotImplementComInterface); + } + } + } + // Don't check conformances for abstract types that // are being used to express *required* conformances. if (auto assocTypeDeclRef = declRef.as()) @@ -3089,11 +3116,12 @@ namespace Slang // code to work. return true; } + + } // Look at the type being inherited from, and validate // appropriately. - auto superType = inheritanceDecl->base.type; DeclaredSubtypeWitness* subIsSuperWitness = m_astBuilder->create(); subIsSuperWitness->declRef = makeDeclRef(inheritanceDecl); -- cgit v1.2.3