From ea200663ffe33d7b4c739c0d84e9c21a3ae2ffa6 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 12 Aug 2019 16:28:18 -0400 Subject: Ability to set Paths on Pass Through/Back End Compilers (#1010) * Expanded prelude for some other resource types. Disable C++ output for ParameterGroup. * WIP: Layout for CPU. * Fixes to CPU layout. * WIP: The uniform is output, but the variable definition is not. * WIP: Entry point parameters to global scope in C++. Handling of resource types (in so far as outputting) * Some discussion of ABI and different input types. * WIP: More C++ support around resource types. * WIP: Split up variables into different structures on emit. * WIP: Emitting C++ with wrapping up of 'Context' * WIP: C++ code has access to semantic values. Wrap in struct so can use method calls to pass shared state. Disable legalizeResourceTypes and legalizeExistentialTypeLayout * Fix structured buffer layout for CPU. * Remove testing/handling of global uniforms on CPU path. Typo fix. Changed CPU tests to use new CPU calling convention. * Check globals are working. Initalize context to zero globals. * Order the global parameters for C++ ouput by their layout. Note - that layout isn't quite working correctly because the StructuredBuffer the int seems to be consuming uniform space. * Work around for reflection not having all data needed for layout ordering for C++ code. * Output constant buffers as pointers. * Entry point parameters accessed through pointer to struct. * WIP: Layout for CPU is reasonable for test case. * Only output 'f' after float literal if type marks as a float. * Cast construction works on C++. * Made IntrinsicOp::ConvertConstruct to make intent clearer. * C++ handling construction from scalar. Handle access of a scalar with .x. Check default initialization. * Comment about need for split of kIROp_construct. Release build works. * Added support from constructVectorFromScalar to C/C++ target. * Handling of in/out in C/C++. * First pass documentation CPU support. * Improvements to C++/C slang code generation documentation. * Small doc change to include need for mechansim to specify cpp compiler path. * WIP: Being able to set path for backends. * Better handling of swizzling - allow swizzling a scalar into a vector. * Fix missing/broken headers for path setting on session. * Fix for compiling using clang on Windows. * Remove Clang test code. * * Removed spSessionGetGlobalSession - no longer needed because SlangSession is slang::IGlobalSession alias. * Gave Session a ref count on spCreateSession, and have it checked on spDestroySession, so behaves correctly as ISlangUnknown Note that spDestroySession does a release (and checks the ref count on debug builds). It's behaviour could be the same as just release, but this seems closer to the original intention. --- source/slang/slang-check.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-check.cpp') diff --git a/source/slang/slang-check.cpp b/source/slang/slang-check.cpp index b7c1ccdc2..9a4a01045 100644 --- a/source/slang/slang-check.cpp +++ b/source/slang/slang-check.cpp @@ -5,6 +5,9 @@ #include "slang-visitor.h" #include "../core/slang-secure-crt.h" + +#include "../core/slang-io.h" + #include namespace Slang @@ -323,6 +326,28 @@ namespace Slang } } + static PassThroughMode _toPassThroughMode(SharedLibraryType type) + { + switch (type) + { + case SharedLibraryType::Dxil: + case SharedLibraryType::Dxc: + { + return PassThroughMode::Dxc; + } + case SharedLibraryType::Fxc: return PassThroughMode::Fxc; + case SharedLibraryType::Glslang: return PassThroughMode::Glslang; + default: break; + } + + return PassThroughMode::None; + } + + void Session::setSharedLibrary(SharedLibraryType type, ISlangSharedLibrary* library) + { + sharedLibraries[int(type)] = library; + } + ISlangSharedLibrary* Session::getOrLoadSharedLibrary(SharedLibraryType type, DiagnosticSink* sink) { // If not loaded, try loading it @@ -336,6 +361,15 @@ namespace Slang } const char* libName = DefaultSharedLibraryLoader::getSharedLibraryNameFromType(type); + + StringBuilder builder; + PassThroughMode passThrough = _toPassThroughMode(type); + if (passThrough != PassThroughMode::None && m_passThroughPaths[int(passThrough)].getLength() > 0) + { + Path::combineIntoBuilder(m_passThroughPaths[int(passThrough)].getUnownedSlice(), UnownedStringSlice(libName), builder); + libName = builder.getBuffer(); + } + if (SLANG_FAILED(sharedLibraryLoader->loadSharedLibrary(libName, sharedLibraries[int(type)].writeRef()))) { if (sink) @@ -386,7 +420,15 @@ namespace Slang if (cppCompilerSet == nullptr) { cppCompilerSet = new CPPCompilerSet; - CPPCompilerUtil::initializeSet(cppCompilerSet); + + typedef CPPCompiler::CompilerType CompilerType; + CPPCompilerUtil::InitializeSetDesc desc; + + desc.paths[int(CompilerType::GCC)] = m_passThroughPaths[int(PassThroughMode::Gcc)]; + desc.paths[int(CompilerType::Clang)] = m_passThroughPaths[int(PassThroughMode::Clang)]; + desc.paths[int(CompilerType::VisualStudio)] = m_passThroughPaths[int(PassThroughMode::VisualStudio)]; + + CPPCompilerUtil::initializeSet(desc, cppCompilerSet); } SLANG_ASSERT(cppCompilerSet); return cppCompilerSet; -- cgit v1.2.3