diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2024-05-08 09:13:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-08 09:13:45 -0700 |
| commit | 4f2330d059ab5943ddf33bfed37be6a0378d43a8 (patch) | |
| tree | 9e3a0790deee6248343d49a644ab9f0be7909901 /source/slang | |
| parent | eb3970897049269602cc18cee644e437c0aff928 (diff) | |
capture/replay: interface implementation 1 (#4122)
* capture/replay: interface implementation 1
- Add global session, filesystem, and session capture interface classes:
GlobalSessionCapture for IGlobalSession
FileSystemCapture for ISlangFileSystemExt
SessionCapture for ISession
- Add environment variables to enable it
The 2 variables are SLANG_CAPTURE_LAYER and SLANG_CAPTURE_LOG_LEVEL
SLANG_CAPTURE_LAYER:
In slang_createGlobalSession(), after the compiling/loading stdlib,
we will check the capture environment variable, if it's set to 1,
we will create a GlobalSessionCapture object and return to user
code.
SLANG_CAPTURE_LOG_LEVEL: This is to set the log level, user can
choose the loglevel to debug. (We can remove this when the feature
is fully implemented).
- Update premake file and cmake file to add the capture/replay source folder
* Fix Windows build error
Fix windows build error by adding the "SLANG_MCALL" keyword.
Change to use Slang::ComPtr for those captured object pointers
to simplify the resource management.
Use __func__ macro to print the function name in the log.
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | source/slang/slang-api.cpp | 15 |
2 files changed, 19 insertions, 1 deletions
diff --git a/source/slang/CMakeLists.txt b/source/slang/CMakeLists.txt index 320cd0ce9..558c1558a 100644 --- a/source/slang/CMakeLists.txt +++ b/source/slang/CMakeLists.txt @@ -159,6 +159,9 @@ set(SLANG_LOOKUP_GENERATOR_OUTPUT_DIR set(SLANG_LOOKUP_GENERATED_SOURCE "${SLANG_LOOKUP_GENERATOR_OUTPUT_DIR}/slang-lookup-GLSLstd450.cpp" ) +set(SLANG_CAPATURE_REPLAY_SYSTEM + "${slang_SOURCE_DIR}/source/slang-capture-replay" +) add_custom_command( OUTPUT ${SLANG_LOOKUP_GENERATED_SOURCE} COMMAND @@ -192,6 +195,7 @@ slang_add_target( . OBJECT TARGET_NAME slang-no-embedded-stdlib + EXTRA_SOURCE_DIRS ${SLANG_CAPATURE_REPLAY_SYSTEM} EXCLUDE_FROM_ALL EXTRA_COMPILE_DEFINITIONS_PUBLIC SLANG_STATIC LINK_WITH_PRIVATE @@ -244,6 +248,7 @@ target_include_directories( slang_add_target( . ${SLANG_LIB_TYPE} + EXTRA_SOURCE_DIRS ${SLANG_CAPATURE_REPLAY_SYSTEM} LINK_WITH_PRIVATE core compiler-core diff --git a/source/slang/slang-api.cpp b/source/slang/slang-api.cpp index 7284f2468..ff37d6398 100644 --- a/source/slang/slang-api.cpp +++ b/source/slang/slang-api.cpp @@ -5,6 +5,8 @@ #include "slang-repro.h" #include "../core/slang-shared-library.h" +#include "../slang-capture-replay/slang-global-session.h" +#include "../slang-capture-replay/capture_utility.h" // implementation of C interface @@ -116,7 +118,18 @@ SLANG_API SlangResult slang_createGlobalSession( } } - *outGlobalSession = globalSession.detach(); + // Check if the SLANG_CAPTURE_ENABLE_ENV is enabled + if (SlangCapture::isCaptureLayerEnabled()) + { + SlangCapture::GlobalSessionCapture* globalSessionCapture = + new SlangCapture::GlobalSessionCapture(globalSession.detach()); + Slang::ComPtr<SlangCapture::GlobalSessionCapture> result(globalSessionCapture); + *outGlobalSession = result.detach(); + } + else + { + *outGlobalSession = globalSession.detach(); + } #ifdef SLANG_ENABLE_IR_BREAK_ALLOC // Reset inst debug alloc counter to 0 so IRInsts for user code always starts from 0. |
