summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-shader.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-02 22:28:02 -0800
committerGitHub <noreply@github.com>2024-02-02 22:28:02 -0800
commit14764896c34b230a5563f48d8b8e565de2f3aa10 (patch)
tree2f105d3f6222103f458054f1cd38e280b6fb52b4 /source/slang/slang-check-shader.cpp
parentc15e7ade4e27e1649d5b98f5854e9e52bb9e60ae (diff)
Capability type checking. (#3530)
* Capability type checking. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-shader.cpp')
-rw-r--r--source/slang/slang-check-shader.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp
index b45107640..2e854554e 100644
--- a/source/slang/slang-check-shader.cpp
+++ b/source/slang/slang-check-shader.cpp
@@ -396,7 +396,6 @@ namespace Slang
auto module = getModule(entryPointFuncDecl);
auto linkage = module->getLinkage();
-
// Every entry point needs to have a stage specified either via
// command-line/API options, or via an explicit `[shader("...")]` attribute.
//
@@ -506,6 +505,38 @@ namespace Slang
}
}
}
+
+ for (auto target : linkage->targets)
+ {
+ auto targetCaps = target->getTargetCaps();
+ auto stageCapabilitySet = CapabilitySet(entryPoint->getProfile().getCapabilityName());
+ targetCaps.join(stageCapabilitySet);
+ if (targetCaps.isIncompatibleWith(entryPointFuncDecl->inferredCapabilityRequirements))
+ {
+ sink->diagnose(entryPointFuncDecl, Diagnostics::entryPointUsesUnavailableCapability, entryPointFuncDecl, entryPointFuncDecl->inferredCapabilityRequirements, targetCaps);
+ auto& interredCapConjunctions = entryPointFuncDecl->inferredCapabilityRequirements.getExpandedAtoms();
+
+ // Find out what exactly is incompatible and print out a trace of provenance to
+ // help user diagnose their code.
+ auto& conjunctions = targetCaps.getExpandedAtoms();
+ if (conjunctions.getCount() == 1 && interredCapConjunctions.getCount() == 1)
+ {
+ for (auto atom : conjunctions[0].getExpandedAtoms())
+ {
+ for (auto inferredAtom : interredCapConjunctions[0].getExpandedAtoms())
+ {
+ if (CapabilityConjunctionSet(inferredAtom).isIncompatibleWith(atom))
+ {
+ diagnoseCapabilityProvenance(sink, entryPointFuncDecl, inferredAtom);
+ goto breakLabel;
+ }
+ }
+ }
+ }
+ }
+ }
+ breakLabel:;
+
}
// Given an entry point specified via API or command line options,
@@ -533,7 +564,7 @@ namespace Slang
auto entryPointName = entryPointReq->getName();
FuncDecl* entryPointFuncDecl = findFunctionDeclByName(translationUnit->getModule(), entryPointName, sink);
-
+
// Did we find a function declaration in our search?
if(!entryPointFuncDecl)
{