summaryrefslogtreecommitdiff
path: root/source/compiler-core/slang-downstream-compiler.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-05-19 15:57:11 -0400
committerGitHub <noreply@github.com>2021-05-19 12:57:11 -0700
commit61e9154cb797cffe19cfbf3205b4a5a614e8b552 (patch)
tree94270d53c8189d25e6d11dee14860704759b7129 /source/compiler-core/slang-downstream-compiler.h
parentd5e8044d0a9723bb0bbd7ae1738d1157265da783 (diff)
Glslang as DownstreamCompiler (#1846)
* #include an absolute path didn't work - because paths were taken to always be relative. * WIP Fxc as downstream compiler. * First pass FXC downstream compiler working. * GCC compile fix. * Fix FXC parsing issue. * Special case filesystem access. * Use StringUtil getSlice. * Fix isses with not emitting source for FXC. * WIP on DXC. * Small fixes for DXBC handling. * Removed DXC from ParseDiagnosticUtil (can use generic) Try to improve output for notes from DXC. * FIrst pass of Glslang as DownstreamCompiler * Fix some problems with parsing for glslang replacement. * Add slang-glslang-compiler.cpp/.h * Fix downstream for spir-v output. * dissassemble -> disassemble * Fix typo and improve some naming/comments. * Remove getSharedLibrary from DownstreamCompiler * Removed some no longer used diagnostics.
Diffstat (limited to 'source/compiler-core/slang-downstream-compiler.h')
-rw-r--r--source/compiler-core/slang-downstream-compiler.h40
1 files changed, 15 insertions, 25 deletions
diff --git a/source/compiler-core/slang-downstream-compiler.h b/source/compiler-core/slang-downstream-compiler.h
index b3af8a506..22ad5e20c 100644
--- a/source/compiler-core/slang-downstream-compiler.h
+++ b/source/compiler-core/slang-downstream-compiler.h
@@ -59,6 +59,14 @@ struct DownstreamDiagnostic
/// Given a path, that holds line number and potentially column number in () after path, writes result into outDiagnostic
static SlangResult splitPathLocation(const UnownedStringSlice& pathLocation, DownstreamDiagnostic& outDiagnostic);
+ /// Split the line (separated by :), where a path is at pathIndex
+ static SlangResult splitColonDelimitedLine(const UnownedStringSlice& line, Int pathIndex, List<UnownedStringSlice>& outSlices);
+
+ typedef SlangResult (*LineParser)(const UnownedStringSlice& line, List<UnownedStringSlice>& lineSlices, DownstreamDiagnostic& outDiagnostic);
+
+ /// Given diagnostics in inText that are colon delimited, use lineParser to do per line parsing.
+ static SlangResult parseColonDelimitedDiagnostics(const UnownedStringSlice& inText, Int pathIndex, LineParser lineParser, List<DownstreamDiagnostic>& outDiagnostics);
+
Severity severity; ///< The severity of error
Stage stage; ///< The stage the error came from
String text; ///< The text of the error
@@ -241,6 +249,7 @@ public:
enum class Kind
{
CUDASM, ///< What the version is for
+ SPIRV,
};
Kind kind;
SemanticVersion version;
@@ -296,7 +305,10 @@ public:
String entryPointName;
/// Profile name to use, only required for compiles that need to compile against a a specific profiles.
/// Profile names are tied to compilers and targets.
- String profileName;
+ String profileName;
+
+ /// The stage being compiled for
+ SlangStage stage = SLANG_STAGE_NONE;
/// NOTE! Not all downstream compilers can use the fileSystemExt/sourceManager. This option will be ignored in those scenarios.
ISlangFileSystemExt* fileSystemExt = nullptr;
@@ -331,13 +343,10 @@ public:
const Desc& getDesc() const { return m_desc; }
/// Compile using the specified options. The result is in resOut
virtual SlangResult compile(const CompileOptions& options, RefPtr<DownstreamCompileResult>& outResult) = 0;
- /// Some downstream compilers are backed by a shared library. This allows access to the shared library to access internal functions.
- virtual ISlangSharedLibrary* getSharedLibrary() { return nullptr; }
-
/// Some compilers have support converting a binary blob into disassembly. Output disassembly is held in the output blob
- virtual SlangResult dissassemble(SlangCompileTarget sourceBlobTarget, const void* blob, size_t blobSize, ISlangBlob** out);
+ virtual SlangResult disassemble(SlangCompileTarget sourceBlobTarget, const void* blob, size_t blobSize, ISlangBlob** out);
- /// True if underlying compiler uses file system to pass source
+ /// True if underlying compiler uses file system to communicate source
virtual bool isFileBased() = 0;
/// Get info for a compiler type
@@ -422,25 +431,6 @@ public:
CommandLine m_cmdLine;
};
-class SharedLibraryDownstreamCompiler: public DownstreamCompiler
-{
-public:
- typedef DownstreamCompiler Super;
-
- // DownstreamCompiler
- virtual SlangResult compile(const CompileOptions& options, RefPtr<DownstreamCompileResult>& outResult) SLANG_OVERRIDE { SLANG_UNUSED(options); SLANG_UNUSED(outResult); return SLANG_E_NOT_IMPLEMENTED; }
- virtual bool isFileBased() SLANG_OVERRIDE { return true; }
- virtual ISlangSharedLibrary* getSharedLibrary() SLANG_OVERRIDE { return m_library; }
-
- SharedLibraryDownstreamCompiler(const Desc& desc, ISlangSharedLibrary* library):
- Super(desc),
- m_library(library)
- {
- }
-protected:
- ComPtr<ISlangSharedLibrary> m_library;
-};
-
class DownstreamCompilerSet : public RefObject
{
public: