summaryrefslogtreecommitdiff
path: root/source/slang-capture-replay
diff options
context:
space:
mode:
authorkaizhangNV <149626564+kaizhangNV@users.noreply.github.com>2024-07-23 10:45:26 -0500
committerGitHub <noreply@github.com>2024-07-23 08:45:26 -0700
commit986256ffb92ab7c8fc7cf9f2c424919a439a824f (patch)
tree260e37bd439275e3398d16fe238b20cd00d08cb7 /source/slang-capture-replay
parentc28d8b6aec721fa3350fc52647f1572a353f6151 (diff)
Feature/capture (#4625)
* Add decoder * Add a replay executable to consume the decoded content Add file-processor.cpp/h where we implement the logic to process the captured file block by block. Each block is: function header + parameter buffer + function tailer + function output[optional]. After reading one block, the block of data is sent to decoder module to dispatch the corresponding API. Add slang-decoder.cpp/h where we implement the logic to dispatch the slang API according to the input block data. - Rename api_callId.h to capture-format.h - Renmae capture_utility.cpp to capture-utility.cpp - Renmae capture_utility.h to capture-utility.h - Change the #include file name accordingly. * Reorganize source files structure Move all the capture logic code into `capture` directory. - the capture code will be build with slang dll. Move all the replay logic code into `relay` directoy. - the replay code is not part of slang dll, it will be built as a stand alone binary and link against slang dll. Change the #include file names accordingly. Add tools/slang-replay/main.cpp for the slang-replay stand alone binary place holder. Will implement it later. Update premake5.lua accordingly. * Update cmake files Update cmake files to change the build process for capture and relay system. - capture component should be build with slang dll, so we should not include replay component. - replay component should be a separate executable tool, which should not include capture component. - In order to easy use our current cmake infrastructure, move the shared files to a `util` folder - change the header include path * Redesgin the interfaces of consumers Fix some issues in capture Finish implementing all slang-decoder functions * Fix the AppleClang build issue * Address few comments - Fix the weird indent issues. - Correct the function name for CreateGlobalSession() - Rename file-processor to captureFile-processor to be more specific. - Use Slang::List instead of std::vector * record/replay: name refactor change Refactor the naming. Change the name "encoder/capture" to "record".
Diffstat (limited to 'source/slang-capture-replay')
-rw-r--r--source/slang-capture-replay/api_callId.h151
-rw-r--r--source/slang-capture-replay/capture-manager.cpp97
-rw-r--r--source/slang-capture-replay/capture-manager.h50
-rw-r--r--source/slang-capture-replay/capture_utility.cpp82
-rw-r--r--source/slang-capture-replay/capture_utility.h37
-rw-r--r--source/slang-capture-replay/output-stream.cpp52
-rw-r--r--source/slang-capture-replay/output-stream.h46
-rw-r--r--source/slang-capture-replay/parameter-encoder.cpp123
-rw-r--r--source/slang-capture-replay/parameter-encoder.h89
-rw-r--r--source/slang-capture-replay/slang-composite-component-type.cpp309
-rw-r--r--source/slang-capture-replay/slang-composite-component-type.h76
-rw-r--r--source/slang-capture-replay/slang-entrypoint.cpp313
-rw-r--r--source/slang-capture-replay/slang-entrypoint.h77
-rw-r--r--source/slang-capture-replay/slang-filesystem.cpp124
-rw-r--r--source/slang-capture-replay/slang-filesystem.h71
-rw-r--r--source/slang-capture-replay/slang-global-session.cpp451
-rw-r--r--source/slang-capture-replay/slang-global-session.h85
-rw-r--r--source/slang-capture-replay/slang-module.cpp506
-rw-r--r--source/slang-capture-replay/slang-module.h102
-rw-r--r--source/slang-capture-replay/slang-session.cpp517
-rw-r--r--source/slang-capture-replay/slang-session.h116
-rw-r--r--source/slang-capture-replay/slang-type-conformance.cpp310
-rw-r--r--source/slang-capture-replay/slang-type-conformance.h77
23 files changed, 0 insertions, 3861 deletions
diff --git a/source/slang-capture-replay/api_callId.h b/source/slang-capture-replay/api_callId.h
deleted file mode 100644
index a0fae73a6..000000000
--- a/source/slang-capture-replay/api_callId.h
+++ /dev/null
@@ -1,151 +0,0 @@
-#ifndef API_CALL_ID_H
-#define API_CALL_ID_H
-
-#include <cstdint>
-
-namespace SlangCapture
-{
- constexpr uint32_t makeApiCallId(uint16_t classId, uint16_t memberFunctionId)
- {
- return ((static_cast<uint32_t>(classId) << 16) & 0xffff0000) | (static_cast<uint32_t>(memberFunctionId) & 0x0000ffff);
- }
-
- constexpr uint16_t getClassId(uint32_t callId)
- {
- return static_cast<uint16_t>((callId >> 16) & 0x0000ffff);
- }
-
- constexpr uint16_t getMemberFunctionId(uint32_t callId)
- {
- return static_cast<uint16_t>(callId & 0x0000ffff);
- }
-
- enum ApiClassId : uint16_t
- {
- GlobalFunction = 1,
- Class_IGlobalSession = 2,
- Class_ISession = 3,
- Class_IModule = 4,
- Class_IEntryPoint = 5,
- Class_ICompositeComponentType = 6,
- Class_ITypeConformance = 7,
- };
-
- typedef uint64_t AddressFormat;
-
- constexpr uint64_t g_globalFunctionHandle = 0;
-
- enum ApiCallId : uint32_t
- {
- InvalidCallId = 0x00000000,
- ICreateGlobalSession = makeApiCallId(GlobalFunction, 0x0000),
- IGlobalSession_createSession = makeApiCallId(Class_IGlobalSession, 0x0001),
- IGlobalSession_findProfile = makeApiCallId(Class_IGlobalSession, 0x0002),
- IGlobalSession_setDownstreamCompilerPath = makeApiCallId(Class_IGlobalSession, 0x0003),
- IGlobalSession_setDownstreamCompilerPrelude = makeApiCallId(Class_IGlobalSession, 0x0004),
- IGlobalSession_getDownstreamCompilerPrelude = makeApiCallId(Class_IGlobalSession, 0x0005),
- IGlobalSession_getBuildTagString = makeApiCallId(Class_IGlobalSession, 0x0006),
- IGlobalSession_setDefaultDownstreamCompiler = makeApiCallId(Class_IGlobalSession, 0x0007),
- IGlobalSession_getDefaultDownstreamCompiler = makeApiCallId(Class_IGlobalSession, 0x0008),
- IGlobalSession_setLanguagePrelude = makeApiCallId(Class_IGlobalSession, 0x0009),
- IGlobalSession_getLanguagePrelude = makeApiCallId(Class_IGlobalSession, 0x000A),
- IGlobalSession_createCompileRequest = makeApiCallId(Class_IGlobalSession, 0x000B),
- IGlobalSession_addBuiltins = makeApiCallId(Class_IGlobalSession, 0x000C),
- IGlobalSession_setSharedLibraryLoader = makeApiCallId(Class_IGlobalSession, 0x000D),
- IGlobalSession_getSharedLibraryLoader = makeApiCallId(Class_IGlobalSession, 0x000E),
- IGlobalSession_checkCompileTargetSupport = makeApiCallId(Class_IGlobalSession, 0x000F),
- IGlobalSession_checkPassThroughSupport = makeApiCallId(Class_IGlobalSession, 0x0010),
- IGlobalSession_compileStdLib = makeApiCallId(Class_IGlobalSession, 0x0011),
- IGlobalSession_loadStdLib = makeApiCallId(Class_IGlobalSession, 0x0012),
- IGlobalSession_saveStdLib = makeApiCallId(Class_IGlobalSession, 0x0013),
- IGlobalSession_findCapability = makeApiCallId(Class_IGlobalSession, 0x0014),
- IGlobalSession_setDownstreamCompilerForTransition = makeApiCallId(Class_IGlobalSession, 0x0015),
- IGlobalSession_getDownstreamCompilerForTransition = makeApiCallId(Class_IGlobalSession, 0x0016),
- IGlobalSession_getCompilerElapsedTime = makeApiCallId(Class_IGlobalSession, 0x0017),
- IGlobalSession_setSPIRVCoreGrammar = makeApiCallId(Class_IGlobalSession, 0x0018),
- IGlobalSession_parseCommandLineArguments = makeApiCallId(Class_IGlobalSession, 0x0019),
- IGlobalSession_getSessionDescDigest = makeApiCallId(Class_IGlobalSession, 0x001A),
-
- ISession_getGlobalSession = makeApiCallId(Class_ISession, 0x0001),
- ISession_loadModule = makeApiCallId(Class_ISession, 0x0002),
- ISession_loadModuleFromBlob = makeApiCallId(Class_ISession, 0x0003),
- ISession_loadModuleFromIRBlob = makeApiCallId(Class_ISession, 0x0004),
- ISession_loadModuleFromSource = makeApiCallId(Class_ISession, 0x0005),
- ISession_loadModuleFromSourceString = makeApiCallId(Class_ISession, 0x0006),
- ISession_createCompositeComponentType = makeApiCallId(Class_ISession, 0x0007),
- ISession_specializeType = makeApiCallId(Class_ISession, 0x0008),
- ISession_getTypeLayout = makeApiCallId(Class_ISession, 0x0009),
- ISession_getContainerType = makeApiCallId(Class_ISession, 0x000A),
- ISession_getDynamicType = makeApiCallId(Class_ISession, 0x000B),
- ISession_getTypeRTTIMangledName = makeApiCallId(Class_ISession, 0x000C),
- ISession_getTypeConformanceWitnessMangledName = makeApiCallId(Class_ISession, 0x000D),
- ISession_getTypeConformanceWitnessSequentialID = makeApiCallId(Class_ISession, 0x000E),
- ISession_createTypeConformanceComponentType = makeApiCallId(Class_ISession, 0x000F),
- ISession_createCompileRequest = makeApiCallId(Class_ISession, 0x0010),
- ISession_getLoadedModuleCount = makeApiCallId(Class_ISession, 0x0011),
- ISession_getLoadedModule = makeApiCallId(Class_ISession, 0x0012),
- ISession_isBinaryModuleUpToDate = makeApiCallId(Class_ISession, 0x0013),
-
- IModule_findEntryPointByName = makeApiCallId(Class_IModule, 0x0001),
- IModule_getDefinedEntryPointCount = makeApiCallId(Class_IModule, 0x0002),
- IModule_getDefinedEntryPoint = makeApiCallId(Class_IModule, 0x0003),
- IModule_serialize = makeApiCallId(Class_IModule, 0x0004),
- IModule_writeToFile = makeApiCallId(Class_IModule, 0x0005),
- IModule_getName = makeApiCallId(Class_IModule, 0x0006),
- IModule_getFilePath = makeApiCallId(Class_IModule, 0x0007),
- IModule_getUniqueIdentity = makeApiCallId(Class_IModule, 0x0008),
- IModule_findAndCheckEntryPoint = makeApiCallId(Class_IModule, 0x0009),
- IModule_getSession = makeApiCallId(Class_IModule, 0x000A),
- IModule_getLayout = makeApiCallId(Class_IModule, 0x000B),
- IModule_getSpecializationParamCount = makeApiCallId(Class_IModule, 0x000C),
- IModule_getEntryPointCode = makeApiCallId(Class_IModule, 0x000D),
- IModule_getTargetCode = makeApiCallId(Class_IModule, 0x000E),
- IModule_getResultAsFileSystem = makeApiCallId(Class_IModule, 0x000F),
- IModule_getEntryPointHash = makeApiCallId(Class_IModule, 0x0010),
- IModule_specialize = makeApiCallId(Class_IModule, 0x0011),
- IModule_link = makeApiCallId(Class_IModule, 0x0012),
- IModule_getEntryPointHostCallable = makeApiCallId(Class_IModule, 0x0013),
- IModule_renameEntryPoint = makeApiCallId(Class_IModule, 0x0014),
- IModule_linkWithOptions = makeApiCallId(Class_IModule, 0x0015),
-
- IEntryPoint_getSession = makeApiCallId(Class_IEntryPoint, 0x0001),
- IEntryPoint_getLayout = makeApiCallId(Class_IEntryPoint, 0x0002),
- IEntryPoint_getSpecializationParamCount = makeApiCallId(Class_IEntryPoint, 0x0003),
- IEntryPoint_getEntryPointCode = makeApiCallId(Class_IEntryPoint, 0x0004),
- IEntryPoint_getTargetCode = makeApiCallId(Class_IEntryPoint, 0x0005),
- IEntryPoint_getResultAsFileSystem = makeApiCallId(Class_IEntryPoint, 0x0006),
- IEntryPoint_getEntryPointHash = makeApiCallId(Class_IEntryPoint, 0x0007),
- IEntryPoint_specialize = makeApiCallId(Class_IEntryPoint, 0x0008),
- IEntryPoint_link = makeApiCallId(Class_IEntryPoint, 0x0009),
- IEntryPoint_getEntryPointHostCallable = makeApiCallId(Class_IEntryPoint, 0x000A),
- IEntryPoint_renameEntryPoint = makeApiCallId(Class_IEntryPoint, 0x000B),
- IEntryPoint_linkWithOptions = makeApiCallId(Class_IEntryPoint, 0x000C),
-
- ICompositeComponentType_getSession = makeApiCallId(Class_ICompositeComponentType, 0x0001),
- ICompositeComponentType_getLayout = makeApiCallId(Class_ICompositeComponentType, 0x0002),
- ICompositeComponentType_getSpecializationParamCount = makeApiCallId(Class_ICompositeComponentType, 0x0003),
- ICompositeComponentType_getEntryPointCode = makeApiCallId(Class_ICompositeComponentType, 0x0004),
- ICompositeComponentType_getTargetCode = makeApiCallId(Class_ICompositeComponentType, 0x0005),
- ICompositeComponentType_getResultAsFileSystem = makeApiCallId(Class_ICompositeComponentType, 0x0006),
- ICompositeComponentType_getEntryPointHash = makeApiCallId(Class_ICompositeComponentType, 0x0007),
- ICompositeComponentType_specialize = makeApiCallId(Class_ICompositeComponentType, 0x0008),
- ICompositeComponentType_link = makeApiCallId(Class_ICompositeComponentType, 0x0009),
- ICompositeComponentType_getEntryPointHostCallable = makeApiCallId(Class_ICompositeComponentType, 0x000A),
- ICompositeComponentType_renameEntryPoint = makeApiCallId(Class_ICompositeComponentType, 0x000B),
- ICompositeComponentType_linkWithOptions = makeApiCallId(Class_ICompositeComponentType, 0x000C),
-
- ITypeConformance_getSession = makeApiCallId(Class_ITypeConformance, 0x0001),
- ITypeConformance_getLayout = makeApiCallId(Class_ITypeConformance, 0x0002),
- ITypeConformance_getSpecializationParamCount = makeApiCallId(Class_ITypeConformance, 0x0003),
- ITypeConformance_getEntryPointCode = makeApiCallId(Class_ITypeConformance, 0x0004),
- ITypeConformance_getTargetCode = makeApiCallId(Class_ITypeConformance, 0x0005),
- ITypeConformance_getResultAsFileSystem = makeApiCallId(Class_ITypeConformance, 0x0006),
- ITypeConformance_getEntryPointHash = makeApiCallId(Class_ITypeConformance, 0x0007),
- ITypeConformance_specialize = makeApiCallId(Class_ITypeConformance, 0x0008),
- ITypeConformance_link = makeApiCallId(Class_ITypeConformance, 0x0009),
- ITypeConformance_getEntryPointHostCallable = makeApiCallId(Class_ITypeConformance, 0x000A),
- ITypeConformance_renameEntryPoint = makeApiCallId(Class_ITypeConformance, 0x000B),
- ITypeConformance_linkWithOptions = makeApiCallId(Class_ITypeConformance, 0x000C)
- };
-}
-#endif
diff --git a/source/slang-capture-replay/capture-manager.cpp b/source/slang-capture-replay/capture-manager.cpp
deleted file mode 100644
index 5ab40d93c..000000000
--- a/source/slang-capture-replay/capture-manager.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-
-#include <string>
-#include <sstream>
-#include <thread>
-#include "capture_utility.h"
-#include "capture-manager.h"
-
-namespace SlangCapture
-{
- CaptureManager::CaptureManager(uint64_t globalSessionHandle)
- : m_encoder(&m_memoryStream)
- {
- std::stringstream ss;
- ss << "gs-"<< globalSessionHandle <<"-t-"<<std::this_thread::get_id() << ".cap";
-
- m_captureFileDirectory = m_captureFileDirectory / "slang-capture";
-
- if (!std::filesystem::exists(m_captureFileDirectory))
- {
- std::error_code ec;
- if (!std::filesystem::create_directory(m_captureFileDirectory, ec))
- {
- slangCaptureLog(LogLevel::Error, "Fail to create directory: %s, error (%d): %s\n",
- m_captureFileDirectory.string().c_str(), ec.value(), ec.message().c_str());
- }
- }
-
- std::filesystem::path captureFilePath = m_captureFileDirectory / ss.str();
- m_fileStream = std::make_unique<FileOutputStream>(captureFilePath.string());
- }
-
- void CaptureManager::clearWithHeader(const ApiCallId& callId, uint64_t handleId)
- {
- m_memoryStream.flush();
- FunctionHeader header;
- header.callId = callId;
- header.handleId = handleId;
-
- // write header to memory stream
- m_memoryStream.write(&header, sizeof(FunctionHeader));
- }
-
- void CaptureManager::clearWithTailer()
- {
- m_memoryStream.flush();
- FunctionTailer tailer;
-
- // write header to memory stream
- m_memoryStream.write(&tailer, sizeof(FunctionTailer));
- }
-
- ParameterEncoder* CaptureManager::beginMethodCapture(const ApiCallId& callId, uint64_t handleId)
- {
- clearWithHeader(callId, handleId);
- return &m_encoder;
- }
-
- ParameterEncoder* CaptureManager::endMethodCapture()
- {
- FunctionHeader* pHeader = const_cast<FunctionHeader*>(
- reinterpret_cast<const FunctionHeader*>(m_memoryStream.getData()));
-
- pHeader->dataSizeInBytes = m_memoryStream.getSizeInBytes() - sizeof(FunctionHeader);
-
- std::hash<std::thread::id> hasher;
- pHeader->threadId = hasher(std::this_thread::get_id());
-
- // write capture data to file
- m_fileStream->write(m_memoryStream.getData(), m_memoryStream.getSizeInBytes());
-
- // take effect of the write
- m_fileStream->flush();
-
- // clear the memory stream
- m_memoryStream.flush();
-
- clearWithTailer();
- return &m_encoder;
- }
-
- void CaptureManager::endMethodCaptureAppendOutput()
- {
- FunctionTailer* pTailer = const_cast<FunctionTailer*>(
- reinterpret_cast<const FunctionTailer*>(m_memoryStream.getData()));
-
- pTailer->dataSizeInBytes = (uint32_t)(m_memoryStream.getSizeInBytes() - sizeof(FunctionTailer));
-
- // write capture data to file
- m_fileStream->write(m_memoryStream.getData(), m_memoryStream.getSizeInBytes());
-
- // take effect of the write
- m_fileStream->flush();
-
- // clear the memory stream
- m_memoryStream.flush();
- }
-}
diff --git a/source/slang-capture-replay/capture-manager.h b/source/slang-capture-replay/capture-manager.h
deleted file mode 100644
index ca06d70a8..000000000
--- a/source/slang-capture-replay/capture-manager.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef CAPTURE_MANAGER_H
-#define CAPTURE_MANAGER_H
-
-#include <filesystem>
-#include "parameter-encoder.h"
-#include "api_callId.h"
-
-namespace SlangCapture
-{
- class CaptureManager
- {
- public:
- CaptureManager(uint64_t globalSessionHandle);
-
- // Each method capture has to start with a FunctionHeader
- ParameterEncoder* beginMethodCapture(const ApiCallId& callId, uint64_t handleId);
- ParameterEncoder* endMethodCapture();
-
- // endMethodCaptureAppendOutput is an optional call that can be used to append output to
- // the end of the capture. It has to start with a FunctionTailer
- void endMethodCaptureAppendOutput();
-
- std::filesystem::path const& getCaptureFileDirectory() const { return m_captureFileDirectory; }
-
- private:
- void clearWithHeader(const ApiCallId& callId, uint64_t handleId);
- void clearWithTailer();
-
- struct FunctionHeader
- {
- uint32_t magic {0x44414548};
- ApiCallId callId {InvalidCallId};
- uint64_t handleId {0};
- uint64_t dataSizeInBytes {0};
- uint64_t threadId {0};
- };
-
- struct FunctionTailer
- {
- uint32_t magic {0x4C494154};
- uint32_t dataSizeInBytes {0};
- };
-
- MemoryStream m_memoryStream;
- std::unique_ptr<FileOutputStream> m_fileStream;
- std::filesystem::path m_captureFileDirectory = std::filesystem::current_path();
- ParameterEncoder m_encoder;
- };
-} // namespace SlangCapture
-#endif // CAPTURE_MANAGER_H
diff --git a/source/slang-capture-replay/capture_utility.cpp b/source/slang-capture-replay/capture_utility.cpp
deleted file mode 100644
index 550edb64f..000000000
--- a/source/slang-capture-replay/capture_utility.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-
-#include <cstring>
-#include <string>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <mutex>
-
-#include "capture_utility.h"
-
-constexpr const char* kCaptureLayerEnvVar = "SLANG_CAPTURE_LAYER";
-constexpr const char* kCaptureLayerLogLevel = "SLANG_CAPTURE_LOG_LEVEL";
-
-namespace SlangCapture
-{
- static thread_local unsigned int g_logLevel = LogLevel::Silent;
-
- static bool getEnvironmentVariable(const char* name, std::string& out)
- {
-#ifdef _WIN32
- char* envVar = nullptr;
- size_t sz = 0;
- if (_dupenv_s(&envVar, &sz, name) == 0 && envVar != nullptr)
- {
- out = envVar;
- free(envVar);
- }
-#else
- if (const char* envVar = std::getenv(name))
- {
- out = envVar;
- }
-#endif
- return out.empty() == false;
- }
-
- bool isCaptureLayerEnabled()
- {
- std::string envVarStr;
- if(getEnvironmentVariable(kCaptureLayerEnvVar, envVarStr))
- {
- if (envVarStr == "1")
- {
- return true;
- }
- }
- return false;
- }
-
- void setLogLevel()
- {
- // We only want to set the log level once
- if (g_logLevel != LogLevel::Silent)
- {
- return;
- }
-
- std::string envVarStr;
- if (getEnvironmentVariable(kCaptureLayerLogLevel, envVarStr))
- {
- char* end = nullptr;
- unsigned int logLevel = std::strtol(envVarStr.c_str(), &end, 10);
- if (end && (*end == 0))
- {
- g_logLevel = std::min((unsigned int)(LogLevel::Verbose), logLevel);
- return;
- }
- }
- }
-
- void slangCaptureLog(LogLevel logLevel, const char* fmt, ...)
- {
- if (logLevel > g_logLevel)
- {
- return;
- }
-
- va_list args;
- va_start(args, fmt);
- vfprintf(stdout, fmt, args);
- va_end(args);
- }
-}
diff --git a/source/slang-capture-replay/capture_utility.h b/source/slang-capture-replay/capture_utility.h
deleted file mode 100644
index 666c41947..000000000
--- a/source/slang-capture-replay/capture_utility.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef CAPTURE_UTILITY_H
-#define CAPTURE_UTILITY_H
-
-// in gcc and clang, __PRETTY_FUNCTION__ is the function signature,
-// while MSVC uses __FUNCSIG__
-#ifdef _MSC_VER
-#define __PRETTY_FUNCTION__ __FUNCSIG__
-#endif
-
-namespace SlangCapture
-{
- enum LogLevel: unsigned int
- {
- Silent = 0,
- Error = 1,
- Debug = 2,
- Verbose = 3,
- };
-
- bool isCaptureLayerEnabled();
- void slangCaptureLog(LogLevel logLevel, const char* fmt, ...);
- void setLogLevel();
-}
-
-#define SLANG_CAPTURE_ASSERT(VALUE) \
- do { \
- if (!(VALUE)) { \
- SlangCapture::slangCaptureLog(SlangCapture::LogLevel::Error, "Assertion failed: %s, %s, %d\n", #VALUE, __FILE__, __LINE__);\
- std::abort(); \
- } \
- } while(0)
-
-#define SLANG_CAPTURE_CHECK(VALUE) \
- do { \
- SLANG_CAPTURE_ASSERT((VALUE) == SLANG_OK); \
- } while(0)
-#endif // CAPTURE_UTILITY_H
diff --git a/source/slang-capture-replay/output-stream.cpp b/source/slang-capture-replay/output-stream.cpp
deleted file mode 100644
index 97c4b098b..000000000
--- a/source/slang-capture-replay/output-stream.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "output-stream.h"
-#include "capture_utility.h"
-
-namespace SlangCapture
-{
- FileOutputStream::FileOutputStream(const std::string& filename, bool append)
- {
- Slang::String path(filename.c_str());
- Slang::FileMode fileMode = append ? Slang::FileMode::Append : Slang::FileMode::Create;
- Slang::FileAccess fileAccess = Slang::FileAccess::Write;
- Slang::FileShare fileShare = Slang::FileShare::None;
-
- SlangResult res = m_fileStream.init(path, fileMode, fileAccess, fileShare);
-
- if (res != SLANG_OK)
- {
- SlangCapture::slangCaptureLog(SlangCapture::LogLevel::Error, "Failed to open file %s\n", filename.c_str());
- std::abort();
- }
- }
-
- FileOutputStream::~FileOutputStream()
- {
- m_fileStream.close();
- }
-
- void FileOutputStream::write(const void* data, size_t len)
- {
- SLANG_CAPTURE_CHECK(m_fileStream.write(data, len));
- }
-
- MemoryStream::MemoryStream()
- : m_memoryStream(Slang::FileAccess::Write)
- { }
-
- void FileOutputStream::flush()
- {
- SLANG_CAPTURE_CHECK(m_fileStream.flush());
- }
-
- void MemoryStream::write(const void* data, size_t len)
- {
- SLANG_CAPTURE_CHECK(m_memoryStream.write(data, len));
- }
-
- void MemoryStream::flush()
- {
- // This call will reset the underlying buffer to size 0,
- // and reset the write position to 0.
- m_memoryStream.setContent(nullptr, 0);
- }
-}
diff --git a/source/slang-capture-replay/output-stream.h b/source/slang-capture-replay/output-stream.h
deleted file mode 100644
index 1f2c882b0..000000000
--- a/source/slang-capture-replay/output-stream.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef OUTPUT_STREAM_H
-#define OUTPUT_STREAM_H
-
-#include <string>
-#include "../core/slang-stream.h"
-
-namespace SlangCapture
-{
- class OutputStream
- {
- public:
- virtual ~OutputStream() {}
- virtual void write(const void* data, size_t len) = 0;
- virtual void flush() {}
- };
-
- class FileOutputStream : public OutputStream
- {
- public:
- FileOutputStream(const std::string& filename, bool append = false);
- virtual ~FileOutputStream() override;
- virtual void write(const void* data, size_t len) override;
- virtual void flush() override;
-
- private:
- Slang::FileStream m_fileStream;
- };
-
- // The reason we inherit from OwnedMemoryStream instead of declaring it
- // as a member is because OwnedMemoryStream lacks some of the functionality
- // of operating on the underlying buffer directly.
- class MemoryStream : public OutputStream
- {
- public:
- MemoryStream();
- virtual ~MemoryStream() { }
- virtual void write(const void* data, size_t len) override;
- virtual void flush() override;
- const void* getData() { return m_memoryStream.getContents().getBuffer(); }
- size_t getSizeInBytes() { return m_memoryStream.getContents().getCount(); }
-
- private:
- Slang::OwnedMemoryStream m_memoryStream;
- };
-} // namespace SlangCapture
-#endif // OUTPUT_STREAM_H
diff --git a/source/slang-capture-replay/parameter-encoder.cpp b/source/slang-capture-replay/parameter-encoder.cpp
deleted file mode 100644
index c73a97b08..000000000
--- a/source/slang-capture-replay/parameter-encoder.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-#include "parameter-encoder.h"
-#include "api_callId.h"
-
-namespace SlangCapture
-{
- void ParameterEncoder::encodeStruct(slang::SessionDesc const& desc)
- {
- encodeUint64(desc.structureSize);
- encodeInt64(desc.targetCount);
-
- for (SlangInt i = 0; i < desc.targetCount; i++)
- {
- encodeStruct(desc.targets[i]);
- }
-
- encodeUint32(desc.flags);
- encodeEnumValue(desc.defaultMatrixLayoutMode);
- encodeInt64(desc.searchPathCount);
- for (SlangInt i = 0; i < desc.searchPathCount; i++)
- {
- encodeString(desc.searchPaths[i]);
- }
-
- encodeInt64(desc.preprocessorMacroCount);
- for (SlangInt i = 0; i < desc.preprocessorMacroCount; i++)
- {
- encodeStruct(desc.preprocessorMacros[i]);
- }
-
- encodeBool(desc.enableEffectAnnotations);
- encodeBool(desc.allowGLSLSyntax);
-
- encodeUint32(desc.compilerOptionEntryCount);
- for (uint32_t i = 0; i < desc.compilerOptionEntryCount; i++)
- {
- encodeStruct(desc.compilerOptionEntries[i]);
- }
- }
-
- void ParameterEncoder::encodeStruct(slang::PreprocessorMacroDesc const& desc)
- {
- encodeString(desc.name);
- encodeString(desc.value);
- }
-
- void ParameterEncoder::encodeStruct(slang::CompilerOptionEntry const& entry)
- {
- encodeEnumValue(entry.name);
- encodeStruct(entry.value);
- }
-
- void ParameterEncoder::encodeStruct(slang::CompilerOptionValue const& value)
- {
- encodeEnumValue(value.kind);
- encodeInt32(value.intValue0);
- encodeString(value.stringValue0);
- encodeString(value.stringValue1);
- }
-
- void ParameterEncoder::encodeStruct(slang::TargetDesc const& targetDesc)
- {
- encodeUint64(targetDesc.structureSize);
- encodeEnumValue(targetDesc.format);
- encodeEnumValue(targetDesc.profile);
- encodeEnumValue(targetDesc.flags);
- encodeEnumValue(targetDesc.floatingPointMode);
- encodeEnumValue(targetDesc.lineDirectiveMode);
- encodeBool(targetDesc.forceGLSLScalarBufferLayout);
- encodeUint32(targetDesc.compilerOptionEntryCount);
- for (uint32_t i = 0; i < targetDesc.compilerOptionEntryCount; i++)
- {
- encodeStruct(targetDesc.compilerOptionEntries[i]);
- }
- }
-
- void ParameterEncoder::encodeStruct(slang::SpecializationArg const& specializationArg)
- {
- encodeEnumValue(specializationArg.kind);
- encodeAddress(specializationArg.type);
- }
-
- void ParameterEncoder::encodePointer(const void* value, bool omitData, size_t size)
- {
- encodeAddress(value);
- if (omitData)
- {
- return;
- }
-
- encodeUint64(size);
- if (size)
- {
- m_stream->write(value, size);
- }
- }
-
- void ParameterEncoder::encodePointer(ISlangBlob* blob)
- {
- encodeAddress(static_cast<const void*>(blob));
-
- if (blob)
- {
- size_t size = blob->getBufferSize();
- const void* buffer = blob->getBufferPointer();
- encodePointer(buffer, false, size);
- }
- }
-
- // first 4-bytes is the length of the string
- void ParameterEncoder::encodeString(const char* value)
- {
- if (value == nullptr)
- {
- encodeUint32(0);
- }
- else
- {
- uint32_t size = (uint32_t)strlen(value);
- encodeUint32(size);
- m_stream->write(value, size);
- }
- }
-}
diff --git a/source/slang-capture-replay/parameter-encoder.h b/source/slang-capture-replay/parameter-encoder.h
deleted file mode 100644
index d5a6ea510..000000000
--- a/source/slang-capture-replay/parameter-encoder.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#ifndef PARAMETER_ENCODER_H
-#define PARAMETER_ENCODER_H
-
-#include <cstdio>
-#include <cinttypes>
-#include <cstdint>
-
-#include "output-stream.h"
-
-namespace SlangCapture
-{
- class ParameterEncoder
- {
- public:
- ParameterEncoder(OutputStream* stream) : m_stream(stream) {};
- void encodeInt8(int8_t value) { encodeValue(value); }
- void encodeUint8(uint8_t value) { encodeValue(value); }
- void encodeInt16(int16_t value) { encodeValue(value); }
- void encodeUint16(uint16_t value) { encodeValue(value); }
- void encodeInt32(int32_t value) { encodeValue(value); }
- void encodeUint32(uint32_t value) { encodeValue(value); }
- void encodeInt64(int64_t value) { encodeValue(value); }
- void encodeUint64(uint64_t value) { encodeValue(value); }
- void encodeFloat(float value) { encodeValue(value); }
- void encodeDouble(double value) { encodeValue(value); }
- void encodeBool(bool value) { encodeValue(value); }
-
- template<typename T>
- void encodeEnumValue(T value) { encodeValue(static_cast<uint32_t>(value)); }
-
- void encodeString(const char* value);
- void encodePointer(const void* value, bool omitData = false, size_t size = 0);
- void encodePointer(ISlangBlob* blob);
- void encodeAddress(const void* value) { encodeValue(reinterpret_cast<uint64_t>(value)); }
-
- void encodeStruct(slang::SessionDesc const& desc);
- void encodeStruct(slang::PreprocessorMacroDesc const& desc);
- void encodeStruct(slang::CompilerOptionEntry const& entry);
- void encodeStruct(slang::CompilerOptionValue const& value);
- void encodeStruct(slang::TargetDesc const& targetDesc);
- void encodeStruct(slang::SpecializationArg const& specializationArg);
-
- template <typename T>
- void encodeValueArray(const T* array, size_t count)
- {
- for (size_t i = 0; i < count; ++i)
- {
- encodeValue(array[i]);
- }
- }
-
- void encodeStringArray(const char* const* array, size_t count)
- {
- for (size_t i = 0; i < count; ++i)
- {
- encodeString(array[i]);
- }
- }
-
- template <typename T>
- void encodeStructArray(T const* array, size_t count)
- {
- for (size_t i = 0; i < count; ++i)
- {
- encodeStruct(array[i]);
- }
- }
-
- template <typename T>
- void encodeAddressArray(T* const* array, size_t count)
- {
- for (size_t i = 0; i < count; ++i)
- {
- encodeAddress(array[i]);
- }
- }
-
-
- private:
- template <typename T>
- void encodeValue(T value)
- {
- m_stream->write(&value, sizeof(T));
- }
- OutputStream* m_stream;
- };
-} // namespace SlangCapture
-
-#endif // PARAMETER_ENCODER_H
diff --git a/source/slang-capture-replay/slang-composite-component-type.cpp b/source/slang-capture-replay/slang-composite-component-type.cpp
deleted file mode 100644
index a0699e27a..000000000
--- a/source/slang-capture-replay/slang-composite-component-type.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-#include "capture_utility.h"
-#include "slang-composite-component-type.h"
-
-namespace SlangCapture
-{
- CompositeComponentTypeCapture::CompositeComponentTypeCapture(
- slang::IComponentType* componentType, CaptureManager* captureManager)
- : m_actualCompositeComponentType(componentType),
- m_captureManager(captureManager)
- {
- SLANG_CAPTURE_ASSERT(m_actualCompositeComponentType != nullptr);
- SLANG_CAPTURE_ASSERT(m_captureManager != nullptr);
-
- m_compositeComponentHandle = reinterpret_cast<uint64_t>(m_actualCompositeComponentType.get());
- slangCaptureLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, componentType);
- }
-
- CompositeComponentTypeCapture::~CompositeComponentTypeCapture()
- {
- m_actualCompositeComponentType->release();
- }
-
- ISlangUnknown* CompositeComponentTypeCapture::getInterface(const Guid& guid)
- {
- if (guid == IComponentType::getTypeGuid())
- {
- return static_cast<ISlangUnknown*>(this);
- }
- return nullptr;
- }
-
- SLANG_NO_THROW slang::ISession* CompositeComponentTypeCapture::getSession()
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_getSession, m_compositeComponentHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::ISession* res = m_actualCompositeComponentType->getSession();
-
- {
- encoder->encodeAddress(res);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW slang::ProgramLayout* CompositeComponentTypeCapture::getLayout(
- SlangInt targetIndex,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_getLayout, m_compositeComponentHandle);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::ProgramLayout* programLayout = m_actualCompositeComponentType->getLayout(targetIndex, outDiagnostics);
-
- {
- encoder->encodeAddress(*outDiagnostics);
- encoder->encodeAddress(programLayout);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return programLayout;
- }
-
- SLANG_NO_THROW SlangInt CompositeComponentTypeCapture::getSpecializationParamCount()
- {
- // No need to capture this call as it is just a query.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- SlangInt res = m_actualCompositeComponentType->getSpecializationParamCount();
- return res;
- }
-
- SLANG_NO_THROW SlangResult CompositeComponentTypeCapture::getEntryPointCode(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_getEntryPointCode, m_compositeComponentHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualCompositeComponentType->getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics);
-
- {
- encoder->encodeAddress(*outCode);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult CompositeComponentTypeCapture::getTargetCode(
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_getTargetCode, m_compositeComponentHandle);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualCompositeComponentType->getTargetCode(targetIndex, outCode, outDiagnostics);
-
- {
- encoder->encodeAddress(*outCode);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult CompositeComponentTypeCapture::getResultAsFileSystem(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- ISlangMutableFileSystem** outFileSystem)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_getResultAsFileSystem, m_compositeComponentHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualCompositeComponentType->getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem);
-
- {
- encoder->encodeAddress(*outFileSystem);
- }
-
- // TODO: We might need to wrap the file system object.
- return res;
- }
-
- SLANG_NO_THROW void CompositeComponentTypeCapture::getEntryPointHash(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outHash)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_getEntryPointHash, m_compositeComponentHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- m_actualCompositeComponentType->getEntryPointHash(entryPointIndex, targetIndex, outHash);
-
- {
- encoder->encodeAddress(*outHash);
- m_captureManager->endMethodCaptureAppendOutput();
- }
- }
-
- SLANG_NO_THROW SlangResult CompositeComponentTypeCapture::specialize(
- slang::SpecializationArg const* specializationArgs,
- SlangInt specializationArgCount,
- slang::IComponentType** outSpecializedComponentType,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_specialize, m_compositeComponentHandle);
- encoder->encodeInt64(specializationArgCount);
- encoder->encodeStructArray(specializationArgs, specializationArgCount);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualCompositeComponentType->specialize(specializationArgs, specializationArgCount, outSpecializedComponentType, outDiagnostics);
-
- {
- encoder->encodeAddress(*outSpecializedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult CompositeComponentTypeCapture::link(
- slang::IComponentType** outLinkedComponentType,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_link, m_compositeComponentHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualCompositeComponentType->link(outLinkedComponentType, outDiagnostics);
-
- {
- encoder->encodeAddress(*outLinkedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult CompositeComponentTypeCapture::getEntryPointHostCallable(
- int entryPointIndex,
- int targetIndex,
- ISlangSharedLibrary** outSharedLibrary,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_getEntryPointHostCallable, m_compositeComponentHandle);
- encoder->encodeInt32(entryPointIndex);
- encoder->encodeInt32(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualCompositeComponentType->getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics);
-
- {
- encoder->encodeAddress(*outSharedLibrary);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult CompositeComponentTypeCapture::renameEntryPoint(
- const char* newName, IComponentType** outEntryPoint)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_renameEntryPoint, m_compositeComponentHandle);
- encoder->encodeString(newName);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualCompositeComponentType->renameEntryPoint(newName, outEntryPoint);
-
- {
- encoder->encodeAddress(*outEntryPoint);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult CompositeComponentTypeCapture::linkWithOptions(
- IComponentType** outLinkedComponentType,
- uint32_t compilerOptionEntryCount,
- slang::CompilerOptionEntry* compilerOptionEntries,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_linkWithOptions, m_compositeComponentHandle);
- encoder->encodeUint32(compilerOptionEntryCount);
- encoder->encodeStructArray(compilerOptionEntries, compilerOptionEntryCount);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualCompositeComponentType->linkWithOptions(outLinkedComponentType, compilerOptionEntryCount, compilerOptionEntries, outDiagnostics);
-
- {
- encoder->encodeAddress(*outLinkedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-}
diff --git a/source/slang-capture-replay/slang-composite-component-type.h b/source/slang-capture-replay/slang-composite-component-type.h
deleted file mode 100644
index 61ebe4cc0..000000000
--- a/source/slang-capture-replay/slang-composite-component-type.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef SLANG_COMPOSITE_COMPONENT_TYPE_H
-#define SLANG_COMPOSITE_COMPONENT_TYPE_H
-
-#include "slang-com-ptr.h"
-#include "slang.h"
-#include "slang-com-helper.h"
-#include "../core/slang-smart-pointer.h"
-#include "../core/slang-dictionary.h"
-#include "../slang/slang-compiler.h"
-#include "capture-manager.h"
-
-namespace SlangCapture
-{
- using namespace Slang;
- class CompositeComponentTypeCapture: public slang::IComponentType, public RefObject
- {
- public:
- SLANG_REF_OBJECT_IUNKNOWN_ALL
- ISlangUnknown* getInterface(const Guid& guid);
-
- explicit CompositeComponentTypeCapture(slang::IComponentType* componentType, CaptureManager* captureManager);
- ~CompositeComponentTypeCapture();
-
- // Interfaces for `IComponentType`
- virtual SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() override;
- virtual SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL getLayout(
- SlangInt targetIndex = 0,
- slang::IBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangInt SLANG_MCALL getSpecializationParamCount() override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- ISlangMutableFileSystem** outFileSystem) override;
- virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outHash) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL specialize(
- slang::SpecializationArg const* specializationArgs,
- SlangInt specializationArgCount,
- slang::IComponentType** outSpecializedComponentType,
- ISlangBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL link(
- slang::IComponentType** outLinkedComponentType,
- ISlangBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable(
- int entryPointIndex,
- int targetIndex,
- ISlangSharedLibrary** outSharedLibrary,
- slang::IBlob** outDiagnostics = 0) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint(
- const char* newName, IComponentType** outEntryPoint) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions(
- IComponentType** outLinkedComponentType,
- uint32_t compilerOptionEntryCount,
- slang::CompilerOptionEntry* compilerOptionEntries,
- ISlangBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCode(
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics = nullptr) override;
-
- slang::IComponentType* getActualCompositeComponentType() const { return m_actualCompositeComponentType; }
- private:
- Slang::ComPtr<slang::IComponentType> m_actualCompositeComponentType;
- uint64_t m_compositeComponentHandle = 0;
- CaptureManager* m_captureManager = nullptr;
-
- };
-}
-#endif // SLANG_COMPOSITE_COMPONENT_TYPE_H
diff --git a/source/slang-capture-replay/slang-entrypoint.cpp b/source/slang-capture-replay/slang-entrypoint.cpp
deleted file mode 100644
index 46d701f98..000000000
--- a/source/slang-capture-replay/slang-entrypoint.cpp
+++ /dev/null
@@ -1,313 +0,0 @@
-#include "capture_utility.h"
-#include "slang-entrypoint.h"
-
-namespace SlangCapture
-{
- EntryPointCapture::EntryPointCapture(slang::IEntryPoint* entryPoint, CaptureManager* captureManager)
- : m_actualEntryPoint(entryPoint),
- m_captureManager(captureManager)
- {
- SLANG_CAPTURE_ASSERT(m_actualEntryPoint != nullptr);
- SLANG_CAPTURE_ASSERT(m_captureManager != nullptr);
-
- m_entryPointHandle = reinterpret_cast<uint64_t>(m_actualEntryPoint.get());
- slangCaptureLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, entryPoint);
- }
-
- EntryPointCapture::~EntryPointCapture()
- {
- m_actualEntryPoint->release();
- }
-
- ISlangUnknown* EntryPointCapture::getInterface(const Guid& guid)
- {
- if(guid == EntryPointCapture::getTypeGuid())
- return static_cast<ISlangUnknown*>(this);
- else
- return nullptr;
- }
-
- SLANG_NO_THROW slang::ISession* EntryPointCapture::getSession()
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IEntryPoint_getSession, m_entryPointHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::ISession* session = m_actualEntryPoint->getSession();
-
- {
- encoder->encodeAddress(session);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return session;
- }
-
- SLANG_NO_THROW slang::ProgramLayout* EntryPointCapture::getLayout(
- SlangInt targetIndex,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IEntryPoint_getLayout, m_entryPointHandle);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::ProgramLayout* programLayout = m_actualEntryPoint->getLayout(targetIndex, outDiagnostics);
-
- {
- encoder->encodeAddress(*outDiagnostics);
- encoder->encodeAddress(programLayout);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return programLayout;
- }
-
- SLANG_NO_THROW SlangInt EntryPointCapture::getSpecializationParamCount()
- {
- // No need to capture this call as it is just a query.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- SlangInt res = m_actualEntryPoint->getSpecializationParamCount();
- return res;
- }
-
- SLANG_NO_THROW SlangResult EntryPointCapture::getEntryPointCode(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IEntryPoint_getEntryPointCode, m_entryPointHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualEntryPoint->getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics);
-
- {
- encoder->encodeAddress(*outCode);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult EntryPointCapture::getTargetCode(
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IEntryPoint_getTargetCode, m_entryPointHandle);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualEntryPoint->getTargetCode(targetIndex, outCode, outDiagnostics);
-
- {
- encoder->encodeAddress(*outCode);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult EntryPointCapture::getResultAsFileSystem(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- ISlangMutableFileSystem** outFileSystem)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IEntryPoint_getResultAsFileSystem, m_entryPointHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualEntryPoint->getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem);
-
- {
- encoder->encodeAddress(*outFileSystem);
- }
-
- // TODO: We might need to wrap the file system object.
- return res;
- }
-
- SLANG_NO_THROW void EntryPointCapture::getEntryPointHash(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outHash)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IEntryPoint_getEntryPointHash, m_entryPointHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- m_actualEntryPoint->getEntryPointHash(entryPointIndex, targetIndex, outHash);
-
- {
- encoder->encodeAddress(*outHash);
- m_captureManager->endMethodCaptureAppendOutput();
- }
- }
-
- SLANG_NO_THROW SlangResult EntryPointCapture::specialize(
- slang::SpecializationArg const* specializationArgs,
- SlangInt specializationArgCount,
- slang::IComponentType** outSpecializedComponentType,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IEntryPoint_specialize, m_entryPointHandle);
- encoder->encodeInt64(specializationArgCount);
- encoder->encodeStructArray(specializationArgs, specializationArgCount);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualEntryPoint->specialize(specializationArgs, specializationArgCount, outSpecializedComponentType, outDiagnostics);
-
- {
- encoder->encodeAddress(*outSpecializedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult EntryPointCapture::link(
- slang::IComponentType** outLinkedComponentType,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IEntryPoint_link, m_entryPointHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualEntryPoint->link(outLinkedComponentType, outDiagnostics);
-
- {
- encoder->encodeAddress(*outLinkedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult EntryPointCapture::getEntryPointHostCallable(
- int entryPointIndex,
- int targetIndex,
- ISlangSharedLibrary** outSharedLibrary,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IEntryPoint_getEntryPointHostCallable, m_entryPointHandle);
- encoder->encodeInt32(entryPointIndex);
- encoder->encodeInt32(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualEntryPoint->getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics);
-
- {
- encoder->encodeAddress(*outSharedLibrary);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult EntryPointCapture::renameEntryPoint(
- const char* newName, IComponentType** outEntryPoint)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IEntryPoint_renameEntryPoint, m_entryPointHandle);
- encoder->encodeString(newName);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualEntryPoint->renameEntryPoint(newName, outEntryPoint);
-
- {
- encoder->encodeAddress(*outEntryPoint);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult EntryPointCapture::linkWithOptions(
- IComponentType** outLinkedComponentType,
- uint32_t compilerOptionEntryCount,
- slang::CompilerOptionEntry* compilerOptionEntries,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IEntryPoint_linkWithOptions, m_entryPointHandle);
- encoder->encodeUint32(compilerOptionEntryCount);
- encoder->encodeStructArray(compilerOptionEntries, compilerOptionEntryCount);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualEntryPoint->linkWithOptions(outLinkedComponentType, compilerOptionEntryCount, compilerOptionEntries, outDiagnostics);
-
- {
- encoder->encodeAddress(*outLinkedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW slang::FunctionReflection* EntryPointCapture::getFunctionReflection()
- {
- return m_actualEntryPoint->getFunctionReflection();
- }
-
-}
diff --git a/source/slang-capture-replay/slang-entrypoint.h b/source/slang-capture-replay/slang-entrypoint.h
deleted file mode 100644
index 5dbe9b14b..000000000
--- a/source/slang-capture-replay/slang-entrypoint.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef SLANG_ENTRY_POINT_H
-#define SLANG_ENTRY_POINT_H
-
-#include "slang-com-ptr.h"
-#include "slang.h"
-#include "slang-com-helper.h"
-#include "../core/slang-smart-pointer.h"
-#include "../core/slang-dictionary.h"
-#include "../slang/slang-compiler.h"
-#include "capture-manager.h"
-
-namespace SlangCapture
-{
- using namespace Slang;
- class EntryPointCapture : public slang::IEntryPoint, public RefObject
- {
- public:
- SLANG_COM_INTERFACE(0xf4c1e23d, 0xb321, 0x4931, { 0x8f, 0x37, 0xf1, 0x22, 0x6a, 0xf9, 0x20, 0x85 })
-
- SLANG_REF_OBJECT_IUNKNOWN_ALL
- ISlangUnknown* getInterface(const Guid& guid);
-
- explicit EntryPointCapture(slang::IEntryPoint* entryPoint, CaptureManager* captureManager);
- ~EntryPointCapture();
-
- // Interfaces for `IComponentType`
- virtual SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() override;
- virtual SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL getLayout(
- SlangInt targetIndex = 0,
- slang::IBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangInt SLANG_MCALL getSpecializationParamCount() override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCode(
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- ISlangMutableFileSystem** outFileSystem) override;
- virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outHash) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL specialize(
- slang::SpecializationArg const* specializationArgs,
- SlangInt specializationArgCount,
- slang::IComponentType** outSpecializedComponentType,
- ISlangBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL link(
- slang::IComponentType** outLinkedComponentType,
- ISlangBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable(
- int entryPointIndex,
- int targetIndex,
- ISlangSharedLibrary** outSharedLibrary,
- slang::IBlob** outDiagnostics = 0) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint(
- const char* newName, IComponentType** outEntryPoint) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions(
- IComponentType** outLinkedComponentType,
- uint32_t compilerOptionEntryCount,
- slang::CompilerOptionEntry* compilerOptionEntries,
- ISlangBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW slang::FunctionReflection* SLANG_MCALL getFunctionReflection() override;
- slang::IEntryPoint* getActualEntryPoint() const { return m_actualEntryPoint; }
- private:
- Slang::ComPtr<slang::IEntryPoint> m_actualEntryPoint;
- uint64_t m_entryPointHandle = 0;
- CaptureManager* m_captureManager = nullptr;
- };
-}
-#endif // SLANG_ENTRY_POINT_H
diff --git a/source/slang-capture-replay/slang-filesystem.cpp b/source/slang-capture-replay/slang-filesystem.cpp
deleted file mode 100644
index 0de17162e..000000000
--- a/source/slang-capture-replay/slang-filesystem.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-#include "slang-filesystem.h"
-#include "capture_utility.h"
-#include "output-stream.h"
-
-namespace SlangCapture
-{
- // We don't actually need to capture the methods of ISlangFileSystemExt, we just want to capture the file content
- // and save them into disk.
- FileSystemCapture::FileSystemCapture(ISlangFileSystemExt* fileSystem, CaptureManager* captureManager)
- : m_actualFileSystem(fileSystem),
- m_captureManager(captureManager)
- {
- SLANG_CAPTURE_ASSERT(m_actualFileSystem);
- SLANG_CAPTURE_ASSERT(m_captureManager);
- slangCaptureLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, m_actualFileSystem.get());
- }
-
- FileSystemCapture::~FileSystemCapture()
- {
- m_actualFileSystem->release();
- }
-
- void* FileSystemCapture::castAs(const Slang::Guid& guid)
- {
- return getInterface(guid);
- }
-
- ISlangUnknown* FileSystemCapture::getInterface(const Slang::Guid& guid)
- {
- if(guid == ISlangUnknown::getTypeGuid() || guid == ISlangFileSystem::getTypeGuid())
- return static_cast<ISlangFileSystem*>(this);
- return nullptr;
- }
-
- // TODO: There could be a potential issue that could not be able to dump the generated file content correctly.
- // Details: https://github.com/shader-slang/slang/issues/4423.
- SLANG_NO_THROW SlangResult FileSystemCapture::loadFile(
- char const* path,
- ISlangBlob** outBlob)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s, :%s\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__, path);
- SlangResult res = m_actualFileSystem->loadFile(path, outBlob);
-
- // Since the loadFile method could be implemented by client, we can't guarantee the result is always as expected,
- // we will check every thing to make sure we won't crash at writing file.
- //
- // We can only dump the file content after this 'loadFile' call, no matter this call crashes or file is not
- // found, we can't save the file anyway, so we don't need to pay special care to the crash recovery. We will
- // know something wrong with the loadFile call if we can't find the file in the capture directory.
- if ((res == SLANG_OK) && (*outBlob != nullptr) && ((*outBlob)->getBufferSize() != 0))
- {
- std::filesystem::path filePath = m_captureManager->getCaptureFileDirectory();
- filePath = filePath / path;
-
- FileOutputStream fileStream(filePath.string().c_str());
-
- fileStream.write((*outBlob)->getBufferPointer(), (*outBlob)->getBufferSize());
- fileStream.flush();
- }
- return res;
- }
-
- SLANG_NO_THROW SlangResult FileSystemCapture::getFileUniqueIdentity(
- const char* path,
- ISlangBlob** outUniqueIdentity)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s :\"%s\"\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__, path);
- SlangResult res = m_actualFileSystem->getFileUniqueIdentity(path, outUniqueIdentity);
- return res;
- }
-
- SLANG_NO_THROW SlangResult FileSystemCapture::calcCombinedPath(
- SlangPathType fromPathType,
- const char* fromPath,
- const char* path,
- ISlangBlob** pathOut)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s, :%s\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__, path);
- SlangResult res = m_actualFileSystem->calcCombinedPath(fromPathType, fromPath, path, pathOut);
- return res;
- }
-
- SLANG_NO_THROW SlangResult FileSystemCapture::getPathType(
- const char* path,
- SlangPathType* pathTypeOut)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s, :%s\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__, path);
- SlangResult res = m_actualFileSystem->getPathType(path, pathTypeOut);
- return res;
- }
-
- SLANG_NO_THROW SlangResult FileSystemCapture::getPath(
- PathKind kind,
- const char* path,
- ISlangBlob** outPath)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s, :%s\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__, path);
- SlangResult res = m_actualFileSystem->getPath(kind, path, outPath);
- return res;
- }
-
- SLANG_NO_THROW void FileSystemCapture::clearCache()
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__);
- m_actualFileSystem->clearCache();
- }
-
- SLANG_NO_THROW SlangResult FileSystemCapture::enumeratePathContents(
- const char* path,
- FileSystemContentsCallBack callback,
- void* userData)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s, :%s\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__, path);
- SlangResult res = m_actualFileSystem->enumeratePathContents(path, callback, userData);
- return res;
- }
-
- SLANG_NO_THROW OSPathKind FileSystemCapture::getOSPathKind()
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__);
- OSPathKind pathKind = m_actualFileSystem->getOSPathKind();
- return pathKind;
- }
-}
diff --git a/source/slang-capture-replay/slang-filesystem.h b/source/slang-capture-replay/slang-filesystem.h
deleted file mode 100644
index 1a7c8c2e2..000000000
--- a/source/slang-capture-replay/slang-filesystem.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef SLANG_FILE_SYSTEM_H
-#define SLANG_FILE_SYSTEM_H
-
-#include "../core/slang-com-object.h"
-#include "slang-com-helper.h"
-#include "slang-com-ptr.h"
-#include "capture-manager.h"
-
-namespace SlangCapture
-{
-
- using namespace Slang;
-
- // slang always requires ISlangFileSystemExt interface, even if user only provides ISlangFileSystem,
- // slang will still wrap it with ISlangFileSystemExt. So we have to capture ISlangFileSystemExt, even
- // though we only need to record loadFile() function.
- class FileSystemCapture : public RefObject, public ISlangFileSystemExt
- {
- public:
- explicit FileSystemCapture(ISlangFileSystemExt* fileSystem, CaptureManager* captureManager);
- ~FileSystemCapture();
-
- // ISlangUnknown
- SLANG_REF_OBJECT_IUNKNOWN_ALL
-
- ISlangUnknown* getInterface(const Slang::Guid& guid);
-
- // ISlangCastable
- virtual SLANG_NO_THROW void* SLANG_MCALL castAs(const Slang::Guid& guid) override;
-
- // ISlangFileSystem
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL loadFile(
- char const* path,
- ISlangBlob** outBlob) override;
-
- // ISlangFileSystemExt
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getFileUniqueIdentity(
- const char* path,
- ISlangBlob** outUniqueIdentity) override;
-
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL calcCombinedPath(
- SlangPathType fromPathType,
- const char* fromPath,
- const char* path,
- ISlangBlob** pathOut) override;
-
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getPathType(
- const char* path,
- SlangPathType* pathTypeOut) override;
-
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getPath(
- PathKind kind,
- const char* path,
- ISlangBlob** outPath) override;
-
- virtual SLANG_NO_THROW void SLANG_MCALL clearCache() override;
-
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL enumeratePathContents(
- const char* path,
- FileSystemContentsCallBack callback,
- void* userData) override;
-
- virtual SLANG_NO_THROW OSPathKind SLANG_MCALL getOSPathKind() override;
- private:
- Slang::ComPtr<ISlangFileSystemExt> m_actualFileSystem;
- CaptureManager* m_captureManager = nullptr;
-};
-
-}
-#endif
-
diff --git a/source/slang-capture-replay/slang-global-session.cpp b/source/slang-capture-replay/slang-global-session.cpp
deleted file mode 100644
index d8f1e361d..000000000
--- a/source/slang-capture-replay/slang-global-session.cpp
+++ /dev/null
@@ -1,451 +0,0 @@
-#include "slang-global-session.h"
-#include "slang-session.h"
-#include "slang-filesystem.h"
-#include "../slang/slang-compiler.h"
-#include "capture_utility.h"
-
-namespace SlangCapture
-{
- // constructor is called in slang_createGlobalSession
- GlobalSessionCapture::GlobalSessionCapture(slang::IGlobalSession* session):
- m_actualGlobalSession(session)
- {
- SLANG_CAPTURE_ASSERT(m_actualGlobalSession != nullptr);
-
- m_globalSessionHandle = reinterpret_cast<SlangCapture::AddressFormat>(m_actualGlobalSession.get());
- m_captureManager = std::make_unique<CaptureManager>(m_globalSessionHandle);
-
- // We will use the address of the global session as the filename for the capture manager
- // to make it unique for each global session.
- // capture slang::createGlobalSession
- ParameterEncoder* encoder = m_captureManager->beginMethodCapture(ApiCallId::ICreateGlobalSession, g_globalFunctionHandle);
- encoder->encodeAddress(m_actualGlobalSession);
- m_captureManager->endMethodCapture();
- }
-
- GlobalSessionCapture::~GlobalSessionCapture()
- {
- m_actualGlobalSession->release();
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::queryInterface(SlangUUID const& uuid, void** outObject)
- {
- if (uuid == Session::getTypeGuid())
- {
- // no add-ref here, the query will cause the inner session to handle the add-ref.
- this->m_actualGlobalSession->queryInterface(uuid, outObject);
- return SLANG_OK;
- }
-
- if (uuid == ISlangUnknown::getTypeGuid() && uuid == IGlobalSession::getTypeGuid())
- {
- addReference();
- *outObject = static_cast<slang::IGlobalSession*>(this);
- return SLANG_OK;
- }
-
- return SLANG_E_NO_INTERFACE;
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::createSession(slang::SessionDesc const& desc, slang::ISession** outSession)
- {
- setLogLevel();
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- slang::ISession* actualSession = nullptr;
-
- ParameterEncoder* encoder{};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_createSession, m_globalSessionHandle);
- encoder->encodeStruct(desc);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualGlobalSession->createSession(desc, &actualSession);
-
- { // capture output
- encoder->encodeAddress(actualSession);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- if (actualSession != nullptr)
- {
- // reset the file system to our capture file system. After createSession() call,
- // the Linkage will set to user provided file system or slang default file system.
- // We need to reset it to our capture file system
- Slang::Linkage* linkage = static_cast<Linkage*>(actualSession);
- FileSystemCapture* fileSystemCapture = new FileSystemCapture(linkage->getFileSystemExt(), m_captureManager.get());
-
- Slang::ComPtr<FileSystemCapture> resultFileSystemCapture(fileSystemCapture);
- linkage->setFileSystem(resultFileSystemCapture.detach());
-
- SessionCapture* sessionCapture = new SessionCapture(actualSession, m_captureManager.get());
- Slang::ComPtr<SessionCapture> result(sessionCapture);
- *outSession = result.detach();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangProfileID SLANG_MCALL GlobalSessionCapture::findProfile(char const* name)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_findProfile, m_globalSessionHandle);
- encoder->encodeString(name);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangProfileID profileId = m_actualGlobalSession->findProfile(name);
- return profileId;
- }
-
- SLANG_NO_THROW void SLANG_MCALL GlobalSessionCapture::setDownstreamCompilerPath(SlangPassThrough passThrough, char const* path)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_setDownstreamCompilerPath, m_globalSessionHandle);
- encoder->encodeEnumValue(passThrough);
- encoder->encodeString(path);
- m_captureManager->endMethodCapture();
- }
-
- m_actualGlobalSession->setDownstreamCompilerPath(passThrough, path);
- }
-
- SLANG_NO_THROW void SLANG_MCALL GlobalSessionCapture::setDownstreamCompilerPrelude(SlangPassThrough inPassThrough, char const* prelude)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_setDownstreamCompilerPrelude, m_globalSessionHandle);
- encoder->encodeEnumValue(inPassThrough);
- encoder->encodeString(prelude);
- m_captureManager->endMethodCapture();
- }
-
- m_actualGlobalSession->setDownstreamCompilerPrelude(inPassThrough, prelude);
- }
-
- SLANG_NO_THROW void SLANG_MCALL GlobalSessionCapture::getDownstreamCompilerPrelude(SlangPassThrough inPassThrough, ISlangBlob** outPrelude)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_getDownstreamCompilerPrelude, m_globalSessionHandle);
- encoder->encodeEnumValue(inPassThrough);
- encoder = m_captureManager->endMethodCapture();
- }
-
- m_actualGlobalSession->getDownstreamCompilerPrelude(inPassThrough, outPrelude);
-
- {
- encoder->encodeAddress(*outPrelude);
- m_captureManager->endMethodCaptureAppendOutput();
- }
- }
-
- SLANG_NO_THROW const char* SLANG_MCALL GlobalSessionCapture::getBuildTagString()
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- // No need to capture this function. It's just a query function and it won't impact the internal state.
- const char* resStr = m_actualGlobalSession->getBuildTagString();
- return resStr;
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::setDefaultDownstreamCompiler(SlangSourceLanguage sourceLanguage, SlangPassThrough defaultCompiler)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_setDefaultDownstreamCompiler, m_globalSessionHandle);
- encoder->encodeEnumValue(sourceLanguage);
- encoder->encodeEnumValue(defaultCompiler);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualGlobalSession->setDefaultDownstreamCompiler(sourceLanguage, defaultCompiler);
- return res;
- }
-
- SLANG_NO_THROW SlangPassThrough SLANG_MCALL GlobalSessionCapture::getDefaultDownstreamCompiler(SlangSourceLanguage sourceLanguage)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_getDefaultDownstreamCompiler, m_globalSessionHandle);
- encoder->encodeEnumValue(sourceLanguage);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangPassThrough passThrough = m_actualGlobalSession->getDefaultDownstreamCompiler(sourceLanguage);
- return passThrough;
- }
-
- SLANG_NO_THROW void SLANG_MCALL GlobalSessionCapture::setLanguagePrelude(SlangSourceLanguage inSourceLanguage, char const* prelude)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_setLanguagePrelude, m_globalSessionHandle);
- encoder->encodeEnumValue(inSourceLanguage);
- encoder->encodeString(prelude);
- encoder = m_captureManager->endMethodCapture();
- }
-
- m_actualGlobalSession->setLanguagePrelude(inSourceLanguage, prelude);
- }
-
- SLANG_NO_THROW void SLANG_MCALL GlobalSessionCapture::getLanguagePrelude(SlangSourceLanguage inSourceLanguage, ISlangBlob** outPrelude)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_getLanguagePrelude, m_globalSessionHandle);
- encoder->encodeEnumValue(inSourceLanguage);
- encoder = m_captureManager->endMethodCapture();
- }
-
- m_actualGlobalSession->getLanguagePrelude(inSourceLanguage, outPrelude);
-
- {
- encoder->encodeAddress(*outPrelude);
- m_captureManager->endMethodCaptureAppendOutput();
- }
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::createCompileRequest(slang::ICompileRequest** outCompileRequest)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_createCompileRequest, m_globalSessionHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualGlobalSession->createCompileRequest(outCompileRequest);
-
- {
- encoder->encodeAddress(*outCompileRequest);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW void SLANG_MCALL GlobalSessionCapture::addBuiltins(char const* sourcePath, char const* sourceString)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_addBuiltins, m_globalSessionHandle);
- encoder->encodeString(sourcePath);
- encoder->encodeString(sourceString);
- encoder = m_captureManager->endMethodCapture();
- }
-
- m_actualGlobalSession->addBuiltins(sourcePath, sourceString);
- }
-
- SLANG_NO_THROW void SLANG_MCALL GlobalSessionCapture::setSharedLibraryLoader(ISlangSharedLibraryLoader* loader)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
- // TODO: Not sure if we need to capture this function. Because this functions is something like the file system
- // override, it's provided by user code. So capturing it makes no sense. The only way is to wrapper this interface
- // by our own implementation, and capture it there.
- m_actualGlobalSession->setSharedLibraryLoader(loader);
- }
-
- SLANG_NO_THROW ISlangSharedLibraryLoader* SLANG_MCALL GlobalSessionCapture::getSharedLibraryLoader()
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_getSharedLibraryLoader, m_globalSessionHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- ISlangSharedLibraryLoader* loader = m_actualGlobalSession->getSharedLibraryLoader();
-
- {
- encoder->encodeAddress(loader);
- m_captureManager->endMethodCaptureAppendOutput();
- }
- return loader;
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::checkCompileTargetSupport(SlangCompileTarget target)
- {
- // No need to capture this function. It's just a query function and it won't impact the internal state.
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
- SlangResult res = m_actualGlobalSession->checkCompileTargetSupport(target);
- return res;
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::checkPassThroughSupport(SlangPassThrough passThrough)
- {
- // No need to capture this function. It's just a query function and it won't impact the internal state.
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
- SlangResult res = m_actualGlobalSession->checkPassThroughSupport(passThrough);
- return res;
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::compileStdLib(slang::CompileStdLibFlags flags)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_compileStdLib, m_globalSessionHandle);
- encoder->encodeEnumValue(flags);
- m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualGlobalSession->compileStdLib(flags);
- return res;
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::loadStdLib(const void* stdLib, size_t stdLibSizeInBytes)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_loadStdLib, m_globalSessionHandle);
- encoder->encodePointer(stdLib, false, stdLibSizeInBytes);
- m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualGlobalSession->loadStdLib(stdLib, stdLibSizeInBytes);
- return res;
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::saveStdLib(SlangArchiveType archiveType, ISlangBlob** outBlob)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_saveStdLib, m_globalSessionHandle);
- encoder->encodeEnumValue(archiveType);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualGlobalSession->saveStdLib(archiveType, outBlob);
-
- {
- encoder->encodeAddress(*outBlob);
- m_captureManager->endMethodCaptureAppendOutput();
- }
- return res;
- }
-
- SLANG_NO_THROW SlangCapabilityID SLANG_MCALL GlobalSessionCapture::findCapability(char const* name)
- {
- // No need to capture this function. It's just a query function and it won't impact the internal state.
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
- SlangCapabilityID capId = m_actualGlobalSession->findCapability(name);
- return capId;
- }
-
- SLANG_NO_THROW void SLANG_MCALL GlobalSessionCapture::setDownstreamCompilerForTransition(SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_setDownstreamCompilerForTransition, m_globalSessionHandle);
- encoder->encodeEnumValue(source);
- encoder->encodeEnumValue(target);
- encoder->encodeEnumValue(compiler);
- m_captureManager->endMethodCapture();
- }
-
- m_actualGlobalSession->setDownstreamCompilerForTransition(source, target, compiler);
- }
-
- SLANG_NO_THROW SlangPassThrough SLANG_MCALL GlobalSessionCapture::getDownstreamCompilerForTransition(SlangCompileTarget source, SlangCompileTarget target)
- {
- // No need to capture this function. It's just a query function and it won't impact the internal state.
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
- SlangPassThrough passThrough = m_actualGlobalSession->getDownstreamCompilerForTransition(source, target);
- return passThrough;
- }
-
- SLANG_NO_THROW void SLANG_MCALL GlobalSessionCapture::getCompilerElapsedTime(double* outTotalTime, double* outDownstreamTime)
- {
- // No need to capture this function. It's just a query function and it won't impact the internal state.
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
- m_actualGlobalSession->getCompilerElapsedTime(outTotalTime, outDownstreamTime);
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::setSPIRVCoreGrammar(char const* jsonPath)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_setSPIRVCoreGrammar, m_globalSessionHandle);
- encoder->encodeString(jsonPath);
- m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualGlobalSession->setSPIRVCoreGrammar(jsonPath);
- return res;
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::parseCommandLineArguments(
- int argc, const char* const* argv, slang::SessionDesc* outSessionDesc, ISlangUnknown** outAllocation)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_parseCommandLineArguments, m_globalSessionHandle);
- encoder->encodeStringArray(argv, argc);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualGlobalSession->parseCommandLineArguments(argc, argv, outSessionDesc, outAllocation);
-
- {
- encoder->encodeStruct(*outSessionDesc);
- encoder->encodeAddress(*outAllocation);
- m_captureManager->endMethodCaptureAppendOutput();
- }
- return res;
- }
-
- SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionCapture::getSessionDescDigest(slang::SessionDesc* sessionDesc, ISlangBlob** outBlob)
- {
- slangCaptureLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IGlobalSession_getSessionDescDigest, m_globalSessionHandle);
- encoder->encodeStruct(*sessionDesc);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualGlobalSession->getSessionDescDigest(sessionDesc, outBlob);
-
- {
- encoder->encodeAddress(*outBlob);
- m_captureManager->endMethodCaptureAppendOutput();
- }
- return res;
- }
-}
diff --git a/source/slang-capture-replay/slang-global-session.h b/source/slang-capture-replay/slang-global-session.h
deleted file mode 100644
index f478e60db..000000000
--- a/source/slang-capture-replay/slang-global-session.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef SLANG_GLOBAL_SESSION_H
-#define SLANG_GLOBAL_SESSION_H
-
-#include "slang-com-ptr.h"
-#include "slang.h"
-#include "slang-com-helper.h"
-#include "../core/slang-smart-pointer.h"
-#include "capture-manager.h"
-
-namespace SlangCapture
-{
- using namespace Slang;
-
- class GlobalSessionCapture : public RefObject, public slang::IGlobalSession
- {
- public:
- explicit GlobalSessionCapture(slang::IGlobalSession* session);
- virtual ~GlobalSessionCapture();
-
- SLANG_REF_OBJECT_IUNKNOWN_ADD_REF
- SLANG_REF_OBJECT_IUNKNOWN_RELEASE
-
- SLANG_NO_THROW SlangResult SLANG_MCALL queryInterface(SlangUUID const& uuid, void** outObject) SLANG_OVERRIDE;
-
- // slang::IGlobalSession
- SLANG_NO_THROW SlangResult SLANG_MCALL createSession(slang::SessionDesc const& desc, slang::ISession** outSession) override;
- SLANG_NO_THROW SlangProfileID SLANG_MCALL findProfile(char const* name) override;
- SLANG_NO_THROW void SLANG_MCALL setDownstreamCompilerPath(SlangPassThrough passThrough, char const* path) override;
- SLANG_NO_THROW void SLANG_MCALL setDownstreamCompilerPrelude(SlangPassThrough inPassThrough, char const* prelude) override;
- SLANG_NO_THROW void SLANG_MCALL getDownstreamCompilerPrelude(SlangPassThrough inPassThrough, ISlangBlob** outPrelude) override;
- SLANG_NO_THROW const char* SLANG_MCALL getBuildTagString() override;
- SLANG_NO_THROW SlangResult SLANG_MCALL setDefaultDownstreamCompiler(SlangSourceLanguage sourceLanguage, SlangPassThrough defaultCompiler) override;
- SLANG_NO_THROW SlangPassThrough SLANG_MCALL getDefaultDownstreamCompiler(SlangSourceLanguage sourceLanguage) override;
-
- SLANG_NO_THROW void SLANG_MCALL setLanguagePrelude(SlangSourceLanguage inSourceLanguage, char const* prelude) override;
- SLANG_NO_THROW void SLANG_MCALL getLanguagePrelude(SlangSourceLanguage inSourceLanguage, ISlangBlob** outPrelude) override;
-
- SLANG_NO_THROW SlangResult SLANG_MCALL createCompileRequest(slang::ICompileRequest** outCompileRequest) override;
-
- SLANG_NO_THROW void SLANG_MCALL addBuiltins(char const* sourcePath, char const* sourceString) override;
- SLANG_NO_THROW void SLANG_MCALL setSharedLibraryLoader(ISlangSharedLibraryLoader* loader) override;
- SLANG_NO_THROW ISlangSharedLibraryLoader* SLANG_MCALL getSharedLibraryLoader() override;
- SLANG_NO_THROW SlangResult SLANG_MCALL checkCompileTargetSupport(SlangCompileTarget target) override;
- SLANG_NO_THROW SlangResult SLANG_MCALL checkPassThroughSupport(SlangPassThrough passThrough) override;
-
- SLANG_NO_THROW SlangResult SLANG_MCALL compileStdLib(slang::CompileStdLibFlags flags) override;
- SLANG_NO_THROW SlangResult SLANG_MCALL loadStdLib(const void* stdLib, size_t stdLibSizeInBytes) override;
- SLANG_NO_THROW SlangResult SLANG_MCALL saveStdLib(SlangArchiveType archiveType, ISlangBlob** outBlob) override;
-
- SLANG_NO_THROW SlangCapabilityID SLANG_MCALL findCapability(char const* name) override;
-
- SLANG_NO_THROW void SLANG_MCALL setDownstreamCompilerForTransition(SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) override;
- SLANG_NO_THROW SlangPassThrough SLANG_MCALL getDownstreamCompilerForTransition(SlangCompileTarget source, SlangCompileTarget target) override;
- SLANG_NO_THROW void SLANG_MCALL getCompilerElapsedTime(double* outTotalTime, double* outDownstreamTime) override;
-
- SLANG_NO_THROW SlangResult SLANG_MCALL setSPIRVCoreGrammar(char const* jsonPath) override;
-
- SLANG_NO_THROW SlangResult SLANG_MCALL parseCommandLineArguments(
- int argc, const char* const* argv, slang::SessionDesc* outSessionDesc, ISlangUnknown** outAllocation) override;
-
- SLANG_NO_THROW SlangResult SLANG_MCALL getSessionDescDigest(slang::SessionDesc* sessionDesc, ISlangBlob** outBlob) override;
-
- CaptureManager* getCaptureManager() { return m_captureManager.get(); }
-
- private:
- SLANG_FORCE_INLINE slang::IGlobalSession* asExternal(GlobalSessionCapture* session)
- {
- return static_cast<slang::IGlobalSession*>(session);
- }
-
- Slang::ComPtr<slang::IGlobalSession> m_actualGlobalSession;
-
- // we will create one capture file per IGlobalSession.
- // We don't try to reproduce the user application's threading model, because it requires lots of effort and it's not necessary.
- // Instead, we record all the compilation jobs associated with the session in the same capture file, so that during replay,
- // those jobs will be executed sequentially. This might violate the user application's threading model, because those jobs might
- // be executed in different threads. But it's not a big problem, because slang doesn't allow multiple threads to access the same
- // session at the same time. So even if there is one session used by multiple threads, those threads will execute the compile jobs
- // sequentially.
- std::unique_ptr<CaptureManager> m_captureManager;
- uint64_t m_globalSessionHandle = 0;
- };
-} // namespace Slang
-
-#endif
diff --git a/source/slang-capture-replay/slang-module.cpp b/source/slang-capture-replay/slang-module.cpp
deleted file mode 100644
index 273faa59d..000000000
--- a/source/slang-capture-replay/slang-module.cpp
+++ /dev/null
@@ -1,506 +0,0 @@
-#include "capture_utility.h"
-#include "slang-module.h"
-
-namespace SlangCapture
-{
- ModuleCapture::ModuleCapture(slang::IModule* module, CaptureManager* captureManager)
- : m_actualModule(module),
- m_captureManager(captureManager)
- {
- SLANG_CAPTURE_ASSERT(m_actualModule != nullptr);
- SLANG_CAPTURE_ASSERT(m_captureManager != nullptr);
-
- m_moduleHandle = reinterpret_cast<uint64_t>(m_actualModule.get());
- slangCaptureLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, module);
- }
-
- ModuleCapture::~ModuleCapture()
- {
- m_actualModule->release();
- }
-
- ISlangUnknown* ModuleCapture::getInterface(const Guid& guid)
- {
- if(guid == ModuleCapture::getTypeGuid())
- return static_cast<ISlangUnknown*>(this);
- else
- return nullptr;
- }
-
- SLANG_NO_THROW slang::DeclReflection* ModuleCapture::getModuleReflection()
- {
- // No need to capture this call as it is just a query.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- slang::DeclReflection* res = (slang::DeclReflection*)m_actualModule->getModuleReflection();
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::findEntryPointByName(
- char const* name,
- slang::IEntryPoint** outEntryPoint)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_findEntryPointByName, m_moduleHandle);
- encoder->encodeString(name);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->findEntryPointByName(name, outEntryPoint);
-
- {
- encoder->encodeAddress(*outEntryPoint);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- if (SLANG_OK == res)
- {
- EntryPointCapture* entryPointCapture = getEntryPointCapture(*outEntryPoint);
- *outEntryPoint = static_cast<slang::IEntryPoint*>(entryPointCapture);
- }
- return res;
- }
-
- SLANG_NO_THROW SlangInt32 ModuleCapture::getDefinedEntryPointCount()
- {
- // No need to capture this call as it is just a query.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- SlangInt32 res = m_actualModule->getDefinedEntryPointCount();
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::getDefinedEntryPoint(SlangInt32 index, slang::IEntryPoint** outEntryPoint)
- {
- // This call is to find the existing entry point, so it has been created already. Therefore, we don't create a new one
- // and assert the error if it is not found in our map.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_getDefinedEntryPoint, m_moduleHandle);
- encoder->encodeInt32(index);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->getDefinedEntryPoint(index, outEntryPoint);
-
- {
- encoder->encodeAddress(*outEntryPoint);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- if (*outEntryPoint)
- {
- EntryPointCapture* entryPointCapture = m_mapEntryPointToCapture.tryGetValue(*outEntryPoint);
- if (!entryPointCapture)
- {
- SLANG_CAPTURE_ASSERT(!"Entrypoint not found in mapEntryPointToCapture");
- }
- *outEntryPoint = static_cast<slang::IEntryPoint*>(entryPointCapture);
- }
- else
- *outEntryPoint = nullptr;
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::serialize(ISlangBlob** outSerializedBlob)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_serialize, m_moduleHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->serialize(outSerializedBlob);
-
- {
- encoder->encodeAddress(*outSerializedBlob);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::writeToFile(char const* fileName)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_writeToFile, m_moduleHandle);
- encoder->encodeString(fileName);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->writeToFile(fileName);
- return res;
- }
-
- SLANG_NO_THROW const char* ModuleCapture::getName()
- {
- // No need to capture this call as it is just a query.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- const char* res = m_actualModule->getName();
- return res;
- }
-
- SLANG_NO_THROW const char* ModuleCapture::getFilePath()
- {
- // No need to capture this call as it is just a query.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- const char* res = m_actualModule->getFilePath();
- return res;
- }
-
- SLANG_NO_THROW const char* ModuleCapture::getUniqueIdentity()
- {
- // No need to capture this call as it is just a query.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- const char* res = m_actualModule->getUniqueIdentity();
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::findAndCheckEntryPoint(
- char const* name,
- SlangStage stage,
- slang::IEntryPoint** outEntryPoint,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_findAndCheckEntryPoint, m_moduleHandle);
- encoder->encodeString(name);
- encoder->encodeEnumValue(stage);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->findAndCheckEntryPoint(name, stage, outEntryPoint, outDiagnostics);
-
- {
- encoder->encodeAddress(*outEntryPoint);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- if (SLANG_OK == res)
- {
- EntryPointCapture* entryPointCapture = getEntryPointCapture(*outEntryPoint);
- *outEntryPoint = static_cast<slang::IEntryPoint*>(entryPointCapture);
- }
- return res;
- }
-
- SLANG_NO_THROW SlangInt32 ModuleCapture::getDependencyFileCount()
- {
- // No need to capture this call as it is just a query.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- SlangInt32 res = m_actualModule->getDependencyFileCount();
- return res;
- }
-
- SLANG_NO_THROW char const* ModuleCapture::getDependencyFilePath(SlangInt32 index)
- {
- // No need to capture this call as it is just a query.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- const char* res = m_actualModule->getDependencyFilePath(index);
- return res;
- }
-
- SLANG_NO_THROW slang::ISession* ModuleCapture::getSession()
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_getSession, m_moduleHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::ISession* session = m_actualModule->getSession();
-
- {
- encoder->encodeAddress(session);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return session;
- }
-
- SLANG_NO_THROW slang::ProgramLayout* ModuleCapture::getLayout(
- SlangInt targetIndex,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_getLayout, m_moduleHandle);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::ProgramLayout* programLayout = m_actualModule->getLayout(targetIndex, outDiagnostics);
-
- {
- encoder->encodeAddress(*outDiagnostics);
- encoder->encodeAddress(programLayout);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return programLayout;
- }
-
- SLANG_NO_THROW SlangInt ModuleCapture::getSpecializationParamCount()
- {
- // No need to capture this call as it is just a query.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- SlangInt res = m_actualModule->getSpecializationParamCount();
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::getEntryPointCode(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_getEntryPointCode, m_moduleHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics);
-
- {
- encoder->encodeAddress(*outCode);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::getTargetCode(
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_getTargetCode, m_moduleHandle);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->getTargetCode(targetIndex, outCode, outDiagnostics);
-
- {
- encoder->encodeAddress(*outCode);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::getResultAsFileSystem(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- ISlangMutableFileSystem** outFileSystem)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_getResultAsFileSystem, m_moduleHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem);
-
- {
- encoder->encodeAddress(*outFileSystem);
- }
-
- // TODO: We might need to wrap the file system object.
- return res;
- }
-
- SLANG_NO_THROW void ModuleCapture::getEntryPointHash(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outHash)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_getEntryPointHash, m_moduleHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- m_actualModule->getEntryPointHash(entryPointIndex, targetIndex, outHash);
-
- {
- encoder->encodeAddress(*outHash);
- m_captureManager->endMethodCaptureAppendOutput();
- }
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::specialize(
- slang::SpecializationArg const* specializationArgs,
- SlangInt specializationArgCount,
- slang::IComponentType** outSpecializedComponentType,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_specialize, m_moduleHandle);
- encoder->encodeInt64(specializationArgCount);
- encoder->encodeStructArray(specializationArgs, specializationArgCount);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->specialize(specializationArgs, specializationArgCount, outSpecializedComponentType, outDiagnostics);
-
- {
- encoder->encodeAddress(*outSpecializedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::link(
- IComponentType** outLinkedComponentType,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_link, m_moduleHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->link(outLinkedComponentType, outDiagnostics);
-
- {
- encoder->encodeAddress(*outLinkedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::getEntryPointHostCallable(
- int entryPointIndex,
- int targetIndex,
- ISlangSharedLibrary** outSharedLibrary,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_getEntryPointHostCallable, m_moduleHandle);
- encoder->encodeInt32(entryPointIndex);
- encoder->encodeInt32(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics);
-
- {
- encoder->encodeAddress(*outSharedLibrary);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::renameEntryPoint(
- const char* newName, IComponentType** outEntryPoint)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_renameEntryPoint, m_moduleHandle);
- encoder->encodeString(newName);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->renameEntryPoint(newName, outEntryPoint);
-
- {
- encoder->encodeAddress(*outEntryPoint);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult ModuleCapture::linkWithOptions(
- IComponentType** outLinkedComponentType,
- uint32_t compilerOptionEntryCount,
- slang::CompilerOptionEntry* compilerOptionEntries,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::IModule_linkWithOptions, m_moduleHandle);
- encoder->encodeUint32(compilerOptionEntryCount);
- encoder->encodeStructArray(compilerOptionEntries, compilerOptionEntryCount);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualModule->linkWithOptions(outLinkedComponentType, compilerOptionEntryCount, compilerOptionEntries, outDiagnostics);
-
- {
- encoder->encodeAddress(*outLinkedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- EntryPointCapture* ModuleCapture::getEntryPointCapture(slang::IEntryPoint* entryPoint)
- {
- EntryPointCapture* entryPointCapture = nullptr;
- entryPointCapture = m_mapEntryPointToCapture.tryGetValue(entryPoint);
- if (!entryPointCapture)
- {
- entryPointCapture = new EntryPointCapture(entryPoint, m_captureManager);
- Slang::ComPtr<EntryPointCapture> result(entryPointCapture);
- m_mapEntryPointToCapture.add(entryPoint, *result.detach());
- }
- return entryPointCapture;
- }
-}
diff --git a/source/slang-capture-replay/slang-module.h b/source/slang-capture-replay/slang-module.h
deleted file mode 100644
index 94539532c..000000000
--- a/source/slang-capture-replay/slang-module.h
+++ /dev/null
@@ -1,102 +0,0 @@
-#ifndef SLANG_MODULE_H
-#define SLANG_MODULE_H
-
-#include "slang-com-ptr.h"
-#include "slang.h"
-#include "slang-com-helper.h"
-#include "../core/slang-smart-pointer.h"
-#include "../slang/slang-compiler.h"
-#include "slang-entrypoint.h"
-#include "capture-manager.h"
-
-namespace SlangCapture
-{
- using namespace Slang;
- class ModuleCapture : public slang::IModule, public RefObject
- {
- public:
- SLANG_COM_INTERFACE(0xb1802991, 0x185a, 0x4a03, { 0xa7, 0x7e, 0x0c, 0x86, 0xe0, 0x68, 0x2a, 0xab })
-
- SLANG_REF_OBJECT_IUNKNOWN_ALL
- ISlangUnknown* getInterface(const Guid& guid);
-
- explicit ModuleCapture(slang::IModule* module, CaptureManager* captureManager);
- ~ModuleCapture();
-
- // Interfaces for `IModule`
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL findEntryPointByName(
- char const* name, slang::IEntryPoint** outEntryPoint) override;
- virtual SLANG_NO_THROW SlangInt32 SLANG_MCALL getDefinedEntryPointCount() override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL
- getDefinedEntryPoint(SlangInt32 index, slang::IEntryPoint** outEntryPoint) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL serialize(ISlangBlob** outSerializedBlob) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL writeToFile(char const* fileName) override;
- virtual SLANG_NO_THROW const char* SLANG_MCALL getName() override;
- virtual SLANG_NO_THROW const char* SLANG_MCALL getFilePath() override;
- virtual SLANG_NO_THROW const char* SLANG_MCALL getUniqueIdentity() override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL findAndCheckEntryPoint(
- char const* name, SlangStage stage, slang::IEntryPoint** outEntryPoint, ISlangBlob** outDiagnostics) override;
- virtual SLANG_NO_THROW SlangInt32 SLANG_MCALL getDependencyFileCount() override;
- virtual SLANG_NO_THROW char const* SLANG_MCALL getDependencyFilePath(
- SlangInt32 index) override;
-
- // Interfaces for `IComponentType`
- virtual SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() override;
- virtual SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL getLayout(
- SlangInt targetIndex = 0,
- slang::IBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangInt SLANG_MCALL getSpecializationParamCount() override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCode(
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- ISlangMutableFileSystem** outFileSystem) override;
- virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outHash) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL specialize(
- slang::SpecializationArg const* specializationArgs,
- SlangInt specializationArgCount,
- slang::IComponentType** outSpecializedComponentType,
- ISlangBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL link(
- slang::IComponentType** outLinkedComponentType,
- ISlangBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable(
- int entryPointIndex,
- int targetIndex,
- ISlangSharedLibrary** outSharedLibrary,
- slang::IBlob** outDiagnostics = 0) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint(
- const char* newName, IComponentType** outEntryPoint) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions(
- IComponentType** outLinkedComponentType,
- uint32_t compilerOptionEntryCount,
- slang::CompilerOptionEntry* compilerOptionEntries,
- ISlangBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW slang::DeclReflection* getModuleReflection() override;
-
- slang::IModule* getActualModule() const { return m_actualModule; }
- private:
- EntryPointCapture* getEntryPointCapture(slang::IEntryPoint* entryPoint);
- Slang::ComPtr<slang::IModule> m_actualModule;
- uint64_t m_moduleHandle = 0;
- CaptureManager* m_captureManager = nullptr;
-
- // `IEntryPoint` can only be created from 'IModule', so we need to capture it in
- // this class, and create a map such that we don't create new `EntryPointCapture`
- // for the same `IEntryPoint`.
- Dictionary<slang::IEntryPoint*, EntryPointCapture> m_mapEntryPointToCapture;
- };
-} // namespace SlangCapture
-
-#endif // SLANG_MODULE_H
diff --git a/source/slang-capture-replay/slang-session.cpp b/source/slang-capture-replay/slang-session.cpp
deleted file mode 100644
index ee9fd9549..000000000
--- a/source/slang-capture-replay/slang-session.cpp
+++ /dev/null
@@ -1,517 +0,0 @@
-#include "capture_utility.h"
-#include "slang-session.h"
-#include "slang-entrypoint.h"
-#include "slang-composite-component-type.h"
-#include "slang-type-conformance.h"
-
-namespace SlangCapture
-{
-
- SessionCapture::SessionCapture(slang::ISession* session, CaptureManager* captureManager)
- : m_actualSession(session),
- m_captureManager(captureManager)
- {
- SLANG_CAPTURE_ASSERT(m_actualSession);
- SLANG_CAPTURE_ASSERT(m_captureManager);
- m_sessionHandle = reinterpret_cast<uint64_t>(m_actualSession.get());
- slangCaptureLog(LogLevel::Verbose, "%s: %p\n", "SessionCapture create:", session);
- }
-
- SessionCapture::~SessionCapture()
- {
- m_actualSession->release();
- }
-
- ISlangUnknown* SessionCapture::getInterface(const Guid& guid)
- {
- if(guid == ISlangUnknown::getTypeGuid() || guid == ISession::getTypeGuid())
- return asExternal(this);
-
- return nullptr;
- }
-
- SLANG_NO_THROW slang::IGlobalSession* SessionCapture::getGlobalSession()
- {
- // No need to capture this function.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- slang::IGlobalSession* pGlobalSession = m_actualSession->getGlobalSession();
- return pGlobalSession;
- }
-
- SLANG_NO_THROW slang::IModule* SessionCapture::loadModule(
- const char* moduleName,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_loadModule, m_sessionHandle);
- encoder->encodeString(moduleName);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::IModule* pModule = m_actualSession->loadModule(moduleName, outDiagnostics);
-
- {
- encoder->encodeAddress(*outDiagnostics);
- encoder->encodeAddress(pModule);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- ModuleCapture* pModuleCapture = getModuleCapture(pModule);
- return static_cast<slang::IModule*>(pModuleCapture);
- }
-
- SLANG_NO_THROW slang::IModule* SessionCapture::loadModuleFromIRBlob(
- const char* moduleName,
- const char* path,
- slang::IBlob* source,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_loadModuleFromIRBlob, m_sessionHandle);
- encoder->encodeString(moduleName);
- encoder->encodeString(path);
- encoder->encodePointer(source);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::IModule* pModule = m_actualSession->loadModuleFromIRBlob(moduleName, path, source, outDiagnostics);
-
- {
- encoder->encodeAddress(*outDiagnostics);
- encoder->encodeAddress(pModule);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- ModuleCapture* pModuleCapture = getModuleCapture(pModule);
- return static_cast<slang::IModule*>(pModuleCapture);
- }
-
- SLANG_NO_THROW slang::IModule* SessionCapture::loadModuleFromSource(
- const char* moduleName,
- const char* path,
- slang::IBlob* source,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_loadModuleFromSource, m_sessionHandle);
- encoder->encodeString(moduleName);
- encoder->encodeString(path);
- encoder->encodePointer(source);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::IModule* pModule = m_actualSession->loadModuleFromSource(moduleName, path, source, outDiagnostics);
-
- {
- encoder->encodeAddress(*outDiagnostics);
- encoder->encodeAddress(pModule);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- ModuleCapture* pModuleCapture = getModuleCapture(pModule);
- return static_cast<slang::IModule*>(pModuleCapture);
- }
-
- SLANG_NO_THROW slang::IModule* SessionCapture::loadModuleFromSourceString(
- const char* moduleName,
- const char* path,
- const char* string,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_loadModuleFromSourceString, m_sessionHandle);
- encoder->encodeString(moduleName);
- encoder->encodeString(path);
- encoder->encodeString(string);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::IModule* pModule = m_actualSession->loadModuleFromSourceString(moduleName, path, string, outDiagnostics);
-
- {
- // TODO: Not sure if we need to capture the diagnostics blob.
- encoder->encodeAddress(*outDiagnostics);
- encoder->encodeAddress(pModule);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- ModuleCapture* pModuleCapture = getModuleCapture(pModule);
- return static_cast<slang::IModule*>(pModuleCapture);
- }
-
- SLANG_NO_THROW SlangResult SessionCapture::createCompositeComponentType(
- slang::IComponentType* const* componentTypes,
- SlangInt componentTypeCount,
- slang::IComponentType** outCompositeComponentType,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- Slang::List<slang::IComponentType*> componentTypeList;
-
- // get the actual component types from our capture wrappers
- if(SLANG_OK != getActualComponentTypes(componentTypes, componentTypeCount, componentTypeList))
- {
- SLANG_CAPTURE_ASSERT(!"Failed to get actual component types");
- }
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_createCompositeComponentType, m_sessionHandle);
- encoder->encodeAddressArray(componentTypeList.getBuffer(), componentTypeCount);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult result = m_actualSession->createCompositeComponentType(
- componentTypeList.getBuffer(), componentTypeCount, outCompositeComponentType, outDiagnostics);
-
- {
- encoder->encodeAddress(*outCompositeComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- if (SLANG_OK == result)
- {
- CompositeComponentTypeCapture* compositeComponentTypeCapture =
- new CompositeComponentTypeCapture(*outCompositeComponentType, m_captureManager);
- Slang::ComPtr<CompositeComponentTypeCapture> resultCapture(compositeComponentTypeCapture);
- *outCompositeComponentType = resultCapture.detach();
- }
-
- return result;
- }
-
- SLANG_NO_THROW slang::TypeReflection* SessionCapture::specializeType(
- slang::TypeReflection* type,
- slang::SpecializationArg const* specializationArgs,
- SlangInt specializationArgCount,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_specializeType, m_sessionHandle);
- encoder->encodeAddress(type);
- encoder->encodeStructArray(specializationArgs, specializationArgCount);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::TypeReflection* pTypeReflection = m_actualSession->specializeType(type, specializationArgs, specializationArgCount, outDiagnostics);
-
- {
- encoder->encodeAddress(*outDiagnostics);
- encoder->encodeAddress(pTypeReflection);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return pTypeReflection;
- }
-
- SLANG_NO_THROW slang::TypeLayoutReflection* SessionCapture::getTypeLayout(
- slang::TypeReflection* type,
- SlangInt targetIndex,
- slang::LayoutRules rules,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_getTypeLayout, m_sessionHandle);
- encoder->encodeAddress(type);
- encoder->encodeInt64(targetIndex);
- encoder->encodeEnumValue(rules);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::TypeLayoutReflection* pTypeLayoutReflection = m_actualSession->getTypeLayout(type, targetIndex, rules, outDiagnostics);
-
- {
- encoder->encodeAddress(*outDiagnostics);
- encoder->encodeAddress(pTypeLayoutReflection);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return pTypeLayoutReflection;
- }
-
- SLANG_NO_THROW slang::TypeReflection* SessionCapture::getContainerType(
- slang::TypeReflection* elementType,
- slang::ContainerType containerType,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_getContainerType, m_sessionHandle);
- encoder->encodeAddress(elementType);
- encoder->encodeEnumValue(containerType);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::TypeReflection* pTypeReflection = m_actualSession->getContainerType(elementType, containerType, outDiagnostics);
-
- {
- encoder->encodeAddress(*outDiagnostics);
- encoder->encodeAddress(pTypeReflection);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return pTypeReflection;
- }
-
- SLANG_NO_THROW slang::TypeReflection* SessionCapture::getDynamicType()
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_getDynamicType, m_sessionHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::TypeReflection* pTypeReflection = m_actualSession->getDynamicType();
-
- {
- encoder->encodeAddress(pTypeReflection);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return pTypeReflection;
- }
-
- SLANG_NO_THROW SlangResult SessionCapture::getTypeRTTIMangledName(
- slang::TypeReflection* type,
- ISlangBlob** outNameBlob)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_getTypeRTTIMangledName, m_sessionHandle);
- encoder->encodeAddress(type);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult result = m_actualSession->getTypeRTTIMangledName(type, outNameBlob);
-
- {
- encoder->encodeAddress(outNameBlob);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return result;
- }
-
- SLANG_NO_THROW SlangResult SessionCapture::getTypeConformanceWitnessMangledName(
- slang::TypeReflection* type,
- slang::TypeReflection* interfaceType,
- ISlangBlob** outNameBlob)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_getTypeConformanceWitnessMangledName, m_sessionHandle);
- encoder->encodeAddress(type);
- encoder->encodeAddress(interfaceType);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult result = m_actualSession->getTypeConformanceWitnessMangledName(type, interfaceType, outNameBlob);
-
- {
- encoder->encodeAddress(outNameBlob);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return result;
- }
-
- SLANG_NO_THROW SlangResult SessionCapture::getTypeConformanceWitnessSequentialID(
- slang::TypeReflection* type,
- slang::TypeReflection* interfaceType,
- uint32_t* outId)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_getTypeConformanceWitnessSequentialID, m_sessionHandle);
- encoder->encodeAddress(type);
- encoder->encodeAddress(interfaceType);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult result = m_actualSession->getTypeConformanceWitnessSequentialID(type, interfaceType, outId);
-
- // No need to capture outId, it's not slang allocation
- return result;
- }
-
- SLANG_NO_THROW SlangResult SessionCapture::createTypeConformanceComponentType(
- slang::TypeReflection* type,
- slang::TypeReflection* interfaceType,
- slang::ITypeConformance** outConformance,
- SlangInt conformanceIdOverride,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_createTypeConformanceComponentType, m_sessionHandle);
- encoder->encodeAddress(type);
- encoder->encodeAddress(interfaceType);
- encoder->encodeInt64(conformanceIdOverride);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult result = m_actualSession->createTypeConformanceComponentType(type, interfaceType, outConformance, conformanceIdOverride, outDiagnostics);
-
- {
- encoder->encodeAddress(*outConformance);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- if (SLANG_OK != result)
- {
- TypeConformanceCapture* conformanceCapture = new TypeConformanceCapture(*outConformance, m_captureManager);
- Slang::ComPtr<TypeConformanceCapture> resultCapture(conformanceCapture);
- *outConformance = resultCapture.detach();
- }
-
- return result;
- }
-
- SLANG_NO_THROW SlangResult SessionCapture::createCompileRequest(
- SlangCompileRequest** outCompileRequest)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_createCompileRequest, m_sessionHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult result = m_actualSession->createCompileRequest(outCompileRequest);
-
- {
- encoder->encodeAddress(*outCompileRequest);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return result;
- }
-
- SLANG_NO_THROW SlangInt SessionCapture::getLoadedModuleCount()
- {
- // No need to capture this function, it's just a query.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- SlangInt count = m_actualSession->getLoadedModuleCount();
- return count;
- }
-
- SLANG_NO_THROW slang::IModule* SessionCapture::getLoadedModule(SlangInt index)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ISession_getLoadedModule, m_sessionHandle);
- encoder->encodeInt64(index);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::IModule* pModule = m_actualSession->getLoadedModule(index);
-
- {
- encoder->encodeAddress(pModule);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- if (pModule)
- {
- ModuleCapture* moduleCapture = m_mapModuleToCapture.tryGetValue(pModule);
- if (!moduleCapture)
- {
- SLANG_CAPTURE_ASSERT(!"Module not found in mapModuleToCapture");
- }
- return static_cast<slang::IModule*>(moduleCapture);
- }
-
- return pModule;
- }
-
- SLANG_NO_THROW bool SessionCapture::isBinaryModuleUpToDate(const char* modulePath, slang::IBlob* binaryModuleBlob)
- {
- // No need to capture this function, it's a query function and doesn't impact slang internal state.
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- bool result = m_actualSession->isBinaryModuleUpToDate(modulePath, binaryModuleBlob);
- return result;
- }
-
- ModuleCapture* SessionCapture::getModuleCapture(slang::IModule* module)
- {
- ModuleCapture* moduleCapture = nullptr;
- moduleCapture = m_mapModuleToCapture.tryGetValue(module);
- if (!moduleCapture)
- {
- moduleCapture = new ModuleCapture(module, m_captureManager);
- Slang::ComPtr<ModuleCapture> result(moduleCapture);
- m_mapModuleToCapture.add(module, *result.detach());
- }
- return moduleCapture;
- }
-
- SlangResult SessionCapture::getActualComponentTypes(
- slang::IComponentType* const* componentTypes,
- SlangInt componentTypeCount,
- List<slang::IComponentType*>& outActualComponentTypes)
- {
- for (SlangInt i = 0; i < componentTypeCount; i++)
- {
- slang::IComponentType* const& componentType = componentTypes[i];
- void* outObj = nullptr;
-
- if (componentType->queryInterface(ModuleCapture::getTypeGuid(), &outObj) == SLANG_OK)
- {
- ModuleCapture* moduleCapture = static_cast<ModuleCapture*>(outObj);
- outActualComponentTypes.add(moduleCapture->getActualModule());
- }
- else if (componentType->queryInterface(EntryPointCapture::getTypeGuid(), &outObj) == SLANG_OK)
- {
- EntryPointCapture* entrypointCapture = static_cast<EntryPointCapture*>(outObj);
- outActualComponentTypes.add(entrypointCapture->getActualEntryPoint());
- }
- // will fall back to the actual component type, it means that we didn't capture this type.
- else
- {
- outActualComponentTypes.add(componentType);
- }
- }
-
- if (componentTypeCount == outActualComponentTypes.getCount())
- {
- return SLANG_OK;
- }
- return SLANG_FAIL;
- }
-} // namespace SlangCapture
diff --git a/source/slang-capture-replay/slang-session.h b/source/slang-capture-replay/slang-session.h
deleted file mode 100644
index 23f818695..000000000
--- a/source/slang-capture-replay/slang-session.h
+++ /dev/null
@@ -1,116 +0,0 @@
-#ifndef SLANG_SESSION_H
-#define SLANG_SESSION_H
-
-#include "slang-com-ptr.h"
-#include "slang.h"
-#include "slang-com-helper.h"
-#include "../core/slang-smart-pointer.h"
-#include "../core/slang-dictionary.h"
-#include "../slang/slang-compiler.h"
-#include "slang-module.h"
-#include "capture-manager.h"
-
-namespace SlangCapture
-{
- using namespace Slang;
- class SessionCapture: public RefObject, public slang::ISession
- {
- public:
- SLANG_REF_OBJECT_IUNKNOWN_ALL
- ISlangUnknown* getInterface(const Guid& guid);
-
- explicit SessionCapture(slang::ISession* session, CaptureManager* captureManager);
- ~SessionCapture();
-
- SLANG_NO_THROW slang::IGlobalSession* SLANG_MCALL getGlobalSession() override;
- SLANG_NO_THROW slang::IModule* SLANG_MCALL loadModule(
- const char* moduleName,
- slang::IBlob** outDiagnostics = nullptr) override;
- slang::IModule* SLANG_MCALL loadModuleFromBlob(
- const char* moduleName,
- const char* path,
- slang::IBlob* source,
- ModuleBlobType blobType,
- slang::IBlob** outDiagnostics = nullptr);
- SLANG_NO_THROW slang::IModule* SLANG_MCALL loadModuleFromIRBlob(
- const char* moduleName,
- const char* path,
- slang::IBlob* source,
- slang::IBlob** outDiagnostics = nullptr) override;
- SLANG_NO_THROW slang::IModule* SLANG_MCALL loadModuleFromSource(
- const char* moduleName,
- const char* path,
- slang::IBlob* source,
- slang::IBlob** outDiagnostics = nullptr) override;
- SLANG_NO_THROW slang::IModule* SLANG_MCALL loadModuleFromSourceString(
- const char* moduleName,
- const char* path,
- const char* string,
- slang::IBlob** outDiagnostics = nullptr) override;
- SLANG_NO_THROW SlangResult SLANG_MCALL createCompositeComponentType(
- slang::IComponentType* const* componentTypes,
- SlangInt componentTypeCount,
- slang::IComponentType** outCompositeComponentType,
- ISlangBlob** outDiagnostics = nullptr) override;
- SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL specializeType(
- slang::TypeReflection* type,
- slang::SpecializationArg const* specializationArgs,
- SlangInt specializationArgCount,
- ISlangBlob** outDiagnostics = nullptr) override;
- SLANG_NO_THROW slang::TypeLayoutReflection* SLANG_MCALL getTypeLayout(
- slang::TypeReflection* type,
- SlangInt targetIndex = 0,
- slang::LayoutRules rules = slang::LayoutRules::Default,
- ISlangBlob** outDiagnostics = nullptr) override;
- SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL getContainerType(
- slang::TypeReflection* elementType,
- slang::ContainerType containerType,
- ISlangBlob** outDiagnostics = nullptr) override;
- SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL getDynamicType() override;
- SLANG_NO_THROW SlangResult SLANG_MCALL getTypeRTTIMangledName(
- slang::TypeReflection* type,
- ISlangBlob** outNameBlob) override;
- SLANG_NO_THROW SlangResult SLANG_MCALL getTypeConformanceWitnessMangledName(
- slang::TypeReflection* type,
- slang::TypeReflection* interfaceType,
- ISlangBlob** outNameBlob) override;
- SLANG_NO_THROW SlangResult SLANG_MCALL getTypeConformanceWitnessSequentialID(
- slang::TypeReflection* type,
- slang::TypeReflection* interfaceType,
- uint32_t* outId) override;
- SLANG_NO_THROW SlangResult SLANG_MCALL createTypeConformanceComponentType(
- slang::TypeReflection* type,
- slang::TypeReflection* interfaceType,
- slang::ITypeConformance** outConformance,
- SlangInt conformanceIdOverride,
- ISlangBlob** outDiagnostics) override;
- SLANG_NO_THROW SlangResult SLANG_MCALL createCompileRequest(
- SlangCompileRequest** outCompileRequest) override;
- SLANG_NO_THROW SlangInt SLANG_MCALL getLoadedModuleCount() override;
- SLANG_NO_THROW slang::IModule* SLANG_MCALL getLoadedModule(SlangInt index) override;
- SLANG_NO_THROW bool SLANG_MCALL isBinaryModuleUpToDate(const char* modulePath, slang::IBlob* binaryModuleBlob) override;
-
- private:
- SLANG_FORCE_INLINE slang::ISession* asExternal(SessionCapture* session)
- {
- return static_cast<slang::ISession*>(session);
- }
-
- // The IComponentType object is the capture target, therefore `componentTypes` will not be
- // the actual component types, we have to use the COM interface to get the actual objects.
- SlangResult getActualComponentTypes(
- slang::IComponentType* const* componentTypes,
- SlangInt componentTypeCount,
- List<slang::IComponentType*>& outActualComponentTypes);
-
- ModuleCapture* getModuleCapture(slang::IModule* module);
-
- Slang::ComPtr<slang::ISession> m_actualSession;
- uint64_t m_sessionHandle = 0;
-
- Dictionary<slang::IModule*, ModuleCapture> m_mapModuleToCapture;
- CaptureManager* m_captureManager = nullptr;
- };
-}
-
-#endif // SLANG_SESSION_H
diff --git a/source/slang-capture-replay/slang-type-conformance.cpp b/source/slang-capture-replay/slang-type-conformance.cpp
deleted file mode 100644
index 3eb108510..000000000
--- a/source/slang-capture-replay/slang-type-conformance.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-#include "capture_utility.h"
-#include "slang-type-conformance.h"
-
-namespace SlangCapture
-{
- TypeConformanceCapture::TypeConformanceCapture(slang::ITypeConformance* typeConformance, CaptureManager* captureManager)
- : m_actualTypeConformance(typeConformance),
- m_captureManager(captureManager)
- {
- SLANG_CAPTURE_ASSERT(m_actualTypeConformance != nullptr);
- SLANG_CAPTURE_ASSERT(m_captureManager != nullptr);
-
- m_typeConformanceHandle = reinterpret_cast<uint64_t>(m_actualTypeConformance.get());
- slangCaptureLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, typeConformance);
- }
-
- TypeConformanceCapture::~TypeConformanceCapture()
- {
- m_actualTypeConformance->release();
- }
-
- ISlangUnknown* TypeConformanceCapture::getInterface(const Guid& guid)
- {
- if (guid == TypeConformanceCapture::getTypeGuid())
- {
- return static_cast<ISlangUnknown*>(this);
- }
- else
- {
- return nullptr;
- }
- }
-
- SLANG_NO_THROW slang::ISession* TypeConformanceCapture::getSession()
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ITypeConformance_getSession, m_typeConformanceHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::ISession* res = m_actualTypeConformance->getSession();
-
- {
- encoder->encodeAddress(res);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW slang::ProgramLayout* TypeConformanceCapture::getLayout(
- SlangInt targetIndex,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ICompositeComponentType_getLayout, m_typeConformanceHandle);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- slang::ProgramLayout* programLayout = m_actualTypeConformance->getLayout(targetIndex, outDiagnostics);
-
- {
- encoder->encodeAddress(*outDiagnostics);
- encoder->encodeAddress(programLayout);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return programLayout;
- }
-
- SLANG_NO_THROW SlangInt TypeConformanceCapture::getSpecializationParamCount()
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
- SlangInt res = m_actualTypeConformance->getSpecializationParamCount();
- return res;
- }
-
- SLANG_NO_THROW SlangResult TypeConformanceCapture::getEntryPointCode(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ITypeConformance_getEntryPointCode, m_typeConformanceHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualTypeConformance->getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics);
-
- {
- encoder->encodeAddress(*outCode);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult TypeConformanceCapture::getTargetCode(
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ITypeConformance_getTargetCode, m_typeConformanceHandle);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualTypeConformance->getTargetCode(targetIndex, outCode, outDiagnostics);
-
- {
- encoder->encodeAddress(*outCode);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult TypeConformanceCapture::getResultAsFileSystem(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- ISlangMutableFileSystem** outFileSystem)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ITypeConformance_getResultAsFileSystem, m_typeConformanceHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualTypeConformance->getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem);
-
- {
- encoder->encodeAddress(*outFileSystem);
- }
-
- // TODO: We might need to wrap the file system object.
- return res;
- }
-
- SLANG_NO_THROW void TypeConformanceCapture::getEntryPointHash(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outHash)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ITypeConformance_getEntryPointHash, m_typeConformanceHandle);
- encoder->encodeInt64(entryPointIndex);
- encoder->encodeInt64(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- m_actualTypeConformance->getEntryPointHash(entryPointIndex, targetIndex, outHash);
-
- {
- encoder->encodeAddress(*outHash);
- m_captureManager->endMethodCaptureAppendOutput();
- }
- }
-
- SLANG_NO_THROW SlangResult TypeConformanceCapture::specialize(
- slang::SpecializationArg const* specializationArgs,
- SlangInt specializationArgCount,
- slang::IComponentType** outSpecializedComponentType,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ITypeConformance_specialize, m_typeConformanceHandle);
- encoder->encodeInt64(specializationArgCount);
- encoder->encodeStructArray(specializationArgs, specializationArgCount);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualTypeConformance->specialize(specializationArgs, specializationArgCount, outSpecializedComponentType, outDiagnostics);
-
- {
- encoder->encodeAddress(*outSpecializedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult TypeConformanceCapture::link(
- slang::IComponentType** outLinkedComponentType,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ITypeConformance_link, m_typeConformanceHandle);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualTypeConformance->link(outLinkedComponentType, outDiagnostics);
-
- {
- encoder->encodeAddress(*outLinkedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult TypeConformanceCapture::getEntryPointHostCallable(
- int entryPointIndex,
- int targetIndex,
- ISlangSharedLibrary** outSharedLibrary,
- slang::IBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ITypeConformance_getEntryPointHostCallable, m_typeConformanceHandle);
- encoder->encodeInt32(entryPointIndex);
- encoder->encodeInt32(targetIndex);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualTypeConformance->getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics);
-
- {
- encoder->encodeAddress(*outSharedLibrary);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult TypeConformanceCapture::renameEntryPoint(
- const char* newName, IComponentType** outEntryPoint)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ITypeConformance_renameEntryPoint, m_typeConformanceHandle);
- encoder->encodeString(newName);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualTypeConformance->renameEntryPoint(newName, outEntryPoint);
-
- {
- encoder->encodeAddress(*outEntryPoint);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-
- SLANG_NO_THROW SlangResult TypeConformanceCapture::linkWithOptions(
- IComponentType** outLinkedComponentType,
- uint32_t compilerOptionEntryCount,
- slang::CompilerOptionEntry* compilerOptionEntries,
- ISlangBlob** outDiagnostics)
- {
- slangCaptureLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
-
- ParameterEncoder* encoder {};
- {
- encoder = m_captureManager->beginMethodCapture(ApiCallId::ITypeConformance_linkWithOptions, m_typeConformanceHandle);
- encoder->encodeUint32(compilerOptionEntryCount);
- encoder->encodeStructArray(compilerOptionEntries, compilerOptionEntryCount);
- encoder = m_captureManager->endMethodCapture();
- }
-
- SlangResult res = m_actualTypeConformance->linkWithOptions(outLinkedComponentType, compilerOptionEntryCount, compilerOptionEntries, outDiagnostics);
-
- {
- encoder->encodeAddress(*outLinkedComponentType);
- encoder->encodeAddress(*outDiagnostics);
- m_captureManager->endMethodCaptureAppendOutput();
- }
-
- return res;
- }
-}
diff --git a/source/slang-capture-replay/slang-type-conformance.h b/source/slang-capture-replay/slang-type-conformance.h
deleted file mode 100644
index 2c36abbfb..000000000
--- a/source/slang-capture-replay/slang-type-conformance.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef SLANG_TYPE_CONFORMANCE_H
-#define SLANG_TYPE_CONFORMANCE_H
-
-#include "slang-com-ptr.h"
-#include "slang.h"
-#include "slang-com-helper.h"
-#include "../core/slang-smart-pointer.h"
-#include "../core/slang-dictionary.h"
-#include "../slang/slang-compiler.h"
-#include "capture-manager.h"
-
-namespace SlangCapture
-{
- using namespace Slang;
- class TypeConformanceCapture: public slang::ITypeConformance, public RefObject
- {
- public:
- SLANG_COM_INTERFACE(0x0e67d05d, 0xee0a, 0x41e1, { 0xb5, 0xa3, 0x23, 0xe3, 0xb0, 0xec, 0x33, 0xf1 })
-
- SLANG_REF_OBJECT_IUNKNOWN_ALL
- ISlangUnknown* getInterface(const Guid& guid);
-
- explicit TypeConformanceCapture(slang::ITypeConformance* typeConformance, CaptureManager* captureManager);
- ~TypeConformanceCapture();
-
- // Interfaces for `IComponentType`
- virtual SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() override;
- virtual SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL getLayout(
- SlangInt targetIndex = 0,
- slang::IBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangInt SLANG_MCALL getSpecializationParamCount() override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCode(
- SlangInt targetIndex,
- slang::IBlob** outCode,
- slang::IBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- ISlangMutableFileSystem** outFileSystem) override;
- virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash(
- SlangInt entryPointIndex,
- SlangInt targetIndex,
- slang::IBlob** outHash) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL specialize(
- slang::SpecializationArg const* specializationArgs,
- SlangInt specializationArgCount,
- slang::IComponentType** outSpecializedComponentType,
- ISlangBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL link(
- slang::IComponentType** outLinkedComponentType,
- ISlangBlob** outDiagnostics = nullptr) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable(
- int entryPointIndex,
- int targetIndex,
- ISlangSharedLibrary** outSharedLibrary,
- slang::IBlob** outDiagnostics = 0) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint(
- const char* newName, IComponentType** outEntryPoint) override;
- virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions(
- IComponentType** outLinkedComponentType,
- uint32_t compilerOptionEntryCount,
- slang::CompilerOptionEntry* compilerOptionEntries,
- ISlangBlob** outDiagnostics = nullptr) override;
-
- slang::ITypeConformance* getActualTypeConformance() const { return m_actualTypeConformance; }
- private:
- Slang::ComPtr<slang::ITypeConformance> m_actualTypeConformance;
- uint64_t m_typeConformanceHandle = 0;
- CaptureManager* m_captureManager = nullptr;
- };
-}
-#endif // SLANG_TYPE_CONFORMANCE_H