summaryrefslogtreecommitdiff
path: root/source/slang-capture-replay/slang-filesystem.cpp
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/slang-filesystem.cpp
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/slang-filesystem.cpp')
-rw-r--r--source/slang-capture-replay/slang-filesystem.cpp124
1 files changed, 0 insertions, 124 deletions
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;
- }
-}