diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-08-12 16:28:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-12 16:28:18 -0400 |
| commit | ea200663ffe33d7b4c739c0d84e9c21a3ae2ffa6 (patch) | |
| tree | 73fae6929c3114be15e84875e4e798ef5a3e563c /source/slang/slang.cpp | |
| parent | 6fc2c37d9a4c408331db1b33deb3b46e74d2a7d2 (diff) | |
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<int> 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.
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 61 |
1 files changed, 57 insertions, 4 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index bb7e705e6..f0570132f 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -146,6 +146,51 @@ SLANG_NO_THROW SlangProfileID SLANG_MCALL Session::findProfile( return Slang::Profile::LookUp(name).raw; } +SLANG_NO_THROW void SLANG_MCALL Session::setPassThroughPath( + SlangPassThrough inPassThrough, + char const* path) +{ + PassThroughMode passThrough = PassThroughMode(inPassThrough); + SLANG_ASSERT(int(passThrough) > int(PassThroughMode::None) && int(passThrough) < int(PassThroughMode::CountOf)); + + if (m_passThroughPaths[int(passThrough)] != path) + { + // If it's changed we should unload any shared libraries that use it + switch (passThrough) + { + case PassThroughMode::Dxc: + { + setSharedLibrary(SharedLibraryType::Dxc, nullptr); + setSharedLibrary(SharedLibraryType::Dxil, nullptr); + break; + } + case PassThroughMode::Fxc: + { + setSharedLibrary(SharedLibraryType::Fxc, nullptr); + break; + } + case PassThroughMode::Glslang: + { + setSharedLibrary(SharedLibraryType::Glslang, nullptr); + break; + } + case PassThroughMode::VisualStudio: + case PassThroughMode::Gcc: + case PassThroughMode::Clang: + case PassThroughMode::GenericCCpp: + { + // If any compiler path set changed, require all to be refreshed + cppCompilerSet.setNull(); + break; + } + default: break; + } + + // Set the path + m_passThroughPaths[int(passThrough)] = path; + } +} + struct IncludeHandlerImpl : IncludeHandler { Linkage* linkage; @@ -2446,7 +2491,9 @@ Session::~Session() SLANG_API SlangSession* spCreateSession(const char*) { - return asExternal(new Slang::Session()); + Slang::RefPtr<Slang::Session> session(new Slang::Session()); + // Will be returned with a refcount of 1 + return asExternal(session.detach()); } SLANG_API SlangResult slang_createGlobalSession( @@ -2463,10 +2510,16 @@ SLANG_API SlangResult slang_createGlobalSession( } SLANG_API void spDestroySession( - SlangSession* session) + SlangSession* inSession) { - if(!session) return; - delete Slang::asInternal(session); + if(!inSession) return; + + Slang::Session* session = Slang::asInternal(inSession); + // It is assumed there is only a single reference on the session (the one placed + // with spCreateSession) if this function is called + SLANG_ASSERT(session->debugGetReferenceCount() == 1); + // Release + session->release(); } SLANG_API void spAddBuiltins( |
