summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-08-28 15:06:23 -0400
committerGitHub <noreply@github.com>2024-08-28 12:06:23 -0700
commit65240d074b4ddec55e56962ebf8de46207bcf5fa (patch)
treefa887d3de8ab55c7498eae2d5bf61966818135a1 /source/slang/slang-check-decl.cpp
parent638e5fb000d4e242a91e8b653da4a72daec0efda (diff)
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 <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
-rw-r--r--source/slang/slang-check-decl.cpp19
1 files changed, 1 insertions, 18 deletions
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<EntryPointAttribute>())
- {
- 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
{