yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

jarcherNVAdd command line option for separate debug info (#7178)0d16228ae

master
5.1 KiB148 linesraw
1// slang-artifact-associated.h
2#ifndef SLANG_ARTIFACT_ASSOCIATED_H
3#define SLANG_ARTIFACT_ASSOCIATED_H
4
5#include "slang-artifact.h"
6
7namespace Slang
8{
9
10struct ArtifactDiagnostic
11{
12    typedef ArtifactDiagnostic ThisType;
13
14    enum class Severity : uint8_t
15    {
16        Unknown,
17        Info,
18        Warning,
19        Error,
20        CountOf,
21    };
22    enum class Stage : uint8_t
23    {
24        Compile,
25        Link,
26    };
27
28    struct Location
29    {
30        typedef Location ThisType;
31        bool operator==(const ThisType& rhs) const
32        {
33            return line == rhs.line && column == rhs.column;
34        }
35        bool operator!=(const ThisType& rhs) const { return !(*this == rhs); }
36
37        Int line = 0;   ///< One indexed line number. 0 if not defined
38        Int column = 0; ///< One indexed *character (not byte)* column number. 0 if not defined
39    };
40
41    bool operator==(const ThisType& rhs) const
42    {
43        return severity == rhs.severity && stage == rhs.stage && text == rhs.text &&
44               code == rhs.code && location == rhs.location;
45    }
46    bool operator!=(const ThisType& rhs) const { return !(*this == rhs); }
47
48    Severity severity = Severity::Unknown; ///< The severity of error
49    Stage stage = Stage::Compile;          ///< The stage the error came from
50    TerminatedCharSlice text;              ///< The text of the error
51    TerminatedCharSlice code;              ///< The compiler specific error code
52    TerminatedCharSlice filePath;          ///< The path the error originated from
53    Location location;                     ///< The location of the diagnostic in the filePath
54};
55
56/* Artifact diagnostics interface.
57
58IArtifactDiagnostics are added as associated types on an IArtifact typically.
59*/
60class IArtifactDiagnostics : public IClonable
61{
62public:
63    SLANG_COM_INTERFACE(
64        0x91f9b857,
65        0xcd6b,
66        0x45ca,
67        {0x8e, 0x3, 0x8f, 0xa3, 0x3c, 0x5c, 0xf0, 0x1a});
68
69    typedef ArtifactDiagnostic Diagnostic;
70
71    /// Get the diagnostic at the index
72    SLANG_NO_THROW virtual const Diagnostic* SLANG_MCALL getAt(Index i) = 0;
73    /// Get the amount of diangostics
74    SLANG_NO_THROW virtual Count SLANG_MCALL getCount() = 0;
75    /// Add a diagnostic
76    SLANG_NO_THROW virtual void SLANG_MCALL add(const Diagnostic& diagnostic) = 0;
77    /// Remove the diagnostic at the index
78    SLANG_NO_THROW virtual void SLANG_MCALL removeAt(Index i) = 0;
79
80    /// Get raw diagnostics information
81    SLANG_NO_THROW virtual TerminatedCharSlice SLANG_MCALL getRaw() = 0;
82    /// Set the raw diagnostic info
83    SLANG_NO_THROW virtual void SLANG_MCALL setRaw(const CharSlice& slice) = 0;
84    /// Append to the raw diagnostic
85    SLANG_NO_THROW virtual void SLANG_MCALL appendRaw(const CharSlice& slice) = 0;
86
87    /// Get the result for a compilation
88    SLANG_NO_THROW virtual SlangResult SLANG_MCALL getResult() = 0;
89    /// Set the result
90    SLANG_NO_THROW virtual void SLANG_MCALL setResult(SlangResult res) = 0;
91
92    /// Reset all state
93    SLANG_NO_THROW virtual void SLANG_MCALL reset() = 0;
94
95    /// Count the number of diagnostics which have 'severity' or greater
96    SLANG_NO_THROW virtual Count SLANG_MCALL
97    getCountAtLeastSeverity(Diagnostic::Severity severity) = 0;
98
99    /// Get the number of diagnostics by severity
100    SLANG_NO_THROW virtual Count SLANG_MCALL getCountBySeverity(Diagnostic::Severity severity) = 0;
101
102    /// True if there are any diagnostics of severity or worse
103    SLANG_NO_THROW virtual bool SLANG_MCALL hasOfAtLeastSeverity(Diagnostic::Severity severity) = 0;
104
105    /// Stores in outCounts, the amount of diagnostics for the stage of each severity
106    SLANG_NO_THROW virtual Count SLANG_MCALL getCountByStage(
107        Diagnostic::Stage stage,
108        Count outCounts[Int(Diagnostic::Severity::CountOf)]) = 0;
109
110    /// Remove all diagnostics of the type
111    SLANG_NO_THROW virtual void SLANG_MCALL removeBySeverity(Diagnostic::Severity severity) = 0;
112
113    /// Add a note
114    SLANG_NO_THROW virtual void SLANG_MCALL maybeAddNote(const CharSlice& in) = 0;
115
116    /// If there are no error diagnostics, adds a generic error diagnostic
117    SLANG_NO_THROW virtual void SLANG_MCALL requireErrorDiagnostic() = 0;
118
119    /// Creates summary text and place in outBlob
120    SLANG_NO_THROW virtual void SLANG_MCALL calcSummary(ISlangBlob** outBlob) = 0;
121    /// Creates a simplified summary text and places it in out blob
122    SLANG_NO_THROW virtual void SLANG_MCALL calcSimplifiedSummary(ISlangBlob** outBlob) = 0;
123};
124
125struct ShaderBindingRange;
126
127class IArtifactPostEmitMetadata : public slang::IMetadata
128{
129public:
130    SLANG_COM_INTERFACE(
131        0x5d03bce9,
132        0xafb1,
133        0x4fc8,
134        {0xa4, 0x6f, 0x3c, 0xe0, 0x7b, 0x6, 0x1b, 0x1b});
135
136    /// Get the binding ranges
137    SLANG_NO_THROW virtual Slice<ShaderBindingRange> SLANG_MCALL getUsedBindingRanges() = 0;
138
139    /// Get the list of functions that were exported in the linked IR
140    SLANG_NO_THROW virtual Slice<String> SLANG_MCALL getExportedFunctionMangledNames() = 0;
141
142    /// Get the debug build identifier for a base and debug spirv pair
143    SLANG_NO_THROW virtual const char* SLANG_MCALL getDebugBuildIdentifier() = 0;
144};
145
146} // namespace Slang
147
148#endif