From 65240d074b4ddec55e56962ebf8de46207bcf5fa Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:06:23 -0400 Subject: Allow capabilities to be used with `[shader("...")]` (#4928) * Allow capabilities to be used with `[shader("...")]` Fixes: #4917 Changes: 1. Allow using capabilities instead of `Stage`s with `EntryPointAttribute`. 2. When resolving capabilities for an entrypoint+profile (per entrypoint) in `resolveStageOfProfileWithEntryPoint` add our `EntryPointAttribute` and resolved capability 3. Added tests and some capabilities related clean-up * fix a warning made by a mistake in syntax * change fineStageByName to assume it is passed a stage without a '_' * test with and without prefix '_' * cleanup some profiles and reprisentation to work better with 'Stage' and 'Profile' This use case is why we need to clean all profile-usage into `CapabilityName`s directly. * change how we compare * only change profiles * let all capabilities be resolved by 'shader' profile for now * fix warning checks I accidently broke * meshshading_internal to _meshshading --------- Co-authored-by: Yong He --- source/slang/slang-check-decl.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (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 3bd6bd327..190433e2f 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -10644,6 +10644,7 @@ namespace Slang void SemanticsDeclCapabilityVisitor::visitFunctionDeclBase(FunctionDeclBase* funcDecl) { + // If the function is an entrypoint and specifies a target stage, add the capabilities to our function capabilities. _dispatchCapabilitiesVisitorOfFunctionDecl(this, funcDecl, [this, funcDecl](SyntaxNode* node, const CapabilitySet& nodeCaps, SourceLoc refLoc) { @@ -10657,30 +10658,12 @@ namespace Slang auto declaredCaps = getDeclaredCapabilitySet(funcDecl); - if (!declaredCaps.isEmpty()) - { - // If the function is an entrypoint, add the stage to declaredCaps. - if (auto entryPointAttr = funcDecl->findModifier()) - { - auto stageCaps = CapabilitySet(Profile(entryPointAttr->stage).getCapabilityName()); - if (declaredCaps.isIncompatibleWith(stageCaps)) - { - maybeDiagnose(getSink(), this->getOptionSet(), DiagnosticCategory::Capability, funcDecl->loc, Diagnostics::stageIsIncompatibleWithCapabilityDefinition, funcDecl, stageCaps, declaredCaps); - } - else - { - declaredCaps.join(stageCaps); - } - } - } - auto vis = getDeclVisibility(funcDecl); // If 0 capabilities were annotated on a function, capabilities are inferred from the function body if (declaredCaps.isEmpty()) { declaredCaps = funcDecl->inferredCapabilityRequirements; - return; } else { -- cgit v1.2.3