summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2025-03-10 08:34:35 +0200
committerGitHub <noreply@github.com>2025-03-10 06:34:35 +0000
commitb59d15539d65472c0e5a89e390ad02b98da61e95 (patch)
tree6178049a0c8d8248b3c24c503f46e4473e094228
parenta3a9ffefdd54fdddeb2efde240d2599645280663 (diff)
Sharpen condition on warning about used capabilities relative to selected profile (#6538)
If the profile/capability in options set, but set to unknown, then don't count the setting as requesting a particular profile/capability. This helps in addressing issue #4760 because the new session-based compilation API always adds a profile setting via Linkage::addTarget, even if the profile is unknown. That caused lots of tests to fail due to unexpected output: "warning 41012: entry point 'computeMain' uses additional capabilities that are not part of the specified profile..." The old compilation request -based API did not add profile/capabiltiy to the options, and so did not generate this warning.
-rw-r--r--source/slang/slang-check-shader.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp
index d04c72e15..fab1d3502 100644
--- a/source/slang/slang-check-shader.cpp
+++ b/source/slang/slang-check-shader.cpp
@@ -537,9 +537,17 @@ void validateEntryPoint(EntryPoint* entryPoint, DiagnosticSink* sink)
}
else
{
- // Only attempt to error if a user adds to slangc either `-profile` or `-capability`
- if ((target->getOptionSet().hasOption(CompilerOptionName::Capability) ||
- target->getOptionSet().hasOption(CompilerOptionName::Profile)) &&
+ auto& targetOptionSet = target->getOptionSet();
+ bool specificProfileRequested =
+ targetOptionSet.hasOption(CompilerOptionName::Profile) &&
+ (targetOptionSet.getIntOption(CompilerOptionName::Profile) !=
+ SLANG_PROFILE_UNKNOWN);
+ bool specificCapabilityRequested =
+ targetOptionSet.hasOption(CompilerOptionName::Capability) &&
+ (targetOptionSet.getIntOption(CompilerOptionName::Capability) !=
+ SLANG_CAPABILITY_UNKNOWN);
+ // Only attempt to error if a specific profile or capability is requested
+ if ((specificCapabilityRequested || specificProfileRequested) &&
targetCaps.atLeastOneSetImpliedInOther(
entryPointFuncDecl->inferredCapabilityRequirements) ==
CapabilitySet::ImpliesReturnFlags::NotImplied)