Skip to content

Commit b59d155

Browse files
authored
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.
1 parent a3a9ffe commit b59d155

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

source/slang/slang-check-shader.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,17 @@ void validateEntryPoint(EntryPoint* entryPoint, DiagnosticSink* sink)
537537
}
538538
else
539539
{
540-
// Only attempt to error if a user adds to slangc either `-profile` or `-capability`
541-
if ((target->getOptionSet().hasOption(CompilerOptionName::Capability) ||
542-
target->getOptionSet().hasOption(CompilerOptionName::Profile)) &&
540+
auto& targetOptionSet = target->getOptionSet();
541+
bool specificProfileRequested =
542+
targetOptionSet.hasOption(CompilerOptionName::Profile) &&
543+
(targetOptionSet.getIntOption(CompilerOptionName::Profile) !=
544+
SLANG_PROFILE_UNKNOWN);
545+
bool specificCapabilityRequested =
546+
targetOptionSet.hasOption(CompilerOptionName::Capability) &&
547+
(targetOptionSet.getIntOption(CompilerOptionName::Capability) !=
548+
SLANG_CAPABILITY_UNKNOWN);
549+
// Only attempt to error if a specific profile or capability is requested
550+
if ((specificCapabilityRequested || specificProfileRequested) &&
543551
targetCaps.atLeastOneSetImpliedInOther(
544552
entryPointFuncDecl->inferredCapabilityRequirements) ==
545553
CapabilitySet::ImpliesReturnFlags::NotImplied)

0 commit comments

Comments
 (0)