From 61e9154cb797cffe19cfbf3205b4a5a614e8b552 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 19 May 2021 15:57:11 -0400 Subject: 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. --- source/compiler-core/slang-downstream-compiler.h | 40 +++++++++--------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'source/compiler-core/slang-downstream-compiler.h') 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& outSlices); + + typedef SlangResult (*LineParser)(const UnownedStringSlice& line, List& 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& 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& 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& 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 m_library; -}; - class DownstreamCompilerSet : public RefObject { public: -- cgit v1.2.3