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-dxc-compiler.cpp | 57 ++--------------------------- 1 file changed, 4 insertions(+), 53 deletions(-) (limited to 'source/compiler-core/slang-dxc-compiler.cpp') diff --git a/source/compiler-core/slang-dxc-compiler.cpp b/source/compiler-core/slang-dxc-compiler.cpp index 281b6173d..7e7850780 100644 --- a/source/compiler-core/slang-dxc-compiler.cpp +++ b/source/compiler-core/slang-dxc-compiler.cpp @@ -126,8 +126,7 @@ public: // DownstreamCompiler virtual SlangResult compile(const CompileOptions& options, RefPtr& outResult) SLANG_OVERRIDE; - virtual ISlangSharedLibrary* getSharedLibrary() SLANG_OVERRIDE { return m_sharedLibrary; } - virtual SlangResult dissassemble(SlangCompileTarget sourceBlobTarget, const void* blob, size_t blobSize, ISlangBlob** out) SLANG_OVERRIDE; + virtual SlangResult disassemble(SlangCompileTarget sourceBlobTarget, const void* blob, size_t blobSize, ISlangBlob** out) SLANG_OVERRIDE; virtual bool isFileBased() SLANG_OVERRIDE { return false; } /// Must be called before use @@ -184,55 +183,6 @@ static SlangResult _parseDiagnosticLine(const UnownedStringSlice& line, List& outSlices) -{ - StringUtil::split(line, ':', outSlices); - const Int pathIndex = 0; - - // Now we want to fix up a path as might have drive letter, and therefore : - // If this is the situation then we need to have a slice after the one at the index - if (outSlices.getCount() > pathIndex + 1) - { - const UnownedStringSlice pathStart = outSlices[pathIndex].trim(); - if (pathStart.getLength() == 1 && CharUtil::isAlpha(pathStart[0])) - { - // Splice back together - outSlices[pathIndex] = UnownedStringSlice(outSlices[pathIndex].begin(), outSlices[pathIndex + 1].end()); - outSlices.removeAt(pathIndex + 1); - } - } - - return SLANG_OK; -} - -static SlangResult _parseDiagnostics(const UnownedStringSlice& inText, List& outDiagnostics) -{ - List splitLine; - - UnownedStringSlice text(inText), line; - while (StringUtil::extractLine(text, line)) - { - SLANG_RETURN_ON_FAIL(_splitDiagnosticLine(line, splitLine)); - - DownstreamDiagnostic diagnostic; - diagnostic.severity = DownstreamDiagnostic::Severity::Error; - diagnostic.stage = DownstreamDiagnostic::Stage::Compile; - diagnostic.fileLine = 0; - - if (SLANG_SUCCEEDED(_parseDiagnosticLine(line, splitLine, diagnostic))) - { - outDiagnostics.add(diagnostic); - } - else - { - // If couldn't parse, just add as a note - DownstreamDiagnostics::addNote(line, outDiagnostics); - } - } - - return SLANG_OK; -} - SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr& outResult) { // This compiler doesn't read files, they should be read externally and stored in sourceContents/sourceContentsPath @@ -383,7 +333,8 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr { diagnostics.rawDiagnostics = String(diagnosticsSlice); - SlangResult diagnosticParseRes = _parseDiagnostics(diagnosticsSlice, diagnostics.diagnostics); + SlangResult diagnosticParseRes = DownstreamDiagnostic::parseColonDelimitedDiagnostics(diagnosticsSlice, 0, _parseDiagnosticLine, diagnostics.diagnostics); + SLANG_UNUSED(diagnosticParseRes); SLANG_ASSERT(SLANG_SUCCEEDED(diagnosticParseRes)); } @@ -408,7 +359,7 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr return SLANG_OK; } -SlangResult DXCDownstreamCompiler::dissassemble(SlangCompileTarget sourceBlobTarget, const void* blob, size_t blobSize, ISlangBlob** out) +SlangResult DXCDownstreamCompiler::disassemble(SlangCompileTarget sourceBlobTarget, const void* blob, size_t blobSize, ISlangBlob** out) { // Can only disassemble blobs that are DXIL if (sourceBlobTarget != SLANG_DXIL) -- cgit v1.2.3