summaryrefslogtreecommitdiff
path: root/source/compiler-core/slang-glslang-compiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/compiler-core/slang-glslang-compiler.cpp')
-rw-r--r--source/compiler-core/slang-glslang-compiler.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/source/compiler-core/slang-glslang-compiler.cpp b/source/compiler-core/slang-glslang-compiler.cpp
index d6ae59690..26cbf3292 100644
--- a/source/compiler-core/slang-glslang-compiler.cpp
+++ b/source/compiler-core/slang-glslang-compiler.cpp
@@ -14,6 +14,8 @@
#include "../core/slang-semantic-version.h"
#include "../core/slang-char-util.h"
+#include "../core/slang-digest.h"
+
#include "slang-artifact-associated-impl.h"
#include "slang-artifact-desc-util.h"
@@ -47,6 +49,7 @@ public:
virtual SLANG_NO_THROW bool SLANG_MCALL canConvert(const ArtifactDesc& from, const ArtifactDesc& to) SLANG_OVERRIDE;
virtual SLANG_NO_THROW SlangResult SLANG_MCALL convert(IArtifact* from, const ArtifactDesc& to, IArtifact** outArtifact) SLANG_OVERRIDE;
virtual SLANG_NO_THROW bool SLANG_MCALL isFileBased() SLANG_OVERRIDE { return false; }
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL getVersionString(slang::IBlob** outVersionString) SLANG_OVERRIDE;
/// Must be called before use
SlangResult init(ISlangSharedLibrary* library);
@@ -60,7 +63,7 @@ protected:
glslang_CompileFunc_1_0 m_compile_1_0 = nullptr;
glslang_CompileFunc_1_1 m_compile_1_1 = nullptr;
- ComPtr<ISlangSharedLibrary> m_sharedLibrary;
+ ComPtr<ISlangSharedLibrary> m_sharedLibrary;
};
SlangResult GlslangDownstreamCompiler::init(ISlangSharedLibrary* library)
@@ -78,6 +81,20 @@ SlangResult GlslangDownstreamCompiler::init(ISlangSharedLibrary* library)
// It's not clear how to query for a version, but we can get a version number from the header
m_desc = Desc(SLANG_PASS_THROUGH_GLSLANG);
+ Slang::String filename;
+ if (m_compile_1_1)
+ {
+ filename = Slang::SharedLibraryUtils::getSharedLibraryFileName((void*)m_compile_1_1);
+ }
+ else if (m_compile_1_0)
+ {
+ filename = Slang::SharedLibraryUtils::getSharedLibraryFileName((void*)m_compile_1_0);
+ }
+ else
+ {
+ return SLANG_FAIL;
+ }
+
return SLANG_OK;
}
@@ -277,6 +294,28 @@ SlangResult GlslangDownstreamCompiler::convert(IArtifact* from, const ArtifactDe
return SLANG_OK;
}
+SlangResult GlslangDownstreamCompiler::getVersionString(slang::IBlob** outVersionString)
+{
+ uint64_t timestamp;
+ if (m_compile_1_1)
+ {
+ timestamp = SharedLibraryUtils::getSharedLibraryTimestamp((void*)m_compile_1_1);
+ }
+ else if (m_compile_1_0)
+ {
+ timestamp = SharedLibraryUtils::getSharedLibraryTimestamp((void*)m_compile_1_0);
+ }
+ else
+ {
+ return SLANG_FAIL;
+ }
+
+ auto timestampString = String(timestamp);
+ ComPtr<ISlangBlob> version = StringBlob::create(timestampString.getBuffer());
+ *outVersionString = version.detach();
+ return SLANG_OK;
+}
+
/* static */SlangResult GlslangDownstreamCompilerUtil::locateCompilers(const String& path, ISlangSharedLibraryLoader* loader, DownstreamCompilerSet* set)
{
ComPtr<ISlangSharedLibrary> library;