summaryrefslogtreecommitdiff
path: root/source/slang
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-api.cpp10
-rwxr-xr-xsource/slang/slang-compiler.h1
-rw-r--r--source/slang/slang.cpp19
3 files changed, 30 insertions, 0 deletions
diff --git a/source/slang/slang-api.cpp b/source/slang/slang-api.cpp
index a4ae92bf9..250b9edf3 100644
--- a/source/slang/slang-api.cpp
+++ b/source/slang/slang-api.cpp
@@ -798,6 +798,16 @@ SLANG_API SlangResult spCompileRequest_getEntryPoint(
return request->getEntryPoint(entryPointIndex, outEntryPoint);
}
+/*! @see slang::ICompileRequest::getCompileTimeProfile */
+SLANG_API SlangResult spGetCompileTimeProfile(
+ slang::ICompileRequest* request,
+ ISlangProfiler** compileTimeProfile,
+ bool shouldClear)
+{
+ SLANG_ASSERT(request);
+ return request->getCompileTimeProfile(compileTimeProfile, shouldClear);
+}
+
// Get the output code associated with a specific translation unit
SLANG_API char const* spGetTranslationUnitSource(
slang::ICompileRequest* /*request*/,
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index fd12a71a3..16f1b9187 100755
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -2782,6 +2782,7 @@ namespace Slang
virtual SLANG_NO_THROW void SLANG_MCALL setSkipSPIRVValidation(bool value) SLANG_OVERRIDE;
virtual SLANG_NO_THROW void SLANG_MCALL setTargetUseMinimumSlangOptimization(int targetIndex, bool value) SLANG_OVERRIDE;
virtual SLANG_NO_THROW void SLANG_MCALL setIgnoreCapabilityCheck(bool value) SLANG_OVERRIDE;
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL getCompileTimeProfile(ISlangProfiler** compileTimeProfile, bool isClear);
void setTrackLiveness(bool v);
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 66e75a282..f820bf8cd 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -6245,6 +6245,25 @@ void const* EndToEndCompileRequest::getEntryPointCode(int entryPointIndex, size_
return (void*)blob->getBufferPointer();
}
+SlangResult EndToEndCompileRequest::getCompileTimeProfile(ISlangProfiler** compileTimeProfile, bool shouldClear)
+{
+ if (compileTimeProfile == nullptr)
+ {
+ return SLANG_E_INVALID_ARG;
+ }
+
+ SlangProfiler* profiler = new SlangProfiler(PerformanceProfiler::getProfiler());
+
+ if (shouldClear)
+ {
+ PerformanceProfiler::getProfiler()->clear();
+ }
+
+ ComPtr<ISlangProfiler> result(profiler);
+ *compileTimeProfile = result.detach();
+ return SLANG_OK;
+}
+
static SlangResult _getEntryPointResult(
EndToEndCompileRequest* req,
int entryPointIndex,