summaryrefslogtreecommitdiff
path: root/source/compiler-core/slang-downstream-compiler.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-05-14 18:38:08 -0400
committerGitHub <noreply@github.com>2021-05-14 18:38:08 -0400
commit1856b8ad85266ed66985b42bd2321a35f8573a00 (patch)
tree0b978ac765741c3a7b29493608d96915013fb571 /source/compiler-core/slang-downstream-compiler.cpp
parentd4316c88457a32f1169b2d7d82053ccbc05fa7ed (diff)
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.
Diffstat (limited to 'source/compiler-core/slang-downstream-compiler.cpp')
-rw-r--r--source/compiler-core/slang-downstream-compiler.cpp41
1 files changed, 22 insertions, 19 deletions
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<ISlangSharedLibrary> dxil;
- DefaultSharedLibraryLoader::load(loader, path, "dxil", dxil.writeRef());
-
- ComPtr<ISlangSharedLibrary> sharedLibrary;
- if (SLANG_SUCCEEDED(DefaultSharedLibraryLoader::load(loader, path, "dxcompiler", sharedLibrary.writeRef())))
- {
- // Can we determine the version?
- DownstreamCompiler::Desc desc(SLANG_PASS_THROUGH_DXC);
- RefPtr<DownstreamCompiler> 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;
}