From 509bfd8bbaaf021507c4045b5fd9eaf43276dc0a Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Tue, 23 Jul 2024 09:36:38 -0400 Subject: 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. --- source/slang/slang-capability.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source/slang/slang-capability.h') diff --git a/source/slang/slang-capability.h b/source/slang/slang-capability.h index cbdf48ac6..299e956e4 100644 --- a/source/slang/slang-capability.h +++ b/source/slang/slang-capability.h @@ -51,6 +51,8 @@ namespace Slang struct CapabilityAtomSet : UIntSet { using UIntSet::UIntSet; + + CapabilityAtomSet newSetWithoutImpliedAtoms() const; }; struct CapabilityTargetSet; @@ -300,6 +302,22 @@ public: /// Add spirv version capabilities from 'spirv CapabilityTargetSet' as glsl_spirv version capability in 'glsl CapabilityTargetSet' void addSpirvVersionFromOtherAsGlslSpirvVersion(CapabilitySet& other); + /// Gets the first valid compile-target found in the CapabilitySet + CapabilityAtom getCompileTarget() + { + if(isEmpty() || isInvalid()) + return CapabilityAtom::Invalid; + return (*m_targetSets.begin()).first; + } + + /// Gets the first valid stage found in the CapabilitySet + CapabilityAtom getTargetStage() + { + if(isEmpty() || isInvalid()) + return CapabilityAtom::Invalid; + return (*(*m_targetSets.begin()).second.shaderStageSets.begin()).first; + } + private: /// underlying data of CapabilitySet. CapabilityTargetSets m_targetSets{}; -- cgit v1.2.3