summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-shader.cpp
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-07-23 09:36:38 -0400
committerGitHub <noreply@github.com>2024-07-23 09:36:38 -0400
commit509bfd8bbaaf021507c4045b5fd9eaf43276dc0a (patch)
tree7adab692d0ec55935d8372d9422b7a653068251a /source/slang/slang-check-shader.cpp
parent15f091aabf5b6f8d37d292dab150395d8a37d644 (diff)
Simplify `CapabilitySet` Diagnostic Printing (#4678)
Fixes: #4675 Fixes: #4683 Fixes: #4443 Fixes: #4585 Fixes: #4172 Made the following changes: 1. All capability diagnostic printing logic tries to simplify before printing. This means that we do not print atoms which imply another atom. 2. Do not print the `_` prefix part of atom names since it is misleading users on what they should use to solve a capability issue encountered. (`_Internal` `External` atom changes are not in this PR) 3. Bundle together printing of all sets which contain exactly the same atoms (excluding abstract atoms). This allows printing the following `vertex/fragment/hull/domain/... + glsl` instead of `vertex + glsl | fragment + glsl | hull + glsl | domain + glsl | ....` 4. Rework how entry-point errors are reported to users (example at bottom of PR comment) 5. Rework how atom-provenance data is collected to be leaner and more useful so we can rework the errors. There are 2 notable changes here: * We no longer store a list which describes where the first of an `CapabilityAtom` comes from. This heavily simplifies AST logic for the capability system. AST parsing of capabilities is much faster. The trade-off is faster AST parsing and correct AST node data for slower diagnostics if an error is found * atom-provenance data now stores a reference to an atom's use-site to provide information on **where** and **what** is wrong with user code versus only sharing **what** and not where.
Diffstat (limited to 'source/slang/slang-check-shader.cpp')
-rw-r--r--source/slang/slang-check-shader.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp
index 3d086b189..a802906a7 100644
--- a/source/slang/slang-check-shader.cpp
+++ b/source/slang/slang-check-shader.cpp
@@ -521,26 +521,15 @@ namespace Slang
targetCaps.join(stageCapabilitySet);
if (targetCaps.isIncompatibleWith(entryPointFuncDecl->inferredCapabilityRequirements))
{
- maybeDiagnose(sink, linkage->m_optionSet, DiagnosticCategory::Capability, entryPointFuncDecl, Diagnostics::entryPointUsesUnavailableCapability, entryPointFuncDecl, entryPointFuncDecl->inferredCapabilityRequirements, targetCaps);
+ // Incompatable means we don't support a set of abstract atoms.
+ // Diagnose that we lack support for 'stage' and 'target' atoms with our provided entry-point
+ auto compileTarget = target->getTargetCaps().getCompileTarget();
+ auto stageTarget = stageCapabilitySet.getTargetStage();
+ maybeDiagnose(sink, linkage->m_optionSet, DiagnosticCategory::Capability, entryPointFuncDecl, Diagnostics::entryPointUsesUnavailableCapability, entryPointFuncDecl, compileTarget, stageTarget);
- // Find out what exactly is incompatible and print out a trace of provenance to
- // help user diagnose their code.
- // TODO: provedence should have a way to filter out for provenance that are missing X capabilitySet from their caps, else in big functions we get junk errors
- // This is specifically a problem for when a function is missing a target but otherwise has identical capabilities.
-
- const auto interredCapConjunctions = entryPointFuncDecl->inferredCapabilityRequirements.getAtomSets();
- const auto compileCaps = targetCaps.getAtomSets();
- if (compileCaps && interredCapConjunctions)
- {
- for (auto inferredAtom : *interredCapConjunctions.begin())
- {
- CapabilityAtom inferredAtomFormatted = asAtom(inferredAtom);
- if (!compileCaps->contains((UInt)inferredAtom))
- {
- diagnoseCapabilityProvenance(linkage->m_optionSet, sink, entryPointFuncDecl, inferredAtomFormatted);
- }
- }
- }
+ // Find out what is incompatible (ancestor missing a super set of 'target+stage')
+ CapabilitySet failedSet({ (CapabilityName)compileTarget, (CapabilityName)stageTarget });
+ diagnoseMissingCapabilityProvenance(linkage->m_optionSet, sink, entryPointFuncDecl, failedSet);
}
else
{
@@ -571,6 +560,8 @@ namespace Slang
entryPointFuncDecl->loc,
Diagnostics::profileImplicitlyUpgraded,
Diagnostics::profileImplicitlyUpgradedRestrictive,
+ entryPointFuncDecl,
+ target->getOptionSet().getProfile().getName(),
addedAtoms.getElements<CapabilityAtom>());
}
}