From 1856b8ad85266ed66985b42bd2321a35f8573a00 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 14 May 2021 18:38:08 -0400 Subject: DXC as DownstreamCompiler (#1845) * #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. --- source/compiler-core/slang-downstream-compiler.cpp | 41 ++++++++++++---------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'source/compiler-core/slang-downstream-compiler.cpp') diff --git a/source/compiler-core/slang-downstream-compiler.cpp b/source/compiler-core/slang-downstream-compiler.cpp index d89434896..9721b45d3 100644 --- a/source/compiler-core/slang-downstream-compiler.cpp +++ b/source/compiler-core/slang-downstream-compiler.cpp @@ -19,6 +19,7 @@ #include "slang-gcc-compiler-util.h" #include "slang-nvrtc-compiler.h" #include "slang-fxc-compiler.h" +#include "slang-dxc-compiler.h" namespace Slang { @@ -158,6 +159,26 @@ Index DownstreamDiagnostics::getCountBySeverity(Diagnostic::Severity severity) c return count; } +void DownstreamDiagnostics::requireErrorDiagnostic() +{ + // If we find an error, we don't need to add a generic diagnostic + for (const auto& msg : diagnostics) + { + if (Index(msg.severity) >= Index(DownstreamDiagnostic::Severity::Error)) + { + return; + } + } + + DownstreamDiagnostic diagnostic; + diagnostic.reset(); + diagnostic.severity = DownstreamDiagnostic::Severity::Error; + diagnostic.text = "Generic error during compilation"; + + // Add the diagnostic + diagnostics.add(diagnostic); +} + Int DownstreamDiagnostics::countByStage(Diagnostic::Stage stage, Index counts[Int(Diagnostic::Severity::CountOf)]) const { Int count = 0; @@ -655,24 +676,6 @@ const DownstreamCompiler::Desc& DownstreamCompilerUtil::getCompiledWithDesc() } } -static SlangResult _locateDXCCompilers(const String& path, ISlangSharedLibraryLoader* loader, DownstreamCompilerSet* set) -{ - // First try dxil, so it's loaded from the same path if it's there - ComPtr dxil; - DefaultSharedLibraryLoader::load(loader, path, "dxil", dxil.writeRef()); - - ComPtr sharedLibrary; - if (SLANG_SUCCEEDED(DefaultSharedLibraryLoader::load(loader, path, "dxcompiler", sharedLibrary.writeRef()))) - { - // Can we determine the version? - DownstreamCompiler::Desc desc(SLANG_PASS_THROUGH_DXC); - RefPtr compiler(new SharedLibraryDownstreamCompiler(desc, sharedLibrary)); - - set->addCompiler(compiler); - } - return SLANG_OK; -} - static SlangResult _locateGlslangCompilers(const String& path, ISlangSharedLibraryLoader* loader, DownstreamCompilerSet* set) { #if SLANG_UNIX_FAMILY @@ -697,7 +700,7 @@ static SlangResult _locateGlslangCompilers(const String& path, ISlangSharedLibra outFuncs[int(SLANG_PASS_THROUGH_CLANG)] = &GCCDownstreamCompilerUtil::locateClangCompilers; outFuncs[int(SLANG_PASS_THROUGH_GCC)] = &GCCDownstreamCompilerUtil::locateGCCCompilers; outFuncs[int(SLANG_PASS_THROUGH_NVRTC)] = &NVRTCDownstreamCompilerUtil::locateCompilers; - outFuncs[int(SLANG_PASS_THROUGH_DXC)] = &_locateDXCCompilers; + outFuncs[int(SLANG_PASS_THROUGH_DXC)] = &DXCDownstreamCompilerUtil::locateCompilers; outFuncs[int(SLANG_PASS_THROUGH_FXC)] = &FXCDownstreamCompilerUtil::locateCompilers; outFuncs[int(SLANG_PASS_THROUGH_GLSLANG)] = &_locateGlslangCompilers; } -- cgit v1.2.3