diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /source/slang-record-replay | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'source/slang-record-replay')
39 files changed, 12773 insertions, 8289 deletions
diff --git a/source/slang-record-replay/record/output-stream.cpp b/source/slang-record-replay/record/output-stream.cpp index 00cbf814a..51fba9835 100644 --- a/source/slang-record-replay/record/output-stream.cpp +++ b/source/slang-record-replay/record/output-stream.cpp @@ -1,51 +1,56 @@ #include "output-stream.h" + #include "../util/record-utility.h" namespace SlangRecord { - FileOutputStream::FileOutputStream(const Slang::String& fileName, bool append) - { - Slang::FileMode fileMode = append ? Slang::FileMode::Append : Slang::FileMode::Create; - Slang::FileAccess fileAccess = Slang::FileAccess::Write; - Slang::FileShare fileShare = Slang::FileShare::None; +FileOutputStream::FileOutputStream(const Slang::String& fileName, bool append) +{ + 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(fileName, fileMode, fileAccess, fileShare); + SlangResult res = m_fileStream.init(fileName, fileMode, fileAccess, fileShare); - if (res != SLANG_OK) - { - SlangRecord::slangRecordLog(SlangRecord::LogLevel::Error, "Failed to open file %s\n", fileName.getBuffer()); - std::abort(); - } - } - - FileOutputStream::~FileOutputStream() + if (res != SLANG_OK) { - m_fileStream.close(); + SlangRecord::slangRecordLog( + SlangRecord::LogLevel::Error, + "Failed to open file %s\n", + fileName.getBuffer()); + std::abort(); } +} - void FileOutputStream::write(const void* data, size_t len) - { - SLANG_RECORD_CHECK(m_fileStream.write(data, len)); - } +FileOutputStream::~FileOutputStream() +{ + m_fileStream.close(); +} - MemoryStream::MemoryStream() - : m_memoryStream(Slang::FileAccess::Write) - { } +void FileOutputStream::write(const void* data, size_t len) +{ + SLANG_RECORD_CHECK(m_fileStream.write(data, len)); +} - void FileOutputStream::flush() - { - SLANG_RECORD_CHECK(m_fileStream.flush()); - } +MemoryStream::MemoryStream() + : m_memoryStream(Slang::FileAccess::Write) +{ +} - void MemoryStream::write(const void* data, size_t len) - { - SLANG_RECORD_CHECK(m_memoryStream.write(data, len)); - } +void FileOutputStream::flush() +{ + SLANG_RECORD_CHECK(m_fileStream.flush()); +} - 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); - } +void MemoryStream::write(const void* data, size_t len) +{ + SLANG_RECORD_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); } +} // namespace SlangRecord diff --git a/source/slang-record-replay/record/output-stream.h b/source/slang-record-replay/record/output-stream.h index e322bccb1..e0eb95ed2 100644 --- a/source/slang-record-replay/record/output-stream.h +++ b/source/slang-record-replay/record/output-stream.h @@ -1,46 +1,46 @@ #ifndef OUTPUT_STREAM_H #define OUTPUT_STREAM_H -#include "../../core/slang-string.h" #include "../../core/slang-stream.h" +#include "../../core/slang-string.h" namespace SlangRecord { - class OutputStream: public Slang::RefObject - { - public: - virtual ~OutputStream() {} - virtual void write(const void* data, size_t len) = 0; - virtual void flush() {} - }; +class OutputStream : public Slang::RefObject +{ +public: + virtual ~OutputStream() {} + virtual void write(const void* data, size_t len) = 0; + virtual void flush() {} +}; - class FileOutputStream : public OutputStream - { - public: - FileOutputStream(const Slang::String& fileName, bool append = false); - virtual ~FileOutputStream() override; - virtual void write(const void* data, size_t len) override; - virtual void flush() override; +class FileOutputStream : public OutputStream +{ +public: + FileOutputStream(const Slang::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; - }; +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(); } +// 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; - }; +private: + Slang::OwnedMemoryStream m_memoryStream; +}; } // namespace SlangRecord #endif // OUTPUT_STREAM_H diff --git a/source/slang-record-replay/record/parameter-recorder.cpp b/source/slang-record-replay/record/parameter-recorder.cpp index 1c2fd9609..af4488f81 100644 --- a/source/slang-record-replay/record/parameter-recorder.cpp +++ b/source/slang-record-replay/record/parameter-recorder.cpp @@ -2,122 +2,122 @@ namespace SlangRecord { - void ParameterRecorder::recordStruct(slang::SessionDesc const& desc) +void ParameterRecorder::recordStruct(slang::SessionDesc const& desc) +{ + recordUint64(desc.structureSize); + recordInt64(desc.targetCount); + + for (SlangInt i = 0; i < desc.targetCount; i++) { - recordUint64(desc.structureSize); - recordInt64(desc.targetCount); - - for (SlangInt i = 0; i < desc.targetCount; i++) - { - recordStruct(desc.targets[i]); - } - - recordUint32(desc.flags); - recordEnumValue(desc.defaultMatrixLayoutMode); - recordInt64(desc.searchPathCount); - for (SlangInt i = 0; i < desc.searchPathCount; i++) - { - recordString(desc.searchPaths[i]); - } - - recordInt64(desc.preprocessorMacroCount); - for (SlangInt i = 0; i < desc.preprocessorMacroCount; i++) - { - recordStruct(desc.preprocessorMacros[i]); - } - - recordBool(desc.enableEffectAnnotations); - recordBool(desc.allowGLSLSyntax); - - recordUint32(desc.compilerOptionEntryCount); - for (uint32_t i = 0; i < desc.compilerOptionEntryCount; i++) - { - recordStruct(desc.compilerOptionEntries[i]); - } + recordStruct(desc.targets[i]); } - void ParameterRecorder::recordStruct(slang::PreprocessorMacroDesc const& desc) + recordUint32(desc.flags); + recordEnumValue(desc.defaultMatrixLayoutMode); + recordInt64(desc.searchPathCount); + for (SlangInt i = 0; i < desc.searchPathCount; i++) { - recordString(desc.name); - recordString(desc.value); + recordString(desc.searchPaths[i]); } - void ParameterRecorder::recordStruct(slang::CompilerOptionEntry const& entry) + recordInt64(desc.preprocessorMacroCount); + for (SlangInt i = 0; i < desc.preprocessorMacroCount; i++) { - recordEnumValue(entry.name); - recordStruct(entry.value); + recordStruct(desc.preprocessorMacros[i]); } - void ParameterRecorder::recordStruct(slang::CompilerOptionValue const& value) + recordBool(desc.enableEffectAnnotations); + recordBool(desc.allowGLSLSyntax); + + recordUint32(desc.compilerOptionEntryCount); + for (uint32_t i = 0; i < desc.compilerOptionEntryCount; i++) { - recordEnumValue(value.kind); - recordInt32(value.intValue0); - recordString(value.stringValue0); - recordString(value.stringValue1); + recordStruct(desc.compilerOptionEntries[i]); } +} + +void ParameterRecorder::recordStruct(slang::PreprocessorMacroDesc const& desc) +{ + recordString(desc.name); + recordString(desc.value); +} + +void ParameterRecorder::recordStruct(slang::CompilerOptionEntry const& entry) +{ + recordEnumValue(entry.name); + recordStruct(entry.value); +} + +void ParameterRecorder::recordStruct(slang::CompilerOptionValue const& value) +{ + recordEnumValue(value.kind); + recordInt32(value.intValue0); + recordString(value.stringValue0); + recordString(value.stringValue1); +} - void ParameterRecorder::recordStruct(slang::TargetDesc const& targetDesc) +void ParameterRecorder::recordStruct(slang::TargetDesc const& targetDesc) +{ + recordUint64(targetDesc.structureSize); + recordEnumValue(targetDesc.format); + recordEnumValue(targetDesc.profile); + recordEnumValue(targetDesc.flags); + recordEnumValue(targetDesc.floatingPointMode); + recordEnumValue(targetDesc.lineDirectiveMode); + recordBool(targetDesc.forceGLSLScalarBufferLayout); + recordUint32(targetDesc.compilerOptionEntryCount); + for (uint32_t i = 0; i < targetDesc.compilerOptionEntryCount; i++) { - recordUint64(targetDesc.structureSize); - recordEnumValue(targetDesc.format); - recordEnumValue(targetDesc.profile); - recordEnumValue(targetDesc.flags); - recordEnumValue(targetDesc.floatingPointMode); - recordEnumValue(targetDesc.lineDirectiveMode); - recordBool(targetDesc.forceGLSLScalarBufferLayout); - recordUint32(targetDesc.compilerOptionEntryCount); - for (uint32_t i = 0; i < targetDesc.compilerOptionEntryCount; i++) - { - recordStruct(targetDesc.compilerOptionEntries[i]); - } + recordStruct(targetDesc.compilerOptionEntries[i]); } +} - void ParameterRecorder::recordStruct(slang::SpecializationArg const& specializationArg) +void ParameterRecorder::recordStruct(slang::SpecializationArg const& specializationArg) +{ + recordEnumValue(specializationArg.kind); + recordAddress(specializationArg.type); +} + +void ParameterRecorder::recordPointer(const void* value, bool omitData, size_t size) +{ + recordAddress(value); + if (omitData) { - recordEnumValue(specializationArg.kind); - recordAddress(specializationArg.type); + recordUint64(0llu); + return; } - void ParameterRecorder::recordPointer(const void* value, bool omitData, size_t size) + recordUint64(size); + if (size) { - recordAddress(value); - if (omitData) - { - recordUint64(0llu); - return; - } - - recordUint64(size); - if (size) - { - m_stream->write(value, size); - } + m_stream->write(value, size); } +} - void ParameterRecorder::recordPointer(ISlangBlob* blob) +void ParameterRecorder::recordPointer(ISlangBlob* blob) +{ + recordAddress(static_cast<const void*>(blob)); + + if (blob) { - recordAddress(static_cast<const void*>(blob)); - - if (blob) - { - size_t size = blob->getBufferSize(); - const void* buffer = blob->getBufferPointer(); - recordPointer(buffer, false, size); - } + size_t size = blob->getBufferSize(); + const void* buffer = blob->getBufferPointer(); + recordPointer(buffer, false, size); } +} - // first 4-bytes is the length of the string - void ParameterRecorder::recordString(const char* value) +// first 4-bytes is the length of the string +void ParameterRecorder::recordString(const char* value) +{ + if (value == nullptr) + { + recordUint32(0); + } + else { - if (value == nullptr) - { - recordUint32(0); - } - else - { - uint32_t size = (uint32_t)strlen(value); - recordUint32(size); - m_stream->write(value, size); - } + uint32_t size = (uint32_t)strlen(value); + recordUint32(size); + m_stream->write(value, size); } } +} // namespace SlangRecord diff --git a/source/slang-record-replay/record/parameter-recorder.h b/source/slang-record-replay/record/parameter-recorder.h index 29bf39fb3..05a16604e 100644 --- a/source/slang-record-replay/record/parameter-recorder.h +++ b/source/slang-record-replay/record/parameter-recorder.h @@ -1,94 +1,101 @@ #ifndef PARAMETER_ENCODER_H #define PARAMETER_ENCODER_H -#include <cstdio> +#include "../util/record-format.h" +#include "output-stream.h" + #include <cinttypes> #include <cstdint> - -#include "output-stream.h" -#include "../util/record-format.h" +#include <cstdio> namespace SlangRecord { - class ParameterRecorder - { - public: - ParameterRecorder(OutputStream* stream) : m_stream(stream) {}; - void recordInt8(int8_t value) { recordValue(value); } - void recordUint8(uint8_t value) { recordValue(value); } - void recordInt16(int16_t value) { recordValue(value); } - void recordUint16(uint16_t value) { recordValue(value); } - void recordInt32(int32_t value) { recordValue(value); } - void recordUint32(uint32_t value) { recordValue(value); } - void recordInt64(int64_t value) { recordValue(value); } - void recordUint64(uint64_t value) { recordValue(value); } - void recordFloat(float value) { recordValue(value); } - void recordDouble(double value) { recordValue(value); } - void recordBool(bool value) { recordValue(value); } +class ParameterRecorder +{ +public: + ParameterRecorder(OutputStream* stream) + : m_stream(stream){}; + void recordInt8(int8_t value) { recordValue(value); } + void recordUint8(uint8_t value) { recordValue(value); } + void recordInt16(int16_t value) { recordValue(value); } + void recordUint16(uint16_t value) { recordValue(value); } + void recordInt32(int32_t value) { recordValue(value); } + void recordUint32(uint32_t value) { recordValue(value); } + void recordInt64(int64_t value) { recordValue(value); } + void recordUint64(uint64_t value) { recordValue(value); } + void recordFloat(float value) { recordValue(value); } + void recordDouble(double value) { recordValue(value); } + void recordBool(bool value) { recordValue(value); } - template<typename T> - void recordEnumValue(T value) { recordValue(static_cast<uint32_t>(value)); } + template<typename T> + void recordEnumValue(T value) + { + recordValue(static_cast<uint32_t>(value)); + } - void recordString(const char* value); - void recordPointer(const void* value, bool omitData = false, size_t size = 0); - void recordPointer(ISlangBlob* blob); - void recordAddress(const void* value) { recordValue(reinterpret_cast<SlangRecord::AddressFormat>(value)); } + void recordString(const char* value); + void recordPointer(const void* value, bool omitData = false, size_t size = 0); + void recordPointer(ISlangBlob* blob); + void recordAddress(const void* value) + { + recordValue(reinterpret_cast<SlangRecord::AddressFormat>(value)); + } - void recordStruct(slang::SessionDesc const& desc); - void recordStruct(slang::PreprocessorMacroDesc const& desc); - void recordStruct(slang::CompilerOptionEntry const& entry); - void recordStruct(slang::CompilerOptionValue const& value); - void recordStruct(slang::TargetDesc const& targetDesc); - void recordStruct(slang::SpecializationArg const& specializationArg); + void recordStruct(slang::SessionDesc const& desc); + void recordStruct(slang::PreprocessorMacroDesc const& desc); + void recordStruct(slang::CompilerOptionEntry const& entry); + void recordStruct(slang::CompilerOptionValue const& value); + void recordStruct(slang::TargetDesc const& targetDesc); + void recordStruct(slang::SpecializationArg const& specializationArg); - template <typename T> - void recordValueArray(const T* array, size_t count) + template<typename T> + void recordValueArray(const T* array, size_t count) + { + recordUint32((uint32_t)count); + for (size_t i = 0; i < count; ++i) { - recordUint32((uint32_t)count); - for (size_t i = 0; i < count; ++i) - { - recordValue(array[i]); - } + recordValue(array[i]); } + } - void recordStringArray(const char* const* array, size_t count) + void recordStringArray(const char* const* array, size_t count) + { + recordUint32((uint32_t)count); + for (size_t i = 0; i < count; ++i) { - recordUint32((uint32_t)count); - for (size_t i = 0; i < count; ++i) - { - recordString(array[i]); - } + recordString(array[i]); } + } - template <typename T> - void recordStructArray(T const* array, size_t count) + template<typename T> + void recordStructArray(T const* array, size_t count) + { + recordUint32((uint32_t)count); + for (size_t i = 0; i < count; ++i) { - recordUint32((uint32_t)count); - for (size_t i = 0; i < count; ++i) - { - recordStruct(array[i]); - } + recordStruct(array[i]); } + } - template <typename T> - void recordAddressArray(T* const* array, size_t count) + template<typename T> + void recordAddressArray(T* const* array, size_t count) + { + recordUint32((uint32_t)count); + for (size_t i = 0; i < count; ++i) { - recordUint32((uint32_t)count); - for (size_t i = 0; i < count; ++i) - { - recordAddress(array[i]); - } + recordAddress(array[i]); } + } - private: - template <typename T> - void recordValue(T value) - { - m_stream->write(&value, sizeof(T)); - } - OutputStream* m_stream; - }; +private: + template<typename T> + void recordValue(T value) + { + m_stream->write(&value, sizeof(T)); + } + OutputStream* m_stream; +}; } // namespace SlangRecord #endif // PARAMETER_ENCODER_H diff --git a/source/slang-record-replay/record/record-manager.cpp b/source/slang-record-replay/record/record-manager.cpp index 03abffcce..3be120c43 100644 --- a/source/slang-record-replay/record/record-manager.cpp +++ b/source/slang-record-replay/record/record-manager.cpp @@ -1,94 +1,99 @@ -#include <sstream> -#include <thread> -#include "../util/record-utility.h" #include "record-manager.h" + #include "../../core/slang-io.h" +#include "../util/record-utility.h" + +#include <sstream> +#include <thread> namespace SlangRecord { - RecordManager::RecordManager(uint64_t globalSessionHandle) - : m_recorder(&m_memoryStream) - { - std::stringstream ss; - ss << "gs-"<< globalSessionHandle <<"-t-"<<std::this_thread::get_id() << ".cap"; +RecordManager::RecordManager(uint64_t globalSessionHandle) + : m_recorder(&m_memoryStream) +{ + std::stringstream ss; + ss << "gs-" << globalSessionHandle << "-t-" << std::this_thread::get_id() << ".cap"; - m_recordFileDirectory = Slang::Path::combine(m_recordFileDirectory, "slang-record"); - if (!Slang::File::exists(m_recordFileDirectory)) + m_recordFileDirectory = Slang::Path::combine(m_recordFileDirectory, "slang-record"); + if (!Slang::File::exists(m_recordFileDirectory)) + { + if (!Slang::Path::createDirectoryRecursive(m_recordFileDirectory)) { - if (!Slang::Path::createDirectoryRecursive(m_recordFileDirectory)) - { - slangRecordLog(LogLevel::Error, "Fail to create directory: %s\n", - m_recordFileDirectory.getBuffer()); - } + slangRecordLog( + LogLevel::Error, + "Fail to create directory: %s\n", + m_recordFileDirectory.getBuffer()); } - - Slang::String recordFilePath = Slang::Path::combine(m_recordFileDirectory, Slang::String(ss.str().c_str())); - m_fileStream = new FileOutputStream(recordFilePath); } - void RecordManager::clearWithHeader(const ApiCallId& callId, uint64_t handleId) - { - m_memoryStream.flush(); - FunctionHeader header; - header.callId = callId; - header.handleId = handleId; + Slang::String recordFilePath = + Slang::Path::combine(m_recordFileDirectory, Slang::String(ss.str().c_str())); + m_fileStream = new FileOutputStream(recordFilePath); +} - // write header to memory stream - m_memoryStream.write(&header, sizeof(FunctionHeader)); - } +void RecordManager::clearWithHeader(const ApiCallId& callId, uint64_t handleId) +{ + m_memoryStream.flush(); + FunctionHeader header; + header.callId = callId; + header.handleId = handleId; - void RecordManager::clearWithTailer() - { - m_memoryStream.flush(); - FunctionTailer tailer; + // write header to memory stream + m_memoryStream.write(&header, sizeof(FunctionHeader)); +} - // write header to memory stream - m_memoryStream.write(&tailer, sizeof(FunctionTailer)); - } +void RecordManager::clearWithTailer() +{ + m_memoryStream.flush(); + FunctionTailer tailer; - ParameterRecorder* RecordManager::beginMethodRecord(const ApiCallId& callId, uint64_t handleId) - { - clearWithHeader(callId, handleId); - return &m_recorder; - } + // write header to memory stream + m_memoryStream.write(&tailer, sizeof(FunctionTailer)); +} - ParameterRecorder* RecordManager::endMethodRecord() - { - FunctionHeader* pHeader = const_cast<FunctionHeader*>( - reinterpret_cast<const FunctionHeader*>(m_memoryStream.getData())); +ParameterRecorder* RecordManager::beginMethodRecord(const ApiCallId& callId, uint64_t handleId) +{ + clearWithHeader(callId, handleId); + return &m_recorder; +} - pHeader->dataSizeInBytes = m_memoryStream.getSizeInBytes() - sizeof(FunctionHeader); +ParameterRecorder* RecordManager::endMethodRecord() +{ + FunctionHeader* pHeader = const_cast<FunctionHeader*>( + reinterpret_cast<const FunctionHeader*>(m_memoryStream.getData())); - std::hash<std::thread::id> hasher; - pHeader->threadId = hasher(std::this_thread::get_id()); + pHeader->dataSizeInBytes = m_memoryStream.getSizeInBytes() - sizeof(FunctionHeader); - // write record data to file - m_fileStream->write(m_memoryStream.getData(), m_memoryStream.getSizeInBytes()); + std::hash<std::thread::id> hasher; + pHeader->threadId = hasher(std::this_thread::get_id()); - // take effect of the write - m_fileStream->flush(); + // write record data to file + m_fileStream->write(m_memoryStream.getData(), m_memoryStream.getSizeInBytes()); - // clear the memory stream - m_memoryStream.flush(); + // take effect of the write + m_fileStream->flush(); - clearWithTailer(); - return &m_recorder; - } + // clear the memory stream + m_memoryStream.flush(); - void RecordManager::apendOutput() - { - FunctionTailer* pTailer = const_cast<FunctionTailer*>( - reinterpret_cast<const FunctionTailer*>(m_memoryStream.getData())); + clearWithTailer(); + return &m_recorder; +} + +void RecordManager::apendOutput() +{ + FunctionTailer* pTailer = const_cast<FunctionTailer*>( + reinterpret_cast<const FunctionTailer*>(m_memoryStream.getData())); - pTailer->dataSizeInBytes = (uint32_t)(m_memoryStream.getSizeInBytes() - sizeof(FunctionTailer)); + pTailer->dataSizeInBytes = (uint32_t)(m_memoryStream.getSizeInBytes() - sizeof(FunctionTailer)); - // write record data to file - m_fileStream->write(m_memoryStream.getData(), m_memoryStream.getSizeInBytes()); + // write record data to file + m_fileStream->write(m_memoryStream.getData(), m_memoryStream.getSizeInBytes()); - // take effect of the write - m_fileStream->flush(); + // take effect of the write + m_fileStream->flush(); - // clear the memory stream - m_memoryStream.flush(); - } + // clear the memory stream + m_memoryStream.flush(); } +} // namespace SlangRecord diff --git a/source/slang-record-replay/record/record-manager.h b/source/slang-record-replay/record/record-manager.h index f46264824..5df30cd93 100644 --- a/source/slang-record-replay/record/record-manager.h +++ b/source/slang-record-replay/record/record-manager.h @@ -1,37 +1,36 @@ #ifndef RECORD_MANAGER_H #define RECORD_MANAGER_H -#include "parameter-recorder.h" -#include "../util/record-format.h" - -#include "../../core/slang-string.h" #include "../../core/slang-io.h" +#include "../../core/slang-string.h" +#include "../util/record-format.h" +#include "parameter-recorder.h" namespace SlangRecord { - class RecordManager: public Slang::RefObject - { - public: - RecordManager(uint64_t globalSessionHandle); +class RecordManager : public Slang::RefObject +{ +public: + RecordManager(uint64_t globalSessionHandle); - // Each method record has to start with a FunctionHeader - ParameterRecorder* beginMethodRecord(const ApiCallId& callId, uint64_t handleId); - ParameterRecorder* endMethodRecord(); + // Each method record has to start with a FunctionHeader + ParameterRecorder* beginMethodRecord(const ApiCallId& callId, uint64_t handleId); + ParameterRecorder* endMethodRecord(); - // apendOutput is an optional call that can be used to append output to - // the end of the record. It has to start with a FunctionTailer - void apendOutput(); + // apendOutput is an optional call that can be used to append output to + // the end of the record. It has to start with a FunctionTailer + void apendOutput(); - const Slang::String& getRecordFileDirectory() const { return m_recordFileDirectory; } + const Slang::String& getRecordFileDirectory() const { return m_recordFileDirectory; } - private: - void clearWithHeader(const ApiCallId& callId, uint64_t handleId); - void clearWithTailer(); +private: + void clearWithHeader(const ApiCallId& callId, uint64_t handleId); + void clearWithTailer(); - MemoryStream m_memoryStream; - Slang::RefPtr<FileOutputStream> m_fileStream; - Slang::String m_recordFileDirectory = Slang::Path::getCurrentPath(); - ParameterRecorder m_recorder; - }; + MemoryStream m_memoryStream; + Slang::RefPtr<FileOutputStream> m_fileStream; + Slang::String m_recordFileDirectory = Slang::Path::getCurrentPath(); + ParameterRecorder m_recorder; +}; } // namespace SlangRecord #endif // RECORD_MANAGER_H diff --git a/source/slang-record-replay/record/slang-component-type.cpp b/source/slang-record-replay/record/slang-component-type.cpp index bc38acfae..05fd68691 100644 --- a/source/slang-record-replay/record/slang-component-type.cpp +++ b/source/slang-record-replay/record/slang-component-type.cpp @@ -1,372 +1,407 @@ -#include "../util/record-utility.h" #include "slang-component-type.h" + +#include "../util/record-utility.h" #include "slang-composite-component-type.h" #include "slang-session.h" namespace SlangRecord { - IComponentTypeRecorder::IComponentTypeRecorder( - slang::IComponentType* componentType, RecordManager* recordManager) - : m_actualComponentType(componentType), - m_recordManager(recordManager) - { - SLANG_RECORD_ASSERT(m_actualComponentType != nullptr); - SLANG_RECORD_ASSERT(m_recordManager != nullptr); - - m_componentHandle = reinterpret_cast<uint64_t>(m_actualComponentType.get()); - slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, componentType); - } - - SLANG_NO_THROW slang::ISession* IComponentTypeRecorder::getSession() - { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - - ApiCallId callId = static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::getSession)); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); - recorder = m_recordManager->endMethodRecord(); - } - - slang::ISession* res = m_actualComponentType->getSession(); +IComponentTypeRecorder::IComponentTypeRecorder( + slang::IComponentType* componentType, + RecordManager* recordManager) + : m_actualComponentType(componentType), m_recordManager(recordManager) +{ + SLANG_RECORD_ASSERT(m_actualComponentType != nullptr); + SLANG_RECORD_ASSERT(m_recordManager != nullptr); - { - recorder->recordAddress(res); - m_recordManager->apendOutput(); - } + m_componentHandle = reinterpret_cast<uint64_t>(m_actualComponentType.get()); + slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, componentType); +} - // instead of returning the actual session, we need to return the recorder - SessionRecorder* sessionRecorder = getSessionRecorder(); - return static_cast<slang::ISession*>(sessionRecorder); - } +SLANG_NO_THROW slang::ISession* IComponentTypeRecorder::getSession() +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW slang::ProgramLayout* IComponentTypeRecorder::getLayout( - SlangInt targetIndex, - slang::IBlob** outDiagnostics) + ApiCallId callId = + static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::getSession)); + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); + recorder = m_recordManager->endMethodRecord(); + } - ApiCallId callId = static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::getLayout)); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); - recorder->recordInt64(targetIndex); - recorder = m_recordManager->endMethodRecord(); - } + slang::ISession* res = m_actualComponentType->getSession(); - slang::ProgramLayout* programLayout = m_actualComponentType->getLayout(targetIndex, outDiagnostics); + { + recorder->recordAddress(res); + m_recordManager->apendOutput(); + } - { - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - recorder->recordAddress(programLayout); - m_recordManager->apendOutput(); - } + // instead of returning the actual session, we need to return the recorder + SessionRecorder* sessionRecorder = getSessionRecorder(); + return static_cast<slang::ISession*>(sessionRecorder); +} - return programLayout; - } +SLANG_NO_THROW slang::ProgramLayout* IComponentTypeRecorder::getLayout( + SlangInt targetIndex, + slang::IBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangInt IComponentTypeRecorder::getSpecializationParamCount() + ApiCallId callId = + static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::getLayout)); + ParameterRecorder* recorder{}; { - // No need to record this call as it is just a query. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SlangInt res = m_actualComponentType->getSpecializationParamCount(); - return res; + recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); + recorder->recordInt64(targetIndex); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangResult IComponentTypeRecorder::getEntryPointCode( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IBlob** outCode, - slang::IBlob** outDiagnostics) - { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + slang::ProgramLayout* programLayout = + m_actualComponentType->getLayout(targetIndex, outDiagnostics); - ApiCallId callId = static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::getEntryPointCode)); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); - recorder->recordInt64(entryPointIndex); - recorder->recordInt64(targetIndex); - recorder = m_recordManager->endMethodRecord(); - } + { + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + recorder->recordAddress(programLayout); + m_recordManager->apendOutput(); + } - SlangResult res = m_actualComponentType->getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics); + return programLayout; +} - { - recorder->recordAddress(*outCode); - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - m_recordManager->apendOutput(); - } +SLANG_NO_THROW SlangInt IComponentTypeRecorder::getSpecializationParamCount() +{ + // No need to record this call as it is just a query. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + SlangInt res = m_actualComponentType->getSpecializationParamCount(); + return res; +} - return res; - } +SLANG_NO_THROW SlangResult IComponentTypeRecorder::getEntryPointCode( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IBlob** outCode, + slang::IBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangResult IComponentTypeRecorder::getTargetCode( - SlangInt targetIndex, - slang::IBlob** outCode, - slang::IBlob** outDiagnostics) + ApiCallId callId = static_cast<ApiCallId>( + makeApiCallId(getClassId(), IComponentTypeMethodId::getEntryPointCode)); + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); + recorder->recordInt64(entryPointIndex); + recorder->recordInt64(targetIndex); + recorder = m_recordManager->endMethodRecord(); + } - ApiCallId callId = static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::getTargetCode)); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); - recorder->recordInt64(targetIndex); - recorder = m_recordManager->endMethodRecord(); - } + SlangResult res = m_actualComponentType->getEntryPointCode( + entryPointIndex, + targetIndex, + outCode, + outDiagnostics); - SlangResult res = m_actualComponentType->getTargetCode(targetIndex, outCode, outDiagnostics); + { + recorder->recordAddress(*outCode); + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + m_recordManager->apendOutput(); + } - { - recorder->recordAddress(*outCode); - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - m_recordManager->apendOutput(); - } + return res; +} - return res; - } +SLANG_NO_THROW SlangResult IComponentTypeRecorder::getTargetCode( + SlangInt targetIndex, + slang::IBlob** outCode, + slang::IBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangResult SLANG_MCALL IComponentTypeRecorder::getEntryPointMetadata( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IMetadata** outMetadata, - slang::IBlob** outDiagnostics) + ApiCallId callId = + static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::getTargetCode)); + ParameterRecorder* recorder{}; { - // No need to record this call. - return m_actualComponentType->getEntryPointMetadata(entryPointIndex, targetIndex, outMetadata, outDiagnostics); + recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); + recorder->recordInt64(targetIndex); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangResult SLANG_MCALL IComponentTypeRecorder::getTargetMetadata( - SlangInt targetIndex, - slang::IMetadata** outMetadata, - slang::IBlob** outDiagnostics) + SlangResult res = m_actualComponentType->getTargetCode(targetIndex, outCode, outDiagnostics); + { - // No need to record this call. - return m_actualComponentType->getTargetMetadata(targetIndex, outMetadata, outDiagnostics); + recorder->recordAddress(*outCode); + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + m_recordManager->apendOutput(); } - SLANG_NO_THROW SlangResult IComponentTypeRecorder::getResultAsFileSystem( - SlangInt entryPointIndex, - SlangInt targetIndex, - ISlangMutableFileSystem** outFileSystem) - { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + return res; +} - ApiCallId callId = static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::getResultAsFileSystem)); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); - recorder->recordInt64(entryPointIndex); - recorder->recordInt64(targetIndex); - recorder = m_recordManager->endMethodRecord(); - } +SLANG_NO_THROW SlangResult SLANG_MCALL IComponentTypeRecorder::getEntryPointMetadata( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IMetadata** outMetadata, + slang::IBlob** outDiagnostics) +{ + // No need to record this call. + return m_actualComponentType + ->getEntryPointMetadata(entryPointIndex, targetIndex, outMetadata, outDiagnostics); +} - SlangResult res = m_actualComponentType->getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem); +SLANG_NO_THROW SlangResult SLANG_MCALL IComponentTypeRecorder::getTargetMetadata( + SlangInt targetIndex, + slang::IMetadata** outMetadata, + slang::IBlob** outDiagnostics) +{ + // No need to record this call. + return m_actualComponentType->getTargetMetadata(targetIndex, outMetadata, outDiagnostics); +} - { - recorder->recordAddress(*outFileSystem); - } +SLANG_NO_THROW SlangResult IComponentTypeRecorder::getResultAsFileSystem( + SlangInt entryPointIndex, + SlangInt targetIndex, + ISlangMutableFileSystem** outFileSystem) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - // TODO: We might need to wrap the file system object. - return res; + ApiCallId callId = static_cast<ApiCallId>( + makeApiCallId(getClassId(), IComponentTypeMethodId::getResultAsFileSystem)); + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); + recorder->recordInt64(entryPointIndex); + recorder->recordInt64(targetIndex); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW void IComponentTypeRecorder::getEntryPointHash( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IBlob** outHash) + SlangResult res = + m_actualComponentType->getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem); + { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder->recordAddress(*outFileSystem); + } - ApiCallId callId = static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::getEntryPointHash)); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); - recorder->recordInt64(entryPointIndex); - recorder->recordInt64(targetIndex); - recorder = m_recordManager->endMethodRecord(); - } + // TODO: We might need to wrap the file system object. + return res; +} - m_actualComponentType->getEntryPointHash(entryPointIndex, targetIndex, outHash); +SLANG_NO_THROW void IComponentTypeRecorder::getEntryPointHash( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IBlob** outHash) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - { - recorder->recordAddress(*outHash); - m_recordManager->apendOutput(); - } + ApiCallId callId = static_cast<ApiCallId>( + makeApiCallId(getClassId(), IComponentTypeMethodId::getEntryPointHash)); + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); + recorder->recordInt64(entryPointIndex); + recorder->recordInt64(targetIndex); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangResult IComponentTypeRecorder::specialize( - slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, - slang::IComponentType** outSpecializedComponentType, - ISlangBlob** outDiagnostics) + m_actualComponentType->getEntryPointHash(entryPointIndex, targetIndex, outHash); + { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder->recordAddress(*outHash); + m_recordManager->apendOutput(); + } +} - ApiCallId callId = static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::specialize)); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); - recorder->recordInt64(specializationArgCount); - recorder->recordStructArray(specializationArgs, specializationArgCount); - recorder = m_recordManager->endMethodRecord(); - } +SLANG_NO_THROW SlangResult IComponentTypeRecorder::specialize( + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + slang::IComponentType** outSpecializedComponentType, + ISlangBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SlangResult res = m_actualComponentType->specialize(specializationArgs, specializationArgCount, outSpecializedComponentType, outDiagnostics); + ApiCallId callId = + static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::specialize)); + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); + recorder->recordInt64(specializationArgCount); + recorder->recordStructArray(specializationArgs, specializationArgCount); + recorder = m_recordManager->endMethodRecord(); + } - { - recorder->recordAddress(*outSpecializedComponentType); - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - m_recordManager->apendOutput(); - } + SlangResult res = m_actualComponentType->specialize( + specializationArgs, + specializationArgCount, + outSpecializedComponentType, + outDiagnostics); - if (SLANG_SUCCEEDED(res)) - { - // replaced output with our recorder - *outSpecializedComponentType = getComponentTypeRecorder(*outSpecializedComponentType); - } - return res; + { + recorder->recordAddress(*outSpecializedComponentType); + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + m_recordManager->apendOutput(); } - SLANG_NO_THROW SlangResult IComponentTypeRecorder::link( - slang::IComponentType** outLinkedComponentType, - ISlangBlob** outDiagnostics) + if (SLANG_SUCCEEDED(res)) { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + // replaced output with our recorder + *outSpecializedComponentType = getComponentTypeRecorder(*outSpecializedComponentType); + } + return res; +} - ApiCallId callId = static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::link)); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); - recorder = m_recordManager->endMethodRecord(); - } +SLANG_NO_THROW SlangResult IComponentTypeRecorder::link( + slang::IComponentType** outLinkedComponentType, + ISlangBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SlangResult res = m_actualComponentType->link(outLinkedComponentType, outDiagnostics); + ApiCallId callId = + static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::link)); + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); + recorder = m_recordManager->endMethodRecord(); + } - { - recorder->recordAddress(*outLinkedComponentType); - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - m_recordManager->apendOutput(); - } + SlangResult res = m_actualComponentType->link(outLinkedComponentType, outDiagnostics); - if (SLANG_SUCCEEDED(res)) - { - // replaced output with our recorder - *outLinkedComponentType = getComponentTypeRecorder(*outLinkedComponentType); - } - return res; + { + recorder->recordAddress(*outLinkedComponentType); + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + m_recordManager->apendOutput(); } - SLANG_NO_THROW SlangResult IComponentTypeRecorder::getEntryPointHostCallable( - int entryPointIndex, - int targetIndex, - ISlangSharedLibrary** outSharedLibrary, - slang::IBlob** outDiagnostics) + if (SLANG_SUCCEEDED(res)) { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + // replaced output with our recorder + *outLinkedComponentType = getComponentTypeRecorder(*outLinkedComponentType); + } + return res; +} - ApiCallId callId = static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::getEntryPointHostCallable)); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); - recorder->recordInt32(entryPointIndex); - recorder->recordInt32(targetIndex); - recorder = m_recordManager->endMethodRecord(); - } +SLANG_NO_THROW SlangResult IComponentTypeRecorder::getEntryPointHostCallable( + int entryPointIndex, + int targetIndex, + ISlangSharedLibrary** outSharedLibrary, + slang::IBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SlangResult res = m_actualComponentType->getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics); + ApiCallId callId = static_cast<ApiCallId>( + makeApiCallId(getClassId(), IComponentTypeMethodId::getEntryPointHostCallable)); + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); + recorder->recordInt32(entryPointIndex); + recorder->recordInt32(targetIndex); + recorder = m_recordManager->endMethodRecord(); + } - { - recorder->recordAddress(*outSharedLibrary); - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - m_recordManager->apendOutput(); - } + SlangResult res = m_actualComponentType->getEntryPointHostCallable( + entryPointIndex, + targetIndex, + outSharedLibrary, + outDiagnostics); - return res; + { + recorder->recordAddress(*outSharedLibrary); + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + m_recordManager->apendOutput(); } - SLANG_NO_THROW SlangResult IComponentTypeRecorder::renameEntryPoint( - const char* newName, IComponentType** outEntryPoint) - { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + return res; +} - ApiCallId callId = static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::renameEntryPoint)); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); - recorder->recordString(newName); - recorder = m_recordManager->endMethodRecord(); - } +SLANG_NO_THROW SlangResult +IComponentTypeRecorder::renameEntryPoint(const char* newName, IComponentType** outEntryPoint) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SlangResult res = m_actualComponentType->renameEntryPoint(newName, outEntryPoint); + ApiCallId callId = static_cast<ApiCallId>( + makeApiCallId(getClassId(), IComponentTypeMethodId::renameEntryPoint)); + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); + recorder->recordString(newName); + recorder = m_recordManager->endMethodRecord(); + } - { - recorder->recordAddress(*outEntryPoint); - m_recordManager->apendOutput(); - } + SlangResult res = m_actualComponentType->renameEntryPoint(newName, outEntryPoint); - // replaced output with our recorder - // 'outEntryPoint' is not actually a IEntryPoint type, but a ComponentType type, so we - // keep using CompositeComponentTypeRecorder to record it. - if (SLANG_SUCCEEDED(res)) - { - // replaced output with our recorder - *outEntryPoint = getComponentTypeRecorder(*outEntryPoint); - } - return res; + { + recorder->recordAddress(*outEntryPoint); + m_recordManager->apendOutput(); } - SLANG_NO_THROW SlangResult IComponentTypeRecorder::linkWithOptions( - IComponentType** outLinkedComponentType, - uint32_t compilerOptionEntryCount, - slang::CompilerOptionEntry* compilerOptionEntries, - ISlangBlob** outDiagnostics) + // replaced output with our recorder + // 'outEntryPoint' is not actually a IEntryPoint type, but a ComponentType type, so we + // keep using CompositeComponentTypeRecorder to record it. + if (SLANG_SUCCEEDED(res)) { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + // replaced output with our recorder + *outEntryPoint = getComponentTypeRecorder(*outEntryPoint); + } + return res; +} - ApiCallId callId = static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::linkWithOptions)); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); - recorder->recordUint32(compilerOptionEntryCount); - recorder->recordStructArray(compilerOptionEntries, compilerOptionEntryCount); - recorder = m_recordManager->endMethodRecord(); - } +SLANG_NO_THROW SlangResult IComponentTypeRecorder::linkWithOptions( + IComponentType** outLinkedComponentType, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ISlangBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SlangResult res = m_actualComponentType->linkWithOptions(outLinkedComponentType, compilerOptionEntryCount, compilerOptionEntries, outDiagnostics); + ApiCallId callId = static_cast<ApiCallId>( + makeApiCallId(getClassId(), IComponentTypeMethodId::linkWithOptions)); + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle); + recorder->recordUint32(compilerOptionEntryCount); + recorder->recordStructArray(compilerOptionEntries, compilerOptionEntryCount); + recorder = m_recordManager->endMethodRecord(); + } - { - recorder->recordAddress(*outLinkedComponentType); - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - m_recordManager->apendOutput(); - } + SlangResult res = m_actualComponentType->linkWithOptions( + outLinkedComponentType, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnostics); - if (SLANG_SUCCEEDED(res)) - { - // replaced output with our recorder - *outLinkedComponentType = getComponentTypeRecorder(*outLinkedComponentType); - } - return res; + { + recorder->recordAddress(*outLinkedComponentType); + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + m_recordManager->apendOutput(); } - IComponentTypeRecorder* IComponentTypeRecorder::getComponentTypeRecorder(slang::IComponentType* componentTypes) + if (SLANG_SUCCEEDED(res)) { - IComponentTypeRecorder* recorder = nullptr; + // replaced output with our recorder + *outLinkedComponentType = getComponentTypeRecorder(*outLinkedComponentType); + } + return res; +} - if (componentTypes) - { - if (m_mapComponentTypeToRecorder.tryGetValue(componentTypes, recorder)) - { - ComPtr<IComponentTypeRecorder> result(recorder); - return result.detach(); - } +IComponentTypeRecorder* IComponentTypeRecorder::getComponentTypeRecorder( + slang::IComponentType* componentTypes) +{ + IComponentTypeRecorder* recorder = nullptr; - recorder = new CompositeComponentTypeRecorder(getSessionRecorder(), componentTypes, m_recordManager); + if (componentTypes) + { + if (m_mapComponentTypeToRecorder.tryGetValue(componentTypes, recorder)) + { ComPtr<IComponentTypeRecorder> result(recorder); - m_componentTypeRecorderAlloation.add(result); - m_mapComponentTypeToRecorder.add(componentTypes, result.detach()); + return result.detach(); } - return recorder; + + recorder = new CompositeComponentTypeRecorder( + getSessionRecorder(), + componentTypes, + m_recordManager); + ComPtr<IComponentTypeRecorder> result(recorder); + m_componentTypeRecorderAlloation.add(result); + m_mapComponentTypeToRecorder.add(componentTypes, result.detach()); } + return recorder; } +} // namespace SlangRecord diff --git a/source/slang-record-replay/record/slang-component-type.h b/source/slang-record-replay/record/slang-component-type.h index 52e07d9c0..2c854ee33 100644 --- a/source/slang-record-replay/record/slang-component-type.h +++ b/source/slang-record-replay/record/slang-component-type.h @@ -1,88 +1,90 @@ #ifndef SLANG_COMPONENT_TYPE_H #define SLANG_COMPONENT_TYPE_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 "record-manager.h" #include "../util/record-utility.h" +#include "record-manager.h" +#include "slang-com-helper.h" +#include "slang-com-ptr.h" +#include "slang.h" namespace SlangRecord { - using namespace Slang; - class SessionRecorder; +using namespace Slang; +class SessionRecorder; + +class IComponentTypeRecorder : public slang::IComponentType +{ +public: + explicit IComponentTypeRecorder( + slang::IComponentType* componentType, + RecordManager* recordManager); - class IComponentTypeRecorder: public slang::IComponentType - { - public: - explicit IComponentTypeRecorder(slang::IComponentType* componentType, RecordManager* recordManager); + 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; + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointMetadata( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IMetadata** outMetadata, + slang::IBlob** outDiagnostics) override; + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetMetadata( + SlangInt targetIndex, + slang::IMetadata** outMetadata, + slang::IBlob** outDiagnostics = nullptr) override; - 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; - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointMetadata( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IMetadata** outMetadata, - slang::IBlob** outDiagnostics) override; - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetMetadata( - SlangInt targetIndex, - slang::IMetadata** outMetadata, - slang::IBlob** outDiagnostics = nullptr) override; - protected: - virtual ApiClassId getClassId() = 0; - virtual SessionRecorder* getSessionRecorder() = 0; - Slang::ComPtr<slang::IComponentType> m_actualComponentType; - uint64_t m_componentHandle = 0; - RecordManager* m_recordManager = nullptr; - private: +protected: + virtual ApiClassId getClassId() = 0; + virtual SessionRecorder* getSessionRecorder() = 0; + Slang::ComPtr<slang::IComponentType> m_actualComponentType; + uint64_t m_componentHandle = 0; + RecordManager* m_recordManager = nullptr; - IComponentTypeRecorder* getComponentTypeRecorder(slang::IComponentType* componentTypes); +private: + IComponentTypeRecorder* getComponentTypeRecorder(slang::IComponentType* componentTypes); - Dictionary<slang::IComponentType*, IComponentTypeRecorder*> m_mapComponentTypeToRecorder; - List<ComPtr<IComponentTypeRecorder>> m_componentTypeRecorderAlloation; - }; -} + Dictionary<slang::IComponentType*, IComponentTypeRecorder*> m_mapComponentTypeToRecorder; + List<ComPtr<IComponentTypeRecorder>> m_componentTypeRecorderAlloation; +}; +} // namespace SlangRecord #endif // #ifndef SLANG_COMPONENT_TYPE_H diff --git a/source/slang-record-replay/record/slang-composite-component-type.cpp b/source/slang-record-replay/record/slang-composite-component-type.cpp index 92e94040b..da76175fd 100644 --- a/source/slang-record-replay/record/slang-composite-component-type.cpp +++ b/source/slang-record-replay/record/slang-composite-component-type.cpp @@ -1,23 +1,24 @@ -#include "../util/record-utility.h" #include "slang-composite-component-type.h" +#include "../util/record-utility.h" + namespace SlangRecord { - CompositeComponentTypeRecorder::CompositeComponentTypeRecorder(SessionRecorder* sessionRecorder, - slang::IComponentType* componentType, - RecordManager* recordManager) - : IComponentTypeRecorder(componentType, recordManager), - m_sessionRecorder(sessionRecorder) - { - slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, componentType); - } +CompositeComponentTypeRecorder::CompositeComponentTypeRecorder( + SessionRecorder* sessionRecorder, + slang::IComponentType* componentType, + RecordManager* recordManager) + : IComponentTypeRecorder(componentType, recordManager), m_sessionRecorder(sessionRecorder) +{ + slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, componentType); +} - ISlangUnknown* CompositeComponentTypeRecorder::getInterface(const Guid& guid) +ISlangUnknown* CompositeComponentTypeRecorder::getInterface(const Guid& guid) +{ + if (guid == CompositeComponentTypeRecorder::getTypeGuid()) { - if (guid == CompositeComponentTypeRecorder::getTypeGuid()) - { - return static_cast<ISlangUnknown*>(this); - } - return nullptr; + return static_cast<ISlangUnknown*>(this); } + return nullptr; } +} // namespace SlangRecord diff --git a/source/slang-record-replay/record/slang-composite-component-type.h b/source/slang-record-replay/record/slang-composite-component-type.h index c5b77f432..778507554 100644 --- a/source/slang-record-replay/record/slang-composite-component-type.h +++ b/source/slang-record-replay/record/slang-composite-component-type.h @@ -1,43 +1,46 @@ #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 "../../core/slang-smart-pointer.h" #include "../../slang/slang-compiler.h" -#include "slang-component-type.h" #include "record-manager.h" +#include "slang-com-helper.h" +#include "slang-com-ptr.h" +#include "slang-component-type.h" +#include "slang.h" namespace SlangRecord { - using namespace Slang; - class SessionRecorder; - - class CompositeComponentTypeRecorder: public IComponentTypeRecorder, public RefObject - { - public: - SLANG_COM_INTERFACE(0x354f30a0, 0x3662, 0x4147, { 0xa2, 0x5d, 0x9b, 0xc6, 0x95, 0x73, 0x8e, 0x07 }) - - SLANG_REF_OBJECT_IUNKNOWN_ALL - ISlangUnknown* getInterface(const Guid& guid); - - explicit CompositeComponentTypeRecorder(SessionRecorder* sessionRecorder, slang::IComponentType* componentType, RecordManager* recordManager); - - slang::IComponentType* getActualCompositeComponentType() const { return m_actualComponentType; } - protected: - virtual ApiClassId getClassId() override - { - return ApiClassId::Class_ICompositeComponentType; - } - - virtual SessionRecorder* getSessionRecorder() override - { - return m_sessionRecorder; - } - private: - SessionRecorder* m_sessionRecorder = nullptr; - }; -} +using namespace Slang; +class SessionRecorder; + +class CompositeComponentTypeRecorder : public IComponentTypeRecorder, public RefObject +{ +public: + SLANG_COM_INTERFACE( + 0x354f30a0, + 0x3662, + 0x4147, + {0xa2, 0x5d, 0x9b, 0xc6, 0x95, 0x73, 0x8e, 0x07}) + + SLANG_REF_OBJECT_IUNKNOWN_ALL + ISlangUnknown* getInterface(const Guid& guid); + + explicit CompositeComponentTypeRecorder( + SessionRecorder* sessionRecorder, + slang::IComponentType* componentType, + RecordManager* recordManager); + + slang::IComponentType* getActualCompositeComponentType() const { return m_actualComponentType; } + +protected: + virtual ApiClassId getClassId() override { return ApiClassId::Class_ICompositeComponentType; } + + virtual SessionRecorder* getSessionRecorder() override { return m_sessionRecorder; } + +private: + SessionRecorder* m_sessionRecorder = nullptr; +}; +} // namespace SlangRecord #endif // SLANG_COMPOSITE_COMPONENT_TYPE_H diff --git a/source/slang-record-replay/record/slang-entrypoint.cpp b/source/slang-record-replay/record/slang-entrypoint.cpp index 038ec321f..3eb9bca77 100644 --- a/source/slang-record-replay/record/slang-entrypoint.cpp +++ b/source/slang-record-replay/record/slang-entrypoint.cpp @@ -1,30 +1,34 @@ -#include "../util/record-utility.h" #include "slang-entrypoint.h" +#include "../util/record-utility.h" + namespace SlangRecord { - EntryPointRecorder::EntryPointRecorder(SessionRecorder* sessionRecorder, slang::IEntryPoint* entryPoint, RecordManager* recordManager) - : IComponentTypeRecorder(entryPoint, recordManager), - m_sessionRecorder(sessionRecorder), - m_actualEntryPoint(entryPoint) - { - SLANG_RECORD_ASSERT(m_actualEntryPoint != nullptr); - slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, entryPoint); - } - - ISlangUnknown* EntryPointRecorder::getInterface(const Guid& guid) - { - if(guid == IEntryPointRecorder::getTypeGuid()) - { - return static_cast<IEntryPointRecorder*>(this); - } - else - return nullptr; - } +EntryPointRecorder::EntryPointRecorder( + SessionRecorder* sessionRecorder, + slang::IEntryPoint* entryPoint, + RecordManager* recordManager) + : IComponentTypeRecorder(entryPoint, recordManager) + , m_sessionRecorder(sessionRecorder) + , m_actualEntryPoint(entryPoint) +{ + SLANG_RECORD_ASSERT(m_actualEntryPoint != nullptr); + slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, entryPoint); +} - SLANG_NO_THROW slang::FunctionReflection* EntryPointRecorder::getFunctionReflection() +ISlangUnknown* EntryPointRecorder::getInterface(const Guid& guid) +{ + if (guid == IEntryPointRecorder::getTypeGuid()) { - return m_actualEntryPoint->getFunctionReflection(); + return static_cast<IEntryPointRecorder*>(this); } + else + return nullptr; +} +SLANG_NO_THROW slang::FunctionReflection* EntryPointRecorder::getFunctionReflection() +{ + return m_actualEntryPoint->getFunctionReflection(); } + +} // namespace SlangRecord diff --git a/source/slang-record-replay/record/slang-entrypoint.h b/source/slang-record-replay/record/slang-entrypoint.h index 29a3329fe..f9906f3a2 100644 --- a/source/slang-record-replay/record/slang-entrypoint.h +++ b/source/slang-record-replay/record/slang-entrypoint.h @@ -1,165 +1,182 @@ #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 "../../core/slang-smart-pointer.h" #include "../../slang/slang-compiler.h" #include "record-manager.h" +#include "slang-com-helper.h" +#include "slang-com-ptr.h" #include "slang-component-type.h" +#include "slang.h" namespace SlangRecord { - using namespace Slang; - class SessionRecorder; +using namespace Slang; +class SessionRecorder; + +class IEntryPointRecorder : 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) { + // (void)guid; return nullptr;} + SLANG_COM_INTERFACE( + 0xf4c1e23d, + 0xb321, + 0x4931, + {0x8f, 0x37, 0xf1, 0x22, 0x6a, 0xf9, 0x20, 0x85}) +}; + +class EntryPointRecorder : public IEntryPointRecorder, public IComponentTypeRecorder +{ + typedef IComponentTypeRecorder Super; + +public: + SLANG_REF_OBJECT_IUNKNOWN_ALL + ISlangUnknown* getInterface(const Guid& guid); - class IEntryPointRecorder : public slang::IEntryPoint, public RefObject + explicit EntryPointRecorder( + SessionRecorder* sessionRecorder, + slang::IEntryPoint* entryPoint, + RecordManager* recordManager); + + // Interfaces for `IComponentType` + virtual SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() override { - 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) { (void)guid; return nullptr;} - SLANG_COM_INTERFACE(0xf4c1e23d, 0xb321, 0x4931, { 0x8f, 0x37, 0xf1, 0x22, 0x6a, 0xf9, 0x20, 0x85 }) - }; - - class EntryPointRecorder : public IEntryPointRecorder, public IComponentTypeRecorder + return Super::getSession(); + } + + virtual SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL + getLayout(SlangInt targetIndex = 0, slang::IBlob** outDiagnostics = nullptr) override { - typedef IComponentTypeRecorder Super; - - public: - SLANG_REF_OBJECT_IUNKNOWN_ALL - ISlangUnknown* getInterface(const Guid& guid); - - explicit EntryPointRecorder(SessionRecorder* sessionRecorder, slang::IEntryPoint* entryPoint, RecordManager* recordManager); - - // Interfaces for `IComponentType` - virtual SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() override - { - return Super::getSession(); - } - - virtual SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL getLayout( - SlangInt targetIndex = 0, - slang::IBlob** outDiagnostics = nullptr) override - { - return Super::getLayout(targetIndex, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangInt SLANG_MCALL getSpecializationParamCount() override - { - return Super::getSpecializationParamCount(); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IBlob** outCode, - slang::IBlob** outDiagnostics = nullptr) override - { - return Super::getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCode( - SlangInt targetIndex, - slang::IBlob** outCode, - slang::IBlob** outDiagnostics = nullptr) override - { - return Super::getTargetCode(targetIndex, outCode, outDiagnostics); - } - - SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointMetadata( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IMetadata** outMetadata, - slang::IBlob** outDiagnostics) SLANG_OVERRIDE - { - return Super::getEntryPointMetadata(entryPointIndex, targetIndex, outMetadata, outDiagnostics); - } - - SLANG_NO_THROW SlangResult SLANG_MCALL getTargetMetadata( - SlangInt targetIndex, - slang::IMetadata** outMetadata, - slang::IBlob** outDiagnostics) SLANG_OVERRIDE - { - return Super::getTargetMetadata(targetIndex, outMetadata, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem( - SlangInt entryPointIndex, - SlangInt targetIndex, - ISlangMutableFileSystem** outFileSystem) override - { - return Super::getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem); - } - - virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IBlob** outHash) override - { - return Super::getEntryPointHash(entryPointIndex, targetIndex, outHash); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL specialize( - slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, - slang::IComponentType** outSpecializedComponentType, - ISlangBlob** outDiagnostics = nullptr) override - { - return Super::specialize(specializationArgs, specializationArgCount, outSpecializedComponentType, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL link( - slang::IComponentType** outLinkedComponentType, - ISlangBlob** outDiagnostics = nullptr) override - { - return Super::link(outLinkedComponentType, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable( - int entryPointIndex, - int targetIndex, - ISlangSharedLibrary** outSharedLibrary, - slang::IBlob** outDiagnostics = 0) override - { - return Super::getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint( - const char* newName, IComponentType** outEntryPoint) override - { - return Super::renameEntryPoint(newName, outEntryPoint); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions( - IComponentType** outLinkedComponentType, - uint32_t compilerOptionEntryCount, - slang::CompilerOptionEntry* compilerOptionEntries, - ISlangBlob** outDiagnostics = nullptr) override - { - return Super::linkWithOptions(outLinkedComponentType, compilerOptionEntryCount, compilerOptionEntries, outDiagnostics); - } - - // Interfaces for `IEntryPoint` - virtual SLANG_NO_THROW slang::FunctionReflection* SLANG_MCALL getFunctionReflection() override; - - slang::IEntryPoint* getActualEntryPoint() const { return m_actualEntryPoint; } - - protected: - virtual ApiClassId getClassId() override - { - return ApiClassId::Class_IEntryPoint; - } - - virtual SessionRecorder* getSessionRecorder() override - { - return m_sessionRecorder; - } - private: - SessionRecorder* m_sessionRecorder; - Slang::ComPtr<slang::IEntryPoint> m_actualEntryPoint; - }; -} + return Super::getLayout(targetIndex, outDiagnostics); + } + + virtual SLANG_NO_THROW SlangInt SLANG_MCALL getSpecializationParamCount() override + { + return Super::getSpecializationParamCount(); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IBlob** outCode, + slang::IBlob** outDiagnostics = nullptr) override + { + return Super::getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCode( + SlangInt targetIndex, + slang::IBlob** outCode, + slang::IBlob** outDiagnostics = nullptr) override + { + return Super::getTargetCode(targetIndex, outCode, outDiagnostics); + } + + SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointMetadata( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IMetadata** outMetadata, + slang::IBlob** outDiagnostics) SLANG_OVERRIDE + { + return Super::getEntryPointMetadata( + entryPointIndex, + targetIndex, + outMetadata, + outDiagnostics); + } + + SLANG_NO_THROW SlangResult SLANG_MCALL getTargetMetadata( + SlangInt targetIndex, + slang::IMetadata** outMetadata, + slang::IBlob** outDiagnostics) SLANG_OVERRIDE + { + return Super::getTargetMetadata(targetIndex, outMetadata, outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem( + SlangInt entryPointIndex, + SlangInt targetIndex, + ISlangMutableFileSystem** outFileSystem) override + { + return Super::getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem); + } + + virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IBlob** outHash) override + { + return Super::getEntryPointHash(entryPointIndex, targetIndex, outHash); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL specialize( + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + slang::IComponentType** outSpecializedComponentType, + ISlangBlob** outDiagnostics = nullptr) override + { + return Super::specialize( + specializationArgs, + specializationArgCount, + outSpecializedComponentType, + outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL link( + slang::IComponentType** outLinkedComponentType, + ISlangBlob** outDiagnostics = nullptr) override + { + return Super::link(outLinkedComponentType, outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable( + int entryPointIndex, + int targetIndex, + ISlangSharedLibrary** outSharedLibrary, + slang::IBlob** outDiagnostics = 0) override + { + return Super::getEntryPointHostCallable( + entryPointIndex, + targetIndex, + outSharedLibrary, + outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL + renameEntryPoint(const char* newName, IComponentType** outEntryPoint) override + { + return Super::renameEntryPoint(newName, outEntryPoint); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions( + IComponentType** outLinkedComponentType, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ISlangBlob** outDiagnostics = nullptr) override + { + return Super::linkWithOptions( + outLinkedComponentType, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnostics); + } + + // Interfaces for `IEntryPoint` + virtual SLANG_NO_THROW slang::FunctionReflection* SLANG_MCALL getFunctionReflection() override; + + slang::IEntryPoint* getActualEntryPoint() const { return m_actualEntryPoint; } + +protected: + virtual ApiClassId getClassId() override { return ApiClassId::Class_IEntryPoint; } + + virtual SessionRecorder* getSessionRecorder() override { return m_sessionRecorder; } + +private: + SessionRecorder* m_sessionRecorder; + Slang::ComPtr<slang::IEntryPoint> m_actualEntryPoint; +}; +} // namespace SlangRecord #endif // SLANG_ENTRY_POINT_H diff --git a/source/slang-record-replay/record/slang-filesystem.cpp b/source/slang-record-replay/record/slang-filesystem.cpp index 87a7182fc..84e2412cc 100644 --- a/source/slang-record-replay/record/slang-filesystem.cpp +++ b/source/slang-record-replay/record/slang-filesystem.cpp @@ -1,134 +1,167 @@ -#include <stdlib.h> - #include "slang-filesystem.h" + +#include "../../core/slang-io.h" #include "../util/record-utility.h" #include "output-stream.h" -#include "../../core/slang-io.h" + +#include <stdlib.h> namespace SlangRecord { - // We don't actually need to record the methods of ISlangFileSystemExt, we just want to record the file content - // and save them into disk. - FileSystemRecorder::FileSystemRecorder(ISlangFileSystemExt* fileSystem, RecordManager* recordManager) - : m_actualFileSystem(fileSystem), - m_recordManager(recordManager) - { - SLANG_RECORD_ASSERT(m_actualFileSystem); - SLANG_RECORD_ASSERT(m_recordManager); - slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, m_actualFileSystem.get()); - } +// We don't actually need to record the methods of ISlangFileSystemExt, we just want to record the +// file content and save them into disk. +FileSystemRecorder::FileSystemRecorder( + ISlangFileSystemExt* fileSystem, + RecordManager* recordManager) + : m_actualFileSystem(fileSystem), m_recordManager(recordManager) +{ + SLANG_RECORD_ASSERT(m_actualFileSystem); + SLANG_RECORD_ASSERT(m_recordManager); + slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, m_actualFileSystem.get()); +} - void* FileSystemRecorder::castAs(const Slang::Guid& guid) - { - return getInterface(guid); - } +void* FileSystemRecorder::castAs(const Slang::Guid& guid) +{ + return getInterface(guid); +} - ISlangUnknown* FileSystemRecorder::getInterface(const Slang::Guid& guid) - { - if(guid == ISlangUnknown::getTypeGuid() || guid == ISlangFileSystem::getTypeGuid()) - return static_cast<ISlangFileSystem*>(this); - return nullptr; - } +ISlangUnknown* FileSystemRecorder::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 FileSystemRecorder::loadFile( - char const* path, - ISlangBlob** outBlob) +// 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 FileSystemRecorder::loadFile(char const* path, ISlangBlob** outBlob) +{ + slangRecordLog( + 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 record directory. + if ((res == SLANG_OK) && (*outBlob != nullptr) && ((*outBlob)->getBufferSize() != 0)) { - slangRecordLog(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 record directory. - if ((res == SLANG_OK) && (*outBlob != nullptr) && ((*outBlob)->getBufferSize() != 0)) + Slang::String filePath = + Slang::Path::combine(m_recordManager->getRecordFileDirectory(), path); + Slang::String dirPath = Slang::Path::getParentDirectory(filePath); + if (!File::exists(dirPath)) { - Slang::String filePath = Slang::Path::combine(m_recordManager->getRecordFileDirectory(), path); - Slang::String dirPath = Slang::Path::getParentDirectory(filePath); - if (!File::exists(dirPath)) + slangRecordLog( + LogLevel::Debug, + "Create directory: %s to save captured shader file: %s\n", + dirPath.getBuffer(), + filePath.getBuffer()); + + if (!Path::createDirectoryRecursive(dirPath)) { - slangRecordLog(LogLevel::Debug, "Create directory: %s to save captured shader file: %s\n", - dirPath.getBuffer(), filePath.getBuffer()); - - if (!Path::createDirectoryRecursive(dirPath)) - { - slangRecordLog(LogLevel::Error, "Fail to create directory: %s\n", - dirPath.getBuffer()); - return SLANG_FAIL; - } + slangRecordLog( + LogLevel::Error, + "Fail to create directory: %s\n", + dirPath.getBuffer()); + return SLANG_FAIL; } + } - FileOutputStream fileStream(filePath); + FileOutputStream fileStream(filePath); - fileStream.write((*outBlob)->getBufferPointer(), (*outBlob)->getBufferSize()); - fileStream.flush(); - } - return res; + fileStream.write((*outBlob)->getBufferPointer(), (*outBlob)->getBufferSize()); + fileStream.flush(); } + return res; +} - SLANG_NO_THROW SlangResult FileSystemRecorder::getFileUniqueIdentity( - const char* path, - ISlangBlob** outUniqueIdentity) - { - slangRecordLog(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 +FileSystemRecorder::getFileUniqueIdentity(const char* path, ISlangBlob** outUniqueIdentity) +{ + slangRecordLog( + 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 FileSystemRecorder::calcCombinedPath( - SlangPathType fromPathType, - const char* fromPath, - const char* path, - ISlangBlob** pathOut) - { - slangRecordLog(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 FileSystemRecorder::calcCombinedPath( + SlangPathType fromPathType, + const char* fromPath, + const char* path, + ISlangBlob** pathOut) +{ + slangRecordLog( + 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 FileSystemRecorder::getPathType( - const char* path, - SlangPathType* pathTypeOut) - { - slangRecordLog(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 +FileSystemRecorder::getPathType(const char* path, SlangPathType* pathTypeOut) +{ + slangRecordLog( + 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 FileSystemRecorder::getPath( - PathKind kind, - const char* path, - ISlangBlob** outPath) - { - slangRecordLog(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 SlangResult +FileSystemRecorder::getPath(PathKind kind, const char* path, ISlangBlob** outPath) +{ + slangRecordLog( + 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 FileSystemRecorder::clearCache() - { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__); - m_actualFileSystem->clearCache(); - } +SLANG_NO_THROW void FileSystemRecorder::clearCache() +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__); + m_actualFileSystem->clearCache(); +} - SLANG_NO_THROW SlangResult FileSystemRecorder::enumeratePathContents( - const char* path, - FileSystemContentsCallBack callback, - void* userData) - { - slangRecordLog(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 SlangResult FileSystemRecorder::enumeratePathContents( + const char* path, + FileSystemContentsCallBack callback, + void* userData) +{ + slangRecordLog( + 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 FileSystemRecorder::getOSPathKind() - { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__); - OSPathKind pathKind = m_actualFileSystem->getOSPathKind(); - return pathKind; - } +SLANG_NO_THROW OSPathKind FileSystemRecorder::getOSPathKind() +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualFileSystem.get(), __PRETTY_FUNCTION__); + OSPathKind pathKind = m_actualFileSystem->getOSPathKind(); + return pathKind; } +} // namespace SlangRecord diff --git a/source/slang-record-replay/record/slang-filesystem.h b/source/slang-record-replay/record/slang-filesystem.h index 6f73e479c..171122d45 100644 --- a/source/slang-record-replay/record/slang-filesystem.h +++ b/source/slang-record-replay/record/slang-filesystem.h @@ -1,70 +1,65 @@ #ifndef SLANG_FILE_SYSTEM_H #define SLANG_FILE_SYSTEM_H -#include "slang-com-helper.h" -#include "slang-com-ptr.h" #include "../../core/slang-com-object.h" #include "record-manager.h" +#include "slang-com-helper.h" +#include "slang-com-ptr.h" namespace SlangRecord { - using namespace Slang; +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 record ISlangFileSystemExt, even - // though we only need to record loadFile() function. - class FileSystemRecorder : public RefObject, public ISlangFileSystemExt - { - public: - explicit FileSystemRecorder(ISlangFileSystemExt* fileSystem, RecordManager* recordManager); +// slang always requires ISlangFileSystemExt interface, even if user only provides ISlangFileSystem, +// slang will still wrap it with ISlangFileSystemExt. So we have to record ISlangFileSystemExt, even +// though we only need to record loadFile() function. +class FileSystemRecorder : public RefObject, public ISlangFileSystemExt +{ +public: + explicit FileSystemRecorder(ISlangFileSystemExt* fileSystem, RecordManager* recordManager); + + // ISlangUnknown + SLANG_REF_OBJECT_IUNKNOWN_ALL - // ISlangUnknown - SLANG_REF_OBJECT_IUNKNOWN_ALL + ISlangUnknown* getInterface(const Slang::Guid& guid); - ISlangUnknown* getInterface(const Slang::Guid& guid); + // ISlangCastable + virtual SLANG_NO_THROW void* SLANG_MCALL castAs(const Slang::Guid& guid) override; - // 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; - // 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; - // 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 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 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 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 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 SlangResult SLANG_MCALL enumeratePathContents( - const char* path, - FileSystemContentsCallBack callback, - void* userData) override; + virtual SLANG_NO_THROW OSPathKind SLANG_MCALL getOSPathKind() override; - virtual SLANG_NO_THROW OSPathKind SLANG_MCALL getOSPathKind() override; - private: - Slang::ComPtr<ISlangFileSystemExt> m_actualFileSystem; - RecordManager* m_recordManager = nullptr; +private: + Slang::ComPtr<ISlangFileSystemExt> m_actualFileSystem; + RecordManager* m_recordManager = nullptr; }; -} +} // namespace SlangRecord #endif - diff --git a/source/slang-record-replay/record/slang-global-session.cpp b/source/slang-record-replay/record/slang-global-session.cpp index 06bbed553..4f04574cd 100644 --- a/source/slang-record-replay/record/slang-global-session.cpp +++ b/source/slang-record-replay/record/slang-global-session.cpp @@ -1,455 +1,540 @@ #include "slang-global-session.h" -#include "slang-session.h" -#include "slang-filesystem.h" + #include "../../slang/slang-compiler.h" #include "../util/record-utility.h" +#include "slang-filesystem.h" +#include "slang-session.h" namespace SlangRecord { - // constructor is called in slang_createGlobalSession - GlobalSessionRecorder::GlobalSessionRecorder(slang::IGlobalSession* session): - m_actualGlobalSession(session) - { - SLANG_RECORD_ASSERT(m_actualGlobalSession != nullptr); - - m_globalSessionHandle = reinterpret_cast<SlangRecord::AddressFormat>(m_actualGlobalSession.get()); - m_recordManager = new RecordManager(m_globalSessionHandle); +// constructor is called in slang_createGlobalSession +GlobalSessionRecorder::GlobalSessionRecorder(slang::IGlobalSession* session) + : m_actualGlobalSession(session) +{ + SLANG_RECORD_ASSERT(m_actualGlobalSession != nullptr); - // We will use the address of the global session as the filename for the record manager - // to make it unique for each global session. - // record slang::createGlobalSession + m_globalSessionHandle = + reinterpret_cast<SlangRecord::AddressFormat>(m_actualGlobalSession.get()); + m_recordManager = new RecordManager(m_globalSessionHandle); - ParameterRecorder* recorder{}; - { - m_recordManager->beginMethodRecord(ApiCallId::CreateGlobalSession, g_globalFunctionHandle); - recorder = m_recordManager->endMethodRecord(); - } + // We will use the address of the global session as the filename for the record manager + // to make it unique for each global session. + // record slang::createGlobalSession - recorder->recordAddress(m_actualGlobalSession); - m_recordManager->apendOutput(); + ParameterRecorder* recorder{}; + { + m_recordManager->beginMethodRecord(ApiCallId::CreateGlobalSession, g_globalFunctionHandle); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::queryInterface(SlangUUID const& uuid, void** outObject) + recorder->recordAddress(m_actualGlobalSession); + m_recordManager->apendOutput(); +} + +SLANG_NO_THROW SlangResult SLANG_MCALL +GlobalSessionRecorder::queryInterface(SlangUUID const& uuid, void** outObject) +{ + if (uuid == Session::getTypeGuid()) { - 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; + // 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; } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::createSession(slang::SessionDesc const& desc, slang::ISession** outSession) + if (uuid == ISlangUnknown::getTypeGuid() && uuid == IGlobalSession::getTypeGuid()) { - setLogLevel(); - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - - slang::ISession* actualSession = nullptr; - - ParameterRecorder* recorder{}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_createSession, m_globalSessionHandle); - recorder->recordStruct(desc); - recorder = m_recordManager->endMethodRecord(); - } - - SlangResult res = m_actualGlobalSession->createSession(desc, &actualSession); - - { // record output - recorder->recordAddress(actualSession); - m_recordManager->apendOutput(); - } - - if (actualSession != nullptr) - { - // reset the file system to our record 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 record file system - Slang::Linkage* linkage = static_cast<Linkage*>(actualSession); - FileSystemRecorder* fileSystemRecord = new FileSystemRecorder(linkage->getFileSystemExt(), m_recordManager.get()); - - Slang::ComPtr<FileSystemRecorder> resultFileSystemRecorder(fileSystemRecord); - linkage->setFileSystem(resultFileSystemRecorder.detach()); - - SessionRecorder* sessionRecord = new SessionRecorder(actualSession, m_recordManager.get()); - Slang::ComPtr<SessionRecorder> result(sessionRecord); - *outSession = result.detach(); - } - - return res; + addReference(); + *outObject = static_cast<slang::IGlobalSession*>(this); + return SLANG_OK; } - SLANG_NO_THROW SlangProfileID SLANG_MCALL GlobalSessionRecorder::findProfile(char const* name) - { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + return SLANG_E_NO_INTERFACE; +} - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_findProfile, m_globalSessionHandle); - recorder->recordString(name); - recorder = m_recordManager->endMethodRecord(); - } +SLANG_NO_THROW SlangResult SLANG_MCALL +GlobalSessionRecorder::createSession(slang::SessionDesc const& desc, slang::ISession** outSession) +{ + setLogLevel(); + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SlangProfileID profileId = m_actualGlobalSession->findProfile(name); - return profileId; - } + slang::ISession* actualSession = nullptr; - SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::setDownstreamCompilerPath(SlangPassThrough passThrough, char const* path) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_createSession, + m_globalSessionHandle); + recorder->recordStruct(desc); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_setDownstreamCompilerPath, m_globalSessionHandle); - recorder->recordEnumValue(passThrough); - recorder->recordString(path); - m_recordManager->endMethodRecord(); - } + SlangResult res = m_actualGlobalSession->createSession(desc, &actualSession); - m_actualGlobalSession->setDownstreamCompilerPath(passThrough, path); + { // record output + recorder->recordAddress(actualSession); + m_recordManager->apendOutput(); } - SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::setDownstreamCompilerPrelude(SlangPassThrough inPassThrough, char const* prelude) + if (actualSession != nullptr) { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + // reset the file system to our record 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 record file system + Slang::Linkage* linkage = static_cast<Linkage*>(actualSession); + FileSystemRecorder* fileSystemRecord = + new FileSystemRecorder(linkage->getFileSystemExt(), m_recordManager.get()); + + Slang::ComPtr<FileSystemRecorder> resultFileSystemRecorder(fileSystemRecord); + linkage->setFileSystem(resultFileSystemRecorder.detach()); + + SessionRecorder* sessionRecord = new SessionRecorder(actualSession, m_recordManager.get()); + Slang::ComPtr<SessionRecorder> result(sessionRecord); + *outSession = result.detach(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_setDownstreamCompilerPrelude, m_globalSessionHandle); - recorder->recordEnumValue(inPassThrough); - recorder->recordString(prelude); - m_recordManager->endMethodRecord(); - } + return res; +} - m_actualGlobalSession->setDownstreamCompilerPrelude(inPassThrough, prelude); - } +SLANG_NO_THROW SlangProfileID SLANG_MCALL GlobalSessionRecorder::findProfile(char const* name) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::getDownstreamCompilerPrelude(SlangPassThrough inPassThrough, ISlangBlob** outPrelude) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_findProfile, + m_globalSessionHandle); + recorder->recordString(name); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_getDownstreamCompilerPrelude, m_globalSessionHandle); - recorder->recordEnumValue(inPassThrough); - recorder = m_recordManager->endMethodRecord(); - } + SlangProfileID profileId = m_actualGlobalSession->findProfile(name); + return profileId; +} - m_actualGlobalSession->getDownstreamCompilerPrelude(inPassThrough, outPrelude); +SLANG_NO_THROW void SLANG_MCALL +GlobalSessionRecorder::setDownstreamCompilerPath(SlangPassThrough passThrough, char const* path) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - { - recorder->recordAddress(*outPrelude); - m_recordManager->apendOutput(); - } + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_setDownstreamCompilerPath, + m_globalSessionHandle); + recorder->recordEnumValue(passThrough); + recorder->recordString(path); + m_recordManager->endMethodRecord(); } - SLANG_NO_THROW const char* SLANG_MCALL GlobalSessionRecorder::getBuildTagString() - { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + m_actualGlobalSession->setDownstreamCompilerPath(passThrough, path); +} - // No need to record 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 void SLANG_MCALL GlobalSessionRecorder::setDownstreamCompilerPrelude( + SlangPassThrough inPassThrough, + char const* prelude) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::setDefaultDownstreamCompiler(SlangSourceLanguage sourceLanguage, SlangPassThrough defaultCompiler) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_setDefaultDownstreamCompiler, m_globalSessionHandle); - recorder->recordEnumValue(sourceLanguage); - recorder->recordEnumValue(defaultCompiler); - recorder = m_recordManager->endMethodRecord(); - } - - SlangResult res = m_actualGlobalSession->setDefaultDownstreamCompiler(sourceLanguage, defaultCompiler); - return res; + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_setDownstreamCompilerPrelude, + m_globalSessionHandle); + recorder->recordEnumValue(inPassThrough); + recorder->recordString(prelude); + m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangPassThrough SLANG_MCALL GlobalSessionRecorder::getDefaultDownstreamCompiler(SlangSourceLanguage sourceLanguage) - { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + m_actualGlobalSession->setDownstreamCompilerPrelude(inPassThrough, prelude); +} - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_getDefaultDownstreamCompiler, m_globalSessionHandle); - recorder->recordEnumValue(sourceLanguage); - recorder = m_recordManager->endMethodRecord(); - } +SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::getDownstreamCompilerPrelude( + SlangPassThrough inPassThrough, + ISlangBlob** outPrelude) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SlangPassThrough passThrough = m_actualGlobalSession->getDefaultDownstreamCompiler(sourceLanguage); - return passThrough; + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_getDownstreamCompilerPrelude, + m_globalSessionHandle); + recorder->recordEnumValue(inPassThrough); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::setLanguagePrelude(SlangSourceLanguage inSourceLanguage, char const* prelude) + m_actualGlobalSession->getDownstreamCompilerPrelude(inPassThrough, outPrelude); + { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + recorder->recordAddress(*outPrelude); + m_recordManager->apendOutput(); + } +} - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_setLanguagePrelude, m_globalSessionHandle); - recorder->recordEnumValue(inSourceLanguage); - recorder->recordString(prelude); - recorder = m_recordManager->endMethodRecord(); - } +SLANG_NO_THROW const char* SLANG_MCALL GlobalSessionRecorder::getBuildTagString() +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - m_actualGlobalSession->setLanguagePrelude(inSourceLanguage, prelude); - } + // No need to record 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 void SLANG_MCALL GlobalSessionRecorder::getLanguagePrelude(SlangSourceLanguage inSourceLanguage, ISlangBlob** outPrelude) +SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::setDefaultDownstreamCompiler( + SlangSourceLanguage sourceLanguage, + SlangPassThrough defaultCompiler) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_setDefaultDownstreamCompiler, + m_globalSessionHandle); + recorder->recordEnumValue(sourceLanguage); + recorder->recordEnumValue(defaultCompiler); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_getLanguagePrelude, m_globalSessionHandle); - recorder->recordEnumValue(inSourceLanguage); - recorder = m_recordManager->endMethodRecord(); - } + SlangResult res = + m_actualGlobalSession->setDefaultDownstreamCompiler(sourceLanguage, defaultCompiler); + return res; +} - m_actualGlobalSession->getLanguagePrelude(inSourceLanguage, outPrelude); +SLANG_NO_THROW SlangPassThrough SLANG_MCALL +GlobalSessionRecorder::getDefaultDownstreamCompiler(SlangSourceLanguage sourceLanguage) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - { - recorder->recordAddress(*outPrelude); - m_recordManager->apendOutput(); - } + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_getDefaultDownstreamCompiler, + m_globalSessionHandle); + recorder->recordEnumValue(sourceLanguage); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::createCompileRequest(slang::ICompileRequest** outCompileRequest) + SlangPassThrough passThrough = + m_actualGlobalSession->getDefaultDownstreamCompiler(sourceLanguage); + return passThrough; +} + +SLANG_NO_THROW void SLANG_MCALL +GlobalSessionRecorder::setLanguagePrelude(SlangSourceLanguage inSourceLanguage, char const* prelude) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_setLanguagePrelude, + m_globalSessionHandle); + recorder->recordEnumValue(inSourceLanguage); + recorder->recordString(prelude); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_createCompileRequest, m_globalSessionHandle); - recorder = m_recordManager->endMethodRecord(); - } + m_actualGlobalSession->setLanguagePrelude(inSourceLanguage, prelude); +} - SLANG_ALLOW_DEPRECATED_BEGIN - SlangResult res = m_actualGlobalSession->createCompileRequest(outCompileRequest); - SLANG_ALLOW_DEPRECATED_END +SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::getLanguagePrelude( + SlangSourceLanguage inSourceLanguage, + ISlangBlob** outPrelude) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_getLanguagePrelude, + m_globalSessionHandle); + recorder->recordEnumValue(inSourceLanguage); + recorder = m_recordManager->endMethodRecord(); + } - { - recorder->recordAddress(*outCompileRequest); - m_recordManager->apendOutput(); - } + m_actualGlobalSession->getLanguagePrelude(inSourceLanguage, outPrelude); - return res; + { + recorder->recordAddress(*outPrelude); + m_recordManager->apendOutput(); } +} - SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::addBuiltins(char const* sourcePath, char const* sourceString) +SLANG_NO_THROW SlangResult SLANG_MCALL +GlobalSessionRecorder::createCompileRequest(slang::ICompileRequest** outCompileRequest) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_addBuiltins, m_globalSessionHandle); - recorder->recordString(sourcePath); - recorder->recordString(sourceString); - recorder = m_recordManager->endMethodRecord(); - } - - m_actualGlobalSession->addBuiltins(sourcePath, sourceString); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_createCompileRequest, + m_globalSessionHandle); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::setSharedLibraryLoader(ISlangSharedLibraryLoader* loader) + SLANG_ALLOW_DEPRECATED_BEGIN + SlangResult res = m_actualGlobalSession->createCompileRequest(outCompileRequest); + SLANG_ALLOW_DEPRECATED_END + { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - // TODO: Not sure if we need to record 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 record it there. - m_actualGlobalSession->setSharedLibraryLoader(loader); + recorder->recordAddress(*outCompileRequest); + m_recordManager->apendOutput(); } - SLANG_NO_THROW ISlangSharedLibraryLoader* SLANG_MCALL GlobalSessionRecorder::getSharedLibraryLoader() + return res; +} + +SLANG_NO_THROW void SLANG_MCALL +GlobalSessionRecorder::addBuiltins(char const* sourcePath, char const* sourceString) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_addBuiltins, + m_globalSessionHandle); + recorder->recordString(sourcePath); + recorder->recordString(sourceString); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_getSharedLibraryLoader, m_globalSessionHandle); - recorder = m_recordManager->endMethodRecord(); - } + m_actualGlobalSession->addBuiltins(sourcePath, sourceString); +} - ISlangSharedLibraryLoader* loader = m_actualGlobalSession->getSharedLibraryLoader(); +SLANG_NO_THROW void SLANG_MCALL +GlobalSessionRecorder::setSharedLibraryLoader(ISlangSharedLibraryLoader* loader) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + // TODO: Not sure if we need to record 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 record it there. + m_actualGlobalSession->setSharedLibraryLoader(loader); +} - { - recorder->recordAddress(loader); - m_recordManager->apendOutput(); - } - return loader; - } +SLANG_NO_THROW ISlangSharedLibraryLoader* SLANG_MCALL +GlobalSessionRecorder::getSharedLibraryLoader() +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::checkCompileTargetSupport(SlangCompileTarget target) + ParameterRecorder* recorder{}; { - // No need to record this function. It's just a query function and it won't impact the internal state. - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SlangResult res = m_actualGlobalSession->checkCompileTargetSupport(target); - return res; + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_getSharedLibraryLoader, + m_globalSessionHandle); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::checkPassThroughSupport(SlangPassThrough passThrough) + ISlangSharedLibraryLoader* loader = m_actualGlobalSession->getSharedLibraryLoader(); + { - // No need to record this function. It's just a query function and it won't impact the internal state. - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SlangResult res = m_actualGlobalSession->checkPassThroughSupport(passThrough); - return res; + recorder->recordAddress(loader); + m_recordManager->apendOutput(); } + return loader; +} - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::compileCoreModule(slang::CompileCoreModuleFlags flags) - { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); +SLANG_NO_THROW SlangResult SLANG_MCALL +GlobalSessionRecorder::checkCompileTargetSupport(SlangCompileTarget target) +{ + // No need to record this function. It's just a query function and it won't impact the internal + // state. + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + SlangResult res = m_actualGlobalSession->checkCompileTargetSupport(target); + return res; +} - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_compileCoreModule, m_globalSessionHandle); - recorder->recordEnumValue(flags); - m_recordManager->endMethodRecord(); - } +SLANG_NO_THROW SlangResult SLANG_MCALL +GlobalSessionRecorder::checkPassThroughSupport(SlangPassThrough passThrough) +{ + // No need to record this function. It's just a query function and it won't impact the internal + // state. + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + SlangResult res = m_actualGlobalSession->checkPassThroughSupport(passThrough); + return res; +} - SlangResult res = m_actualGlobalSession->compileCoreModule(flags); - return res; - } +SLANG_NO_THROW SlangResult SLANG_MCALL +GlobalSessionRecorder::compileCoreModule(slang::CompileCoreModuleFlags flags) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_compileCoreModule, + m_globalSessionHandle); + recorder->recordEnumValue(flags); + m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_loadCoreModule, m_globalSessionHandle); - recorder->recordPointer(coreModule, false, coreModuleSizeInBytes); - m_recordManager->endMethodRecord(); - } + SlangResult res = m_actualGlobalSession->compileCoreModule(flags); + return res; +} - SlangResult res = m_actualGlobalSession->loadCoreModule(coreModule, coreModuleSizeInBytes); - return res; - } +SLANG_NO_THROW SlangResult SLANG_MCALL +GlobalSessionRecorder::loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_saveCoreModule, m_globalSessionHandle); - recorder->recordEnumValue(archiveType); - recorder = m_recordManager->endMethodRecord(); - } - - SlangResult res = m_actualGlobalSession->saveCoreModule(archiveType, outBlob); - - { - recorder->recordAddress(*outBlob); - m_recordManager->apendOutput(); - } - return res; + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_loadCoreModule, + m_globalSessionHandle); + recorder->recordPointer(coreModule, false, coreModuleSizeInBytes); + m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangCapabilityID SLANG_MCALL GlobalSessionRecorder::findCapability(char const* name) + SlangResult res = m_actualGlobalSession->loadCoreModule(coreModule, coreModuleSizeInBytes); + return res; +} + +SLANG_NO_THROW SlangResult SLANG_MCALL +GlobalSessionRecorder::saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + + ParameterRecorder* recorder{}; { - // No need to record this function. It's just a query function and it won't impact the internal state. - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SlangCapabilityID capId = m_actualGlobalSession->findCapability(name); - return capId; + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_saveCoreModule, + m_globalSessionHandle); + recorder->recordEnumValue(archiveType); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::setDownstreamCompilerForTransition(SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) + SlangResult res = m_actualGlobalSession->saveCoreModule(archiveType, outBlob); + { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_setDownstreamCompilerForTransition, m_globalSessionHandle); - recorder->recordEnumValue(source); - recorder->recordEnumValue(target); - recorder->recordEnumValue(compiler); - m_recordManager->endMethodRecord(); - } - - m_actualGlobalSession->setDownstreamCompilerForTransition(source, target, compiler); + recorder->recordAddress(*outBlob); + m_recordManager->apendOutput(); } + return res; +} + +SLANG_NO_THROW SlangCapabilityID SLANG_MCALL GlobalSessionRecorder::findCapability(char const* name) +{ + // No need to record this function. It's just a query function and it won't impact the internal + // state. + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + SlangCapabilityID capId = m_actualGlobalSession->findCapability(name); + return capId; +} + +SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::setDownstreamCompilerForTransition( + SlangCompileTarget source, + SlangCompileTarget target, + SlangPassThrough compiler) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangPassThrough SLANG_MCALL GlobalSessionRecorder::getDownstreamCompilerForTransition(SlangCompileTarget source, SlangCompileTarget target) + ParameterRecorder* recorder{}; { - // No need to record this function. It's just a query function and it won't impact the internal state. - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - SlangPassThrough passThrough = m_actualGlobalSession->getDownstreamCompilerForTransition(source, target); - return passThrough; + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_setDownstreamCompilerForTransition, + m_globalSessionHandle); + recorder->recordEnumValue(source); + recorder->recordEnumValue(target); + recorder->recordEnumValue(compiler); + m_recordManager->endMethodRecord(); } - SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::getCompilerElapsedTime(double* outTotalTime, double* outDownstreamTime) + m_actualGlobalSession->setDownstreamCompilerForTransition(source, target, compiler); +} + +SLANG_NO_THROW SlangPassThrough SLANG_MCALL +GlobalSessionRecorder::getDownstreamCompilerForTransition( + SlangCompileTarget source, + SlangCompileTarget target) +{ + // No need to record this function. It's just a query function and it won't impact the internal + // state. + slangRecordLog(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 +GlobalSessionRecorder::getCompilerElapsedTime(double* outTotalTime, double* outDownstreamTime) +{ + // No need to record this function. It's just a query function and it won't impact the internal + // state. + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + m_actualGlobalSession->getCompilerElapsedTime(outTotalTime, outDownstreamTime); +} + +SLANG_NO_THROW SlangResult SLANG_MCALL +GlobalSessionRecorder::setSPIRVCoreGrammar(char const* jsonPath) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + + ParameterRecorder* recorder{}; { - // No need to record this function. It's just a query function and it won't impact the internal state. - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - m_actualGlobalSession->getCompilerElapsedTime(outTotalTime, outDownstreamTime); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_setSPIRVCoreGrammar, + m_globalSessionHandle); + recorder->recordString(jsonPath); + m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::setSPIRVCoreGrammar(char const* jsonPath) + SlangResult res = m_actualGlobalSession->setSPIRVCoreGrammar(jsonPath); + return res; +} + +SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::parseCommandLineArguments( + int argc, + const char* const* argv, + slang::SessionDesc* outSessionDesc, + ISlangUnknown** outAllocation) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_parseCommandLineArguments, + m_globalSessionHandle); + recorder->recordInt32(argc); + recorder->recordStringArray(argv, argc); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_setSPIRVCoreGrammar, m_globalSessionHandle); - recorder->recordString(jsonPath); - m_recordManager->endMethodRecord(); - } + SlangResult res = + m_actualGlobalSession->parseCommandLineArguments(argc, argv, outSessionDesc, outAllocation); - SlangResult res = m_actualGlobalSession->setSPIRVCoreGrammar(jsonPath); - return res; + { + recorder->recordAddress(outSessionDesc); + recorder->recordAddress(*outAllocation); + m_recordManager->apendOutput(); } + return res; +} - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::parseCommandLineArguments( - int argc, const char* const* argv, slang::SessionDesc* outSessionDesc, ISlangUnknown** outAllocation) +SLANG_NO_THROW SlangResult SLANG_MCALL +GlobalSessionRecorder::getSessionDescDigest(slang::SessionDesc* sessionDesc, ISlangBlob** outBlob) +{ + slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); + + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_parseCommandLineArguments, m_globalSessionHandle); - recorder->recordInt32(argc); - recorder->recordStringArray(argv, argc); - recorder = m_recordManager->endMethodRecord(); - } - - SlangResult res = m_actualGlobalSession->parseCommandLineArguments(argc, argv, outSessionDesc, outAllocation); - - { - recorder->recordAddress(outSessionDesc); - recorder->recordAddress(*outAllocation); - m_recordManager->apendOutput(); - } - return res; + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IGlobalSession_getSessionDescDigest, + m_globalSessionHandle); + recorder->recordStruct(*sessionDesc); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::getSessionDescDigest(slang::SessionDesc* sessionDesc, ISlangBlob** outBlob) + SlangResult res = m_actualGlobalSession->getSessionDescDigest(sessionDesc, outBlob); + { - slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__); - - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IGlobalSession_getSessionDescDigest, m_globalSessionHandle); - recorder->recordStruct(*sessionDesc); - recorder = m_recordManager->endMethodRecord(); - } - - SlangResult res = m_actualGlobalSession->getSessionDescDigest(sessionDesc, outBlob); - - { - recorder->recordAddress(*outBlob); - m_recordManager->apendOutput(); - } - return res; + recorder->recordAddress(*outBlob); + m_recordManager->apendOutput(); } + return res; } +} // namespace SlangRecord diff --git a/source/slang-record-replay/record/slang-global-session.h b/source/slang-record-replay/record/slang-global-session.h index 284185cb4..f6c976f72 100644 --- a/source/slang-record-replay/record/slang-global-session.h +++ b/source/slang-record-replay/record/slang-global-session.h @@ -1,84 +1,113 @@ #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 "record-manager.h" +#include "slang-com-helper.h" +#include "slang-com-ptr.h" +#include "slang.h" namespace SlangRecord { - using namespace Slang; +using namespace Slang; - class GlobalSessionRecorder : public RefObject, public slang::IGlobalSession +class GlobalSessionRecorder : public RefObject, public slang::IGlobalSession +{ +public: + explicit GlobalSessionRecorder(slang::IGlobalSession* session); + + 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 + compileCoreModule(slang::CompileCoreModuleFlags flags) override; + SLANG_NO_THROW SlangResult SLANG_MCALL + loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) override; + SLANG_NO_THROW SlangResult SLANG_MCALL + saveCoreModule(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; + + RecordManager* getRecordManager() { return m_recordManager.get(); } + +private: + SLANG_FORCE_INLINE slang::IGlobalSession* asExternal(GlobalSessionRecorder* session) { - public: - explicit GlobalSessionRecorder(slang::IGlobalSession* session); - - 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 compileCoreModule(slang::CompileCoreModuleFlags flags) override; - SLANG_NO_THROW SlangResult SLANG_MCALL loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes) override; - SLANG_NO_THROW SlangResult SLANG_MCALL saveCoreModule(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; - - RecordManager* getRecordManager() { return m_recordManager.get(); } - - private: - SLANG_FORCE_INLINE slang::IGlobalSession* asExternal(GlobalSessionRecorder* session) - { - return static_cast<slang::IGlobalSession*>(session); - } - - Slang::ComPtr<slang::IGlobalSession> m_actualGlobalSession; - - // we will create one record 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 record 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. - Slang::RefPtr<RecordManager> m_recordManager; - uint64_t m_globalSessionHandle = 0; - }; -} // namespace Slang + return static_cast<slang::IGlobalSession*>(session); + } + + Slang::ComPtr<slang::IGlobalSession> m_actualGlobalSession; + + // we will create one record 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 record 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. + Slang::RefPtr<RecordManager> m_recordManager; + uint64_t m_globalSessionHandle = 0; +}; +} // namespace SlangRecord #endif diff --git a/source/slang-record-replay/record/slang-module.cpp b/source/slang-record-replay/record/slang-module.cpp index 5f624a2e0..2071a8491 100644 --- a/source/slang-record-replay/record/slang-module.cpp +++ b/source/slang-record-replay/record/slang-module.cpp @@ -1,235 +1,247 @@ -#include "../util/record-utility.h" #include "slang-module.h" + +#include "../util/record-utility.h" #include "slang-session.h" namespace SlangRecord { - ModuleRecorder::ModuleRecorder(SessionRecorder* sessionRecorder, slang::IModule* module, RecordManager* recordManager) - : IComponentTypeRecorder(module, recordManager), - m_sessionRecorder(sessionRecorder), - m_actualModule(module), - m_recordManager(recordManager) - { - SLANG_RECORD_ASSERT(m_actualModule != nullptr); - SLANG_RECORD_ASSERT(m_recordManager != nullptr); +ModuleRecorder::ModuleRecorder( + SessionRecorder* sessionRecorder, + slang::IModule* module, + RecordManager* recordManager) + : IComponentTypeRecorder(module, recordManager) + , m_sessionRecorder(sessionRecorder) + , m_actualModule(module) + , m_recordManager(recordManager) +{ + SLANG_RECORD_ASSERT(m_actualModule != nullptr); + SLANG_RECORD_ASSERT(m_recordManager != nullptr); - m_moduleHandle = reinterpret_cast<uint64_t>(m_actualModule.get()); - slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, module); - } + m_moduleHandle = reinterpret_cast<uint64_t>(m_actualModule.get()); + slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, module); +} + +ISlangUnknown* ModuleRecorder::getInterface(const Guid& guid) +{ + if (guid == IModuleRecorder::getTypeGuid()) + return static_cast<IModuleRecorder*>(this); + else + return nullptr; +} + +SLANG_NO_THROW slang::DeclReflection* ModuleRecorder::getModuleReflection() +{ + // No need to record this call as it is just a query. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + slang::DeclReflection* res = (slang::DeclReflection*)m_actualModule->getModuleReflection(); + return res; +} + +SLANG_NO_THROW SlangResult +ModuleRecorder::findEntryPointByName(char const* name, slang::IEntryPoint** outEntryPoint) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - ISlangUnknown* ModuleRecorder::getInterface(const Guid& guid) + ParameterRecorder* recorder{}; { - if(guid == IModuleRecorder::getTypeGuid()) - return static_cast<IModuleRecorder*>(this); - else - return nullptr; + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IModule_findEntryPointByName, + m_moduleHandle); + recorder->recordString(name); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW slang::DeclReflection* ModuleRecorder::getModuleReflection() + SlangResult res = m_actualModule->findEntryPointByName(name, outEntryPoint); + { - // No need to record this call as it is just a query. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - slang::DeclReflection* res = (slang::DeclReflection*)m_actualModule->getModuleReflection(); - return res; + recorder->recordAddress(*outEntryPoint); + m_recordManager->apendOutput(); } - SLANG_NO_THROW SlangResult ModuleRecorder::findEntryPointByName( - char const* name, - slang::IEntryPoint** outEntryPoint) + if (SLANG_OK == res) { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IModule_findEntryPointByName, m_moduleHandle); - recorder->recordString(name); - recorder = m_recordManager->endMethodRecord(); - } + IEntryPointRecorder* entryPointRecord = getEntryPointRecorder(*outEntryPoint); + *outEntryPoint = static_cast<slang::IEntryPoint*>(entryPointRecord); + } + return res; +} - SlangResult res = m_actualModule->findEntryPointByName(name, outEntryPoint); +SLANG_NO_THROW SlangInt32 ModuleRecorder::getDefinedEntryPointCount() +{ + // No need to record this call as it is just a query. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + SlangInt32 res = m_actualModule->getDefinedEntryPointCount(); + return res; +} - { - recorder->recordAddress(*outEntryPoint); - m_recordManager->apendOutput(); - } +SLANG_NO_THROW SlangResult +ModuleRecorder::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. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - if (SLANG_OK == res) - { - IEntryPointRecorder* entryPointRecord = getEntryPointRecorder(*outEntryPoint); - *outEntryPoint = static_cast<slang::IEntryPoint*>(entryPointRecord); - } - return res; + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IModule_getDefinedEntryPoint, + m_moduleHandle); + recorder->recordInt32(index); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangInt32 ModuleRecorder::getDefinedEntryPointCount() + SlangResult res = m_actualModule->getDefinedEntryPoint(index, outEntryPoint); + { - // No need to record this call as it is just a query. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SlangInt32 res = m_actualModule->getDefinedEntryPointCount(); - return res; + recorder->recordAddress(*outEntryPoint); + m_recordManager->apendOutput(); } - SLANG_NO_THROW SlangResult ModuleRecorder::getDefinedEntryPoint(SlangInt32 index, slang::IEntryPoint** outEntryPoint) + if (*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. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - - ParameterRecorder* recorder {}; + IEntryPointRecorder* entryPointRecord = nullptr; + bool ret = m_mapEntryPointToRecord.tryGetValue(*outEntryPoint, entryPointRecord); + if (!ret) { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IModule_getDefinedEntryPoint, m_moduleHandle); - recorder->recordInt32(index); - recorder = m_recordManager->endMethodRecord(); + SLANG_RECORD_ASSERT(!"Entrypoint not found in mapEntryPointToRecord"); } + ComPtr<slang::IEntryPoint> result(static_cast<slang::IEntryPoint*>(entryPointRecord)); + *outEntryPoint = result.detach(); + } + else + *outEntryPoint = nullptr; - SlangResult res = m_actualModule->getDefinedEntryPoint(index, outEntryPoint); - - { - recorder->recordAddress(*outEntryPoint); - m_recordManager->apendOutput(); - } + return res; +} - if (*outEntryPoint) - { - IEntryPointRecorder* entryPointRecord = nullptr; - bool ret = m_mapEntryPointToRecord.tryGetValue(*outEntryPoint, entryPointRecord); - if (!ret) - { - SLANG_RECORD_ASSERT(!"Entrypoint not found in mapEntryPointToRecord"); - } - ComPtr<slang::IEntryPoint> result(static_cast<slang::IEntryPoint*>(entryPointRecord)); - *outEntryPoint = result.detach(); - } - else - *outEntryPoint = nullptr; +SLANG_NO_THROW SlangResult ModuleRecorder::serialize(ISlangBlob** outSerializedBlob) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - return res; + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord(ApiCallId::IModule_serialize, m_moduleHandle); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangResult ModuleRecorder::serialize(ISlangBlob** outSerializedBlob) - { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + SlangResult res = m_actualModule->serialize(outSerializedBlob); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IModule_serialize, m_moduleHandle); - recorder = m_recordManager->endMethodRecord(); - } + { + recorder->recordAddress(*outSerializedBlob); + m_recordManager->apendOutput(); + } - SlangResult res = m_actualModule->serialize(outSerializedBlob); + return res; +} - { - recorder->recordAddress(*outSerializedBlob); - m_recordManager->apendOutput(); - } +SLANG_NO_THROW SlangResult ModuleRecorder::writeToFile(char const* fileName) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - return res; + ParameterRecorder* recorder{}; + { + recorder = + m_recordManager->beginMethodRecord(ApiCallId::IModule_writeToFile, m_moduleHandle); + recorder->recordString(fileName); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangResult ModuleRecorder::writeToFile(char const* fileName) - { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + SlangResult res = m_actualModule->writeToFile(fileName); + return res; +} - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IModule_writeToFile, m_moduleHandle); - recorder->recordString(fileName); - recorder = m_recordManager->endMethodRecord(); - } +SLANG_NO_THROW const char* ModuleRecorder::getName() +{ + // No need to record this call as it is just a query. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + const char* res = m_actualModule->getName(); + return res; +} - SlangResult res = m_actualModule->writeToFile(fileName); - return res; - } +SLANG_NO_THROW const char* ModuleRecorder::getFilePath() +{ + // No need to record this call as it is just a query. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + const char* res = m_actualModule->getFilePath(); + return res; +} - SLANG_NO_THROW const char* ModuleRecorder::getName() - { - // No need to record this call as it is just a query. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - const char* res = m_actualModule->getName(); - return res; - } +SLANG_NO_THROW const char* ModuleRecorder::getUniqueIdentity() +{ + // No need to record this call as it is just a query. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + const char* res = m_actualModule->getUniqueIdentity(); + return res; +} - SLANG_NO_THROW const char* ModuleRecorder::getFilePath() +SLANG_NO_THROW SlangResult ModuleRecorder::findAndCheckEntryPoint( + char const* name, + SlangStage stage, + slang::IEntryPoint** outEntryPoint, + ISlangBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + + ParameterRecorder* recorder{}; { - // No need to record this call as it is just a query. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - const char* res = m_actualModule->getFilePath(); - return res; + recorder = m_recordManager->beginMethodRecord( + ApiCallId::IModule_findAndCheckEntryPoint, + m_moduleHandle); + recorder->recordString(name); + recorder->recordEnumValue(stage); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW const char* ModuleRecorder::getUniqueIdentity() + SlangResult res = + m_actualModule->findAndCheckEntryPoint(name, stage, outEntryPoint, outDiagnostics); + { - // No need to record this call as it is just a query. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - const char* res = m_actualModule->getUniqueIdentity(); - return res; + recorder->recordAddress(*outEntryPoint); + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + m_recordManager->apendOutput(); } - SLANG_NO_THROW SlangResult ModuleRecorder::findAndCheckEntryPoint( - char const* name, - SlangStage stage, - slang::IEntryPoint** outEntryPoint, - ISlangBlob** outDiagnostics) + if (SLANG_OK == res) { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::IModule_findAndCheckEntryPoint, m_moduleHandle); - recorder->recordString(name); - recorder->recordEnumValue(stage); - recorder = m_recordManager->endMethodRecord(); - } - - SlangResult res = m_actualModule->findAndCheckEntryPoint(name, stage, outEntryPoint, outDiagnostics); + IEntryPointRecorder* entryPointRecord = getEntryPointRecorder(*outEntryPoint); + *outEntryPoint = static_cast<slang::IEntryPoint*>(entryPointRecord); + } + return res; +} - { - recorder->recordAddress(*outEntryPoint); - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - m_recordManager->apendOutput(); - } +SLANG_NO_THROW SlangInt32 ModuleRecorder::getDependencyFileCount() +{ + // No need to record this call as it is just a query. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + SlangInt32 res = m_actualModule->getDependencyFileCount(); + return res; +} - if (SLANG_OK == res) - { - IEntryPointRecorder* entryPointRecord = getEntryPointRecorder(*outEntryPoint); - *outEntryPoint = static_cast<slang::IEntryPoint*>(entryPointRecord); - } - return res; - } +SLANG_NO_THROW char const* ModuleRecorder::getDependencyFilePath(SlangInt32 index) +{ + // No need to record this call as it is just a query. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + const char* res = m_actualModule->getDependencyFilePath(index); + return res; +} - SLANG_NO_THROW SlangInt32 ModuleRecorder::getDependencyFileCount() +IEntryPointRecorder* ModuleRecorder::getEntryPointRecorder(slang::IEntryPoint* entryPoint) +{ + IEntryPointRecorder* entryPointRecord = nullptr; + bool ret = m_mapEntryPointToRecord.tryGetValue(entryPoint, entryPointRecord); + if (!ret) { - // No need to record this call as it is just a query. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SlangInt32 res = m_actualModule->getDependencyFileCount(); - return res; - } + entryPointRecord = new EntryPointRecorder(m_sessionRecorder, entryPoint, m_recordManager); + Slang::ComPtr<IEntryPointRecorder> result(entryPointRecord); - SLANG_NO_THROW char const* ModuleRecorder::getDependencyFilePath(SlangInt32 index) - { - // No need to record this call as it is just a query. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - const char* res = m_actualModule->getDependencyFilePath(index); - return res; + m_entryPointsRecordAllocation.add(result); + m_mapEntryPointToRecord.add(entryPoint, result.detach()); + return entryPointRecord; } - - IEntryPointRecorder* ModuleRecorder::getEntryPointRecorder(slang::IEntryPoint* entryPoint) + else { - IEntryPointRecorder* entryPointRecord = nullptr; - bool ret = m_mapEntryPointToRecord.tryGetValue(entryPoint, entryPointRecord); - if (!ret) - { - entryPointRecord = new EntryPointRecorder(m_sessionRecorder, entryPoint, m_recordManager); - Slang::ComPtr<IEntryPointRecorder> result(entryPointRecord); - - m_entryPointsRecordAllocation.add(result); - m_mapEntryPointToRecord.add(entryPoint, result.detach()); - return entryPointRecord; - } - else - { - Slang::ComPtr<IEntryPointRecorder> result(entryPointRecord); - return result.detach(); - } + Slang::ComPtr<IEntryPointRecorder> result(entryPointRecord); + return result.detach(); } } +} // namespace SlangRecord diff --git a/source/slang-record-replay/record/slang-module.h b/source/slang-record-replay/record/slang-module.h index 2a22bd214..5cf3126f7 100644 --- a/source/slang-record-replay/record/slang-module.h +++ b/source/slang-record-replay/record/slang-module.h @@ -1,191 +1,209 @@ #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 "record-manager.h" +#include "slang-com-helper.h" +#include "slang-com-ptr.h" +#include "slang-entrypoint.h" +#include "slang.h" namespace SlangRecord { - using namespace Slang; - class SessionRecorder; +using namespace Slang; +class SessionRecorder; - class IModuleRecorder : public slang::IModule, public RefObject +class IModuleRecorder : public slang::IModule, public RefObject +{ +public: + SLANG_COM_INTERFACE( + 0xb1802991, + 0x185a, + 0x4a03, + {0xa7, 0x7e, 0x0c, 0x86, 0xe0, 0x68, 0x2a, 0xab}) +}; + +class ModuleRecorder : public IModuleRecorder, public IComponentTypeRecorder +{ + typedef IComponentTypeRecorder Super; + +public: + SLANG_REF_OBJECT_IUNKNOWN_ALL + ISlangUnknown* getInterface(const Guid& guid); + + explicit ModuleRecorder( + SessionRecorder* sessionRecorder, + slang::IModule* module, + RecordManager* recordManager); + + // 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 + { + return Super::getSession(); + } + + virtual SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL + getLayout(SlangInt targetIndex = 0, slang::IBlob** outDiagnostics = nullptr) override + { + return Super::getLayout(targetIndex, outDiagnostics); + } + + virtual SLANG_NO_THROW SlangInt SLANG_MCALL getSpecializationParamCount() override + { + return Super::getSpecializationParamCount(); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IBlob** outCode, + slang::IBlob** outDiagnostics = nullptr) override { - public: - SLANG_COM_INTERFACE(0xb1802991, 0x185a, 0x4a03, { 0xa7, 0x7e, 0x0c, 0x86, 0xe0, 0x68, 0x2a, 0xab }) - }; + return Super::getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics); + } - class ModuleRecorder : public IModuleRecorder, public IComponentTypeRecorder + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCode( + SlangInt targetIndex, + slang::IBlob** outCode, + slang::IBlob** outDiagnostics = nullptr) override + { + return Super::getTargetCode(targetIndex, outCode, outDiagnostics); + } + + SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointMetadata( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IMetadata** outMetadata, + slang::IBlob** outDiagnostics) SLANG_OVERRIDE + { + return Super::getEntryPointMetadata( + entryPointIndex, + targetIndex, + outMetadata, + outDiagnostics); + } + + SLANG_NO_THROW SlangResult SLANG_MCALL getTargetMetadata( + SlangInt targetIndex, + slang::IMetadata** outMetadata, + slang::IBlob** outDiagnostics) SLANG_OVERRIDE { - typedef IComponentTypeRecorder Super; - - public: - SLANG_REF_OBJECT_IUNKNOWN_ALL - ISlangUnknown* getInterface(const Guid& guid); - - explicit ModuleRecorder(SessionRecorder* sessionRecorder, slang::IModule* module, RecordManager* recordManager); - - // 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 - { - return Super::getSession(); - } - - virtual SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL getLayout( - SlangInt targetIndex = 0, - slang::IBlob** outDiagnostics = nullptr) override - { - return Super::getLayout(targetIndex, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangInt SLANG_MCALL getSpecializationParamCount() override - { - return Super::getSpecializationParamCount(); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IBlob** outCode, - slang::IBlob** outDiagnostics = nullptr) override - { - return Super::getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCode( - SlangInt targetIndex, - slang::IBlob** outCode, - slang::IBlob** outDiagnostics = nullptr) override - { - return Super::getTargetCode(targetIndex, outCode, outDiagnostics); - } - - SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointMetadata( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IMetadata** outMetadata, - slang::IBlob** outDiagnostics) SLANG_OVERRIDE - { - return Super::getEntryPointMetadata(entryPointIndex, targetIndex, outMetadata, outDiagnostics); - } - - SLANG_NO_THROW SlangResult SLANG_MCALL getTargetMetadata( - SlangInt targetIndex, - slang::IMetadata** outMetadata, - slang::IBlob** outDiagnostics) SLANG_OVERRIDE - { - return Super::getTargetMetadata(targetIndex, outMetadata, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem( - SlangInt entryPointIndex, - SlangInt targetIndex, - ISlangMutableFileSystem** outFileSystem) override - { - return Super::getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem); - } - - virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IBlob** outHash) override - { - return Super::getEntryPointHash(entryPointIndex, targetIndex, outHash); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL specialize( - slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, - slang::IComponentType** outSpecializedComponentType, - ISlangBlob** outDiagnostics = nullptr) override - { - return Super::specialize(specializationArgs, specializationArgCount, outSpecializedComponentType, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL link( - slang::IComponentType** outLinkedComponentType, - ISlangBlob** outDiagnostics = nullptr) override - { - return Super::link(outLinkedComponentType, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable( - int entryPointIndex, - int targetIndex, - ISlangSharedLibrary** outSharedLibrary, - slang::IBlob** outDiagnostics = 0) override - { - return Super::getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint( - const char* newName, IComponentType** outEntryPoint) override - { - return Super::renameEntryPoint(newName, outEntryPoint); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions( - IComponentType** outLinkedComponentType, - uint32_t compilerOptionEntryCount, - slang::CompilerOptionEntry* compilerOptionEntries, - ISlangBlob** outDiagnostics = nullptr) override - { - return Super::linkWithOptions(outLinkedComponentType, compilerOptionEntryCount, compilerOptionEntries, outDiagnostics); - } - - virtual SLANG_NO_THROW slang::DeclReflection* getModuleReflection() override; - - slang::IModule* getActualModule() const { return m_actualModule; } - - protected: - - // `IComponentTypeRecorder` interface - virtual ApiClassId getClassId() override - { - return ApiClassId::Class_IModule; - } - - virtual SessionRecorder* getSessionRecorder() override - { - return m_sessionRecorder; - } - - private: - IEntryPointRecorder* getEntryPointRecorder(slang::IEntryPoint* entryPoint); - - SessionRecorder* m_sessionRecorder; - Slang::ComPtr<slang::IModule> m_actualModule; - uint64_t m_moduleHandle = 0; - RecordManager* m_recordManager = nullptr; - - // `IEntryPoint` can only be created from 'IModule', so we need to record it in - // this class, and create a map such that we don't create new `EntryPointRecorder` - // for the same `IEntryPoint`. - Dictionary<slang::IEntryPoint*, IEntryPointRecorder*> m_mapEntryPointToRecord; - List<ComPtr<IEntryPointRecorder>> m_entryPointsRecordAllocation; - }; + return Super::getTargetMetadata(targetIndex, outMetadata, outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem( + SlangInt entryPointIndex, + SlangInt targetIndex, + ISlangMutableFileSystem** outFileSystem) override + { + return Super::getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem); + } + + virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IBlob** outHash) override + { + return Super::getEntryPointHash(entryPointIndex, targetIndex, outHash); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL specialize( + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + slang::IComponentType** outSpecializedComponentType, + ISlangBlob** outDiagnostics = nullptr) override + { + return Super::specialize( + specializationArgs, + specializationArgCount, + outSpecializedComponentType, + outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL link( + slang::IComponentType** outLinkedComponentType, + ISlangBlob** outDiagnostics = nullptr) override + { + return Super::link(outLinkedComponentType, outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable( + int entryPointIndex, + int targetIndex, + ISlangSharedLibrary** outSharedLibrary, + slang::IBlob** outDiagnostics = 0) override + { + return Super::getEntryPointHostCallable( + entryPointIndex, + targetIndex, + outSharedLibrary, + outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL + renameEntryPoint(const char* newName, IComponentType** outEntryPoint) override + { + return Super::renameEntryPoint(newName, outEntryPoint); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions( + IComponentType** outLinkedComponentType, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ISlangBlob** outDiagnostics = nullptr) override + { + return Super::linkWithOptions( + outLinkedComponentType, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnostics); + } + + virtual SLANG_NO_THROW slang::DeclReflection* getModuleReflection() override; + + slang::IModule* getActualModule() const { return m_actualModule; } + +protected: + // `IComponentTypeRecorder` interface + virtual ApiClassId getClassId() override { return ApiClassId::Class_IModule; } + + virtual SessionRecorder* getSessionRecorder() override { return m_sessionRecorder; } + +private: + IEntryPointRecorder* getEntryPointRecorder(slang::IEntryPoint* entryPoint); + + SessionRecorder* m_sessionRecorder; + Slang::ComPtr<slang::IModule> m_actualModule; + uint64_t m_moduleHandle = 0; + RecordManager* m_recordManager = nullptr; + + // `IEntryPoint` can only be created from 'IModule', so we need to record it in + // this class, and create a map such that we don't create new `EntryPointRecorder` + // for the same `IEntryPoint`. + Dictionary<slang::IEntryPoint*, IEntryPointRecorder*> m_mapEntryPointToRecord; + List<ComPtr<IEntryPointRecorder>> m_entryPointsRecordAllocation; +}; } // namespace SlangRecord #endif // SLANG_MODULE_H diff --git a/source/slang-record-replay/record/slang-session.cpp b/source/slang-record-replay/record/slang-session.cpp index 9ccaedc6e..d290afe0d 100644 --- a/source/slang-record-replay/record/slang-session.cpp +++ b/source/slang-record-replay/record/slang-session.cpp @@ -1,532 +1,588 @@ -#include "../util/record-utility.h" #include "slang-session.h" -#include "slang-entrypoint.h" + +#include "../util/record-utility.h" +#include "slang-component-type.h" #include "slang-composite-component-type.h" +#include "slang-entrypoint.h" #include "slang-type-conformance.h" -#include "slang-component-type.h" namespace SlangRecord { - SessionRecorder::SessionRecorder(slang::ISession* session, RecordManager* recordManager) - : m_actualSession(session), - m_recordManager(recordManager) +SessionRecorder::SessionRecorder(slang::ISession* session, RecordManager* recordManager) + : m_actualSession(session), m_recordManager(recordManager) +{ + SLANG_RECORD_ASSERT(m_actualSession); + SLANG_RECORD_ASSERT(m_recordManager); + m_sessionHandle = reinterpret_cast<uint64_t>(m_actualSession.get()); + slangRecordLog(LogLevel::Verbose, "%s: %p\n", "SessionRecorder create:", session); +} + +ISlangUnknown* SessionRecorder::getInterface(const Guid& guid) +{ + if (guid == ISlangUnknown::getTypeGuid() || guid == ISession::getTypeGuid()) + return asExternal(this); + + return nullptr; +} + +SLANG_NO_THROW slang::IGlobalSession* SessionRecorder::getGlobalSession() +{ + // No need to record this function. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + slang::IGlobalSession* pGlobalSession = m_actualSession->getGlobalSession(); + return pGlobalSession; +} + +SLANG_NO_THROW slang::IModule* SessionRecorder::loadModule( + const char* moduleName, + slang::IBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + + ParameterRecorder* recorder{}; { - SLANG_RECORD_ASSERT(m_actualSession); - SLANG_RECORD_ASSERT(m_recordManager); - m_sessionHandle = reinterpret_cast<uint64_t>(m_actualSession.get()); - slangRecordLog(LogLevel::Verbose, "%s: %p\n", "SessionRecorder create:", session); + recorder = + m_recordManager->beginMethodRecord(ApiCallId::ISession_loadModule, m_sessionHandle); + recorder->recordString(moduleName); + recorder = m_recordManager->endMethodRecord(); } - ISlangUnknown* SessionRecorder::getInterface(const Guid& guid) - { - if(guid == ISlangUnknown::getTypeGuid() || guid == ISession::getTypeGuid()) - return asExternal(this); + slang::IModule* pModule = m_actualSession->loadModule(moduleName, outDiagnostics); - return nullptr; + { + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + recorder->recordAddress(pModule); + m_recordManager->apendOutput(); } - SLANG_NO_THROW slang::IGlobalSession* SessionRecorder::getGlobalSession() + IModuleRecorder* pModuleRecorder = getModuleRecorder(pModule); + return static_cast<slang::IModule*>(pModuleRecorder); +} + +SLANG_NO_THROW slang::IModule* SessionRecorder::loadModuleFromIRBlob( + const char* moduleName, + const char* path, + slang::IBlob* source, + slang::IBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + + ParameterRecorder* recorder{}; { - // No need to record this function. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - slang::IGlobalSession* pGlobalSession = m_actualSession->getGlobalSession(); - return pGlobalSession; + recorder = m_recordManager->beginMethodRecord( + ApiCallId::ISession_loadModuleFromIRBlob, + m_sessionHandle); + recorder->recordString(moduleName); + recorder->recordString(path); + recorder->recordPointer(source); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW slang::IModule* SessionRecorder::loadModule( - const char* moduleName, - slang::IBlob** outDiagnostics) - { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + slang::IModule* pModule = + m_actualSession->loadModuleFromIRBlob(moduleName, path, source, outDiagnostics); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_loadModule, m_sessionHandle); - recorder->recordString(moduleName); - recorder = m_recordManager->endMethodRecord(); - } + { + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + recorder->recordAddress(pModule); + m_recordManager->apendOutput(); + } - slang::IModule* pModule = m_actualSession->loadModule(moduleName, outDiagnostics); + IModuleRecorder* pModuleRecorder = getModuleRecorder(pModule); + return static_cast<slang::IModule*>(pModuleRecorder); +} - { - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - recorder->recordAddress(pModule); - m_recordManager->apendOutput(); - } +SLANG_NO_THROW slang::IModule* SessionRecorder::loadModuleFromSource( + const char* moduleName, + const char* path, + slang::IBlob* source, + slang::IBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - IModuleRecorder* pModuleRecorder = getModuleRecorder(pModule); - return static_cast<slang::IModule*>(pModuleRecorder); + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord( + ApiCallId::ISession_loadModuleFromSource, + m_sessionHandle); + recorder->recordString(moduleName); + recorder->recordString(path); + recorder->recordPointer(source); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW slang::IModule* SessionRecorder::loadModuleFromIRBlob( - const char* moduleName, - const char* path, - slang::IBlob* source, - slang::IBlob** outDiagnostics) - { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + slang::IModule* pModule = + m_actualSession->loadModuleFromSource(moduleName, path, source, outDiagnostics); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_loadModuleFromIRBlob, m_sessionHandle); - recorder->recordString(moduleName); - recorder->recordString(path); - recorder->recordPointer(source); - recorder = m_recordManager->endMethodRecord(); - } + { + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + recorder->recordAddress(pModule); + m_recordManager->apendOutput(); + } - slang::IModule* pModule = m_actualSession->loadModuleFromIRBlob(moduleName, path, source, outDiagnostics); + IModuleRecorder* pModuleRecorder = getModuleRecorder(pModule); + return static_cast<slang::IModule*>(pModuleRecorder); +} - { - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - recorder->recordAddress(pModule); - m_recordManager->apendOutput(); - } +SLANG_NO_THROW slang::IModule* SessionRecorder::loadModuleFromSourceString( + const char* moduleName, + const char* path, + const char* string, + slang::IBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - IModuleRecorder* pModuleRecorder = getModuleRecorder(pModule); - return static_cast<slang::IModule*>(pModuleRecorder); + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord( + ApiCallId::ISession_loadModuleFromSourceString, + m_sessionHandle); + recorder->recordString(moduleName); + recorder->recordString(path); + recorder->recordString(string); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW slang::IModule* SessionRecorder::loadModuleFromSource( - const char* moduleName, - const char* path, - slang::IBlob* source, - slang::IBlob** outDiagnostics) + slang::IModule* pModule = + m_actualSession->loadModuleFromSourceString(moduleName, path, string, outDiagnostics); + { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + // TODO: Not sure if we need to record the diagnostics blob. + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + recorder->recordAddress(pModule); + m_recordManager->apendOutput(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_loadModuleFromSource, m_sessionHandle); - recorder->recordString(moduleName); - recorder->recordString(path); - recorder->recordPointer(source); - recorder = m_recordManager->endMethodRecord(); - } + IModuleRecorder* pModuleRecorder = getModuleRecorder(pModule); + return static_cast<slang::IModule*>(pModuleRecorder); +} - slang::IModule* pModule = m_actualSession->loadModuleFromSource(moduleName, path, source, outDiagnostics); +SLANG_NO_THROW SlangResult SessionRecorder::createCompositeComponentType( + slang::IComponentType* const* componentTypes, + SlangInt componentTypeCount, + slang::IComponentType** outCompositeComponentType, + ISlangBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - { - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - recorder->recordAddress(pModule); - m_recordManager->apendOutput(); - } + Slang::List<slang::IComponentType*> componentTypeList; - IModuleRecorder* pModuleRecorder = getModuleRecorder(pModule); - return static_cast<slang::IModule*>(pModuleRecorder); + // get the actual component types from our record wrappers + if (SLANG_OK != getActualComponentTypes(componentTypes, componentTypeCount, componentTypeList)) + { + SLANG_RECORD_ASSERT(!"Failed to get actual component types"); } - SLANG_NO_THROW slang::IModule* SessionRecorder::loadModuleFromSourceString( - const char* moduleName, - const char* path, - const char* string, - slang::IBlob** outDiagnostics) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_loadModuleFromSourceString, m_sessionHandle); - recorder->recordString(moduleName); - recorder->recordString(path); - recorder->recordString(string); - recorder = m_recordManager->endMethodRecord(); - } + recorder = m_recordManager->beginMethodRecord( + ApiCallId::ISession_createCompositeComponentType, + m_sessionHandle); + recorder->recordAddressArray(componentTypeList.getBuffer(), componentTypeCount); + recorder = m_recordManager->endMethodRecord(); + } - slang::IModule* pModule = m_actualSession->loadModuleFromSourceString(moduleName, path, string, outDiagnostics); + SlangResult result = m_actualSession->createCompositeComponentType( + componentTypeList.getBuffer(), + componentTypeCount, + outCompositeComponentType, + outDiagnostics); - { - // TODO: Not sure if we need to record the diagnostics blob. - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - recorder->recordAddress(pModule); - m_recordManager->apendOutput(); - } - - IModuleRecorder* pModuleRecorder = getModuleRecorder(pModule); - return static_cast<slang::IModule*>(pModuleRecorder); + { + recorder->recordAddress(*outCompositeComponentType); + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + m_recordManager->apendOutput(); } - SLANG_NO_THROW SlangResult SessionRecorder::createCompositeComponentType( - slang::IComponentType* const* componentTypes, - SlangInt componentTypeCount, - slang::IComponentType** outCompositeComponentType, - ISlangBlob** outDiagnostics) + if (SLANG_OK == result) { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + CompositeComponentTypeRecorder* compositeComponentTypeRecord = + new CompositeComponentTypeRecorder(this, *outCompositeComponentType, m_recordManager); + Slang::ComPtr<CompositeComponentTypeRecorder> resultRecord(compositeComponentTypeRecord); + *outCompositeComponentType = resultRecord.detach(); + } - Slang::List<slang::IComponentType*> componentTypeList; + return result; +} - // get the actual component types from our record wrappers - if(SLANG_OK != getActualComponentTypes(componentTypes, componentTypeCount, componentTypeList)) - { - SLANG_RECORD_ASSERT(!"Failed to get actual component types"); - } +SLANG_NO_THROW slang::TypeReflection* SessionRecorder::specializeType( + slang::TypeReflection* type, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ISlangBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_createCompositeComponentType, m_sessionHandle); - recorder->recordAddressArray(componentTypeList.getBuffer(), componentTypeCount); - recorder = m_recordManager->endMethodRecord(); - } + ParameterRecorder* recorder{}; + { + recorder = + m_recordManager->beginMethodRecord(ApiCallId::ISession_specializeType, m_sessionHandle); + recorder->recordAddress(type); + recorder->recordStructArray(specializationArgs, specializationArgCount); + recorder = m_recordManager->endMethodRecord(); + } - SlangResult result = m_actualSession->createCompositeComponentType( - componentTypeList.getBuffer(), componentTypeCount, outCompositeComponentType, outDiagnostics); + slang::TypeReflection* pTypeReflection = m_actualSession->specializeType( + type, + specializationArgs, + specializationArgCount, + outDiagnostics); - { - recorder->recordAddress(*outCompositeComponentType); - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - m_recordManager->apendOutput(); - } + { + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + recorder->recordAddress(pTypeReflection); + m_recordManager->apendOutput(); + } - if (SLANG_OK == result) - { - CompositeComponentTypeRecorder* compositeComponentTypeRecord = - new CompositeComponentTypeRecorder(this, *outCompositeComponentType, m_recordManager); - Slang::ComPtr<CompositeComponentTypeRecorder> resultRecord(compositeComponentTypeRecord); - *outCompositeComponentType = resultRecord.detach(); - } + return pTypeReflection; +} - return result; - } +SLANG_NO_THROW slang::TypeLayoutReflection* SessionRecorder::getTypeLayout( + slang::TypeReflection* type, + SlangInt targetIndex, + slang::LayoutRules rules, + ISlangBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW slang::TypeReflection* SessionRecorder::specializeType( - slang::TypeReflection* type, - slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, - ISlangBlob** outDiagnostics) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder = + m_recordManager->beginMethodRecord(ApiCallId::ISession_getTypeLayout, m_sessionHandle); + recorder->recordAddress(type); + recorder->recordInt64(targetIndex); + recorder->recordEnumValue(rules); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_specializeType, m_sessionHandle); - recorder->recordAddress(type); - recorder->recordStructArray(specializationArgs, specializationArgCount); - recorder = m_recordManager->endMethodRecord(); - } + slang::TypeLayoutReflection* pTypeLayoutReflection = + m_actualSession->getTypeLayout(type, targetIndex, rules, outDiagnostics); - slang::TypeReflection* pTypeReflection = m_actualSession->specializeType(type, specializationArgs, specializationArgCount, outDiagnostics); + { + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + recorder->recordAddress(pTypeLayoutReflection); + m_recordManager->apendOutput(); + } - { - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - recorder->recordAddress(pTypeReflection); - m_recordManager->apendOutput(); - } + return pTypeLayoutReflection; +} - return pTypeReflection; - } +SLANG_NO_THROW slang::TypeReflection* SessionRecorder::getContainerType( + slang::TypeReflection* elementType, + slang::ContainerType containerType, + ISlangBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW slang::TypeLayoutReflection* SessionRecorder::getTypeLayout( - slang::TypeReflection* type, - SlangInt targetIndex, - slang::LayoutRules rules, - ISlangBlob** outDiagnostics) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::ISession_getContainerType, + m_sessionHandle); + recorder->recordAddress(elementType); + recorder->recordEnumValue(containerType); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_getTypeLayout, m_sessionHandle); - recorder->recordAddress(type); - recorder->recordInt64(targetIndex); - recorder->recordEnumValue(rules); - recorder = m_recordManager->endMethodRecord(); - } + slang::TypeReflection* pTypeReflection = + m_actualSession->getContainerType(elementType, containerType, outDiagnostics); - slang::TypeLayoutReflection* pTypeLayoutReflection = m_actualSession->getTypeLayout(type, targetIndex, rules, outDiagnostics); + { + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + recorder->recordAddress(pTypeReflection); + m_recordManager->apendOutput(); + } - { - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - recorder->recordAddress(pTypeLayoutReflection); - m_recordManager->apendOutput(); - } + return pTypeReflection; +} - return pTypeLayoutReflection; - } +SLANG_NO_THROW slang::TypeReflection* SessionRecorder::getDynamicType() +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW slang::TypeReflection* SessionRecorder::getContainerType( - slang::TypeReflection* elementType, - slang::ContainerType containerType, - ISlangBlob** outDiagnostics) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder = + m_recordManager->beginMethodRecord(ApiCallId::ISession_getDynamicType, m_sessionHandle); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_getContainerType, m_sessionHandle); - recorder->recordAddress(elementType); - recorder->recordEnumValue(containerType); - recorder = m_recordManager->endMethodRecord(); - } + slang::TypeReflection* pTypeReflection = m_actualSession->getDynamicType(); - slang::TypeReflection* pTypeReflection = m_actualSession->getContainerType(elementType, containerType, outDiagnostics); + { + recorder->recordAddress(pTypeReflection); + m_recordManager->apendOutput(); + } - { - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - recorder->recordAddress(pTypeReflection); - m_recordManager->apendOutput(); - } + return pTypeReflection; +} - return pTypeReflection; - } +SLANG_NO_THROW SlangResult +SessionRecorder::getTypeRTTIMangledName(slang::TypeReflection* type, ISlangBlob** outNameBlob) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW slang::TypeReflection* SessionRecorder::getDynamicType() + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::ISession_getTypeRTTIMangledName, + m_sessionHandle); + recorder->recordAddress(type); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_getDynamicType, m_sessionHandle); - recorder = m_recordManager->endMethodRecord(); - } + SlangResult result = m_actualSession->getTypeRTTIMangledName(type, outNameBlob); - slang::TypeReflection* pTypeReflection = m_actualSession->getDynamicType(); + { + recorder->recordAddress(outNameBlob); + m_recordManager->apendOutput(); + } - { - recorder->recordAddress(pTypeReflection); - m_recordManager->apendOutput(); - } + return result; +} - return pTypeReflection; - } +SLANG_NO_THROW SlangResult SessionRecorder::getTypeConformanceWitnessMangledName( + slang::TypeReflection* type, + slang::TypeReflection* interfaceType, + ISlangBlob** outNameBlob) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangResult SessionRecorder::getTypeRTTIMangledName( - slang::TypeReflection* type, - ISlangBlob** outNameBlob) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::ISession_getTypeConformanceWitnessMangledName, + m_sessionHandle); + recorder->recordAddress(type); + recorder->recordAddress(interfaceType); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_getTypeRTTIMangledName, m_sessionHandle); - recorder->recordAddress(type); - recorder = m_recordManager->endMethodRecord(); - } + SlangResult result = + m_actualSession->getTypeConformanceWitnessMangledName(type, interfaceType, outNameBlob); - SlangResult result = m_actualSession->getTypeRTTIMangledName(type, outNameBlob); + { + recorder->recordAddress(outNameBlob); + m_recordManager->apendOutput(); + } - { - recorder->recordAddress(outNameBlob); - m_recordManager->apendOutput(); - } + return result; +} - return result; - } +SLANG_NO_THROW SlangResult SessionRecorder::getTypeConformanceWitnessSequentialID( + slang::TypeReflection* type, + slang::TypeReflection* interfaceType, + uint32_t* outId) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangResult SessionRecorder::getTypeConformanceWitnessMangledName( - slang::TypeReflection* type, - slang::TypeReflection* interfaceType, - ISlangBlob** outNameBlob) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::ISession_getTypeConformanceWitnessSequentialID, + m_sessionHandle); + recorder->recordAddress(type); + recorder->recordAddress(interfaceType); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_getTypeConformanceWitnessMangledName, m_sessionHandle); - recorder->recordAddress(type); - recorder->recordAddress(interfaceType); - recorder = m_recordManager->endMethodRecord(); - } + SlangResult result = + m_actualSession->getTypeConformanceWitnessSequentialID(type, interfaceType, outId); - SlangResult result = m_actualSession->getTypeConformanceWitnessMangledName(type, interfaceType, outNameBlob); + // No need to record outId, it's not slang allocation + return result; +} - { - recorder->recordAddress(outNameBlob); - m_recordManager->apendOutput(); - } +SLANG_NO_THROW SlangResult SessionRecorder::createTypeConformanceComponentType( + slang::TypeReflection* type, + slang::TypeReflection* interfaceType, + slang::ITypeConformance** outConformance, + SlangInt conformanceIdOverride, + ISlangBlob** outDiagnostics) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - return result; + ParameterRecorder* recorder{}; + { + recorder = m_recordManager->beginMethodRecord( + ApiCallId::ISession_createTypeConformanceComponentType, + m_sessionHandle); + recorder->recordAddress(type); + recorder->recordAddress(interfaceType); + recorder->recordInt64(conformanceIdOverride); + recorder = m_recordManager->endMethodRecord(); } - SLANG_NO_THROW SlangResult SessionRecorder::getTypeConformanceWitnessSequentialID( - slang::TypeReflection* type, - slang::TypeReflection* interfaceType, - uint32_t* outId) + SlangResult result = m_actualSession->createTypeConformanceComponentType( + type, + interfaceType, + outConformance, + conformanceIdOverride, + outDiagnostics); + { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder->recordAddress(*outConformance); + recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); + m_recordManager->apendOutput(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_getTypeConformanceWitnessSequentialID, m_sessionHandle); - recorder->recordAddress(type); - recorder->recordAddress(interfaceType); - recorder = m_recordManager->endMethodRecord(); - } + if (SLANG_OK != result) + { + ITypeConformanceRecorder* conformanceRecord = + new TypeConformanceRecorder(this, *outConformance, m_recordManager); + Slang::ComPtr<ITypeConformanceRecorder> resultRecord(conformanceRecord); + *outConformance = resultRecord.detach(); + } - SlangResult result = m_actualSession->getTypeConformanceWitnessSequentialID(type, interfaceType, outId); + return result; +} - // No need to record outId, it's not slang allocation - return result; - } +SLANG_NO_THROW SlangResult +SessionRecorder::createCompileRequest(SlangCompileRequest** outCompileRequest) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangResult SessionRecorder::createTypeConformanceComponentType( - slang::TypeReflection* type, - slang::TypeReflection* interfaceType, - slang::ITypeConformance** outConformance, - SlangInt conformanceIdOverride, - ISlangBlob** outDiagnostics) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::ISession_createCompileRequest, + m_sessionHandle); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_createTypeConformanceComponentType, m_sessionHandle); - recorder->recordAddress(type); - recorder->recordAddress(interfaceType); - recorder->recordInt64(conformanceIdOverride); - recorder = m_recordManager->endMethodRecord(); - } + SlangResult result = m_actualSession->createCompileRequest(outCompileRequest); - SlangResult result = m_actualSession->createTypeConformanceComponentType(type, interfaceType, outConformance, conformanceIdOverride, outDiagnostics); + { + recorder->recordAddress(*outCompileRequest); + m_recordManager->apendOutput(); + } - { - recorder->recordAddress(*outConformance); - recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr); - m_recordManager->apendOutput(); - } + return result; +} - if (SLANG_OK != result) - { - ITypeConformanceRecorder* conformanceRecord = new TypeConformanceRecorder(this, *outConformance, m_recordManager); - Slang::ComPtr<ITypeConformanceRecorder> resultRecord(conformanceRecord); - *outConformance = resultRecord.detach(); - } +SLANG_NO_THROW SlangInt SessionRecorder::getLoadedModuleCount() +{ + // No need to record this function, it's just a query. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + SlangInt count = m_actualSession->getLoadedModuleCount(); + return count; +} - return result; - } +SLANG_NO_THROW slang::IModule* SessionRecorder::getLoadedModule(SlangInt index) +{ + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SLANG_NO_THROW SlangResult SessionRecorder::createCompileRequest( - SlangCompileRequest** outCompileRequest) + ParameterRecorder* recorder{}; { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + recorder = m_recordManager->beginMethodRecord( + ApiCallId::ISession_getLoadedModule, + m_sessionHandle); + recorder->recordInt64(index); + recorder = m_recordManager->endMethodRecord(); + } - ParameterRecorder* recorder {}; - { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_createCompileRequest, m_sessionHandle); - recorder = m_recordManager->endMethodRecord(); - } + slang::IModule* pModule = m_actualSession->getLoadedModule(index); - SlangResult result = m_actualSession->createCompileRequest(outCompileRequest); + { + recorder->recordAddress(pModule); + m_recordManager->apendOutput(); + } + if (pModule) + { + IModuleRecorder* moduleRecord = nullptr; + bool ret = m_mapModuleToRecord.tryGetValue(pModule, moduleRecord); + if (!ret) { - recorder->recordAddress(*outCompileRequest); - m_recordManager->apendOutput(); + SLANG_RECORD_ASSERT(!"Module not found in mapModuleToRecord"); } - - return result; + ComPtr<slang::IModule> result(static_cast<slang::IModule*>(moduleRecord)); + return result.detach(); } - SLANG_NO_THROW SlangInt SessionRecorder::getLoadedModuleCount() + return pModule; +} + +SLANG_NO_THROW bool SessionRecorder::isBinaryModuleUpToDate( + const char* modulePath, + slang::IBlob* binaryModuleBlob) +{ + // No need to record this function, it's a query function and doesn't impact slang internal + // state. + slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + bool result = m_actualSession->isBinaryModuleUpToDate(modulePath, binaryModuleBlob); + return result; +} + +IModuleRecorder* SessionRecorder::getModuleRecorder(slang::IModule* module) +{ + IModuleRecorder* moduleRecord = nullptr; + bool ret = m_mapModuleToRecord.tryGetValue(module, moduleRecord); + if (!ret) + { + moduleRecord = new ModuleRecorder(this, module, m_recordManager); + Slang::ComPtr<IModuleRecorder> result(moduleRecord); + m_moduleRecordersAlloation.add(result); + m_mapModuleToRecord.add(module, result.detach()); + } + else { - // No need to record this function, it's just a query. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - SlangInt count = m_actualSession->getLoadedModuleCount(); - return count; + ComPtr<IModuleRecorder> result(moduleRecord); + return result.detach(); } - SLANG_NO_THROW slang::IModule* SessionRecorder::getLoadedModule(SlangInt index) + return moduleRecord; +} + +SlangResult SessionRecorder::getActualComponentTypes( + slang::IComponentType* const* componentTypes, + SlangInt componentTypeCount, + List<slang::IComponentType*>& outActualComponentTypes) +{ + for (SlangInt i = 0; i < componentTypeCount; i++) { - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); + slang::IComponentType* const& componentType = componentTypes[i]; + void* outObj = nullptr; - ParameterRecorder* recorder {}; + if (componentType->queryInterface(IModuleRecorder::getTypeGuid(), &outObj) == SLANG_OK) { - recorder = m_recordManager->beginMethodRecord(ApiCallId::ISession_getLoadedModule, m_sessionHandle); - recorder->recordInt64(index); - recorder = m_recordManager->endMethodRecord(); + ModuleRecorder* moduleRecord = static_cast<ModuleRecorder*>(outObj); + outActualComponentTypes.add(moduleRecord->getActualModule()); } - - slang::IModule* pModule = m_actualSession->getLoadedModule(index); - + else if ( + componentType->queryInterface(IEntryPointRecorder::getTypeGuid(), &outObj) == SLANG_OK) { - recorder->recordAddress(pModule); - m_recordManager->apendOutput(); + EntryPointRecorder* entrypointRecord = static_cast<EntryPointRecorder*>(outObj); + outActualComponentTypes.add(entrypointRecord->getActualEntryPoint()); } - - if (pModule) + else if ( + componentType->queryInterface(CompositeComponentTypeRecorder::getTypeGuid(), &outObj) == + SLANG_OK) { - IModuleRecorder* moduleRecord = nullptr; - bool ret = m_mapModuleToRecord.tryGetValue(pModule, moduleRecord); - if (!ret) - { - SLANG_RECORD_ASSERT(!"Module not found in mapModuleToRecord"); - } - ComPtr<slang::IModule> result(static_cast<slang::IModule*>(moduleRecord)); - return result.detach(); + CompositeComponentTypeRecorder* compositeComponentTypeRecord = + static_cast<CompositeComponentTypeRecorder*>(outObj); + outActualComponentTypes.add( + compositeComponentTypeRecord->getActualCompositeComponentType()); } - - return pModule; - } - - SLANG_NO_THROW bool SessionRecorder::isBinaryModuleUpToDate(const char* modulePath, slang::IBlob* binaryModuleBlob) - { - // No need to record this function, it's a query function and doesn't impact slang internal state. - slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__); - bool result = m_actualSession->isBinaryModuleUpToDate(modulePath, binaryModuleBlob); - return result; - } - - IModuleRecorder* SessionRecorder::getModuleRecorder(slang::IModule* module) - { - IModuleRecorder* moduleRecord = nullptr; - bool ret = m_mapModuleToRecord.tryGetValue(module, moduleRecord); - if (!ret) + else if ( + componentType->queryInterface(ITypeConformanceRecorder::getTypeGuid(), &outObj) == + SLANG_OK) { - moduleRecord = new ModuleRecorder(this, module, m_recordManager); - Slang::ComPtr<IModuleRecorder> result(moduleRecord); - m_moduleRecordersAlloation.add(result); - m_mapModuleToRecord.add(module, result.detach()); + TypeConformanceRecorder* typeConformanceRecorder = + static_cast<TypeConformanceRecorder*>(outObj); + outActualComponentTypes.add(typeConformanceRecorder->getActualTypeConformance()); } + // will fall back to the actual component type, it means that we didn't record this type. else { - ComPtr<IModuleRecorder> result(moduleRecord); - return result.detach(); + outActualComponentTypes.add(componentType); } - - return moduleRecord; } - SlangResult SessionRecorder::getActualComponentTypes( - slang::IComponentType* const* componentTypes, - SlangInt componentTypeCount, - List<slang::IComponentType*>& outActualComponentTypes) + if (componentTypeCount == outActualComponentTypes.getCount()) { - for (SlangInt i = 0; i < componentTypeCount; i++) - { - slang::IComponentType* const& componentType = componentTypes[i]; - void* outObj = nullptr; - - if (componentType->queryInterface(IModuleRecorder::getTypeGuid(), &outObj) == SLANG_OK) - { - ModuleRecorder* moduleRecord = static_cast<ModuleRecorder*>(outObj); - outActualComponentTypes.add(moduleRecord->getActualModule()); - } - else if (componentType->queryInterface(IEntryPointRecorder::getTypeGuid(), &outObj) == SLANG_OK) - { - EntryPointRecorder* entrypointRecord = static_cast<EntryPointRecorder*>(outObj); - outActualComponentTypes.add(entrypointRecord->getActualEntryPoint()); - } - else if (componentType->queryInterface(CompositeComponentTypeRecorder::getTypeGuid(), &outObj) == SLANG_OK) - { - CompositeComponentTypeRecorder* compositeComponentTypeRecord = static_cast<CompositeComponentTypeRecorder*>(outObj); - outActualComponentTypes.add(compositeComponentTypeRecord->getActualCompositeComponentType()); - } - else if (componentType->queryInterface(ITypeConformanceRecorder::getTypeGuid(), &outObj) == SLANG_OK) - { - TypeConformanceRecorder* typeConformanceRecorder = static_cast<TypeConformanceRecorder*>(outObj); - outActualComponentTypes.add(typeConformanceRecorder->getActualTypeConformance()); - } - // will fall back to the actual component type, it means that we didn't record this type. - else - { - outActualComponentTypes.add(componentType); - } - } - - if (componentTypeCount == outActualComponentTypes.getCount()) - { - return SLANG_OK; - } - return SLANG_FAIL; + return SLANG_OK; } + return SLANG_FAIL; +} } // namespace SlangRecord diff --git a/source/slang-record-replay/record/slang-session.h b/source/slang-record-replay/record/slang-session.h index e1f88675f..ea76d0dde 100644 --- a/source/slang-record-replay/record/slang-session.h +++ b/source/slang-record-replay/record/slang-session.h @@ -1,110 +1,109 @@ #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 "../../core/slang-smart-pointer.h" #include "../../slang/slang-compiler.h" -#include "slang-module.h" #include "record-manager.h" +#include "slang-com-helper.h" +#include "slang-com-ptr.h" +#include "slang-module.h" +#include "slang.h" namespace SlangRecord { - using namespace Slang; - class SessionRecorder: public RefObject, public slang::ISession - { - public: - SLANG_REF_OBJECT_IUNKNOWN_ALL - ISlangUnknown* getInterface(const Guid& guid); +using namespace Slang; +class SessionRecorder : public RefObject, public slang::ISession +{ +public: + SLANG_REF_OBJECT_IUNKNOWN_ALL + ISlangUnknown* getInterface(const Guid& guid); - explicit SessionRecorder(slang::ISession* session, RecordManager* recordManager); + explicit SessionRecorder(slang::ISession* session, RecordManager* recordManager); - 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_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; + 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_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(SessionRecorder* session) - { - return static_cast<slang::ISession*>(session); - } +private: + SLANG_FORCE_INLINE slang::ISession* asExternal(SessionRecorder* session) + { + return static_cast<slang::ISession*>(session); + } - // The IComponentType object is the record 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); + // The IComponentType object is the record 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); - IModuleRecorder* getModuleRecorder(slang::IModule* module); + IModuleRecorder* getModuleRecorder(slang::IModule* module); - Slang::ComPtr<slang::ISession> m_actualSession; - uint64_t m_sessionHandle = 0; + Slang::ComPtr<slang::ISession> m_actualSession; + uint64_t m_sessionHandle = 0; - Dictionary<slang::IModule*, IModuleRecorder*> m_mapModuleToRecord; - List<ComPtr<IModuleRecorder>> m_moduleRecordersAlloation; - RecordManager* m_recordManager = nullptr; - }; -} + Dictionary<slang::IModule*, IModuleRecorder*> m_mapModuleToRecord; + List<ComPtr<IModuleRecorder>> m_moduleRecordersAlloation; + RecordManager* m_recordManager = nullptr; +}; +} // namespace SlangRecord #endif // SLANG_SESSION_H diff --git a/source/slang-record-replay/record/slang-type-conformance.cpp b/source/slang-record-replay/record/slang-type-conformance.cpp index 9b27215d0..a908afe2d 100644 --- a/source/slang-record-replay/record/slang-type-conformance.cpp +++ b/source/slang-record-replay/record/slang-type-conformance.cpp @@ -1,29 +1,33 @@ -#include "../util/record-utility.h" #include "slang-type-conformance.h" +#include "../util/record-utility.h" + namespace SlangRecord { - TypeConformanceRecorder::TypeConformanceRecorder(SessionRecorder* sessionRecorder, slang::ITypeConformance* typeConformance, RecordManager* recordManager) - : IComponentTypeRecorder(typeConformance, recordManager), - m_sessionRecorder(sessionRecorder), - m_actualTypeConformance(typeConformance) - { - SLANG_RECORD_ASSERT(m_actualTypeConformance != nullptr); - SLANG_RECORD_ASSERT(m_recordManager != nullptr); +TypeConformanceRecorder::TypeConformanceRecorder( + SessionRecorder* sessionRecorder, + slang::ITypeConformance* typeConformance, + RecordManager* recordManager) + : IComponentTypeRecorder(typeConformance, recordManager) + , m_sessionRecorder(sessionRecorder) + , m_actualTypeConformance(typeConformance) +{ + SLANG_RECORD_ASSERT(m_actualTypeConformance != nullptr); + SLANG_RECORD_ASSERT(m_recordManager != nullptr); - m_typeConformanceHandle = reinterpret_cast<uint64_t>(m_actualTypeConformance.get()); - slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, typeConformance); - } + m_typeConformanceHandle = reinterpret_cast<uint64_t>(m_actualTypeConformance.get()); + slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, typeConformance); +} - ISlangUnknown* TypeConformanceRecorder::getInterface(const Guid& guid) +ISlangUnknown* TypeConformanceRecorder::getInterface(const Guid& guid) +{ + if (guid == ITypeConformanceRecorder::getTypeGuid()) + { + return static_cast<ITypeConformanceRecorder*>(this); + } + else { - if (guid == ITypeConformanceRecorder::getTypeGuid()) - { - return static_cast<ITypeConformanceRecorder*>(this); - } - else - { - return nullptr; - } + return nullptr; } } +} // namespace SlangRecord diff --git a/source/slang-record-replay/record/slang-type-conformance.h b/source/slang-record-replay/record/slang-type-conformance.h index 6c6889d02..12a0e4021 100644 --- a/source/slang-record-replay/record/slang-type-conformance.h +++ b/source/slang-record-replay/record/slang-type-conformance.h @@ -1,160 +1,178 @@ #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 "../../core/slang-smart-pointer.h" #include "../../slang/slang-compiler.h" #include "record-manager.h" +#include "slang-com-helper.h" +#include "slang-com-ptr.h" #include "slang-component-type.h" +#include "slang.h" namespace SlangRecord { - using namespace Slang; - class SessionRecorder; +using namespace Slang; +class SessionRecorder; + +class ITypeConformanceRecorder : public slang::ITypeConformance, public RefObject +{ +public: + SLANG_COM_INTERFACE( + 0x0e67d05d, + 0xee0a, + 0x41e1, + {0xb5, 0xa3, 0x23, 0xe3, 0xb0, 0xec, 0x33, 0xf1}) +}; + +class TypeConformanceRecorder : public ITypeConformanceRecorder, public IComponentTypeRecorder +{ + typedef IComponentTypeRecorder Super; + +public: + SLANG_REF_OBJECT_IUNKNOWN_ALL + ISlangUnknown* getInterface(const Guid& guid); + + explicit TypeConformanceRecorder( + SessionRecorder* sessionRecorder, + slang::ITypeConformance* typeConformance, + RecordManager* recordManager); + + // Interfaces for `IComponentType` + virtual SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() override + { + return Super::getSession(); + } - class ITypeConformanceRecorder : public slang::ITypeConformance, public RefObject + virtual SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL + getLayout(SlangInt targetIndex = 0, slang::IBlob** outDiagnostics = nullptr) override { - public: - SLANG_COM_INTERFACE(0x0e67d05d, 0xee0a, 0x41e1, { 0xb5, 0xa3, 0x23, 0xe3, 0xb0, 0xec, 0x33, 0xf1 }) - }; + return Super::getLayout(targetIndex, outDiagnostics); + } - class TypeConformanceRecorder: public ITypeConformanceRecorder, public IComponentTypeRecorder + virtual SLANG_NO_THROW SlangInt SLANG_MCALL getSpecializationParamCount() override + { + return Super::getSpecializationParamCount(); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IBlob** outCode, + slang::IBlob** outDiagnostics = nullptr) override + { + return Super::getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCode( + SlangInt targetIndex, + slang::IBlob** outCode, + slang::IBlob** outDiagnostics = nullptr) override + { + return Super::getTargetCode(targetIndex, outCode, outDiagnostics); + } + + SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointMetadata( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IMetadata** outMetadata, + slang::IBlob** outDiagnostics) SLANG_OVERRIDE + { + return Super::getEntryPointMetadata( + entryPointIndex, + targetIndex, + outMetadata, + outDiagnostics); + } + + SLANG_NO_THROW SlangResult SLANG_MCALL getTargetMetadata( + SlangInt targetIndex, + slang::IMetadata** outMetadata, + slang::IBlob** outDiagnostics) SLANG_OVERRIDE + { + return Super::getTargetMetadata(targetIndex, outMetadata, outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem( + SlangInt entryPointIndex, + SlangInt targetIndex, + ISlangMutableFileSystem** outFileSystem) override + { + return Super::getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem); + } + + virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash( + SlangInt entryPointIndex, + SlangInt targetIndex, + slang::IBlob** outHash) override + { + return Super::getEntryPointHash(entryPointIndex, targetIndex, outHash); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL specialize( + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + slang::IComponentType** outSpecializedComponentType, + ISlangBlob** outDiagnostics = nullptr) override + { + return Super::specialize( + specializationArgs, + specializationArgCount, + outSpecializedComponentType, + outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL link( + slang::IComponentType** outLinkedComponentType, + ISlangBlob** outDiagnostics = nullptr) override + { + return Super::link(outLinkedComponentType, outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable( + int entryPointIndex, + int targetIndex, + ISlangSharedLibrary** outSharedLibrary, + slang::IBlob** outDiagnostics = 0) override + { + return Super::getEntryPointHostCallable( + entryPointIndex, + targetIndex, + outSharedLibrary, + outDiagnostics); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL + renameEntryPoint(const char* newName, IComponentType** outEntryPoint) override + { + return Super::renameEntryPoint(newName, outEntryPoint); + } + + virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions( + IComponentType** outLinkedComponentType, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ISlangBlob** outDiagnostics = nullptr) override { - typedef IComponentTypeRecorder Super; - public: - SLANG_REF_OBJECT_IUNKNOWN_ALL - ISlangUnknown* getInterface(const Guid& guid); - - explicit TypeConformanceRecorder(SessionRecorder* sessionRecorder, slang::ITypeConformance* typeConformance, RecordManager* recordManager); - - // Interfaces for `IComponentType` - virtual SLANG_NO_THROW slang::ISession* SLANG_MCALL getSession() override - { - return Super::getSession(); - } - - virtual SLANG_NO_THROW slang::ProgramLayout* SLANG_MCALL getLayout( - SlangInt targetIndex = 0, - slang::IBlob** outDiagnostics = nullptr) override - { - return Super::getLayout(targetIndex, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangInt SLANG_MCALL getSpecializationParamCount() override - { - return Super::getSpecializationParamCount(); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCode( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IBlob** outCode, - slang::IBlob** outDiagnostics = nullptr) override - { - return Super::getEntryPointCode(entryPointIndex, targetIndex, outCode, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCode( - SlangInt targetIndex, - slang::IBlob** outCode, - slang::IBlob** outDiagnostics = nullptr) override - { - return Super::getTargetCode(targetIndex, outCode, outDiagnostics); - } - - SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointMetadata( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IMetadata** outMetadata, - slang::IBlob** outDiagnostics) SLANG_OVERRIDE - { - return Super::getEntryPointMetadata(entryPointIndex, targetIndex, outMetadata, outDiagnostics); - } - - SLANG_NO_THROW SlangResult SLANG_MCALL getTargetMetadata( - SlangInt targetIndex, - slang::IMetadata** outMetadata, - slang::IBlob** outDiagnostics) SLANG_OVERRIDE - { - return Super::getTargetMetadata(targetIndex, outMetadata, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem( - SlangInt entryPointIndex, - SlangInt targetIndex, - ISlangMutableFileSystem** outFileSystem) override - { - return Super::getResultAsFileSystem(entryPointIndex, targetIndex, outFileSystem); - } - - virtual SLANG_NO_THROW void SLANG_MCALL getEntryPointHash( - SlangInt entryPointIndex, - SlangInt targetIndex, - slang::IBlob** outHash) override - { - return Super::getEntryPointHash(entryPointIndex, targetIndex, outHash); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL specialize( - slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, - slang::IComponentType** outSpecializedComponentType, - ISlangBlob** outDiagnostics = nullptr) override - { - return Super::specialize(specializationArgs, specializationArgCount, outSpecializedComponentType, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL link( - slang::IComponentType** outLinkedComponentType, - ISlangBlob** outDiagnostics = nullptr) override - { - return Super::link(outLinkedComponentType, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointHostCallable( - int entryPointIndex, - int targetIndex, - ISlangSharedLibrary** outSharedLibrary, - slang::IBlob** outDiagnostics = 0) override - { - return Super::getEntryPointHostCallable(entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL renameEntryPoint( - const char* newName, IComponentType** outEntryPoint) override - { - return Super::renameEntryPoint(newName, outEntryPoint); - } - - virtual SLANG_NO_THROW SlangResult SLANG_MCALL linkWithOptions( - IComponentType** outLinkedComponentType, - uint32_t compilerOptionEntryCount, - slang::CompilerOptionEntry* compilerOptionEntries, - ISlangBlob** outDiagnostics = nullptr) override - { - return Super::linkWithOptions(outLinkedComponentType, compilerOptionEntryCount, compilerOptionEntries, outDiagnostics); - } - - slang::ITypeConformance* getActualTypeConformance() const { return m_actualTypeConformance; } - - protected: - virtual ApiClassId getClassId() override - { - return ApiClassId::Class_ITypeConformance; - } - - virtual SessionRecorder* getSessionRecorder() override - { - return m_sessionRecorder; - } - private: - SessionRecorder* m_sessionRecorder = nullptr; - Slang::ComPtr<slang::ITypeConformance> m_actualTypeConformance; - uint64_t m_typeConformanceHandle = 0; - RecordManager* m_recordManager = nullptr; - }; -} + return Super::linkWithOptions( + outLinkedComponentType, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnostics); + } + + slang::ITypeConformance* getActualTypeConformance() const { return m_actualTypeConformance; } + +protected: + virtual ApiClassId getClassId() override { return ApiClassId::Class_ITypeConformance; } + + virtual SessionRecorder* getSessionRecorder() override { return m_sessionRecorder; } + +private: + SessionRecorder* m_sessionRecorder = nullptr; + Slang::ComPtr<slang::ITypeConformance> m_actualTypeConformance; + uint64_t m_typeConformanceHandle = 0; + RecordManager* m_recordManager = nullptr; +}; +} // namespace SlangRecord #endif // SLANG_TYPE_CONFORMANCE_H diff --git a/source/slang-record-replay/replay/decoder-consumer.h b/source/slang-record-replay/replay/decoder-consumer.h index d1039d867..31c10bdab 100644 --- a/source/slang-record-replay/replay/decoder-consumer.h +++ b/source/slang-record-replay/replay/decoder-consumer.h @@ -1,179 +1,464 @@ #ifndef DECODER_CONSUMER_H #define DECODER_CONSUMER_H -#include "slang.h" #include "../../core/slang-stream.h" #include "../util/record-format.h" #include "../util/record-utility.h" +#include "slang.h" namespace SlangRecord { - class IDecoderConsumer +class IDecoderConsumer +{ +public: + virtual void CreateGlobalSession(ObjectID outGlobalSessionId) = 0; + virtual void IGlobalSession_createSession( + ObjectID objectId, + slang::SessionDesc const& desc, + ObjectID outSessionId) = 0; + virtual void IGlobalSession_findProfile(ObjectID objectId, char const* name) = 0; + virtual void IGlobalSession_setDownstreamCompilerPath( + ObjectID objectId, + SlangPassThrough passThrough, + char const* path) = 0; + virtual void IGlobalSession_setDownstreamCompilerPrelude( + ObjectID objectId, + SlangPassThrough inPassThrough, + char const* prelude) = 0; + virtual void IGlobalSession_getDownstreamCompilerPrelude( + ObjectID objectId, + SlangPassThrough inPassThrough, + ObjectID outPreludeId) = 0; + + virtual void IGlobalSession_getBuildTagString(ObjectID objectId) { (void)objectId; } + + virtual void IGlobalSession_setDefaultDownstreamCompiler( + ObjectID objectId, + SlangSourceLanguage sourceLanguage, + SlangPassThrough defaultCompiler) = 0; + virtual void IGlobalSession_getDefaultDownstreamCompiler( + ObjectID objectId, + SlangSourceLanguage sourceLanguage) = 0; + virtual void IGlobalSession_setLanguagePrelude( + ObjectID objectId, + SlangSourceLanguage inSourceLanguage, + char const* prelude) = 0; + virtual void IGlobalSession_getLanguagePrelude( + ObjectID objectId, + SlangSourceLanguage inSourceLanguage, + ObjectID outPreludeId) = 0; + virtual void IGlobalSession_createCompileRequest( + ObjectID objectId, + ObjectID outCompileRequest) = 0; + virtual void IGlobalSession_addBuiltins( + ObjectID objectId, + char const* sourcePath, + char const* sourceString) = 0; + virtual void IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ObjectID loaderId) = 0; + virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) = 0; + virtual void IGlobalSession_checkCompileTargetSupport( + ObjectID objectId, + SlangCompileTarget target) = 0; + virtual void IGlobalSession_checkPassThroughSupport( + ObjectID objectId, + SlangPassThrough passThrough) = 0; + virtual void IGlobalSession_compileCoreModule( + ObjectID objectId, + slang::CompileCoreModuleFlags flags) = 0; + virtual void IGlobalSession_loadCoreModule( + ObjectID objectId, + const void* coreModule, + size_t coreModuleSizeInBytes) = 0; + virtual void IGlobalSession_saveCoreModule( + ObjectID objectId, + SlangArchiveType archiveType, + ObjectID outBlobId) = 0; + virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name) = 0; + virtual void IGlobalSession_setDownstreamCompilerForTransition( + ObjectID objectId, + SlangCompileTarget source, + SlangCompileTarget target, + SlangPassThrough compiler) = 0; + virtual void IGlobalSession_getDownstreamCompilerForTransition( + ObjectID objectId, + SlangCompileTarget source, + SlangCompileTarget target) = 0; + + virtual void IGlobalSession_getCompilerElapsedTime(ObjectID objectId) { (void)objectId; } + + virtual void IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, char const* jsonPath) = 0; + virtual void IGlobalSession_parseCommandLineArguments( + ObjectID objectId, + int argc, + const char* const* argv, + ObjectID outSessionDescId, + ObjectID outAllocationId) = 0; + virtual void IGlobalSession_getSessionDescDigest( + ObjectID objectId, + slang::SessionDesc* sessionDesc, + ObjectID outBlobId) = 0; + + // ISession + virtual void ISession_getGlobalSession(ObjectID objectId, ObjectID outGlobalSessionId) = 0; + virtual void ISession_loadModule( + ObjectID objectId, + const char* moduleName, + ObjectID outDiagnostics, + ObjectID outModuleId) = 0; + + virtual void ISession_loadModuleFromIRBlob( + ObjectID objectId, + const char* moduleName, + const char* path, + slang::IBlob* source, + ObjectID outDiagnosticsId, + ObjectID outModuleId) = 0; + virtual void ISession_loadModuleFromSource( + ObjectID objectId, + const char* moduleName, + const char* path, + slang::IBlob* source, + ObjectID outDiagnosticsId, + ObjectID outModuleId) = 0; + virtual void ISession_loadModuleFromSourceString( + ObjectID objectId, + const char* moduleName, + const char* path, + const char* string, + ObjectID outDiagnosticsId, + ObjectID outModuleId) = 0; + virtual void ISession_createCompositeComponentType( + ObjectID objectId, + ObjectID* componentTypeIds, + SlangInt componentTypeCount, + ObjectID outCompositeComponentTypeIds, + ObjectID outDiagnosticsId) = 0; + + virtual void ISession_specializeType( + ObjectID objectId, + ObjectID typeId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outDiagnosticsId, + ObjectID outTypeReflectionId) = 0; + + virtual void ISession_getTypeLayout( + ObjectID objectId, + ObjectID typeId, + SlangInt targetIndex, + slang::LayoutRules rules, + ObjectID outDiagnosticsId, + ObjectID outTypeLayoutReflection) = 0; + + virtual void ISession_getContainerType( + ObjectID objectId, + ObjectID elementType, + slang::ContainerType containerType, + ObjectID outDiagnosticsId, + ObjectID outTypeReflectionId) = 0; + + virtual void ISession_getDynamicType(ObjectID objectId, ObjectID outTypeReflectionId) = 0; + + virtual void ISession_getTypeRTTIMangledName( + ObjectID objectId, + ObjectID typeId, + ObjectID outNameBlobId) = 0; + + virtual void ISession_getTypeConformanceWitnessMangledName( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + ObjectID outNameBlobId) = 0; + + virtual void ISession_getTypeConformanceWitnessSequentialID( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + uint32_t outId) = 0; + + virtual void ISession_createTypeConformanceComponentType( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + ObjectID outConformanceId, + SlangInt conformanceIdOverride, + ObjectID outDiagnosticsId) = 0; + + virtual void ISession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequestId) = 0; + + virtual void ISession_getLoadedModuleCount(ObjectID objectId) { (void)objectId; } + + virtual void ISession_getLoadedModule( + ObjectID objectId, + SlangInt index, + ObjectID outModuleId) = 0; + + virtual void ISession_isBinaryModuleUpToDate(ObjectID objectId) { (void)objectId; } + + // IModule + virtual void IModule_findEntryPointByName( + ObjectID objectId, + char const* name, + ObjectID outEntryPointId) = 0; + + virtual void IModule_getDefinedEntryPointCount(ObjectID objectId) { (void)objectId; } + + virtual void IModule_getDefinedEntryPoint( + ObjectID objectId, + SlangInt32 index, + ObjectID outEntryPointId) = 0; + virtual void IModule_serialize(ObjectID objectId, ObjectID outSerializedBlobId) = 0; + virtual void IModule_writeToFile(ObjectID objectId, char const* fileName) = 0; + + virtual void IModule_getName(ObjectID objectId) { (void)objectId; } + virtual void IModule_getFilePath(ObjectID objectId) { (void)objectId; } + virtual void IModule_getUniqueIdentity(ObjectID objectId) { (void)objectId; } + + virtual void IModule_findAndCheckEntryPoint( + ObjectID objectId, + char const* name, + SlangStage stage, + ObjectID outEntryPointId, + ObjectID outDiagnostics) = 0; + + virtual void IModule_getSession(ObjectID objectId, ObjectID outSessionId) = 0; + virtual void IModule_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) = 0; + + virtual void IModule_getSpecializationParamCount(ObjectID objectId) { (void)objectId; } + + virtual void IModule_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) = 0; + virtual void IModule_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) = 0; + virtual void IModule_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) = 0; + virtual void IModule_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) = 0; + virtual void IModule_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) = 0; + virtual void IModule_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) = 0; + virtual void IModule_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) = 0; + virtual void IModule_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) = 0; + virtual void IModule_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) = 0; + + // IEntryPoint + virtual void IEntryPoint_getSession(ObjectID objectId, ObjectID outSessionId) = 0; + virtual void IEntryPoint_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) = 0; + + virtual void IEntryPoint_getSpecializationParamCount(ObjectID objectId) { (void)objectId; }; + + virtual void IEntryPoint_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) = 0; + virtual void IEntryPoint_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) = 0; + virtual void IEntryPoint_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) = 0; + virtual void IEntryPoint_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) = 0; + virtual void IEntryPoint_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) = 0; + virtual void IEntryPoint_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) = 0; + virtual void IEntryPoint_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) = 0; + virtual void IEntryPoint_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) = 0; + virtual void IEntryPoint_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) = 0; + + // ICompositeComponentType + virtual void ICompositeComponentType_getSession(ObjectID objectId, ObjectID outSessionId) = 0; + virtual void ICompositeComponentType_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) = 0; + + virtual void ICompositeComponentType_getSpecializationParamCount(ObjectID objectId) { - public: - virtual void CreateGlobalSession(ObjectID outGlobalSessionId) = 0; - virtual void IGlobalSession_createSession(ObjectID objectId, slang::SessionDesc const& desc, ObjectID outSessionId) = 0; - virtual void IGlobalSession_findProfile(ObjectID objectId, char const* name) = 0; - virtual void IGlobalSession_setDownstreamCompilerPath(ObjectID objectId, SlangPassThrough passThrough, char const* path) = 0; - virtual void IGlobalSession_setDownstreamCompilerPrelude(ObjectID objectId, SlangPassThrough inPassThrough, char const* prelude) = 0; - virtual void IGlobalSession_getDownstreamCompilerPrelude(ObjectID objectId, SlangPassThrough inPassThrough, ObjectID outPreludeId) = 0; - - virtual void IGlobalSession_getBuildTagString(ObjectID objectId) { (void) objectId; } - - virtual void IGlobalSession_setDefaultDownstreamCompiler(ObjectID objectId, SlangSourceLanguage sourceLanguage, SlangPassThrough defaultCompiler) = 0; - virtual void IGlobalSession_getDefaultDownstreamCompiler(ObjectID objectId, SlangSourceLanguage sourceLanguage) = 0; - virtual void IGlobalSession_setLanguagePrelude(ObjectID objectId, SlangSourceLanguage inSourceLanguage, char const* prelude) = 0; - virtual void IGlobalSession_getLanguagePrelude(ObjectID objectId, SlangSourceLanguage inSourceLanguage, ObjectID outPreludeId) = 0; - virtual void IGlobalSession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequest) = 0; - virtual void IGlobalSession_addBuiltins(ObjectID objectId, char const* sourcePath, char const* sourceString) = 0; - virtual void IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ObjectID loaderId) = 0; - virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) = 0; - virtual void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, SlangCompileTarget target) = 0; - virtual void IGlobalSession_checkPassThroughSupport(ObjectID objectId, SlangPassThrough passThrough) = 0; - virtual void IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) = 0; - virtual void IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) = 0; - virtual void IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) = 0; - virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name) = 0; - virtual void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) = 0; - virtual void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target) = 0; - - virtual void IGlobalSession_getCompilerElapsedTime(ObjectID objectId) { (void) objectId; } - - virtual void IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, char const* jsonPath) = 0; - virtual void IGlobalSession_parseCommandLineArguments(ObjectID objectId, int argc, const char* const* argv, ObjectID outSessionDescId, ObjectID outAllocationId) = 0; - virtual void IGlobalSession_getSessionDescDigest(ObjectID objectId, slang::SessionDesc* sessionDesc, ObjectID outBlobId) = 0; - - // ISession - virtual void ISession_getGlobalSession(ObjectID objectId, ObjectID outGlobalSessionId) = 0; - virtual void ISession_loadModule(ObjectID objectId, const char* moduleName, ObjectID outDiagnostics, ObjectID outModuleId) = 0; - - virtual void ISession_loadModuleFromIRBlob(ObjectID objectId, const char* moduleName, - const char* path, slang::IBlob* source, ObjectID outDiagnosticsId, ObjectID outModuleId) = 0; - virtual void ISession_loadModuleFromSource(ObjectID objectId, const char* moduleName, - const char* path, slang::IBlob* source, ObjectID outDiagnosticsId, ObjectID outModuleId) = 0; - virtual void ISession_loadModuleFromSourceString(ObjectID objectId, const char* moduleName, - const char* path, const char* string, ObjectID outDiagnosticsId, ObjectID outModuleId) = 0; - virtual void ISession_createCompositeComponentType(ObjectID objectId, ObjectID* componentTypeIds, - SlangInt componentTypeCount, ObjectID outCompositeComponentTypeIds, ObjectID outDiagnosticsId) = 0; - - virtual void ISession_specializeType(ObjectID objectId, ObjectID typeId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outDiagnosticsId, ObjectID outTypeReflectionId) = 0; - - virtual void ISession_getTypeLayout(ObjectID objectId, ObjectID typeId, SlangInt targetIndex, - slang::LayoutRules rules, ObjectID outDiagnosticsId, ObjectID outTypeLayoutReflection) = 0; - - virtual void ISession_getContainerType(ObjectID objectId, ObjectID elementType, - slang::ContainerType containerType, ObjectID outDiagnosticsId, ObjectID outTypeReflectionId) = 0; - - virtual void ISession_getDynamicType(ObjectID objectId, ObjectID outTypeReflectionId) = 0; - - virtual void ISession_getTypeRTTIMangledName(ObjectID objectId, ObjectID typeId, ObjectID outNameBlobId) = 0; - - virtual void ISession_getTypeConformanceWitnessMangledName(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, ObjectID outNameBlobId) = 0; - - virtual void ISession_getTypeConformanceWitnessSequentialID(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, uint32_t outId) = 0; - - virtual void ISession_createTypeConformanceComponentType(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, ObjectID outConformanceId, - SlangInt conformanceIdOverride, ObjectID outDiagnosticsId) = 0; - - virtual void ISession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequestId) = 0; - - virtual void ISession_getLoadedModuleCount(ObjectID objectId) { (void) objectId; } - - virtual void ISession_getLoadedModule(ObjectID objectId, SlangInt index, ObjectID outModuleId) = 0; - - virtual void ISession_isBinaryModuleUpToDate(ObjectID objectId) { (void) objectId; } - - // IModule - virtual void IModule_findEntryPointByName(ObjectID objectId, char const* name, ObjectID outEntryPointId) = 0; - - virtual void IModule_getDefinedEntryPointCount(ObjectID objectId) { (void) objectId; } - - virtual void IModule_getDefinedEntryPoint(ObjectID objectId, SlangInt32 index, ObjectID outEntryPointId) = 0; - virtual void IModule_serialize(ObjectID objectId, ObjectID outSerializedBlobId) = 0; - virtual void IModule_writeToFile(ObjectID objectId, char const* fileName) = 0; - - virtual void IModule_getName(ObjectID objectId) { (void) objectId; } - virtual void IModule_getFilePath(ObjectID objectId) { (void) objectId; } - virtual void IModule_getUniqueIdentity(ObjectID objectId) { (void) objectId; } - - virtual void IModule_findAndCheckEntryPoint(ObjectID objectId, char const* name, SlangStage stage, ObjectID outEntryPointId, ObjectID outDiagnostics) = 0; - - virtual void IModule_getSession(ObjectID objectId, ObjectID outSessionId) = 0; - virtual void IModule_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) = 0; - - virtual void IModule_getSpecializationParamCount(ObjectID objectId) { (void) objectId; } - - virtual void IModule_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) = 0; - virtual void IModule_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) = 0; - virtual void IModule_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) = 0; - virtual void IModule_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) = 0; - virtual void IModule_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) = 0; - virtual void IModule_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) = 0; - virtual void IModule_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) = 0; - virtual void IModule_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) = 0; - virtual void IModule_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) = 0; - - // IEntryPoint - virtual void IEntryPoint_getSession(ObjectID objectId, ObjectID outSessionId) = 0; - virtual void IEntryPoint_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) = 0; - - virtual void IEntryPoint_getSpecializationParamCount(ObjectID objectId) { (void) objectId; }; - - virtual void IEntryPoint_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) = 0; - virtual void IEntryPoint_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) = 0; - virtual void IEntryPoint_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) = 0; - virtual void IEntryPoint_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) = 0; - virtual void IEntryPoint_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) = 0; - virtual void IEntryPoint_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) = 0; - virtual void IEntryPoint_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) = 0; - virtual void IEntryPoint_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) = 0; - virtual void IEntryPoint_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) = 0; - - // ICompositeComponentType - virtual void ICompositeComponentType_getSession(ObjectID objectId, ObjectID outSessionId) = 0; - virtual void ICompositeComponentType_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) = 0; - - virtual void ICompositeComponentType_getSpecializationParamCount(ObjectID objectId) { (void) objectId; }; - - virtual void ICompositeComponentType_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) = 0; - virtual void ICompositeComponentType_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) = 0; - virtual void ICompositeComponentType_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) = 0; - virtual void ICompositeComponentType_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) = 0; - virtual void ICompositeComponentType_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) = 0; - virtual void ICompositeComponentType_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) = 0; - virtual void ICompositeComponentType_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) = 0; - virtual void ICompositeComponentType_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) = 0; - virtual void ICompositeComponentType_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) = 0; - - // ITypeConformance - virtual void ITypeConformance_getSession(ObjectID objectId, ObjectID outSessionId) = 0; - virtual void ITypeConformance_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) = 0; + (void)objectId; + }; - virtual void ITypeConformance_getSpecializationParamCount(ObjectID objectId) { (void) objectId; }; - - virtual void ITypeConformance_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) = 0; - virtual void ITypeConformance_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) = 0; - virtual void ITypeConformance_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) = 0; - virtual void ITypeConformance_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) = 0; - virtual void ITypeConformance_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) = 0; - virtual void ITypeConformance_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) = 0; - virtual void ITypeConformance_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) = 0; - virtual void ITypeConformance_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) = 0; - virtual void ITypeConformance_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) = 0; + virtual void ICompositeComponentType_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) = 0; + virtual void ICompositeComponentType_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) = 0; + virtual void ICompositeComponentType_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) = 0; + virtual void ICompositeComponentType_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) = 0; + virtual void ICompositeComponentType_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) = 0; + virtual void ICompositeComponentType_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) = 0; + virtual void ICompositeComponentType_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) = 0; + virtual void ICompositeComponentType_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) = 0; + virtual void ICompositeComponentType_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) = 0; + + // ITypeConformance + virtual void ITypeConformance_getSession(ObjectID objectId, ObjectID outSessionId) = 0; + virtual void ITypeConformance_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) = 0; + + virtual void ITypeConformance_getSpecializationParamCount(ObjectID objectId) + { + (void)objectId; }; -} + + virtual void ITypeConformance_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) = 0; + virtual void ITypeConformance_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) = 0; + virtual void ITypeConformance_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) = 0; + virtual void ITypeConformance_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) = 0; + virtual void ITypeConformance_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) = 0; + virtual void ITypeConformance_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) = 0; + virtual void ITypeConformance_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) = 0; + virtual void ITypeConformance_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) = 0; + virtual void ITypeConformance_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) = 0; +}; +} // namespace SlangRecord #endif // DECODER_CONSUMER_H diff --git a/source/slang-record-replay/replay/decoder-helper.cpp b/source/slang-record-replay/replay/decoder-helper.cpp index c9252bbc6..0c8240617 100644 --- a/source/slang-record-replay/replay/decoder-helper.cpp +++ b/source/slang-record-replay/replay/decoder-helper.cpp @@ -1,60 +1,63 @@ -#include <cstdlib> -#include <vector> #include "decoder-helper.h" + #include "parameter-decoder.h" +#include <cstdlib> +#include <vector> + namespace SlangRecord { - DecoderAllocatorSingleton* DecoderAllocatorSingleton::getInstance() - { - thread_local DecoderAllocatorSingleton instance; - return &instance; - } - - void* DecoderAllocatorSingleton::allocate(size_t size) - { - void* data = calloc(1, size); - - if (!data) - { - slangRecordLog(LogLevel::Error, "Failed to allocate memory\n"); - std::abort(); - } +DecoderAllocatorSingleton* DecoderAllocatorSingleton::getInstance() +{ + thread_local DecoderAllocatorSingleton instance; + return &instance; +} - m_allocations.add(data); - return data; - } +void* DecoderAllocatorSingleton::allocate(size_t size) +{ + void* data = calloc(1, size); - DecoderAllocatorSingleton::~DecoderAllocatorSingleton() + if (!data) { - for (auto allocation : m_allocations) - { - free(allocation); - } + slangRecordLog(LogLevel::Error, "Failed to allocate memory\n"); + std::abort(); } - template <typename T, typename U> - size_t StructDecoder<T, U>::decode(const uint8_t* buffer, int64_t bufferSize) + m_allocations.add(data); + return data; +} + +DecoderAllocatorSingleton::~DecoderAllocatorSingleton() +{ + for (auto allocation : m_allocations) { - return ParameterDecoder::decodeStruct(buffer, bufferSize, *this); + free(allocation); } +} - size_t BlobDecoder::decode(const uint8_t* buffer, int64_t bufferSize) +template<typename T, typename U> +size_t StructDecoder<T, U>::decode(const uint8_t* buffer, int64_t bufferSize) +{ + return ParameterDecoder::decodeStruct(buffer, bufferSize, *this); +} + +size_t BlobDecoder::decode(const uint8_t* buffer, int64_t bufferSize) +{ + size_t readByte = 0; + readByte = ParameterDecoder::decodeAddress(buffer, bufferSize, m_address); + + if (!m_address) { - size_t readByte = 0; - readByte = ParameterDecoder::decodeAddress(buffer, bufferSize, m_address); - - if (!m_address) - { - readByte += ParameterDecoder::decodePointer(buffer + readByte, bufferSize - readByte, m_blobData); - } - return readByte; + readByte += + ParameterDecoder::decodePointer(buffer + readByte, bufferSize - readByte, m_blobData); } - - template class StructDecoder<slang::SessionDesc>; - template class StructDecoder<slang::PreprocessorMacroDesc>; - template class StructDecoder<slang::CompilerOptionEntry>; - template class StructDecoder<slang::CompilerOptionValue>; - template class StructDecoder<slang::TargetDesc>; - template class StructDecoder<slang::SpecializationArg>; + return readByte; } + +template class StructDecoder<slang::SessionDesc>; +template class StructDecoder<slang::PreprocessorMacroDesc>; +template class StructDecoder<slang::CompilerOptionEntry>; +template class StructDecoder<slang::CompilerOptionValue>; +template class StructDecoder<slang::TargetDesc>; +template class StructDecoder<slang::SpecializationArg>; +} // namespace SlangRecord diff --git a/source/slang-record-replay/replay/decoder-helper.h b/source/slang-record-replay/replay/decoder-helper.h index c109348e9..f3f1c17f0 100644 --- a/source/slang-record-replay/replay/decoder-helper.h +++ b/source/slang-record-replay/replay/decoder-helper.h @@ -1,109 +1,125 @@ #ifndef SLANG_DECODER_HELPER_H #define SLANG_DECODER_HELPER_H -#include <stdint.h> -#include "slang.h" -#include "slang-com-helper.h" -#include "../util/record-format.h" #include "../../core/slang-list.h" +#include "../util/record-format.h" +#include "slang-com-helper.h" +#include "slang.h" -namespace SlangRecord { +#include <stdint.h> - // This class is used to allocate memory for the type decoder - class DecoderAllocatorSingleton - { - public: - static DecoderAllocatorSingleton* getInstance(); - void* allocate(size_t size); - ~DecoderAllocatorSingleton(); - private: - DecoderAllocatorSingleton() = default; - Slang::List<void*> m_allocations; - }; +namespace SlangRecord +{ - class DecoderBase - { - public: - virtual ~DecoderBase() = default; - void* allocate(size_t size) { return m_allocator->allocate(size); } - protected: - DecoderAllocatorSingleton* m_allocator = DecoderAllocatorSingleton::getInstance(); - }; +// This class is used to allocate memory for the type decoder +class DecoderAllocatorSingleton +{ +public: + static DecoderAllocatorSingleton* getInstance(); + void* allocate(size_t size); + ~DecoderAllocatorSingleton(); - // We don't allow pointer type to be used as a template parameter - template <typename T, typename U = typename std::enable_if< !std::is_pointer<T>::value >::type> - class ValueDecoder : public DecoderBase - { - public: - T& getValue() { return m_value;} +private: + DecoderAllocatorSingleton() = default; + Slang::List<void*> m_allocations; +}; - protected: - T m_value {}; - }; +class DecoderBase +{ +public: + virtual ~DecoderBase() = default; + void* allocate(size_t size) { return m_allocator->allocate(size); } - template <typename T, typename = typename std::enable_if< !std::is_pointer<T>::value >::type> - class StructDecoder : public ValueDecoder<T> - { - public: - using Super = ValueDecoder<T>; - size_t decode(const uint8_t* buffer, int64_t bufferSize); - }; +protected: + DecoderAllocatorSingleton* m_allocator = DecoderAllocatorSingleton::getInstance(); +}; - // We only allow pointer type to be used as a template parameter - template <typename T, typename U = typename std::enable_if< std::is_pointer<T>::value >::type> - class PointerDecoder : public DecoderBase - { - public: - void setPointer(void* data) { m_pointer = static_cast<T>(data); } - T getPointer() const { return m_pointer; } - void setPointerAddress(uint64_t address) { m_pointerAddress = address; } - void setDataSize(size_t size) { m_dataSize = size; } - size_t getDataSize() const { return m_dataSize; } - private: - T m_pointer {nullptr}; - uint64_t m_pointerAddress = 0; - size_t m_dataSize = 0; - }; +// We don't allow pointer type to be used as a template parameter +template<typename T, typename U = typename std::enable_if<!std::is_pointer<T>::value>::type> +class ValueDecoder : public DecoderBase +{ +public: + T& getValue() { return m_value; } - class BlobDecoder - { - private: - PointerDecoder<void*> m_blobData; +protected: + T m_value{}; +}; + +template<typename T, typename = typename std::enable_if<!std::is_pointer<T>::value>::type> +class StructDecoder : public ValueDecoder<T> +{ +public: + using Super = ValueDecoder<T>; + size_t decode(const uint8_t* buffer, int64_t bufferSize); +}; + +// We only allow pointer type to be used as a template parameter +template<typename T, typename U = typename std::enable_if<std::is_pointer<T>::value>::type> +class PointerDecoder : public DecoderBase +{ +public: + void setPointer(void* data) { m_pointer = static_cast<T>(data); } + T getPointer() const { return m_pointer; } + void setPointerAddress(uint64_t address) { m_pointerAddress = address; } + void setDataSize(size_t size) { m_dataSize = size; } + size_t getDataSize() const { return m_dataSize; } + +private: + T m_pointer{nullptr}; + uint64_t m_pointerAddress = 0; + size_t m_dataSize = 0; +}; - class BlobImpl : public slang::IBlob +class BlobDecoder +{ +private: + PointerDecoder<void*> m_blobData; + + class BlobImpl : public slang::IBlob + { + public: + // ISlangUnknown + virtual SlangResult SLANG_MCALL + queryInterface(SlangUUID const& uuid, void** outObject) override { - public: - // ISlangUnknown - virtual SlangResult SLANG_MCALL queryInterface(SlangUUID const& uuid, void** outObject) override + if (uuid == ISlangUnknown::getTypeGuid() || uuid == ISlangBlob::getTypeGuid()) { - if (uuid == ISlangUnknown::getTypeGuid() || - uuid == ISlangBlob::getTypeGuid()) - { - *outObject = static_cast<ISlangBlob*>(this); - return SLANG_OK; - } - *outObject = nullptr; - return SLANG_E_NO_INTERFACE; + *outObject = static_cast<ISlangBlob*>(this); + return SLANG_OK; } + *outObject = nullptr; + return SLANG_E_NO_INTERFACE; + } - virtual uint32_t SLANG_MCALL addRef() override { return 1; } - virtual uint32_t SLANG_MCALL release() override { return 1; } + virtual uint32_t SLANG_MCALL addRef() override { return 1; } + virtual uint32_t SLANG_MCALL release() override { return 1; } - BlobImpl(const PointerDecoder<void*>* blobData) : m_pBlobData(blobData) {} - virtual const void* SLANG_MCALL getBufferPointer() SLANG_OVERRIDE { return m_pBlobData->getPointer();} - virtual size_t SLANG_MCALL getBufferSize() SLANG_OVERRIDE { return m_pBlobData->getDataSize(); } - private: - const PointerDecoder<void*>* m_pBlobData; - }; + BlobImpl(const PointerDecoder<void*>* blobData) + : m_pBlobData(blobData) + { + } + virtual const void* SLANG_MCALL getBufferPointer() SLANG_OVERRIDE + { + return m_pBlobData->getPointer(); + } + virtual size_t SLANG_MCALL getBufferSize() SLANG_OVERRIDE + { + return m_pBlobData->getDataSize(); + } - BlobImpl m_blobImpl {&m_blobData}; - AddressFormat m_address {0}; - public: - size_t decode(const uint8_t* buffer, int64_t bufferSize); - slang::IBlob* getBlob() { return &m_blobImpl; } + private: + const PointerDecoder<void*>* m_pBlobData; }; - using StringDecoder = PointerDecoder<char*>; + BlobImpl m_blobImpl{&m_blobData}; + AddressFormat m_address{0}; + +public: + size_t decode(const uint8_t* buffer, int64_t bufferSize); + slang::IBlob* getBlob() { return &m_blobImpl; } +}; + +using StringDecoder = PointerDecoder<char*>; } // namespace SlangRecord #endif // SLANG_RECORD_DECODER_HELPER_H diff --git a/source/slang-record-replay/replay/json-consumer.cpp b/source/slang-record-replay/replay/json-consumer.cpp index 21fd45807..45d23667b 100644 --- a/source/slang-record-replay/replay/json-consumer.cpp +++ b/source/slang-record-replay/replay/json-consumer.cpp @@ -1,1095 +1,1730 @@ -#include "slang.h" #include "json-consumer.h" -#include "../util/record-utility.h" -#include "../util/emum-to-string.h" -#include "../../core/slang-string-util.h" + #include "../../core/slang-io.h" +#include "../../core/slang-string-util.h" +#include "../util/emum-to-string.h" +#include "../util/record-utility.h" +#include "slang.h" namespace SlangRecord { -#define SANITY_CHECK() if (!m_isFileValid) return +#define SANITY_CHECK() \ + if (!m_isFileValid) \ + return - static inline void _writeIndent(Slang::StringBuilder& builder, int indent) +static inline void _writeIndent(Slang::StringBuilder& builder, int indent) +{ + for (int i = 0; i < indent; i++) { - for (int i = 0; i < indent; i++) - { - builder << " "; - } + builder << " "; } +} - template <typename T> - static inline void _writeString(Slang::StringBuilder& builder, int indent, T const& str) - { - _writeIndent(builder, indent); - builder << str; - } +template<typename T> +static inline void _writeString(Slang::StringBuilder& builder, int indent, T const& str) +{ + _writeIndent(builder, indent); + builder << str; +} + +template<typename T, typename U> +static inline void _writePair( + Slang::StringBuilder& builder, + int indent, + T const& name, + U const& value) +{ + _writeIndent(builder, indent); + builder << name << ": " << value << ",\n"; +} + +template<typename T, typename U> +static inline void _writePairNoComma( + Slang::StringBuilder& builder, + int indent, + T const& name, + U const& value) +{ + _writeIndent(builder, indent); + builder << name << ": " << value << "\n"; +} - template <typename T, typename U> - static inline void _writePair(Slang::StringBuilder& builder, int indent, T const& name, U const& value) +class ScopeWritterForKey +{ +public: + ScopeWritterForKey( + Slang::StringBuilder* pBuilder, + int* pIndent, + Slang::String const& keyName, + bool isOutterScope = true) + : m_pBuilder(pBuilder), m_pIndent(pIndent), m_isOutterScope(isOutterScope) { - _writeIndent(builder, indent); - builder << name << ": " << value << ",\n"; + _writeString((*m_pBuilder), (*m_pIndent), keyName + ": {\n"); + (*m_pIndent)++; } - template <typename T, typename U> - static inline void _writePairNoComma(Slang::StringBuilder& builder, int indent, T const& name, U const& value) + ~ScopeWritterForKey() { - _writeIndent(builder, indent); - builder << name << ": " << value << "\n"; - } + (*m_pIndent)--; - class ScopeWritterForKey - { - public: - ScopeWritterForKey(Slang::StringBuilder* pBuilder, int* pIndent, Slang::String const& keyName, bool isOutterScope = true) - : m_pBuilder(pBuilder) - , m_pIndent(pIndent) - , m_isOutterScope(isOutterScope) - { - _writeString((*m_pBuilder), (*m_pIndent), keyName + ": {\n"); - (*m_pIndent)++; - } + if (m_isOutterScope) + _writeString((*m_pBuilder), (*m_pIndent), "}\n"); + else + _writeString((*m_pBuilder), (*m_pIndent), "},\n"); + } - ~ScopeWritterForKey() - { - (*m_pIndent)--; +private: + Slang::StringBuilder* m_pBuilder; + int* m_pIndent; + bool m_isOutterScope; +}; - if (m_isOutterScope) - _writeString((*m_pBuilder), (*m_pIndent), "}\n"); - else - _writeString((*m_pBuilder), (*m_pIndent), "},\n"); +void CommonInterfaceWriter::getSession(ObjectID objectId, ObjectID outSessionId) +{ + Slang::StringBuilder builder; + int indent = 0; - } - private: - Slang::StringBuilder* m_pBuilder; - int* m_pIndent; - bool m_isOutterScope; - }; + Slang::String functionName = m_className; + functionName = functionName + "::getSession"; - void CommonInterfaceWriter::getSession(ObjectID objectId, ObjectID outSessionId) { - Slang::StringBuilder builder; - int indent = 0; - - Slang::String functionName = m_className; - functionName = functionName + "::getSession"; - + ScopeWritterForKey scopeWritter(&builder, &indent, functionName); { - ScopeWritterForKey scopeWritter(&builder, &indent, functionName); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "retSession", Slang::StringUtil::makeStringWithFormat("0x%llX", outSessionId)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "retSession", + Slang::StringUtil::makeStringWithFormat("0x%llX", outSessionId)); } - - m_fileStream.write(builder.begin(), builder.getLength()); - m_fileStream.flush(); } - void CommonInterfaceWriter::getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) - { - Slang::StringBuilder builder; - int indent = 0; - - Slang::String functionName = m_className; - functionName = functionName + "::getLayout"; + m_fileStream.write(builder.begin(), builder.getLength()); + m_fileStream.flush(); +} - { - ScopeWritterForKey scopeWritter(&builder, &indent, functionName); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "targetIndex", targetIndex); - _writePair(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); - _writePairNoComma(builder, indent, "retProgramLayout", Slang::StringUtil::makeStringWithFormat("0x%llX", retProgramLayoutId)); - } - } +void CommonInterfaceWriter::getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) +{ + Slang::StringBuilder builder; + int indent = 0; + + Slang::String functionName = m_className; + functionName = functionName + "::getLayout"; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, functionName); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "targetIndex", targetIndex); + _writePair( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + _writePairNoComma( + builder, + indent, + "retProgramLayout", + Slang::StringUtil::makeStringWithFormat("0x%llX", retProgramLayoutId)); + } + } + + m_fileStream.write(builder.begin(), builder.getLength()); + m_fileStream.flush(); +} + +void CommonInterfaceWriter::getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + Slang::StringBuilder builder; + int indent = 0; + + Slang::String functionName = m_className; + functionName = functionName + "::getEntryPointCode"; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, functionName); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "entryPointIndex", entryPointIndex); + _writePair(builder, indent, "targetIndex", targetIndex); + _writePair( + builder, + indent, + "outCode", + Slang::StringUtil::makeStringWithFormat("0x%llX", outCodeId)); + _writePairNoComma( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + } + } + + m_fileStream.write(builder.begin(), builder.getLength()); + m_fileStream.flush(); +} + +void CommonInterfaceWriter::getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + Slang::StringBuilder builder; + int indent = 0; + + Slang::String functionName = m_className; + functionName = functionName + "::getTargetCode"; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, functionName); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "targetIndex", targetIndex); + _writePair( + builder, + indent, + "outCode", + Slang::StringUtil::makeStringWithFormat("0x%llX", outCodeId)); + _writePairNoComma( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + } + } + + m_fileStream.write(builder.begin(), builder.getLength()); + m_fileStream.flush(); +} + +void CommonInterfaceWriter::getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystemId) +{ + Slang::StringBuilder builder; + int indent = 0; - m_fileStream.write(builder.begin(), builder.getLength()); - m_fileStream.flush(); - } + Slang::String functionName = m_className; + functionName = functionName + "::getResultAsFileSystem"; - void CommonInterfaceWriter::getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) { - Slang::StringBuilder builder; - int indent = 0; - - Slang::String functionName = m_className; - functionName = functionName + "::getEntryPointCode"; - + ScopeWritterForKey scopeWritter(&builder, &indent, functionName); { - ScopeWritterForKey scopeWritter(&builder, &indent, functionName); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "entryPointIndex", entryPointIndex); - _writePair(builder, indent, "targetIndex", targetIndex); - _writePair(builder, indent, "outCode", Slang::StringUtil::makeStringWithFormat("0x%llX", outCodeId)); - _writePairNoComma(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "entryPointIndex", entryPointIndex); + _writePair(builder, indent, "targetIndex", targetIndex); + _writePairNoComma( + builder, + indent, + "outFileSystem", + Slang::StringUtil::makeStringWithFormat("0x%llX", outFileSystemId)); } - - m_fileStream.write(builder.begin(), builder.getLength()); - m_fileStream.flush(); } - void CommonInterfaceWriter::getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - Slang::StringBuilder builder; - int indent = 0; - - Slang::String functionName = m_className; - functionName = functionName + "::getTargetCode"; + m_fileStream.write(builder.begin(), builder.getLength()); + m_fileStream.flush(); +} - { - ScopeWritterForKey scopeWritter(&builder, &indent, functionName); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "targetIndex", targetIndex); - _writePair(builder, indent, "outCode", Slang::StringUtil::makeStringWithFormat("0x%llX", outCodeId)); - _writePairNoComma(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); - } - } +void CommonInterfaceWriter::getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) +{ + Slang::StringBuilder builder; + int indent = 0; - m_fileStream.write(builder.begin(), builder.getLength()); - m_fileStream.flush(); - } + Slang::String functionName = m_className; + functionName = functionName + "::getEntryPointHash"; - void CommonInterfaceWriter::getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystemId) { - Slang::StringBuilder builder; - int indent = 0; - - Slang::String functionName = m_className; - functionName = functionName + "::getResultAsFileSystem"; - + ScopeWritterForKey scopeWritter(&builder, &indent, functionName); { - ScopeWritterForKey scopeWritter(&builder, &indent, functionName); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "entryPointIndex", entryPointIndex); - _writePair(builder, indent, "targetIndex", targetIndex); - _writePairNoComma(builder, indent, "outFileSystem", Slang::StringUtil::makeStringWithFormat("0x%llX", outFileSystemId)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "entryPointIndex", entryPointIndex); + _writePair(builder, indent, "targetIndex", targetIndex); + _writePairNoComma( + builder, + indent, + "outHash", + Slang::StringUtil::makeStringWithFormat("0x%llX", outHashId)); } - - m_fileStream.write(builder.begin(), builder.getLength()); - m_fileStream.flush(); } - void CommonInterfaceWriter::getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) - { - Slang::StringBuilder builder; - int indent = 0; - - Slang::String functionName = m_className; - functionName = functionName + "::getEntryPointHash"; + m_fileStream.write(builder.begin(), builder.getLength()); + m_fileStream.flush(); +} - { - ScopeWritterForKey scopeWritter(&builder, &indent, functionName); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "entryPointIndex", entryPointIndex); - _writePair(builder, indent, "targetIndex", targetIndex); - _writePairNoComma(builder, indent, "outHash", Slang::StringUtil::makeStringWithFormat("0x%llX", outHashId)); - } - } +void CommonInterfaceWriter::specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) +{ + Slang::StringBuilder builder; + int indent = 0; - m_fileStream.write(builder.begin(), builder.getLength()); - m_fileStream.flush(); - } + Slang::String functionName = m_className; + functionName = functionName + "::specialize"; - void CommonInterfaceWriter::specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) { - Slang::StringBuilder builder; - int indent = 0; - - Slang::String functionName = m_className; - functionName = functionName + "::specialize"; - + ScopeWritterForKey scopeWritter(&builder, &indent, functionName); { - ScopeWritterForKey scopeWritter(&builder, &indent, functionName); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + if (specializationArgCount) { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - if (specializationArgCount) + ScopeWritterForKey scopeWritterForArgs( + &builder, + &indent, + "specializationArgs", + false); + for (int i = 0; i < specializationArgCount; i++) { - ScopeWritterForKey scopeWritterForArgs(&builder, &indent, "specializationArgs", false); - for(int i = 0; i < specializationArgCount; i++) + bool isLastField = (i == specializationArgCount - 1); + ScopeWritterForKey scopeWritterForArg( + &builder, + &indent, + Slang::StringUtil::makeStringWithFormat("[%d]", i), + isLastField); { - bool isLastField = (i == specializationArgCount - 1); - ScopeWritterForKey scopeWritterForArg(&builder, &indent, Slang::StringUtil::makeStringWithFormat("[%d]", i), isLastField); - { - _writePair(builder, indent, "kind", SpecializationArgKindToString(specializationArgs[i].kind)); - _writePairNoComma(builder, indent, "type", Slang::StringUtil::makeStringWithFormat("0x%llX", specializationArgs[i].type)); - } + _writePair( + builder, + indent, + "kind", + SpecializationArgKindToString(specializationArgs[i].kind)); + _writePairNoComma( + builder, + indent, + "type", + Slang::StringUtil::makeStringWithFormat( + "0x%llX", + specializationArgs[i].type)); } } - else - { - _writePair(builder, indent, "specializationArgs", "nullptr"); - } - _writePair(builder, indent, "specializationArgCount", specializationArgCount); - _writePair(builder, indent, "outSpecializedComponentType", Slang::StringUtil::makeStringWithFormat("0x%llX", outSpecializedComponentTypeId)); - _writePairNoComma(builder, indent, "outSpecializedComponentType", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); } - } - - m_fileStream.write(builder.begin(), builder.getLength()); - m_fileStream.flush(); - } - - void CommonInterfaceWriter::link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) - { - Slang::StringBuilder builder; - int indent = 0; - - Slang::String functionName = m_className; - functionName = functionName + "::link"; - - { - ScopeWritterForKey scopeWritter(&builder, &indent, functionName); + else { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "outLinkedComponentType", Slang::StringUtil::makeStringWithFormat("0x%llX", outLinkedComponentTypeId)); - _writePairNoComma(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + _writePair(builder, indent, "specializationArgs", "nullptr"); } - } - - m_fileStream.write(builder.begin(), builder.getLength()); - m_fileStream.flush(); - } + _writePair(builder, indent, "specializationArgCount", specializationArgCount); + _writePair( + builder, + indent, + "outSpecializedComponentType", + Slang::StringUtil::makeStringWithFormat("0x%llX", outSpecializedComponentTypeId)); + _writePairNoComma( + builder, + indent, + "outSpecializedComponentType", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + } + } + + m_fileStream.write(builder.begin(), builder.getLength()); + m_fileStream.flush(); +} + +void CommonInterfaceWriter::link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) +{ + Slang::StringBuilder builder; + int indent = 0; + + Slang::String functionName = m_className; + functionName = functionName + "::link"; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, functionName); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "outLinkedComponentType", + Slang::StringUtil::makeStringWithFormat("0x%llX", outLinkedComponentTypeId)); + _writePairNoComma( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + } + } + + m_fileStream.write(builder.begin(), builder.getLength()); + m_fileStream.flush(); +} + +void CommonInterfaceWriter::getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibraryId, + ObjectID outDiagnosticsId) +{ + Slang::StringBuilder builder; + int indent = 0; + + Slang::String functionName = m_className; + functionName = functionName + "::getEntryPointHostCallable"; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, functionName); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "entryPointIndex", entryPointIndex); + _writePair(builder, indent, "targetIndex", targetIndex); + _writePair( + builder, + indent, + "outSharedLibrary", + Slang::StringUtil::makeStringWithFormat("0x%llX", outSharedLibraryId)); + _writePairNoComma( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + } + } + + m_fileStream.write(builder.begin(), builder.getLength()); + m_fileStream.flush(); +} + +void CommonInterfaceWriter::renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) +{ + Slang::StringBuilder builder; + int indent = 0; + + Slang::String functionName = m_className; + functionName = functionName + "::renameEntryPoint"; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, functionName); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "newName", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + newName != nullptr ? newName : "nullptr")); + _writePairNoComma( + builder, + indent, + "outEntryPoint", + Slang::StringUtil::makeStringWithFormat("0x%llX", outEntryPointId)); + } + } + + m_fileStream.write(builder.begin(), builder.getLength()); + m_fileStream.flush(); +} + +void CommonInterfaceWriter::linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) +{ - void CommonInterfaceWriter::getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibraryId, - ObjectID outDiagnosticsId) - { - Slang::StringBuilder builder; - int indent = 0; + Slang::StringBuilder builder; + int indent = 0; - Slang::String functionName = m_className; - functionName = functionName + "::getEntryPointHostCallable"; + Slang::String functionName = m_className; + functionName = functionName + "::linkWithOptions"; + { + ScopeWritterForKey scopeWritter(&builder, &indent, functionName); { - ScopeWritterForKey scopeWritter(&builder, &indent, functionName); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "entryPointIndex", entryPointIndex); - _writePair(builder, indent, "targetIndex", targetIndex); - _writePair(builder, indent, "outSharedLibrary", Slang::StringUtil::makeStringWithFormat("0x%llX", outSharedLibraryId)); - _writePairNoComma(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); - } - } - - m_fileStream.write(builder.begin(), builder.getLength()); - m_fileStream.flush(); - } - void CommonInterfaceWriter::renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) - { - Slang::StringBuilder builder; - int indent = 0; + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "compilerOptionEntryCount", compilerOptionEntryCount); - Slang::String functionName = m_className; - functionName = functionName + "::renameEntryPoint"; + JsonConsumer::_writeCompilerOptionEntryHelper( + builder, + indent, + compilerOptionEntries, + compilerOptionEntryCount); - { - ScopeWritterForKey scopeWritter(&builder, &indent, functionName); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "newName", Slang::StringUtil::makeStringWithFormat("\"%s\"", - newName != nullptr ? newName : "nullptr")); - _writePairNoComma(builder, indent, "outEntryPoint", Slang::StringUtil::makeStringWithFormat("0x%llX", outEntryPointId)); - } + _writePair( + builder, + indent, + "outLinkedComponentType", + Slang::StringUtil::makeStringWithFormat("0x%llX", outLinkedComponentTypeId)); + _writePairNoComma( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); } - - m_fileStream.write(builder.begin(), builder.getLength()); - m_fileStream.flush(); } - void CommonInterfaceWriter::linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) - { - - Slang::StringBuilder builder; - int indent = 0; + m_fileStream.write(builder.begin(), builder.getLength()); + m_fileStream.flush(); +} - Slang::String functionName = m_className; - functionName = functionName + "::linkWithOptions"; - - { - ScopeWritterForKey scopeWritter(&builder, &indent, functionName); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "compilerOptionEntryCount", compilerOptionEntryCount); +JsonConsumer::JsonConsumer(const Slang::String& filePath) +{ + if (!Slang::File::exists(Slang::Path::getParentDirectory(filePath))) + { + slangRecordLog( + LogLevel::Error, + "Directory for json file does not exist: %s\n", + filePath.getBuffer()); + } - JsonConsumer::_writeCompilerOptionEntryHelper(builder, indent, compilerOptionEntries, compilerOptionEntryCount); + Slang::FileMode fileMode = Slang::FileMode::Create; + Slang::FileAccess fileAccess = Slang::FileAccess::Write; + Slang::FileShare fileShare = Slang::FileShare::None; - _writePair(builder, indent, "outLinkedComponentType", Slang::StringUtil::makeStringWithFormat("0x%llX", outLinkedComponentTypeId)); - _writePairNoComma(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); - } - } + SlangResult res = m_fileStream.init(filePath, fileMode, fileAccess, fileShare); - m_fileStream.write(builder.begin(), builder.getLength()); - m_fileStream.flush(); + if (res != SLANG_OK) + { + slangRecordLog(LogLevel::Error, "Failed to open file %s\n", filePath.getBuffer()); } + m_isFileValid = true; +} - JsonConsumer::JsonConsumer(const Slang::String& filePath) +void JsonConsumer::_writeCompilerOptionEntryHelper( + Slang::StringBuilder& builder, + int indent, + slang::CompilerOptionEntry* compilerOptionEntries, + uint32_t compilerOptionEntryCount, + bool isLastField) +{ + if (compilerOptionEntryCount) { - if (!Slang::File::exists(Slang::Path::getParentDirectory(filePath))) - { - slangRecordLog(LogLevel::Error, "Directory for json file does not exist: %s\n", filePath.getBuffer()); - } - - Slang::FileMode fileMode = Slang::FileMode::Create; - Slang::FileAccess fileAccess = Slang::FileAccess::Write; - Slang::FileShare fileShare = Slang::FileShare::None; + ScopeWritterForKey scopeWritterForCompilerOptionEntries( + &builder, + &indent, + "compilerOptionEntries", + isLastField); - SlangResult res = m_fileStream.init(filePath, fileMode, fileAccess, fileShare); - - if (res != SLANG_OK) + for (uint32_t j = 0; j < compilerOptionEntryCount; j++) { - slangRecordLog(LogLevel::Error, "Failed to open file %s\n", filePath.getBuffer()); - } - - m_isFileValid = true; - } - - void JsonConsumer::_writeCompilerOptionEntryHelper(Slang::StringBuilder& builder, int indent, slang::CompilerOptionEntry* compilerOptionEntries, uint32_t compilerOptionEntryCount, bool isLastField) - { - if (compilerOptionEntryCount) - { - ScopeWritterForKey scopeWritterForCompilerOptionEntries(&builder, &indent, "compilerOptionEntries", isLastField); - - for (uint32_t j = 0; j < compilerOptionEntryCount; j++) + ScopeWritterForKey scopeWritterForCompileOptionElement( + &builder, + &indent, + Slang::StringUtil::makeStringWithFormat("[%d]\n", j)); { - ScopeWritterForKey scopeWritterForCompileOptionElement(&builder, &indent, Slang::StringUtil::makeStringWithFormat("[%d]\n", j)); + _writePair( + builder, + indent, + "name", + CompilerOptionNameToString(compilerOptionEntries[j].name)); + + bool isLastEntry = (j == compilerOptionEntryCount - 1); + ScopeWritterForKey scopeWritterValue(&builder, &indent, "value", isLastEntry); { - _writePair(builder, indent, "name", CompilerOptionNameToString(compilerOptionEntries[j].name)); - - bool isLastEntry = (j == compilerOptionEntryCount - 1); - ScopeWritterForKey scopeWritterValue(&builder, &indent, "value", isLastEntry); - { - _writePair(builder, indent, "kind", CompilerOptionValueKindToString(compilerOptionEntries[j].value.kind)); - _writePair(builder, indent, "intValue0", compilerOptionEntries[j].value.intValue0); - _writePair(builder, indent, "intValue1", compilerOptionEntries[j].value.intValue1); - _writePair(builder, indent, "stringValue0", compilerOptionEntries[j].value.stringValue0); - _writePairNoComma(builder, indent, "stringValue1", compilerOptionEntries[j].value.stringValue1); - } + _writePair( + builder, + indent, + "kind", + CompilerOptionValueKindToString(compilerOptionEntries[j].value.kind)); + _writePair( + builder, + indent, + "intValue0", + compilerOptionEntries[j].value.intValue0); + _writePair( + builder, + indent, + "intValue1", + compilerOptionEntries[j].value.intValue1); + _writePair( + builder, + indent, + "stringValue0", + compilerOptionEntries[j].value.stringValue0); + _writePairNoComma( + builder, + indent, + "stringValue1", + compilerOptionEntries[j].value.stringValue1); } } } - else - { - _writePairNoComma(builder, indent, "compilerOptionEntries", "nullptr"); - } } + else + { + _writePairNoComma(builder, indent, "compilerOptionEntries", "nullptr"); + } +} - void JsonConsumer::_writeSessionDescHelper(Slang::StringBuilder& builder, int indent, slang::SessionDesc const& desc, Slang::String keyName, bool isLastField) +void JsonConsumer::_writeSessionDescHelper( + Slang::StringBuilder& builder, + int indent, + slang::SessionDesc const& desc, + Slang::String keyName, + bool isLastField) +{ + ScopeWritterForKey scopeWritterForSessionDesc(&builder, &indent, keyName); { - ScopeWritterForKey scopeWritterForSessionDesc(&builder, &indent, keyName); - { - _writePair(builder, indent, "structureSize", (uint32_t)desc.structureSize); + _writePair(builder, indent, "structureSize", (uint32_t)desc.structureSize); - if (desc.targetCount) + if (desc.targetCount) + { + ScopeWritterForKey scopeWritterForTarget( + &builder, + &indent, + Slang::StringUtil::makeStringWithFormat("targets (0x%llX)", desc.targets), + isLastField); { - ScopeWritterForKey scopeWritterForTarget(&builder, &indent, Slang::StringUtil::makeStringWithFormat("targets (0x%llX)", desc.targets), isLastField); + for (int i = 0; i < desc.targetCount; i++) { - for (int i = 0; i < desc.targetCount; i++) + bool isLastEntry = (i == desc.targetCount - 1); + ScopeWritterForKey scopeWritterForTargetElement( + &builder, + &indent, + Slang::StringUtil::makeStringWithFormat("[%d]", i), + isLastEntry); { - bool isLastEntry = (i == desc.targetCount - 1); - ScopeWritterForKey scopeWritterForTargetElement(&builder, &indent, Slang::StringUtil::makeStringWithFormat("[%d]", i), isLastEntry); - { - _writePair(builder, indent, "structureSize", (uint32_t)desc.targets[i].structureSize); - _writePair(builder, indent, "format", SlangCompileTargetToString(desc.targets[i].format)); - _writePair(builder, indent, "profile", SlangProfileIDToString(desc.targets[i].profile)); - _writePair(builder, indent, "flags", SlangTargetFlagsToString(desc.targets[i].flags)); - _writePair(builder, indent, "floatingPointMode", SlangFloatingPointModeToString(desc.targets[i].floatingPointMode)); - _writePair(builder, indent, "lineDirectiveMode", SlangLineDirectiveModeToString(desc.targets[i].lineDirectiveMode)); - _writePair(builder, indent, "forceGLSLScalarBufferLayout", (desc.targets[i].floatingPointMode ? "true" : "false")); - - _writeCompilerOptionEntryHelper(builder, indent, desc.targets[i].compilerOptionEntries, desc.targets[i].compilerOptionEntryCount); - } + _writePair( + builder, + indent, + "structureSize", + (uint32_t)desc.targets[i].structureSize); + _writePair( + builder, + indent, + "format", + SlangCompileTargetToString(desc.targets[i].format)); + _writePair( + builder, + indent, + "profile", + SlangProfileIDToString(desc.targets[i].profile)); + _writePair( + builder, + indent, + "flags", + SlangTargetFlagsToString(desc.targets[i].flags)); + _writePair( + builder, + indent, + "floatingPointMode", + SlangFloatingPointModeToString(desc.targets[i].floatingPointMode)); + _writePair( + builder, + indent, + "lineDirectiveMode", + SlangLineDirectiveModeToString(desc.targets[i].lineDirectiveMode)); + _writePair( + builder, + indent, + "forceGLSLScalarBufferLayout", + (desc.targets[i].floatingPointMode ? "true" : "false")); + + _writeCompilerOptionEntryHelper( + builder, + indent, + desc.targets[i].compilerOptionEntries, + desc.targets[i].compilerOptionEntryCount); } } } - else - { - _writePair(builder, indent, "targets", "nullptr"); - } + } + else + { + _writePair(builder, indent, "targets", "nullptr"); + } - _writePair(builder, indent, "targetCount", desc.targetCount); - _writePair(builder, indent, "flags", SessionFlagsToString(desc.flags)); - _writePair(builder, indent, "defaultMatrixLayoutMode", SlangMatrixLayoutModeToString(desc.defaultMatrixLayoutMode)); + _writePair(builder, indent, "targetCount", desc.targetCount); + _writePair(builder, indent, "flags", SessionFlagsToString(desc.flags)); + _writePair( + builder, + indent, + "defaultMatrixLayoutMode", + SlangMatrixLayoutModeToString(desc.defaultMatrixLayoutMode)); - if (desc.searchPathCount) - { - ScopeWritterForKey scopeWritterForSearchPath(&builder, &indent, "searchPaths", false); - for (int i = 0; i < desc.searchPathCount; i++) - { - Slang::String searchPath(desc.searchPaths[i]); - searchPath = searchPath + ",\n"; - _writeString(builder, indent, searchPath); - } - } - else + if (desc.searchPathCount) + { + ScopeWritterForKey scopeWritterForSearchPath(&builder, &indent, "searchPaths", false); + for (int i = 0; i < desc.searchPathCount; i++) { - _writePair(builder, indent, "searchPaths", "nullptr"); + Slang::String searchPath(desc.searchPaths[i]); + searchPath = searchPath + ",\n"; + _writeString(builder, indent, searchPath); } - _writePair(builder, indent, "searchPathCount", desc.searchPathCount); - - if (desc.preprocessorMacroCount) - { - ScopeWritterForKey scopeWritterForMacro(&builder, &indent, "preprocessorMacros", false); - for (int i = 0; i < desc.preprocessorMacroCount; i++) - { - bool isLastField = (i == desc.preprocessorMacroCount - 1); - ScopeWritterForKey scopeWritterForMacroElement(&builder, &indent, Slang::StringUtil::makeStringWithFormat("[%d]", i), isLastField); - - _writePair(builder, indent, "name", Slang::StringUtil::makeStringWithFormat("\"%s\"", - desc.preprocessorMacros[i].name != nullptr ? desc.preprocessorMacros[i].name : "nullptr")); + } + else + { + _writePair(builder, indent, "searchPaths", "nullptr"); + } + _writePair(builder, indent, "searchPathCount", desc.searchPathCount); - _writePairNoComma(builder, indent, "value", Slang::StringUtil::makeStringWithFormat("\"%s\"", - desc.preprocessorMacros[i].value != nullptr ? desc.preprocessorMacros[i].value : "nullptr")); - } - } - else + if (desc.preprocessorMacroCount) + { + ScopeWritterForKey scopeWritterForMacro(&builder, &indent, "preprocessorMacros", false); + for (int i = 0; i < desc.preprocessorMacroCount; i++) { - _writePair(builder, indent, "preprocessorMacros", "nullptr"); + bool isLastField = (i == desc.preprocessorMacroCount - 1); + ScopeWritterForKey scopeWritterForMacroElement( + &builder, + &indent, + Slang::StringUtil::makeStringWithFormat("[%d]", i), + isLastField); + + _writePair( + builder, + indent, + "name", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + desc.preprocessorMacros[i].name != nullptr ? desc.preprocessorMacros[i].name + : "nullptr")); + + _writePairNoComma( + builder, + indent, + "value", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + desc.preprocessorMacros[i].value != nullptr + ? desc.preprocessorMacros[i].value + : "nullptr")); } - _writePair(builder, indent, "preprocessorMacroCount", desc.preprocessorMacroCount); - - AddressFormat address = reinterpret_cast<AddressFormat>(desc.fileSystem); - _writePair(builder, indent, "fileSystem", Slang::StringUtil::makeStringWithFormat("0x%llX", address)); - _writePair(builder, indent, "enableEffectAnnotations", (desc.enableEffectAnnotations ? "true" : "false")); - _writePair(builder, indent, "allowGLSLSyntax", (desc.allowGLSLSyntax ? "true" : "false")); - _writePair(builder, indent, "compilerOptionEntryCount", desc.compilerOptionEntryCount); - _writeCompilerOptionEntryHelper(builder, indent, desc.compilerOptionEntries, desc.compilerOptionEntryCount); } + else + { + _writePair(builder, indent, "preprocessorMacros", "nullptr"); + } + _writePair(builder, indent, "preprocessorMacroCount", desc.preprocessorMacroCount); + + AddressFormat address = reinterpret_cast<AddressFormat>(desc.fileSystem); + _writePair( + builder, + indent, + "fileSystem", + Slang::StringUtil::makeStringWithFormat("0x%llX", address)); + _writePair( + builder, + indent, + "enableEffectAnnotations", + (desc.enableEffectAnnotations ? "true" : "false")); + _writePair(builder, indent, "allowGLSLSyntax", (desc.allowGLSLSyntax ? "true" : "false")); + _writePair(builder, indent, "compilerOptionEntryCount", desc.compilerOptionEntryCount); + _writeCompilerOptionEntryHelper( + builder, + indent, + desc.compilerOptionEntries, + desc.compilerOptionEntryCount); + } +} + +void JsonConsumer::CreateGlobalSession(ObjectID outGlobalSessionId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - } - - void JsonConsumer::CreateGlobalSession(ObjectID outGlobalSessionId) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::createGlobalSession"); + _writePairNoComma( + builder, + indent, + "outGlobalSession", + Slang::StringUtil::makeStringWithFormat("0x%llX", outGlobalSessionId)); + } - { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::createGlobalSession"); - _writePairNoComma(builder, indent, "outGlobalSession", Slang::StringUtil::makeStringWithFormat("0x%llX", outGlobalSessionId)); - } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +void JsonConsumer::IGlobalSession_createSession( + ObjectID objectId, + slang::SessionDesc const& desc, + ObjectID outSessionId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::IGlobalSession_createSession(ObjectID objectId, slang::SessionDesc const& desc, ObjectID outSessionId) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::createSession"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::createSession"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writeSessionDescHelper(builder, indent, desc, "inDesc"); + _writeSessionDescHelper(builder, indent, desc, "inDesc"); - _writePairNoComma(builder, indent, "outSession", Slang::StringUtil::makeStringWithFormat("0x%llX", outSessionId)); - } + _writePairNoComma( + builder, + indent, + "outSession", + Slang::StringUtil::makeStringWithFormat("0x%llX", outSessionId)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } - void JsonConsumer::IGlobalSession_findProfile(ObjectID objectId, char const* name) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - - { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::findProfile"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "name", Slang::StringUtil::makeStringWithFormat("\"%s\"", - name != nullptr ? name : "nullptr")); - } - } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} +void JsonConsumer::IGlobalSession_findProfile(ObjectID objectId, char const* name) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::IGlobalSession_setDownstreamCompilerPath(ObjectID objectId, SlangPassThrough passThrough, char const* path) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::findProfile"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::setDownstreamCompilerPath"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "passThrough", SlangPassThroughToString(passThrough)); - _writePairNoComma(builder, indent, "path", Slang::StringUtil::makeStringWithFormat("\"%s\"", - path != nullptr ? path : "nullptr")); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "name", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + name != nullptr ? name : "nullptr")); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_setDownstreamCompilerPrelude(ObjectID objectId, SlangPassThrough inPassThrough, char const* prelude) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; +void JsonConsumer::IGlobalSession_setDownstreamCompilerPath( + ObjectID objectId, + SlangPassThrough passThrough, + char const* path) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::setDownstreamCompilerPath"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::setDownstreamCompilerPrelude"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "passThrough", SlangPassThroughToString(inPassThrough)); - _writePairNoComma(builder, indent, "preludeText", Slang::StringUtil::makeStringWithFormat("\"%s\"", - prelude != nullptr ? prelude : "nullptr")); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "passThrough", SlangPassThroughToString(passThrough)); + _writePairNoComma( + builder, + indent, + "path", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + path != nullptr ? path : "nullptr")); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_getDownstreamCompilerPrelude(ObjectID objectId, SlangPassThrough inPassThrough, ObjectID outPreludeId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; +void JsonConsumer::IGlobalSession_setDownstreamCompilerPrelude( + ObjectID objectId, + SlangPassThrough inPassThrough, + char const* prelude) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::setDownstreamCompilerPrelude"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::getDownstreamCompilerPrelude"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "passThrough", SlangPassThroughToString(inPassThrough)); - _writePairNoComma(builder, indent, "outPrelude", Slang::StringUtil::makeStringWithFormat("0x%llX", outPreludeId)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "passThrough", SlangPassThroughToString(inPassThrough)); + _writePairNoComma( + builder, + indent, + "preludeText", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + prelude != nullptr ? prelude : "nullptr")); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_setDefaultDownstreamCompiler(ObjectID objectId, SlangSourceLanguage sourceLanguage, SlangPassThrough defaultCompiler) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; +void JsonConsumer::IGlobalSession_getDownstreamCompilerPrelude( + ObjectID objectId, + SlangPassThrough inPassThrough, + ObjectID outPreludeId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::getDownstreamCompilerPrelude"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::setDefaultDownstreamCompiler"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "sourceLanguage", SlangSourceLanguageToString(sourceLanguage)); - _writePairNoComma(builder, indent, "defaultCompiler", SlangPassThroughToString(defaultCompiler)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "passThrough", SlangPassThroughToString(inPassThrough)); + _writePairNoComma( + builder, + indent, + "outPrelude", + Slang::StringUtil::makeStringWithFormat("0x%llX", outPreludeId)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_getDefaultDownstreamCompiler(ObjectID objectId, SlangSourceLanguage sourceLanguage) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; +void JsonConsumer::IGlobalSession_setDefaultDownstreamCompiler( + ObjectID objectId, + SlangSourceLanguage sourceLanguage, + SlangPassThrough defaultCompiler) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::setDefaultDownstreamCompiler"); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "sourceLanguage", + SlangSourceLanguageToString(sourceLanguage)); + _writePairNoComma( + builder, + indent, + "defaultCompiler", + SlangPassThroughToString(defaultCompiler)); + } + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + + +void JsonConsumer::IGlobalSession_getDefaultDownstreamCompiler( + ObjectID objectId, + SlangSourceLanguage sourceLanguage) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::getDefaultDownstreamCompiler"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::getDefaultDownstreamCompiler"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "sourceLanguage", SlangSourceLanguageToString(sourceLanguage)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "sourceLanguage", + SlangSourceLanguageToString(sourceLanguage)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_setLanguagePrelude(ObjectID objectId, SlangSourceLanguage inSourceLanguage, char const* prelude) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; +void JsonConsumer::IGlobalSession_setLanguagePrelude( + ObjectID objectId, + SlangSourceLanguage inSourceLanguage, + char const* prelude) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::setLanguagePrelude"); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "sourceLanguage", + SlangSourceLanguageToString(inSourceLanguage)); + _writePairNoComma( + builder, + indent, + "preludeText", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + prelude != nullptr ? prelude : "nullptr")); + } + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + + +void JsonConsumer::IGlobalSession_getLanguagePrelude( + ObjectID objectId, + SlangSourceLanguage inSourceLanguage, + ObjectID outPreludeId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::getLanguagePrelude"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::setLanguagePrelude"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "sourceLanguage", SlangSourceLanguageToString(inSourceLanguage)); - _writePairNoComma(builder, indent, "preludeText", Slang::StringUtil::makeStringWithFormat("\"%s\"", - prelude != nullptr ? prelude : "nullptr")); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "sourceLanguage", + SlangSourceLanguageToString(inSourceLanguage)); + _writePairNoComma( + builder, + indent, + "outPrelude", + Slang::StringUtil::makeStringWithFormat("0x%llX", outPreludeId)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_getLanguagePrelude(ObjectID objectId, SlangSourceLanguage inSourceLanguage, ObjectID outPreludeId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; +void JsonConsumer::IGlobalSession_createCompileRequest( + ObjectID objectId, + ObjectID outCompileRequest) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + _writeString(builder, indent, "IGlobalSession::createCompileRequest: {\n"); + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::createCompileRequest"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::getLanguagePrelude"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "sourceLanguage", SlangSourceLanguageToString(inSourceLanguage)); - _writePairNoComma(builder, indent, "outPrelude", Slang::StringUtil::makeStringWithFormat("0x%llX", outPreludeId)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "outCompileRequest", + Slang::StringUtil::makeStringWithFormat("0x%llX", outCompileRequest)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequest) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - _writeString(builder, indent, "IGlobalSession::createCompileRequest: {\n"); +void JsonConsumer::IGlobalSession_addBuiltins( + ObjectID objectId, + char const* sourcePath, + char const* sourceString) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + _writeString(builder, indent, "IGlobalSession::addBuiltins: {\n"); + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::addBuiltins"); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "sourcePath", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + sourcePath != nullptr ? sourcePath : "nullptr")); + _writePairNoComma( + builder, + indent, + "sourceString", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + sourceString != nullptr ? sourceString : "nullptr")); + } + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + + +void JsonConsumer::IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ObjectID loaderId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::setSharedLibraryLoader"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::createCompileRequest"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "outCompileRequest", Slang::StringUtil::makeStringWithFormat("0x%llX", outCompileRequest)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "loader", + Slang::StringUtil::makeStringWithFormat("0x%llX", loaderId)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_addBuiltins(ObjectID objectId, char const* sourcePath, char const* sourceString) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - _writeString(builder, indent, "IGlobalSession::addBuiltins: {\n"); +void JsonConsumer::IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::getSharedLibraryLoader"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::addBuiltins"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "sourcePath", Slang::StringUtil::makeStringWithFormat("\"%s\"", - sourcePath != nullptr ? sourcePath : "nullptr")); - _writePairNoComma(builder, indent, "sourceString", Slang::StringUtil::makeStringWithFormat("\"%s\"", - sourceString != nullptr ? sourceString : "nullptr")); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "retLoader", + Slang::StringUtil::makeStringWithFormat("0x%llX", outLoaderId)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + _writeString(builder, indent, "}\n"); - void JsonConsumer::IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ObjectID loaderId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::setSharedLibraryLoader"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "loader", Slang::StringUtil::makeStringWithFormat("0x%llX", loaderId)); - } - } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +void JsonConsumer::IGlobalSession_checkCompileTargetSupport( + ObjectID objectId, + SlangCompileTarget target) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::checkCompileTargetSupport"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::getSharedLibraryLoader"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "retLoader", Slang::StringUtil::makeStringWithFormat("0x%llX", outLoaderId)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma(builder, indent, "target", SlangCompileTargetToString(target)); } + } - _writeString(builder, indent, "}\n"); + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +void JsonConsumer::IGlobalSession_checkPassThroughSupport( + ObjectID objectId, + SlangPassThrough passThrough) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::IGlobalSession_checkCompileTargetSupport(ObjectID objectId, SlangCompileTarget target) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::checkPassThroughSupport"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::checkCompileTargetSupport"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "target", SlangCompileTargetToString(target)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "passThrough", + SlangPassThroughToString(passThrough)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_checkPassThroughSupport(ObjectID objectId, SlangPassThrough passThrough) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - - { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::checkPassThroughSupport"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "passThrough", SlangPassThroughToString(passThrough)); - } - } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +void JsonConsumer::IGlobalSession_compileCoreModule( + ObjectID objectId, + slang::CompileCoreModuleFlags flags) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::compileCoreModule"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::compileCoreModule"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "flags", CompileCoreModuleFlagsToString(flags)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma(builder, indent, "flags", CompileCoreModuleFlagsToString(flags)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - _writeString(builder, indent, "IGlobalSession::loadCoreModule: {\n"); - - { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::loadCoreModule"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "coreModule-Ignore-Data", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "coreModuleSizeInBytes", (uint32_t)coreModuleSizeInBytes); - } - } - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +void JsonConsumer::IGlobalSession_loadCoreModule( + ObjectID objectId, + const void* coreModule, + size_t coreModuleSizeInBytes) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + _writeString(builder, indent, "IGlobalSession::loadCoreModule: {\n"); + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::loadCoreModule"); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "coreModule-Ignore-Data", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "coreModuleSizeInBytes", + (uint32_t)coreModuleSizeInBytes); + } + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + +void JsonConsumer::IGlobalSession_saveCoreModule( + ObjectID objectId, + SlangArchiveType archiveType, + ObjectID outBlobId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::saveCoreModule"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::saveCoreModule"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "archiveType", SlangArchiveTypeToString(archiveType)); - _writePairNoComma(builder, indent, "outBlobId", Slang::StringUtil::makeStringWithFormat("0x%llX", outBlobId)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "archiveType", SlangArchiveTypeToString(archiveType)); + _writePairNoComma( + builder, + indent, + "outBlobId", + Slang::StringUtil::makeStringWithFormat("0x%llX", outBlobId)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_findCapability(ObjectID objectId, char const* name) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - - { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::findCapability"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "name", Slang::StringUtil::makeStringWithFormat("\"%s\"", - name != nullptr ? name : "nullptr")); - } - } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +void JsonConsumer::IGlobalSession_findCapability(ObjectID objectId, char const* name) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::findCapability"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::setDownstreamCompilerForTransition"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "source", SlangCompileTargetToString(source)); - _writePair(builder, indent, "target", SlangCompileTargetToString(target)); - _writePairNoComma(builder, indent, "compiler", SlangPassThroughToString(compiler)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "name", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + name != nullptr ? name : "nullptr")); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; +void JsonConsumer::IGlobalSession_setDownstreamCompilerForTransition( + ObjectID objectId, + SlangCompileTarget source, + SlangCompileTarget target, + SlangPassThrough compiler) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::setDownstreamCompilerForTransition"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::getDownstreamCompilerForTransition"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "source", SlangCompileTargetToString(source)); - _writePairNoComma(builder, indent, "target", SlangCompileTargetToString(target)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "source", SlangCompileTargetToString(source)); + _writePair(builder, indent, "target", SlangCompileTargetToString(target)); + _writePairNoComma(builder, indent, "compiler", SlangPassThroughToString(compiler)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, char const* jsonPath) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; +void JsonConsumer::IGlobalSession_getDownstreamCompilerForTransition( + ObjectID objectId, + SlangCompileTarget source, + SlangCompileTarget target) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::getDownstreamCompilerForTransition"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::setSPIRVCoreGrammar"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "jsonPath", Slang::StringUtil::makeStringWithFormat("\"%s\"", - jsonPath != nullptr ? jsonPath : "nullptr")); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "source", SlangCompileTargetToString(source)); + _writePairNoComma(builder, indent, "target", SlangCompileTargetToString(target)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_parseCommandLineArguments(ObjectID objectId, int argc, const char* const* argv, ObjectID outSessionDescId, ObjectID outAllocationId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::parseCommandLineArguments"); - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "argc", argc); +void JsonConsumer::IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, char const* jsonPath) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - if (argv) - { - _writeString(builder, indent, "argv: {\n"); - ScopeWritterForKey scopeWritteriForArgv(&builder, &indent, "argv"); - for (int i = 0; i < argc; i++) - { - if (i == (argc -1)) - _writePairNoComma(builder, indent, Slang::StringUtil::makeStringWithFormat("[%d]", i), argv[i]); - else - _writePair(builder, indent, Slang::StringUtil::makeStringWithFormat("[%d]", i), argv[i]); - } - } - else - { - _writePair(builder, indent, "argv", "nullptr"); - } + { + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::setSPIRVCoreGrammar"); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "jsonPath", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + jsonPath != nullptr ? jsonPath : "nullptr")); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IGlobalSession_getSessionDescDigest(ObjectID objectId, slang::SessionDesc* sessionDesc, ObjectID outBlobId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - - { - ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::getSessionDescDigest"); - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - if (sessionDesc) - { - _writeSessionDescHelper(builder, indent, *sessionDesc, Slang::StringUtil::makeStringWithFormat("sessionDesc (0x%llX)\n", sessionDesc)); - } - else +void JsonConsumer::IGlobalSession_parseCommandLineArguments( + ObjectID objectId, + int argc, + const char* const* argv, + ObjectID outSessionDescId, + ObjectID outAllocationId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "IGlobalSession::parseCommandLineArguments"); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "argc", argc); + + if (argv) + { + _writeString(builder, indent, "argv: {\n"); + ScopeWritterForKey scopeWritteriForArgv(&builder, &indent, "argv"); + for (int i = 0; i < argc; i++) { - _writePair(builder, indent, "sessionDesc", "nullptr"); + if (i == (argc - 1)) + _writePairNoComma( + builder, + indent, + Slang::StringUtil::makeStringWithFormat("[%d]", i), + argv[i]); + else + _writePair( + builder, + indent, + Slang::StringUtil::makeStringWithFormat("[%d]", i), + argv[i]); } - - _writePair(builder, indent, "outBlob", Slang::StringUtil::makeStringWithFormat("0x%llX", outBlobId)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } - - // ISession - void JsonConsumer::ISession_getGlobalSession(ObjectID objectId, ObjectID outGlobalSessionId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + else { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getGlobalSession"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "retGlobalSession", Slang::StringUtil::makeStringWithFormat("0x%llX", outGlobalSessionId)); - } + _writePair(builder, indent, "argv", "nullptr"); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + + +void JsonConsumer::IGlobalSession_getSessionDescDigest( + ObjectID objectId, + slang::SessionDesc* sessionDesc, + ObjectID outBlobId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::ISession_loadModule(ObjectID objectId, const char* moduleName, ObjectID outDiagnostics, ObjectID outModuleId) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::getSessionDescDigest"); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + if (sessionDesc) { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::loadModule"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "moduleName", Slang::StringUtil::makeStringWithFormat("\"%s\"", - moduleName != nullptr ? moduleName : "nullptr")); - _writePair(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnostics)); - _writePairNoComma(builder, indent, "retIModule", Slang::StringUtil::makeStringWithFormat("0x%llX", outModuleId)); - } + _writeSessionDescHelper( + builder, + indent, + *sessionDesc, + Slang::StringUtil::makeStringWithFormat("sessionDesc (0x%llX)\n", sessionDesc)); + } + else + { + _writePair(builder, indent, "sessionDesc", "nullptr"); } - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); + _writePair( + builder, + indent, + "outBlob", + Slang::StringUtil::makeStringWithFormat("0x%llX", outBlobId)); } - void JsonConsumer::ISession_loadModuleFromIRBlob(ObjectID objectId, const char* moduleName, - const char* path, slang::IBlob* source, ObjectID outDiagnosticsId, ObjectID outModuleId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::loadModuleFromIRBlob"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "moduleName", Slang::StringUtil::makeStringWithFormat("\"%s\"", - moduleName != nullptr ? moduleName : "nullptr")); - _writePair(builder, indent, "path", Slang::StringUtil::makeStringWithFormat("\"%s\"", - path != nullptr ? path : "nullptr")); - if (source) - { - void const* bufPtr = source->getBufferPointer(); - size_t bufSize = source->getBufferSize(); - - ScopeWritterForKey scopeWritterForSource(&builder, &indent, Slang::StringUtil::makeStringWithFormat("source (0x%llX): {\n", source), false); - { - _writePair(builder, indent, "bufferPointer", Slang::StringUtil::makeStringWithFormat("0x%llX", bufPtr)); - _writePairNoComma(builder, indent, "bufferSize", (uint32_t)bufSize); - } - } - else - { - _writePair(builder, indent, "source", "nullptr"); - } +// ISession +void JsonConsumer::ISession_getGlobalSession(ObjectID objectId, ObjectID outGlobalSessionId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - _writePair(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); - _writePairNoComma(builder, indent, "retIModule", Slang::StringUtil::makeStringWithFormat("0x%llX", outModuleId)); - } + { + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getGlobalSession"); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "retGlobalSession", + Slang::StringUtil::makeStringWithFormat("0x%llX", outGlobalSessionId)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::ISession_loadModuleFromSource(ObjectID objectId, const char* moduleName, - const char* path, slang::IBlob* source, ObjectID outDiagnosticsId, ObjectID outModuleId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::loadModuleFromSource"); - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "moduleName", Slang::StringUtil::makeStringWithFormat("\"%s\"", - moduleName != nullptr ? moduleName : "nullptr")); - _writePair(builder, indent, "path", Slang::StringUtil::makeStringWithFormat("\"%s\"", - path != nullptr ? path : "nullptr")); +void JsonConsumer::ISession_loadModule( + ObjectID objectId, + const char* moduleName, + ObjectID outDiagnostics, + ObjectID outModuleId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::loadModule"); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "moduleName", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + moduleName != nullptr ? moduleName : "nullptr")); + _writePair( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnostics)); + _writePairNoComma( + builder, + indent, + "retIModule", + Slang::StringUtil::makeStringWithFormat("0x%llX", outModuleId)); + } + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + +void JsonConsumer::ISession_loadModuleFromIRBlob( + ObjectID objectId, + const char* moduleName, + const char* path, + slang::IBlob* source, + ObjectID outDiagnosticsId, + ObjectID outModuleId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::loadModuleFromIRBlob"); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "moduleName", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + moduleName != nullptr ? moduleName : "nullptr")); + _writePair( + builder, + indent, + "path", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + path != nullptr ? path : "nullptr")); if (source) { void const* bufPtr = source->getBufferPointer(); size_t bufSize = source->getBufferSize(); - ScopeWritterForKey scopeWritterForSource(&builder, &indent, Slang::StringUtil::makeStringWithFormat("source (0x%llX): {\n", source), false); + + ScopeWritterForKey scopeWritterForSource( + &builder, + &indent, + Slang::StringUtil::makeStringWithFormat("source (0x%llX): {\n", source), + false); { - _writePair(builder, indent, "bufferPointer", Slang::StringUtil::makeStringWithFormat("0x%llX", bufPtr)); + _writePair( + builder, + indent, + "bufferPointer", + Slang::StringUtil::makeStringWithFormat("0x%llX", bufPtr)); _writePairNoComma(builder, indent, "bufferSize", (uint32_t)bufSize); } } @@ -1098,715 +1733,1315 @@ namespace SlangRecord _writePair(builder, indent, "source", "nullptr"); } - _writePair(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); - _writePairNoComma(builder, indent, "retIModule", Slang::StringUtil::makeStringWithFormat("0x%llX", outModuleId)); + _writePair( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + _writePairNoComma( + builder, + indent, + "retIModule", + Slang::StringUtil::makeStringWithFormat("0x%llX", outModuleId)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::ISession_loadModuleFromSourceString(ObjectID objectId, const char* moduleName, - const char* path, const char* string, ObjectID outDiagnosticsId, ObjectID outModuleId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; +void JsonConsumer::ISession_loadModuleFromSource( + ObjectID objectId, + const char* moduleName, + const char* path, + slang::IBlob* source, + ObjectID outDiagnosticsId, + ObjectID outModuleId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::loadModuleFromSource"); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "moduleName", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + moduleName != nullptr ? moduleName : "nullptr")); + _writePair( + builder, + indent, + "path", + Slang::StringUtil::makeStringWithFormat("\"%s\"", path != nullptr ? path : "nullptr")); + if (source) + { + void const* bufPtr = source->getBufferPointer(); + size_t bufSize = source->getBufferSize(); + ScopeWritterForKey scopeWritterForSource( + &builder, + &indent, + Slang::StringUtil::makeStringWithFormat("source (0x%llX): {\n", source), + false); + { + _writePair( + builder, + indent, + "bufferPointer", + Slang::StringUtil::makeStringWithFormat("0x%llX", bufPtr)); + _writePairNoComma(builder, indent, "bufferSize", (uint32_t)bufSize); + } + } + else { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::loadModuleFromSourceString"); - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "moduleName", Slang::StringUtil::makeStringWithFormat("\"%s\"", - moduleName != nullptr ? moduleName : "nullptr")); - - _writePair(builder, indent, "path", Slang::StringUtil::makeStringWithFormat("\"%s\"", - path != nullptr ? path : "nullptr")); - - _writePair(builder, indent, "string", Slang::StringUtil::makeStringWithFormat("\"%s\"", - string != nullptr ? string : "nullptr")); - - _writePair(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); - _writePairNoComma(builder, indent, "retIModule", Slang::StringUtil::makeStringWithFormat("0x%llX", outModuleId)); + _writePair(builder, indent, "source", "nullptr"); } - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); + _writePair( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + _writePairNoComma( + builder, + indent, + "retIModule", + Slang::StringUtil::makeStringWithFormat("0x%llX", outModuleId)); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::ISession_createCompositeComponentType(ObjectID objectId, ObjectID* componentTypeIds, - SlangInt componentTypeCount, ObjectID outCompositeComponentTypeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::createCompositeComponentType"); +void JsonConsumer::ISession_loadModuleFromSourceString( + ObjectID objectId, + const char* moduleName, + const char* path, + const char* string, + ObjectID outDiagnosticsId, + ObjectID outModuleId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::loadModuleFromSourceString"); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "moduleName", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + moduleName != nullptr ? moduleName : "nullptr")); + + _writePair( + builder, + indent, + "path", + Slang::StringUtil::makeStringWithFormat("\"%s\"", path != nullptr ? path : "nullptr")); + + _writePair( + builder, + indent, + "string", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + string != nullptr ? string : "nullptr")); + + _writePair( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + _writePairNoComma( + builder, + indent, + "retIModule", + Slang::StringUtil::makeStringWithFormat("0x%llX", outModuleId)); + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + + +void JsonConsumer::ISession_createCompositeComponentType( + ObjectID objectId, + ObjectID* componentTypeIds, + SlangInt componentTypeCount, + ObjectID outCompositeComponentTypeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "ISession::createCompositeComponentType"); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + if (componentTypeCount) { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - if (componentTypeCount) + ScopeWritterForKey scopeWritterForComponentTypes( + &builder, + &indent, + "componentTypes", + false); + for (int i = 0; i < componentTypeCount; i++) { - ScopeWritterForKey scopeWritterForComponentTypes(&builder, &indent, "componentTypes", false); - for (int i = 0; i < componentTypeCount; i++) + if (i != componentTypeCount - 1) { - if (i != componentTypeCount - 1) - { - _writeString(builder, indent, Slang::StringUtil::makeStringWithFormat("[%d]: 0x%llX,\n", i, componentTypeIds[i])); - } - else - { - _writeString(builder, indent, Slang::StringUtil::makeStringWithFormat("[%d]: 0x%llX\n", i, componentTypeIds[i])); - } + _writeString( + builder, + indent, + Slang::StringUtil::makeStringWithFormat( + "[%d]: 0x%llX,\n", + i, + componentTypeIds[i])); } - } - else - { - _writePair(builder, indent, "componentTypes", "nullptr"); - } - } - _writePair(builder, indent, "componentTypeCount", componentTypeCount); - _writePair(builder, indent, "outCompositeComponentType", Slang::StringUtil::makeStringWithFormat("0x%llX", outCompositeComponentTypeId)); - _writePairNoComma(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); - } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } - - - void JsonConsumer::ISession_specializeType(ObjectID objectId, ObjectID typeId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outDiagnosticsId, ObjectID outTypeReflectionId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - - { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::specializeType"); - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "type", Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); - - if (specializationArgCount) - { - ScopeWritterForKey scopeWritterForArgs(&builder, &indent, "specializationArgs", false); - for(int i = 0; i < specializationArgCount; i++) - { - ScopeWritterForKey scopeWritterForArg(&builder, &indent, Slang::StringUtil::makeStringWithFormat("[%d]\n", i), false); + else { - _writePair(builder, indent, "kind", SpecializationArgKindToString(specializationArgs[i].kind)); - _writePairNoComma(builder, indent, "type", Slang::StringUtil::makeStringWithFormat("0x%llX", specializationArgs[i].type)); + _writeString( + builder, + indent, + Slang::StringUtil::makeStringWithFormat( + "[%d]: 0x%llX\n", + i, + componentTypeIds[i])); } } } else { - _writePair(builder, indent, "specializationArgs", "nullptr"); + _writePair(builder, indent, "componentTypes", "nullptr"); } - - _writePair(builder, indent, "specializationArgCount", specializationArgCount); - _writePair(builder, indent, "outDiagnostics", outDiagnosticsId); - _writePairNoComma(builder, indent, "retTypeReflectionId", outTypeReflectionId); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } - - void JsonConsumer::ISession_getTypeLayout(ObjectID objectId, ObjectID typeId, SlangInt targetIndex, - slang::LayoutRules rules, ObjectID outDiagnosticsId, ObjectID outTypeLayoutReflectionId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - - { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getTypeLayout"); + _writePair(builder, indent, "componentTypeCount", componentTypeCount); + _writePair( + builder, + indent, + "outCompositeComponentType", + Slang::StringUtil::makeStringWithFormat("0x%llX", outCompositeComponentTypeId)); + _writePairNoComma( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + + +void JsonConsumer::ISession_specializeType( + ObjectID objectId, + ObjectID typeId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outDiagnosticsId, + ObjectID outTypeReflectionId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::specializeType"); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "type", + Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); + + if (specializationArgCount) + { + ScopeWritterForKey scopeWritterForArgs(&builder, &indent, "specializationArgs", false); + for (int i = 0; i < specializationArgCount; i++) { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "type", Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); - _writePair(builder, indent, "rules", LayoutRulesToString(rules)); - _writePair(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); - _writePairNoComma(builder, indent, "retTypeReflectionId", Slang::StringUtil::makeStringWithFormat("0x%llX", outTypeLayoutReflectionId)); + ScopeWritterForKey scopeWritterForArg( + &builder, + &indent, + Slang::StringUtil::makeStringWithFormat("[%d]\n", i), + false); + { + _writePair( + builder, + indent, + "kind", + SpecializationArgKindToString(specializationArgs[i].kind)); + _writePairNoComma( + builder, + indent, + "type", + Slang::StringUtil::makeStringWithFormat( + "0x%llX", + specializationArgs[i].type)); + } } } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } - - void JsonConsumer::ISession_getContainerType(ObjectID objectId, ObjectID elementTypeId, - slang::ContainerType containerType, ObjectID outDiagnosticsId, ObjectID outTypeReflectionId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + else { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getContainerType"); - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "elementType", Slang::StringUtil::makeStringWithFormat("0x%llX", elementTypeId)); - _writePair(builder, indent, "containerType", ContainerTypeToString(containerType)); - _writePair(builder, indent, "outDiagnosticsId", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); - _writePairNoComma(builder, indent, "outTypeReflectionId", Slang::StringUtil::makeStringWithFormat("0x%llX", outTypeReflectionId)); + _writePair(builder, indent, "specializationArgs", "nullptr"); } - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); + _writePair(builder, indent, "specializationArgCount", specializationArgCount); + _writePair(builder, indent, "outDiagnostics", outDiagnosticsId); + _writePairNoComma(builder, indent, "retTypeReflectionId", outTypeReflectionId); } - void JsonConsumer::ISession_getDynamicType(ObjectID objectId, ObjectID outTypeReflectionId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getDynamicType"); - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "outTypeReflectionId", Slang::StringUtil::makeStringWithFormat("0x%llX", outTypeReflectionId)); - } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +void JsonConsumer::ISession_getTypeLayout( + ObjectID objectId, + ObjectID typeId, + SlangInt targetIndex, + slang::LayoutRules rules, + ObjectID outDiagnosticsId, + ObjectID outTypeLayoutReflectionId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getTypeLayout"); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "type", + Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); + _writePair(builder, indent, "rules", LayoutRulesToString(rules)); + _writePair( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + _writePairNoComma( + builder, + indent, + "retTypeReflectionId", + Slang::StringUtil::makeStringWithFormat("0x%llX", outTypeLayoutReflectionId)); + } + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + +void JsonConsumer::ISession_getContainerType( + ObjectID objectId, + ObjectID elementTypeId, + slang::ContainerType containerType, + ObjectID outDiagnosticsId, + ObjectID outTypeReflectionId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getContainerType"); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "elementType", + Slang::StringUtil::makeStringWithFormat("0x%llX", elementTypeId)); + _writePair(builder, indent, "containerType", ContainerTypeToString(containerType)); + _writePair( + builder, + indent, + "outDiagnosticsId", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnosticsId)); + _writePairNoComma( + builder, + indent, + "outTypeReflectionId", + Slang::StringUtil::makeStringWithFormat("0x%llX", outTypeReflectionId)); + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + +void JsonConsumer::ISession_getDynamicType(ObjectID objectId, ObjectID outTypeReflectionId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getDynamicType"); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "outTypeReflectionId", + Slang::StringUtil::makeStringWithFormat("0x%llX", outTypeReflectionId)); + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + +void JsonConsumer::ISession_getTypeRTTIMangledName( + ObjectID objectId, + ObjectID typeId, + ObjectID outNameBlobId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getTypeRTTIMangledName"); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "type", + Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); + _writePairNoComma( + builder, + indent, + "outNameBlobId", + Slang::StringUtil::makeStringWithFormat("0x%llX", outNameBlobId)); + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + +void JsonConsumer::ISession_getTypeConformanceWitnessMangledName( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + ObjectID outNameBlobId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "ISession::getTypeConformanceWitnessMangledName"); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "type", + Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); + _writePair( + builder, + indent, + "interfaceType", + Slang::StringUtil::makeStringWithFormat("0x%llX", interfaceTypeId)); + _writePairNoComma( + builder, + indent, + "outNameBlobId", + Slang::StringUtil::makeStringWithFormat("0x%llX", outNameBlobId)); + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + + +void JsonConsumer::ISession_getTypeConformanceWitnessSequentialID( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + uint32_t outId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "ISession::getTypeConformanceWitnessSequentialID"); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "type", + Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + +void JsonConsumer::ISession_createTypeConformanceComponentType( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + ObjectID outConformanceId, + SlangInt conformanceIdOverride, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter( + &builder, + &indent, + "ISession::createTypeConformanceComponentType"); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "type", + Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); + _writePair( + builder, + indent, + "interfaceTypeId", + Slang::StringUtil::makeStringWithFormat("0x%llX", interfaceTypeId)); + _writePair( + builder, + indent, + "outConformanceId", + Slang::StringUtil::makeStringWithFormat("0x%llX", outConformanceId)); + _writePair(builder, indent, "conformanceIdOverride", conformanceIdOverride); + _writePairNoComma( + builder, + indent, + "outDiagnosticsId", + Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + + +void JsonConsumer::ISession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequestId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::ISession_getTypeRTTIMangledName(ObjectID objectId, ObjectID typeId, ObjectID outNameBlobId) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::createCompileRequest"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getTypeRTTIMangledName"); - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "type", Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); - _writePairNoComma(builder, indent, "outNameBlobId", Slang::StringUtil::makeStringWithFormat("0x%llX", outNameBlobId)); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "outCompileRequest", outCompileRequestId); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } - void JsonConsumer::ISession_getTypeConformanceWitnessMangledName(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, ObjectID outNameBlobId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getTypeConformanceWitnessMangledName"); - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "type", Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); - _writePair(builder, indent, "interfaceType", Slang::StringUtil::makeStringWithFormat("0x%llX", interfaceTypeId)); - _writePairNoComma(builder, indent, "outNameBlobId", Slang::StringUtil::makeStringWithFormat("0x%llX", outNameBlobId)); - } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +void JsonConsumer::ISession_getLoadedModule(ObjectID objectId, SlangInt index, ObjectID outModuleId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::ISession_getTypeConformanceWitnessSequentialID(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, uint32_t outId) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getLoadedModule"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getTypeConformanceWitnessSequentialID"); - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "type", Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "index", index); + _writePairNoComma( + builder, + indent, + "retModule", + Slang::StringUtil::makeStringWithFormat("0x%llX", outModuleId)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } - void JsonConsumer::ISession_createTypeConformanceComponentType(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, ObjectID outConformanceId, - SlangInt conformanceIdOverride, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::createTypeConformanceComponentType"); - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "type", Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); - _writePair(builder, indent, "interfaceTypeId", Slang::StringUtil::makeStringWithFormat("0x%llX", interfaceTypeId)); - _writePair(builder, indent, "outConformanceId", Slang::StringUtil::makeStringWithFormat("0x%llX", outConformanceId)); - _writePair(builder, indent, "conformanceIdOverride", conformanceIdOverride); - _writePairNoComma(builder, indent, "outDiagnosticsId", Slang::StringUtil::makeStringWithFormat("0x%llX", typeId)); - } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +// IModule +void JsonConsumer::IModule_findEntryPointByName( + ObjectID objectId, + char const* name, + ObjectID outEntryPointId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::ISession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequestId) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter(&builder, &indent, "IModule::findEntryPointByName"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::createCompileRequest"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "outCompileRequest", outCompileRequestId); - } - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "name", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + name != nullptr ? name : "nullptr")); - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); + _writePairNoComma( + builder, + indent, + "outEntryPoint", + Slang::StringUtil::makeStringWithFormat("0x%llX", outEntryPointId)); + } } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::ISession_getLoadedModule(ObjectID objectId, SlangInt index, ObjectID outModuleId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - - { - ScopeWritterForKey scopeWritter(&builder, &indent, "ISession::getLoadedModule"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "index", index); - _writePairNoComma(builder, indent, "retModule", Slang::StringUtil::makeStringWithFormat("0x%llX", outModuleId)); - } - } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +void JsonConsumer::IModule_getDefinedEntryPoint( + ObjectID objectId, + SlangInt32 index, + ObjectID outEntryPointId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - // IModule - void JsonConsumer::IModule_findEntryPointByName(ObjectID objectId, char const* name, ObjectID outEntryPointId) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter(&builder, &indent, "IModule::getDefinedEntryPoint"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IModule::findEntryPointByName"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "name", Slang::StringUtil::makeStringWithFormat("\"%s\"", - name != nullptr ? name : "nullptr")); - - _writePairNoComma(builder, indent, "outEntryPoint", Slang::StringUtil::makeStringWithFormat("0x%llX", outEntryPointId)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair(builder, indent, "index", index); + _writePairNoComma( + builder, + indent, + "outEntryPoint", + Slang::StringUtil::makeStringWithFormat("0x%llX", outEntryPointId)); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IModule_getDefinedEntryPoint(ObjectID objectId, SlangInt32 index, ObjectID outEntryPointId) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - - { - ScopeWritterForKey scopeWritter(&builder, &indent, "IModule::getDefinedEntryPoint"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "index", index); - _writePairNoComma(builder, indent, "outEntryPoint", Slang::StringUtil::makeStringWithFormat("0x%llX", outEntryPointId)); - } - } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +void JsonConsumer::IModule_serialize(ObjectID objectId, ObjectID outSerializedBlobId) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::IModule_serialize(ObjectID objectId, ObjectID outSerializedBlobId) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter(&builder, &indent, "IModule::serialize"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IModule::serialize"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "outSerializedBlob", outSerializedBlobId); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma(builder, indent, "outSerializedBlob", outSerializedBlobId); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IModule_writeToFile(ObjectID objectId, char const* fileName) - { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - - { - ScopeWritterForKey scopeWritter(&builder, &indent, "IModule::writeToFile"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePairNoComma(builder, indent, "fileName", Slang::StringUtil::makeStringWithFormat("\"%s\"", - fileName != nullptr ? fileName : "nullptr")); - } - } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } +void JsonConsumer::IModule_writeToFile(ObjectID objectId, char const* fileName) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; - void JsonConsumer::IModule_findAndCheckEntryPoint(ObjectID objectId, char const* name, SlangStage stage, ObjectID outEntryPointId, ObjectID outDiagnostics) { - SANITY_CHECK(); - Slang::StringBuilder builder; - int indent = 0; - + ScopeWritterForKey scopeWritter(&builder, &indent, "IModule::writeToFile"); { - ScopeWritterForKey scopeWritter(&builder, &indent, "IModule::findAndCheckEntryPoint"); - { - _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); - _writePair(builder, indent, "name", Slang::StringUtil::makeStringWithFormat("\"%s\"", - name != nullptr ? name : "nullptr")); - _writePair(builder, indent, "stage", SlangStageToString(stage)); - _writePair(builder, indent, "outEntryPoint", Slang::StringUtil::makeStringWithFormat("0x%llX", outEntryPointId)); - _writePairNoComma(builder, indent, "outDiagnostics", Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnostics)); - } + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePairNoComma( + builder, + indent, + "fileName", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + fileName != nullptr ? fileName : "nullptr")); } - - m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); - m_fileStream.flush(); - } - - void JsonConsumer::IModule_getSession(ObjectID objectId, ObjectID outSessionId) - { - SANITY_CHECK(); - m_moduleHelper.getSession(objectId, outSessionId); - } - - void JsonConsumer::IModule_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) - { - SANITY_CHECK(); - m_moduleHelper.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); - } - - - void JsonConsumer::IModule_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_moduleHelper.getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); - } - - - void JsonConsumer::IModule_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_moduleHelper.getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); } - - void JsonConsumer::IModule_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystemId) - { - SANITY_CHECK(); - m_moduleHelper.getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystemId); - } - - - void JsonConsumer::IModule_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) - { - SANITY_CHECK(); - m_moduleHelper.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); - } - - - void JsonConsumer::IModule_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_moduleHelper.specialize(objectId, specializationArgs, specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - } + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} - void JsonConsumer::IModule_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_moduleHelper.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - } - - - void JsonConsumer::IModule_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibraryId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_moduleHelper.getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibraryId, outDiagnosticsId); - } - - - void JsonConsumer::IModule_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) - { - SANITY_CHECK(); - m_moduleHelper.renameEntryPoint(objectId, newName, outEntryPointId); - } - - - void JsonConsumer::IModule_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_moduleHelper.linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries, outDiagnosticsId); - } - - // IEntryPoint - void JsonConsumer::IEntryPoint_getSession(ObjectID objectId, ObjectID outSessionId) - { - SANITY_CHECK(); - m_entryPointHelper.getSession(objectId, outSessionId); - } - - - void JsonConsumer::IEntryPoint_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) - { - SANITY_CHECK(); - m_entryPointHelper.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); - } - - - void JsonConsumer::IEntryPoint_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_entryPointHelper.getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); - } - - - void JsonConsumer::IEntryPoint_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_entryPointHelper.getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); - } - - - void JsonConsumer::IEntryPoint_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) - { - SANITY_CHECK(); - m_entryPointHelper.getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystem); - } +void JsonConsumer::IModule_findAndCheckEntryPoint( + ObjectID objectId, + char const* name, + SlangStage stage, + ObjectID outEntryPointId, + ObjectID outDiagnostics) +{ + SANITY_CHECK(); + Slang::StringBuilder builder; + int indent = 0; + + { + ScopeWritterForKey scopeWritter(&builder, &indent, "IModule::findAndCheckEntryPoint"); + { + _writePair( + builder, + indent, + "this", + Slang::StringUtil::makeStringWithFormat("0x%llX", objectId)); + _writePair( + builder, + indent, + "name", + Slang::StringUtil::makeStringWithFormat( + "\"%s\"", + name != nullptr ? name : "nullptr")); + _writePair(builder, indent, "stage", SlangStageToString(stage)); + _writePair( + builder, + indent, + "outEntryPoint", + Slang::StringUtil::makeStringWithFormat("0x%llX", outEntryPointId)); + _writePairNoComma( + builder, + indent, + "outDiagnostics", + Slang::StringUtil::makeStringWithFormat("0x%llX", outDiagnostics)); + } + } + + m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); + m_fileStream.flush(); +} + +void JsonConsumer::IModule_getSession(ObjectID objectId, ObjectID outSessionId) +{ + SANITY_CHECK(); + m_moduleHelper.getSession(objectId, outSessionId); +} + +void JsonConsumer::IModule_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) +{ + SANITY_CHECK(); + m_moduleHelper.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); +} - void JsonConsumer::IEntryPoint_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) - { - SANITY_CHECK(); - m_entryPointHelper.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); - } +void JsonConsumer::IModule_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_moduleHelper + .getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); +} - void JsonConsumer::IEntryPoint_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_entryPointHelper.specialize(objectId, specializationArgs, specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - } +void JsonConsumer::IModule_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_moduleHelper.getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); +} - void JsonConsumer::IEntryPoint_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_entryPointHelper.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - } +void JsonConsumer::IModule_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystemId) +{ + SANITY_CHECK(); + m_moduleHelper.getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystemId); +} - void JsonConsumer::IEntryPoint_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) - { - SANITY_CHECK(); - m_entryPointHelper.getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics); - } +void JsonConsumer::IModule_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) +{ + SANITY_CHECK(); + m_moduleHelper.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); +} - void JsonConsumer::IEntryPoint_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) - { - SANITY_CHECK(); - m_entryPointHelper.renameEntryPoint(objectId, newName, outEntryPointId); - } +void JsonConsumer::IModule_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_moduleHelper.specialize( + objectId, + specializationArgs, + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); +} + + +void JsonConsumer::IModule_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_moduleHelper.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); +} - void JsonConsumer::IEntryPoint_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_entryPointHelper.linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries, outDiagnosticsId); - } +void JsonConsumer::IModule_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibraryId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_moduleHelper.getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibraryId, + outDiagnosticsId); +} + + +void JsonConsumer::IModule_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) +{ + SANITY_CHECK(); + m_moduleHelper.renameEntryPoint(objectId, newName, outEntryPointId); +} +void JsonConsumer::IModule_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_moduleHelper.linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnosticsId); +} + +// IEntryPoint +void JsonConsumer::IEntryPoint_getSession(ObjectID objectId, ObjectID outSessionId) +{ + SANITY_CHECK(); + m_entryPointHelper.getSession(objectId, outSessionId); +} - // ICompositeComponentType - void JsonConsumer::ICompositeComponentType_getSession(ObjectID objectId, ObjectID outSessionId) - { - SANITY_CHECK(); - m_compositeComponentTypeHelper.getSession(objectId, outSessionId); - } +void JsonConsumer::IEntryPoint_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) +{ + SANITY_CHECK(); + m_entryPointHelper.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); +} - void JsonConsumer::ICompositeComponentType_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) - { - SANITY_CHECK(); - m_compositeComponentTypeHelper.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); - } +void JsonConsumer::IEntryPoint_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_entryPointHelper + .getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); +} - void JsonConsumer::ICompositeComponentType_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_compositeComponentTypeHelper.getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); - } +void JsonConsumer::IEntryPoint_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_entryPointHelper.getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); +} - void JsonConsumer::ICompositeComponentType_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_compositeComponentTypeHelper.getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); - } +void JsonConsumer::IEntryPoint_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) +{ + SANITY_CHECK(); + m_entryPointHelper.getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystem); +} - void JsonConsumer::ICompositeComponentType_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) - { - SANITY_CHECK(); - m_compositeComponentTypeHelper.getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystem); - } +void JsonConsumer::IEntryPoint_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) +{ + SANITY_CHECK(); + m_entryPointHelper.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); +} - void JsonConsumer::ICompositeComponentType_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) - { - SANITY_CHECK(); - m_compositeComponentTypeHelper.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); - } +void JsonConsumer::IEntryPoint_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_entryPointHelper.specialize( + objectId, + specializationArgs, + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); +} + + +void JsonConsumer::IEntryPoint_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_entryPointHelper.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); +} - void JsonConsumer::ICompositeComponentType_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_compositeComponentTypeHelper.specialize(objectId, specializationArgs, specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - } +void JsonConsumer::IEntryPoint_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) +{ + SANITY_CHECK(); + m_entryPointHelper.getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibrary, + outDiagnostics); +} + + +void JsonConsumer::IEntryPoint_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) +{ + SANITY_CHECK(); + m_entryPointHelper.renameEntryPoint(objectId, newName, outEntryPointId); +} - void JsonConsumer::ICompositeComponentType_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_compositeComponentTypeHelper.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - } +void JsonConsumer::IEntryPoint_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_entryPointHelper.linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnosticsId); +} + + +// ICompositeComponentType +void JsonConsumer::ICompositeComponentType_getSession(ObjectID objectId, ObjectID outSessionId) +{ + SANITY_CHECK(); + m_compositeComponentTypeHelper.getSession(objectId, outSessionId); +} - void JsonConsumer::ICompositeComponentType_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) - { - SANITY_CHECK(); - m_compositeComponentTypeHelper.getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics); - } +void JsonConsumer::ICompositeComponentType_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) +{ + SANITY_CHECK(); + m_compositeComponentTypeHelper + .getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); +} + + +void JsonConsumer::ICompositeComponentType_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_compositeComponentTypeHelper + .getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); +} - void JsonConsumer::ICompositeComponentType_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) - { - SANITY_CHECK(); - m_compositeComponentTypeHelper.renameEntryPoint(objectId, newName, outEntryPointId); - } +void JsonConsumer::ICompositeComponentType_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_compositeComponentTypeHelper + .getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); +} - void JsonConsumer::ICompositeComponentType_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_compositeComponentTypeHelper.linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries, outDiagnosticsId); - } +void JsonConsumer::ICompositeComponentType_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) +{ + SANITY_CHECK(); + m_compositeComponentTypeHelper + .getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystem); +} - // ITypeConformance - void JsonConsumer::ITypeConformance_getSession(ObjectID objectId, ObjectID outSessionId) - { - SANITY_CHECK(); - m_typeConformanceHelper.getSession(objectId, outSessionId); - } +void JsonConsumer::ICompositeComponentType_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) +{ + SANITY_CHECK(); + m_compositeComponentTypeHelper + .getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); +} + + +void JsonConsumer::ICompositeComponentType_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_compositeComponentTypeHelper.specialize( + objectId, + specializationArgs, + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); +} + + +void JsonConsumer::ICompositeComponentType_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_compositeComponentTypeHelper.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); +} - void JsonConsumer::ITypeConformance_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) - { - SANITY_CHECK(); - m_typeConformanceHelper.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); - } +void JsonConsumer::ICompositeComponentType_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) +{ + SANITY_CHECK(); + m_compositeComponentTypeHelper.getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibrary, + outDiagnostics); +} + + +void JsonConsumer::ICompositeComponentType_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) +{ + SANITY_CHECK(); + m_compositeComponentTypeHelper.renameEntryPoint(objectId, newName, outEntryPointId); +} - void JsonConsumer::ITypeConformance_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_typeConformanceHelper.getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); - } +void JsonConsumer::ICompositeComponentType_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_compositeComponentTypeHelper.linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnosticsId); +} + + +// ITypeConformance +void JsonConsumer::ITypeConformance_getSession(ObjectID objectId, ObjectID outSessionId) +{ + SANITY_CHECK(); + m_typeConformanceHelper.getSession(objectId, outSessionId); +} - void JsonConsumer::ITypeConformance_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_typeConformanceHelper.getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); - } +void JsonConsumer::ITypeConformance_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) +{ + SANITY_CHECK(); + m_typeConformanceHelper.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); +} - void JsonConsumer::ITypeConformance_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) - { - SANITY_CHECK(); - m_typeConformanceHelper.getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystem); - } +void JsonConsumer::ITypeConformance_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_typeConformanceHelper + .getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); +} - void JsonConsumer::ITypeConformance_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) - { - SANITY_CHECK(); - m_typeConformanceHelper.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); - } +void JsonConsumer::ITypeConformance_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_typeConformanceHelper.getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); +} - void JsonConsumer::ITypeConformance_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_typeConformanceHelper.specialize(objectId, specializationArgs, specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - } +void JsonConsumer::ITypeConformance_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) +{ + SANITY_CHECK(); + m_typeConformanceHelper + .getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystem); +} - void JsonConsumer::ITypeConformance_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_typeConformanceHelper.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - } +void JsonConsumer::ITypeConformance_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) +{ + SANITY_CHECK(); + m_typeConformanceHelper.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); +} - void JsonConsumer::ITypeConformance_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) - { - SANITY_CHECK(); - m_typeConformanceHelper.getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics); - } +void JsonConsumer::ITypeConformance_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_typeConformanceHelper.specialize( + objectId, + specializationArgs, + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); +} + + +void JsonConsumer::ITypeConformance_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_typeConformanceHelper.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); +} - void JsonConsumer::ITypeConformance_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) - { - SANITY_CHECK(); - m_typeConformanceHelper.renameEntryPoint(objectId, newName, outEntryPointId); - } +void JsonConsumer::ITypeConformance_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) +{ + SANITY_CHECK(); + m_typeConformanceHelper.getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibrary, + outDiagnostics); +} + + +void JsonConsumer::ITypeConformance_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) +{ + SANITY_CHECK(); + m_typeConformanceHelper.renameEntryPoint(objectId, newName, outEntryPointId); +} - void JsonConsumer::ITypeConformance_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) - { - SANITY_CHECK(); - m_typeConformanceHelper.linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries, outDiagnosticsId); - } +void JsonConsumer::ITypeConformance_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) +{ + SANITY_CHECK(); + m_typeConformanceHelper.linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnosticsId); +} }; // namespace SlangRecord diff --git a/source/slang-record-replay/replay/json-consumer.h b/source/slang-record-replay/replay/json-consumer.h index a7eaf1ec2..8a367cc20 100644 --- a/source/slang-record-replay/replay/json-consumer.h +++ b/source/slang-record-replay/replay/json-consumer.h @@ -1,236 +1,553 @@ #ifndef JSON_CONSUMER_H #define JSON_CONSUMER_H -#include "decoder-consumer.h" #include "../../core/slang-stream.h" -#include "../util/record-utility.h" #include "../util/record-format.h" +#include "../util/record-utility.h" +#include "decoder-consumer.h" namespace SlangRecord { - class CommonInterfaceWriter +class CommonInterfaceWriter +{ +public: + CommonInterfaceWriter(ApiClassId classId, Slang::FileStream& fileStream) + : m_fileStream(fileStream) { - public: - CommonInterfaceWriter(ApiClassId classId, Slang::FileStream& fileStream) - : m_fileStream(fileStream) + switch (classId) { - switch(classId) - { - case ApiClassId::Class_IModule: - m_className = "IModule"; - break; - case ApiClassId::Class_IEntryPoint: - m_className = "IEntryPoint"; - break; - case ApiClassId::Class_ICompositeComponentType: - m_className = "ICompositeComponentType"; - break; - case ApiClassId::Class_ITypeConformance: - m_className = "ITypeConformance"; - break; - default: - slangRecordLog(LogLevel::Error, "Invalid classNo %u\n", classId); - break; - } + case ApiClassId::Class_IModule: m_className = "IModule"; break; + case ApiClassId::Class_IEntryPoint: m_className = "IEntryPoint"; break; + case ApiClassId::Class_ICompositeComponentType: + m_className = "ICompositeComponentType"; + break; + case ApiClassId::Class_ITypeConformance: m_className = "ITypeConformance"; break; + default: slangRecordLog(LogLevel::Error, "Invalid classNo %u\n", classId); break; } - CommonInterfaceWriter() = delete; - void getSession(ObjectID objectId, ObjectID outSessionId); - void getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId); - void getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId); - void getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId); - void getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystemId); - void getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId); - void specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId); - void link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId); - void getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibraryId, - ObjectID outDiagnosticsId); - void renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId); - void linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId); - protected: - Slang::String m_className; - Slang::FileStream& m_fileStream; + } + CommonInterfaceWriter() = delete; + void getSession(ObjectID objectId, ObjectID outSessionId); + void getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId); + void getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId); + void getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId); + void getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystemId); + void getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId); + void specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId); + void link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId); + void getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibraryId, + ObjectID outDiagnosticsId); + void renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId); + void linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId); + +protected: + Slang::String m_className; + Slang::FileStream& m_fileStream; +}; + +class JsonConsumer : public IDecoderConsumer, public Slang::RefObject +{ +public: + JsonConsumer(const Slang::String& filePath); + virtual ~JsonConsumer() = default; + virtual void CreateGlobalSession(ObjectID outGlobalSessionId); + virtual void IGlobalSession_createSession( + ObjectID objectId, + slang::SessionDesc const& desc, + ObjectID outSessionId); + virtual void IGlobalSession_findProfile(ObjectID objectId, char const* name); + virtual void IGlobalSession_setDownstreamCompilerPath( + ObjectID objectId, + SlangPassThrough passThrough, + char const* path); + virtual void IGlobalSession_setDownstreamCompilerPrelude( + ObjectID objectId, + SlangPassThrough inPassThrough, + char const* prelude); + virtual void IGlobalSession_getDownstreamCompilerPrelude( + ObjectID objectId, + SlangPassThrough inPassThrough, + ObjectID outPreludeId); + + virtual void IGlobalSession_getBuildTagString(ObjectID objectId) { (void)objectId; } + + virtual void IGlobalSession_setDefaultDownstreamCompiler( + ObjectID objectId, + SlangSourceLanguage sourceLanguage, + SlangPassThrough defaultCompiler); + virtual void IGlobalSession_getDefaultDownstreamCompiler( + ObjectID objectId, + SlangSourceLanguage sourceLanguage); + virtual void IGlobalSession_setLanguagePrelude( + ObjectID objectId, + SlangSourceLanguage inSourceLanguage, + char const* prelude); + virtual void IGlobalSession_getLanguagePrelude( + ObjectID objectId, + SlangSourceLanguage inSourceLanguage, + ObjectID outPreludeId); + virtual void IGlobalSession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequest); + virtual void IGlobalSession_addBuiltins( + ObjectID objectId, + char const* sourcePath, + char const* sourceString); + virtual void IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ObjectID loaderId); + virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId); + virtual void IGlobalSession_checkCompileTargetSupport( + ObjectID objectId, + SlangCompileTarget target); + virtual void IGlobalSession_checkPassThroughSupport( + ObjectID objectId, + SlangPassThrough passThrough); + virtual void IGlobalSession_compileCoreModule( + ObjectID objectId, + slang::CompileCoreModuleFlags flags); + virtual void IGlobalSession_loadCoreModule( + ObjectID objectId, + const void* coreModule, + size_t coreModuleSizeInBytes); + virtual void IGlobalSession_saveCoreModule( + ObjectID objectId, + SlangArchiveType archiveType, + ObjectID outBlobId); + virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name); + virtual void IGlobalSession_setDownstreamCompilerForTransition( + ObjectID objectId, + SlangCompileTarget source, + SlangCompileTarget target, + SlangPassThrough compiler); + virtual void IGlobalSession_getDownstreamCompilerForTransition( + ObjectID objectId, + SlangCompileTarget source, + SlangCompileTarget target); + + virtual void IGlobalSession_getCompilerElapsedTime(ObjectID objectId) { (void)objectId; } + + virtual void IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, char const* jsonPath); + virtual void IGlobalSession_parseCommandLineArguments( + ObjectID objectId, + int argc, + const char* const* argv, + ObjectID outSessionDescId, + ObjectID outAllocationId); + virtual void IGlobalSession_getSessionDescDigest( + ObjectID objectId, + slang::SessionDesc* sessionDesc, + ObjectID outBlobId); + + // ISession + virtual void ISession_getGlobalSession(ObjectID objectId, ObjectID outGlobalSessionId); + virtual void ISession_loadModule( + ObjectID objectId, + const char* moduleName, + ObjectID outDiagnostics, + ObjectID outModuleId); + + virtual void ISession_loadModuleFromIRBlob( + ObjectID objectId, + const char* moduleName, + const char* path, + slang::IBlob* source, + ObjectID outDiagnosticsId, + ObjectID outModuleId); + virtual void ISession_loadModuleFromSource( + ObjectID objectId, + const char* moduleName, + const char* path, + slang::IBlob* source, + ObjectID outDiagnosticsId, + ObjectID outModuleId); + virtual void ISession_loadModuleFromSourceString( + ObjectID objectId, + const char* moduleName, + const char* path, + const char* string, + ObjectID outDiagnosticsId, + ObjectID outModuleId); + virtual void ISession_createCompositeComponentType( + ObjectID objectId, + ObjectID* componentTypeIds, + SlangInt componentTypeCount, + ObjectID outCompositeComponentTypeIds, + ObjectID outDiagnosticsId); + + virtual void ISession_specializeType( + ObjectID objectId, + ObjectID typeId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outDiagnosticsId, + ObjectID outTypeReflectionId); + + virtual void ISession_getTypeLayout( + ObjectID objectId, + ObjectID typeId, + SlangInt targetIndex, + slang::LayoutRules rules, + ObjectID outDiagnosticsId, + ObjectID outTypeLayoutReflection); + + virtual void ISession_getContainerType( + ObjectID objectId, + ObjectID elementType, + slang::ContainerType containerType, + ObjectID outDiagnosticsId, + ObjectID outTypeReflectionId); + + virtual void ISession_getDynamicType(ObjectID objectId, ObjectID outTypeReflectionId); + + virtual void ISession_getTypeRTTIMangledName( + ObjectID objectId, + ObjectID typeId, + ObjectID outNameBlobId); + + virtual void ISession_getTypeConformanceWitnessMangledName( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + ObjectID outNameBlobId); + + virtual void ISession_getTypeConformanceWitnessSequentialID( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + uint32_t outId); + + virtual void ISession_createTypeConformanceComponentType( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + ObjectID outConformanceId, + SlangInt conformanceIdOverride, + ObjectID outDiagnosticsId); + + virtual void ISession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequestId); + + virtual void ISession_getLoadedModuleCount(ObjectID objectId) { (void)objectId; } + + virtual void ISession_getLoadedModule(ObjectID objectId, SlangInt index, ObjectID outModuleId); + + virtual void ISession_isBinaryModuleUpToDate(ObjectID objectId) { (void)objectId; } + + // IModule + virtual void IModule_findEntryPointByName( + ObjectID objectId, + char const* name, + ObjectID outEntryPointId); + + virtual void IModule_getDefinedEntryPointCount(ObjectID objectId) { (void)objectId; } + + virtual void IModule_getDefinedEntryPoint( + ObjectID objectId, + SlangInt32 index, + ObjectID outEntryPointId); + virtual void IModule_serialize(ObjectID objectId, ObjectID outSerializedBlobId); + virtual void IModule_writeToFile(ObjectID objectId, char const* fileName); + + virtual void IModule_getName(ObjectID objectId) { (void)objectId; } + virtual void IModule_getFilePath(ObjectID objectId) { (void)objectId; } + virtual void IModule_getUniqueIdentity(ObjectID objectId) { (void)objectId; } + + virtual void IModule_findAndCheckEntryPoint( + ObjectID objectId, + char const* name, + SlangStage stage, + ObjectID outEntryPointId, + ObjectID outDiagnostics); + + virtual void IModule_getSession(ObjectID objectId, ObjectID outSessionId); + virtual void IModule_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId); + + virtual void IModule_getSpecializationParamCount(ObjectID objectId) { (void)objectId; } + + virtual void IModule_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId); + virtual void IModule_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId); + virtual void IModule_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem); + virtual void IModule_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId); + virtual void IModule_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId); + virtual void IModule_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId); + virtual void IModule_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics); + virtual void IModule_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId); + virtual void IModule_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId); + + // IEntryPoint + virtual void IEntryPoint_getSession(ObjectID objectId, ObjectID outSessionId); + virtual void IEntryPoint_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId); + + virtual void IEntryPoint_getSpecializationParamCount(ObjectID objectId) { (void)objectId; }; + + virtual void IEntryPoint_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId); + virtual void IEntryPoint_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId); + virtual void IEntryPoint_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem); + virtual void IEntryPoint_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId); + virtual void IEntryPoint_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId); + virtual void IEntryPoint_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId); + virtual void IEntryPoint_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics); + virtual void IEntryPoint_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId); + virtual void IEntryPoint_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId); + + // ICompositeComponentType + virtual void ICompositeComponentType_getSession(ObjectID objectId, ObjectID outSessionId); + virtual void ICompositeComponentType_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId); + + virtual void ICompositeComponentType_getSpecializationParamCount(ObjectID objectId) + { + (void)objectId; }; - class JsonConsumer : public IDecoderConsumer, public Slang::RefObject + virtual void ICompositeComponentType_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnostics); + virtual void ICompositeComponentType_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnostics); + virtual void ICompositeComponentType_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem); + virtual void ICompositeComponentType_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId); + virtual void ICompositeComponentType_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId); + virtual void ICompositeComponentType_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId); + virtual void ICompositeComponentType_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics); + virtual void ICompositeComponentType_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId); + virtual void ICompositeComponentType_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId); + + // ITypeConformance + virtual void ITypeConformance_getSession(ObjectID objectId, ObjectID outSessionId); + virtual void ITypeConformance_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId); + + virtual void ITypeConformance_getSpecializationParamCount(ObjectID objectId) { - public: - JsonConsumer(const Slang::String& filePath); - virtual ~JsonConsumer() = default; - virtual void CreateGlobalSession(ObjectID outGlobalSessionId); - virtual void IGlobalSession_createSession(ObjectID objectId, slang::SessionDesc const& desc, ObjectID outSessionId); - virtual void IGlobalSession_findProfile(ObjectID objectId, char const* name); - virtual void IGlobalSession_setDownstreamCompilerPath(ObjectID objectId, SlangPassThrough passThrough, char const* path); - virtual void IGlobalSession_setDownstreamCompilerPrelude(ObjectID objectId, SlangPassThrough inPassThrough, char const* prelude); - virtual void IGlobalSession_getDownstreamCompilerPrelude(ObjectID objectId, SlangPassThrough inPassThrough, ObjectID outPreludeId); - - virtual void IGlobalSession_getBuildTagString(ObjectID objectId) { (void) objectId; } - - virtual void IGlobalSession_setDefaultDownstreamCompiler(ObjectID objectId, SlangSourceLanguage sourceLanguage, SlangPassThrough defaultCompiler); - virtual void IGlobalSession_getDefaultDownstreamCompiler(ObjectID objectId, SlangSourceLanguage sourceLanguage); - virtual void IGlobalSession_setLanguagePrelude(ObjectID objectId, SlangSourceLanguage inSourceLanguage, char const* prelude); - virtual void IGlobalSession_getLanguagePrelude(ObjectID objectId, SlangSourceLanguage inSourceLanguage, ObjectID outPreludeId); - virtual void IGlobalSession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequest); - virtual void IGlobalSession_addBuiltins(ObjectID objectId, char const* sourcePath, char const* sourceString); - virtual void IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ObjectID loaderId); - virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId); - virtual void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, SlangCompileTarget target); - virtual void IGlobalSession_checkPassThroughSupport(ObjectID objectId, SlangPassThrough passThrough); - virtual void IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags); - virtual void IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes); - virtual void IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId); - virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name); - virtual void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler); - virtual void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target); - - virtual void IGlobalSession_getCompilerElapsedTime(ObjectID objectId) { (void) objectId; } - - virtual void IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, char const* jsonPath); - virtual void IGlobalSession_parseCommandLineArguments(ObjectID objectId, int argc, const char* const* argv, ObjectID outSessionDescId, ObjectID outAllocationId); - virtual void IGlobalSession_getSessionDescDigest(ObjectID objectId, slang::SessionDesc* sessionDesc, ObjectID outBlobId); - - // ISession - virtual void ISession_getGlobalSession(ObjectID objectId, ObjectID outGlobalSessionId); - virtual void ISession_loadModule(ObjectID objectId, const char* moduleName, ObjectID outDiagnostics, ObjectID outModuleId); - - virtual void ISession_loadModuleFromIRBlob(ObjectID objectId, const char* moduleName, - const char* path, slang::IBlob* source, ObjectID outDiagnosticsId, ObjectID outModuleId); - virtual void ISession_loadModuleFromSource(ObjectID objectId, const char* moduleName, - const char* path, slang::IBlob* source, ObjectID outDiagnosticsId, ObjectID outModuleId); - virtual void ISession_loadModuleFromSourceString(ObjectID objectId, const char* moduleName, - const char* path, const char* string, ObjectID outDiagnosticsId, ObjectID outModuleId); - virtual void ISession_createCompositeComponentType(ObjectID objectId, ObjectID* componentTypeIds, - SlangInt componentTypeCount, ObjectID outCompositeComponentTypeIds, ObjectID outDiagnosticsId); - - virtual void ISession_specializeType(ObjectID objectId, ObjectID typeId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outDiagnosticsId, ObjectID outTypeReflectionId); - - virtual void ISession_getTypeLayout(ObjectID objectId, ObjectID typeId, SlangInt targetIndex, - slang::LayoutRules rules, ObjectID outDiagnosticsId, ObjectID outTypeLayoutReflection); - - virtual void ISession_getContainerType(ObjectID objectId, ObjectID elementType, - slang::ContainerType containerType, ObjectID outDiagnosticsId, ObjectID outTypeReflectionId); - - virtual void ISession_getDynamicType(ObjectID objectId, ObjectID outTypeReflectionId); - - virtual void ISession_getTypeRTTIMangledName(ObjectID objectId, ObjectID typeId, ObjectID outNameBlobId); - - virtual void ISession_getTypeConformanceWitnessMangledName(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, ObjectID outNameBlobId); - - virtual void ISession_getTypeConformanceWitnessSequentialID(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, uint32_t outId); - - virtual void ISession_createTypeConformanceComponentType(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, ObjectID outConformanceId, - SlangInt conformanceIdOverride, ObjectID outDiagnosticsId); - - virtual void ISession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequestId); - - virtual void ISession_getLoadedModuleCount(ObjectID objectId) { (void) objectId; } - - virtual void ISession_getLoadedModule(ObjectID objectId, SlangInt index, ObjectID outModuleId); - - virtual void ISession_isBinaryModuleUpToDate(ObjectID objectId) { (void) objectId; } - - // IModule - virtual void IModule_findEntryPointByName(ObjectID objectId, char const* name, ObjectID outEntryPointId); - - virtual void IModule_getDefinedEntryPointCount(ObjectID objectId) { (void) objectId; } - - virtual void IModule_getDefinedEntryPoint(ObjectID objectId, SlangInt32 index, ObjectID outEntryPointId); - virtual void IModule_serialize(ObjectID objectId, ObjectID outSerializedBlobId); - virtual void IModule_writeToFile(ObjectID objectId, char const* fileName); - - virtual void IModule_getName(ObjectID objectId) { (void) objectId; } - virtual void IModule_getFilePath(ObjectID objectId) { (void) objectId; } - virtual void IModule_getUniqueIdentity(ObjectID objectId) { (void) objectId; } - - virtual void IModule_findAndCheckEntryPoint(ObjectID objectId, char const* name, SlangStage stage, ObjectID outEntryPointId, ObjectID outDiagnostics); - - virtual void IModule_getSession(ObjectID objectId, ObjectID outSessionId); - virtual void IModule_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId); - - virtual void IModule_getSpecializationParamCount(ObjectID objectId) { (void) objectId; } - - virtual void IModule_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId); - virtual void IModule_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId); - virtual void IModule_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem); - virtual void IModule_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId); - virtual void IModule_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId); - virtual void IModule_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId); - virtual void IModule_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics); - virtual void IModule_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId); - virtual void IModule_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId); - - // IEntryPoint - virtual void IEntryPoint_getSession(ObjectID objectId, ObjectID outSessionId); - virtual void IEntryPoint_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId); - - virtual void IEntryPoint_getSpecializationParamCount(ObjectID objectId) { (void) objectId; }; - - virtual void IEntryPoint_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId); - virtual void IEntryPoint_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId); - virtual void IEntryPoint_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem); - virtual void IEntryPoint_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId); - virtual void IEntryPoint_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId); - virtual void IEntryPoint_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId); - virtual void IEntryPoint_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics); - virtual void IEntryPoint_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId); - virtual void IEntryPoint_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId); - - // ICompositeComponentType - virtual void ICompositeComponentType_getSession(ObjectID objectId, ObjectID outSessionId); - virtual void ICompositeComponentType_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId); - - virtual void ICompositeComponentType_getSpecializationParamCount(ObjectID objectId) { (void) objectId; }; - - virtual void ICompositeComponentType_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnostics); - virtual void ICompositeComponentType_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnostics); - virtual void ICompositeComponentType_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem); - virtual void ICompositeComponentType_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId); - virtual void ICompositeComponentType_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId); - virtual void ICompositeComponentType_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId); - virtual void ICompositeComponentType_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics); - virtual void ICompositeComponentType_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId); - virtual void ICompositeComponentType_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId); - - // ITypeConformance - virtual void ITypeConformance_getSession(ObjectID objectId, ObjectID outSessionId); - virtual void ITypeConformance_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId); - - virtual void ITypeConformance_getSpecializationParamCount(ObjectID objectId) { (void) objectId; }; - - virtual void ITypeConformance_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId); - virtual void ITypeConformance_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId); - virtual void ITypeConformance_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem); - virtual void ITypeConformance_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId); - virtual void ITypeConformance_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId); - virtual void ITypeConformance_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId); - virtual void ITypeConformance_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics); - virtual void ITypeConformance_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId); - virtual void ITypeConformance_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId); - - static void _writeCompilerOptionEntryHelper(Slang::StringBuilder& builder, int indent, slang::CompilerOptionEntry* compilerOptionEntries, uint32_t compilerOptionEntryCount, bool isLast = false); - static void _writeSessionDescHelper(Slang::StringBuilder& builder, int indent, slang::SessionDesc const& sessionDesc, Slang::String keyName, bool isLast = false); - - private: - Slang::FileStream m_fileStream; - bool m_isFileValid = false; - CommonInterfaceWriter m_moduleHelper {ApiClassId::Class_IModule, m_fileStream}; - CommonInterfaceWriter m_entryPointHelper {ApiClassId::Class_IEntryPoint, m_fileStream}; - CommonInterfaceWriter m_compositeComponentTypeHelper {ApiClassId::Class_ICompositeComponentType, m_fileStream}; - CommonInterfaceWriter m_typeConformanceHelper {ApiClassId::Class_ITypeConformance, m_fileStream}; - + (void)objectId; }; -} + + virtual void ITypeConformance_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId); + virtual void ITypeConformance_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId); + virtual void ITypeConformance_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem); + virtual void ITypeConformance_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId); + virtual void ITypeConformance_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId); + virtual void ITypeConformance_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId); + virtual void ITypeConformance_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics); + virtual void ITypeConformance_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId); + virtual void ITypeConformance_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId); + + static void _writeCompilerOptionEntryHelper( + Slang::StringBuilder& builder, + int indent, + slang::CompilerOptionEntry* compilerOptionEntries, + uint32_t compilerOptionEntryCount, + bool isLast = false); + static void _writeSessionDescHelper( + Slang::StringBuilder& builder, + int indent, + slang::SessionDesc const& sessionDesc, + Slang::String keyName, + bool isLast = false); + +private: + Slang::FileStream m_fileStream; + bool m_isFileValid = false; + CommonInterfaceWriter m_moduleHelper{ApiClassId::Class_IModule, m_fileStream}; + CommonInterfaceWriter m_entryPointHelper{ApiClassId::Class_IEntryPoint, m_fileStream}; + CommonInterfaceWriter m_compositeComponentTypeHelper{ + ApiClassId::Class_ICompositeComponentType, + m_fileStream}; + CommonInterfaceWriter m_typeConformanceHelper{ApiClassId::Class_ITypeConformance, m_fileStream}; +}; +} // namespace SlangRecord #endif // JSON_CONSUMER_H diff --git a/source/slang-record-replay/replay/parameter-decoder.cpp b/source/slang-record-replay/replay/parameter-decoder.cpp index ed1c1dfe2..824b69de8 100644 --- a/source/slang-record-replay/replay/parameter-decoder.cpp +++ b/source/slang-record-replay/replay/parameter-decoder.cpp @@ -1,215 +1,275 @@ -#include <string.h> #include "parameter-decoder.h" +#include <string.h> + namespace SlangRecord { - size_t ParameterDecoder::decodeString(const uint8_t* buffer, int64_t bufferSize, PointerDecoder<char*>& typeDecoder) +size_t ParameterDecoder::decodeString( + const uint8_t* buffer, + int64_t bufferSize, + PointerDecoder<char*>& typeDecoder) +{ + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); + + if (bufferSize < (int64_t)sizeof(uint32_t)) { - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); + return 0; + } - if (bufferSize < (int64_t)sizeof(uint32_t)) - { - return 0; - } + uint32_t stringLength = 0; + size_t readByte = 0; + readByte += decodeUint32(buffer, bufferSize - readByte, stringLength); - uint32_t stringLength = 0; - size_t readByte = 0; - readByte += decodeUint32(buffer, bufferSize - readByte, stringLength); + SLANG_RECORD_ASSERT(bufferSize >= (int64_t)(readByte + stringLength)); - SLANG_RECORD_ASSERT(bufferSize >= (int64_t)(readByte + stringLength)); + if (stringLength == 0) + { + return readByte; + } - if (stringLength == 0) - { - return readByte; - } + uint8_t* data = (uint8_t*)typeDecoder.allocate(stringLength + 1); + memcpy(data, buffer + readByte, stringLength); + typeDecoder.setPointer(data); + typeDecoder.setDataSize(stringLength + 1); + return readByte + stringLength; +} - uint8_t* data = (uint8_t*)typeDecoder.allocate(stringLength + 1); - memcpy(data, buffer + readByte, stringLength); - typeDecoder.setPointer(data); - typeDecoder.setDataSize(stringLength + 1); - return readByte + stringLength; +size_t ParameterDecoder::decodePointer( + const uint8_t* buffer, + int64_t bufferSize, + PointerDecoder<void*>& pointerDecoder) +{ + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); + + if (bufferSize < (int64_t)sizeof(uint32_t)) + { + return 0; } - size_t ParameterDecoder::decodePointer(const uint8_t* buffer, int64_t bufferSize, PointerDecoder<void*>& pointerDecoder) + uint64_t address = 0; + size_t readByte = decodeAddress(buffer, bufferSize, address); + pointerDecoder.setPointerAddress(address); + + uint64_t dataSize = 0; + readByte += decodeUint64(buffer + readByte, bufferSize - readByte, dataSize); + + // return if the data size is 0 + if (dataSize == 0) { - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); + return readByte; + } - if (bufferSize < (int64_t)sizeof(uint32_t)) - { - return 0; - } + SLANG_RECORD_ASSERT(bufferSize >= (int64_t)(readByte + dataSize)); - uint64_t address = 0; - size_t readByte = decodeAddress(buffer, bufferSize, address); - pointerDecoder.setPointerAddress(address); + uint8_t* data = (uint8_t*)pointerDecoder.allocate(dataSize); + memcpy(data, buffer + readByte, dataSize); + pointerDecoder.setPointer(data); + pointerDecoder.setDataSize(dataSize); + return readByte + dataSize; +} - uint64_t dataSize = 0; - readByte += decodeUint64(buffer + readByte, bufferSize - readByte, dataSize); +size_t ParameterDecoder::decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::SessionDesc>& sessionDesc) +{ + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - // return if the data size is 0 - if (dataSize == 0) - { - return readByte; - } + if (bufferSize < (int64_t)sizeof(uint64_t)) + { + return 0; + } + + size_t readByte = 0; + slang::SessionDesc& desc = sessionDesc.getValue(); - SLANG_RECORD_ASSERT(bufferSize >= (int64_t)(readByte + dataSize)); + uint64_t structSize = 0; + readByte = decodeUint64(buffer, bufferSize, structSize); + desc.structureSize = structSize; - uint8_t* data = (uint8_t*)pointerDecoder.allocate(dataSize); - memcpy(data, buffer + readByte, dataSize); - pointerDecoder.setPointer(data); - pointerDecoder.setDataSize(dataSize); - return readByte + dataSize; + readByte += decodeInt64(buffer + readByte, bufferSize - readByte, desc.targetCount); + + if (desc.targetCount > 0) + { + slang::TargetDesc* targets = + (slang::TargetDesc*)sessionDesc.allocate(sizeof(slang::TargetDesc) * desc.targetCount); + readByte += + decodeStructArray(buffer + readByte, bufferSize - readByte, targets, desc.targetCount); + desc.targets = targets; } - size_t ParameterDecoder::decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::SessionDesc>& sessionDesc) + readByte += decodeUint32(buffer + readByte, bufferSize - readByte, desc.flags); + readByte += + decodeEnumValue(buffer + readByte, bufferSize - readByte, desc.defaultMatrixLayoutMode); + readByte += decodeInt64(buffer + readByte, bufferSize - readByte, desc.searchPathCount); + + if (desc.searchPathCount > 0) { - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - - if(bufferSize < (int64_t)sizeof(uint64_t)) - { - return 0; - } - - size_t readByte = 0; - slang::SessionDesc& desc = sessionDesc.getValue(); - - uint64_t structSize = 0; - readByte = decodeUint64(buffer, bufferSize, structSize); - desc.structureSize = structSize; - - readByte += decodeInt64(buffer + readByte, bufferSize - readByte, desc.targetCount); - - if (desc.targetCount > 0) - { - slang::TargetDesc* targets = (slang::TargetDesc*)sessionDesc.allocate(sizeof(slang::TargetDesc) * desc.targetCount); - readByte += decodeStructArray(buffer + readByte, bufferSize - readByte, targets, desc.targetCount); - desc.targets = targets; - } - - readByte += decodeUint32(buffer + readByte, bufferSize - readByte, desc.flags); - readByte += decodeEnumValue(buffer + readByte, bufferSize - readByte, desc.defaultMatrixLayoutMode); - readByte += decodeInt64(buffer + readByte, bufferSize - readByte, desc.searchPathCount); - - if (desc.searchPathCount > 0) - { - char** searchPaths = (char**)sessionDesc.allocate(sizeof(char*) * desc.searchPathCount); - decodeStringArray(buffer + readByte, bufferSize - readByte, searchPaths, desc.searchPathCount); - desc.searchPaths = searchPaths; - } - - readByte += decodeInt64(buffer + readByte, bufferSize - readByte, desc.preprocessorMacroCount); - if (desc.preprocessorMacroCount > 0) - { - slang::PreprocessorMacroDesc* macros = (slang::PreprocessorMacroDesc*) - sessionDesc.allocate(sizeof(slang::PreprocessorMacroDesc) * desc.preprocessorMacroCount); - readByte += decodeStructArray(buffer + readByte, bufferSize - readByte, macros, desc.preprocessorMacroCount); - desc.preprocessorMacros = macros; - } - - readByte += decodeBool(buffer + readByte, bufferSize - readByte, desc.enableEffectAnnotations); - readByte += decodeBool(buffer + readByte, bufferSize - readByte, desc.allowGLSLSyntax); - readByte += decodeUint32(buffer + readByte, bufferSize - readByte, desc.compilerOptionEntryCount); - - if (desc.compilerOptionEntryCount > 0) - { - slang::CompilerOptionEntry* entries = (slang::CompilerOptionEntry*) - sessionDesc.allocate(sizeof(slang::CompilerOptionEntry) * desc.compilerOptionEntryCount); - readByte += decodeStructArray(buffer + readByte, bufferSize - readByte, entries, desc.compilerOptionEntryCount); - desc.compilerOptionEntries = entries; - } + char** searchPaths = (char**)sessionDesc.allocate(sizeof(char*) * desc.searchPathCount); + decodeStringArray( + buffer + readByte, + bufferSize - readByte, + searchPaths, + desc.searchPathCount); + desc.searchPaths = searchPaths; + } - return readByte; + readByte += decodeInt64(buffer + readByte, bufferSize - readByte, desc.preprocessorMacroCount); + if (desc.preprocessorMacroCount > 0) + { + slang::PreprocessorMacroDesc* macros = (slang::PreprocessorMacroDesc*)sessionDesc.allocate( + sizeof(slang::PreprocessorMacroDesc) * desc.preprocessorMacroCount); + readByte += decodeStructArray( + buffer + readByte, + bufferSize - readByte, + macros, + desc.preprocessorMacroCount); + desc.preprocessorMacros = macros; } - size_t ParameterDecoder::decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::PreprocessorMacroDesc>& desc) + readByte += decodeBool(buffer + readByte, bufferSize - readByte, desc.enableEffectAnnotations); + readByte += decodeBool(buffer + readByte, bufferSize - readByte, desc.allowGLSLSyntax); + readByte += + decodeUint32(buffer + readByte, bufferSize - readByte, desc.compilerOptionEntryCount); + + if (desc.compilerOptionEntryCount > 0) { - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); + slang::CompilerOptionEntry* entries = (slang::CompilerOptionEntry*)sessionDesc.allocate( + sizeof(slang::CompilerOptionEntry) * desc.compilerOptionEntryCount); + readByte += decodeStructArray( + buffer + readByte, + bufferSize - readByte, + entries, + desc.compilerOptionEntryCount); + desc.compilerOptionEntries = entries; + } - size_t readByte = 0; - PointerDecoder<char*> name; - PointerDecoder<char*> value; + return readByte; +} - readByte = decodeString(buffer, bufferSize, name); - readByte += decodeString(buffer + readByte, bufferSize - readByte, value); +size_t ParameterDecoder::decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::PreprocessorMacroDesc>& desc) +{ + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - desc.getValue().name = name.getPointer(); - desc.getValue().value = value.getPointer(); + size_t readByte = 0; + PointerDecoder<char*> name; + PointerDecoder<char*> value; - return readByte; - } + readByte = decodeString(buffer, bufferSize, name); + readByte += decodeString(buffer + readByte, bufferSize - readByte, value); - size_t ParameterDecoder::decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::CompilerOptionEntry>& entry) - { - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); + desc.getValue().name = name.getPointer(); + desc.getValue().value = value.getPointer(); - size_t readByte = 0; - readByte = decodeEnumValue(buffer, bufferSize, entry.getValue().name); + return readByte; +} - ValueDecoder<slang::CompilerOptionValue> value; - readByte += decodeStruct(buffer + readByte, bufferSize - readByte, value); - entry.getValue().value = value.getValue(); +size_t ParameterDecoder::decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::CompilerOptionEntry>& entry) +{ + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - return readByte; - } + size_t readByte = 0; + readByte = decodeEnumValue(buffer, bufferSize, entry.getValue().name); - size_t ParameterDecoder::decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::CompilerOptionValue>& value) - { - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); + ValueDecoder<slang::CompilerOptionValue> value; + readByte += decodeStruct(buffer + readByte, bufferSize - readByte, value); + entry.getValue().value = value.getValue(); - size_t readByte = 0; - readByte = decodeEnumValue(buffer, bufferSize, value.getValue().kind); - readByte += decodeInt32(buffer + readByte, bufferSize - readByte, value.getValue().intValue0); + return readByte; +} - PointerDecoder<char*> stringValue0; - readByte += decodeString(buffer + readByte, bufferSize - readByte, stringValue0); - value.getValue().stringValue0 = stringValue0.getPointer(); +size_t ParameterDecoder::decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::CompilerOptionValue>& value) +{ + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - PointerDecoder<char*> stringValue1; - readByte += decodeString(buffer + readByte, bufferSize - readByte, stringValue1); - value.getValue().stringValue1 = stringValue1.getPointer(); - return 0; - } + size_t readByte = 0; + readByte = decodeEnumValue(buffer, bufferSize, value.getValue().kind); + readByte += decodeInt32(buffer + readByte, bufferSize - readByte, value.getValue().intValue0); - size_t ParameterDecoder::decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::TargetDesc>& targetDesc) - { - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - - size_t readByte = 0; - uint64_t structSize = 0; - readByte = decodeUint64(buffer, bufferSize, structSize); - targetDesc.getValue().structureSize = structSize; - - readByte += decodeEnumValue(buffer + readByte, bufferSize - readByte, targetDesc.getValue().format); - readByte += decodeEnumValue(buffer + readByte, bufferSize - readByte, targetDesc.getValue().profile); - readByte += decodeEnumValue(buffer + readByte, bufferSize - readByte, targetDesc.getValue().flags); - readByte += decodeEnumValue(buffer + readByte, bufferSize - readByte, targetDesc.getValue().floatingPointMode); - readByte += decodeEnumValue(buffer + readByte, bufferSize - readByte, targetDesc.getValue().lineDirectiveMode); - readByte += decodeBool(buffer + readByte, bufferSize - readByte, targetDesc.getValue().forceGLSLScalarBufferLayout); - readByte += decodeUint32(buffer + readByte, bufferSize - readByte, targetDesc.getValue().compilerOptionEntryCount); - - if (targetDesc.getValue().compilerOptionEntryCount > 0) - { - slang::CompilerOptionEntry* entries = (slang::CompilerOptionEntry*) - targetDesc.allocate(sizeof(slang::CompilerOptionEntry) * targetDesc.getValue().compilerOptionEntryCount); - readByte += decodeStructArray(buffer + readByte, bufferSize - readByte, entries, targetDesc.getValue().compilerOptionEntryCount); - targetDesc.getValue().compilerOptionEntries = entries; - } + PointerDecoder<char*> stringValue0; + readByte += decodeString(buffer + readByte, bufferSize - readByte, stringValue0); + value.getValue().stringValue0 = stringValue0.getPointer(); - return readByte; - } + PointerDecoder<char*> stringValue1; + readByte += decodeString(buffer + readByte, bufferSize - readByte, stringValue1); + value.getValue().stringValue1 = stringValue1.getPointer(); + return 0; +} - size_t ParameterDecoder::decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::SpecializationArg>& specializationArg) +size_t ParameterDecoder::decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::TargetDesc>& targetDesc) +{ + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); + + size_t readByte = 0; + uint64_t structSize = 0; + readByte = decodeUint64(buffer, bufferSize, structSize); + targetDesc.getValue().structureSize = structSize; + + readByte += + decodeEnumValue(buffer + readByte, bufferSize - readByte, targetDesc.getValue().format); + readByte += + decodeEnumValue(buffer + readByte, bufferSize - readByte, targetDesc.getValue().profile); + readByte += + decodeEnumValue(buffer + readByte, bufferSize - readByte, targetDesc.getValue().flags); + readByte += decodeEnumValue( + buffer + readByte, + bufferSize - readByte, + targetDesc.getValue().floatingPointMode); + readByte += decodeEnumValue( + buffer + readByte, + bufferSize - readByte, + targetDesc.getValue().lineDirectiveMode); + readByte += decodeBool( + buffer + readByte, + bufferSize - readByte, + targetDesc.getValue().forceGLSLScalarBufferLayout); + readByte += decodeUint32( + buffer + readByte, + bufferSize - readByte, + targetDesc.getValue().compilerOptionEntryCount); + + if (targetDesc.getValue().compilerOptionEntryCount > 0) { - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); + slang::CompilerOptionEntry* entries = (slang::CompilerOptionEntry*)targetDesc.allocate( + sizeof(slang::CompilerOptionEntry) * targetDesc.getValue().compilerOptionEntryCount); + readByte += decodeStructArray( + buffer + readByte, + bufferSize - readByte, + entries, + targetDesc.getValue().compilerOptionEntryCount); + targetDesc.getValue().compilerOptionEntries = entries; + } - size_t readByte = 0; - readByte = decodeEnumValue(buffer, bufferSize, specializationArg.getValue().kind); + return readByte; +} - // TODO: Special handle to address decode is needed. - uint64_t address = 0; - readByte += decodeAddress(buffer + readByte, bufferSize - readByte, address); - (void)address; +size_t ParameterDecoder::decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::SpecializationArg>& specializationArg) +{ + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - return readByte; - } + size_t readByte = 0; + readByte = decodeEnumValue(buffer, bufferSize, specializationArg.getValue().kind); + + // TODO: Special handle to address decode is needed. + uint64_t address = 0; + readByte += decodeAddress(buffer + readByte, bufferSize - readByte, address); + (void)address; + + return readByte; } +} // namespace SlangRecord diff --git a/source/slang-record-replay/replay/parameter-decoder.h b/source/slang-record-replay/replay/parameter-decoder.h index d1deca3eb..50cbc69ad 100644 --- a/source/slang-record-replay/replay/parameter-decoder.h +++ b/source/slang-record-replay/replay/parameter-decoder.h @@ -1,146 +1,224 @@ #ifndef PARAMETER_DECODER_H #define PARAMETER_DECODER_H -#include <cinttypes> -#include <cstring> -#include <cstdlib> -#include <vector> #include "../util/record-format.h" #include "../util/record-utility.h" -#include "slang.h" #include "decoder-helper.h" +#include "slang.h" + +#include <cinttypes> +#include <cstdlib> +#include <cstring> +#include <vector> namespace SlangRecord { - class ParameterDecoder - { - public: - static size_t decodeInt8(const uint8_t* buffer, int64_t bufferSize, int8_t& value) { return decodeValue(buffer, bufferSize, value); } - static size_t decodeUint8(const uint8_t* buffer, int64_t bufferSize, uint8_t& value) { return decodeValue(buffer, bufferSize, value); } - static size_t decodeInt16(const uint8_t* buffer, int64_t bufferSize, int16_t& value) { return decodeValue(buffer, bufferSize, value); } - static size_t decodeUint16(const uint8_t* buffer, int64_t bufferSize, uint16_t& value) { return decodeValue(buffer, bufferSize, value); } - static size_t decodeInt32(const uint8_t* buffer, int64_t bufferSize, int32_t& value) { return decodeValue(buffer, bufferSize, value); } - static size_t decodeUint32(const uint8_t* buffer, int64_t bufferSize, uint32_t& value) { return decodeValue(buffer, bufferSize, value); } - static size_t decodeInt64(const uint8_t* buffer, int64_t bufferSize, int64_t& value) { return decodeValue(buffer, bufferSize, value); } - static size_t decodeUint64(const uint8_t* buffer, int64_t bufferSize, uint64_t& value) { return decodeValue(buffer, bufferSize, value); } - static size_t decodeFloat(const uint8_t* buffer, int64_t bufferSize, float& value) { return decodeValue(buffer, bufferSize, value); } - static size_t decodeDouble(const uint8_t* buffer, int64_t bufferSize, double& value) { return decodeValue(buffer, bufferSize, value); } - static size_t decodeBool(const uint8_t* buffer, int64_t bufferSize, bool& value) { return decodeValue(buffer, bufferSize, value); } - - template<typename T> - static size_t decodeEnumValue(const uint8_t* buffer, size_t bufferSize, T& value) +class ParameterDecoder +{ +public: + static size_t decodeInt8(const uint8_t* buffer, int64_t bufferSize, int8_t& value) + { + return decodeValue(buffer, bufferSize, value); + } + static size_t decodeUint8(const uint8_t* buffer, int64_t bufferSize, uint8_t& value) + { + return decodeValue(buffer, bufferSize, value); + } + static size_t decodeInt16(const uint8_t* buffer, int64_t bufferSize, int16_t& value) + { + return decodeValue(buffer, bufferSize, value); + } + static size_t decodeUint16(const uint8_t* buffer, int64_t bufferSize, uint16_t& value) + { + return decodeValue(buffer, bufferSize, value); + } + static size_t decodeInt32(const uint8_t* buffer, int64_t bufferSize, int32_t& value) + { + return decodeValue(buffer, bufferSize, value); + } + static size_t decodeUint32(const uint8_t* buffer, int64_t bufferSize, uint32_t& value) + { + return decodeValue(buffer, bufferSize, value); + } + static size_t decodeInt64(const uint8_t* buffer, int64_t bufferSize, int64_t& value) + { + return decodeValue(buffer, bufferSize, value); + } + static size_t decodeUint64(const uint8_t* buffer, int64_t bufferSize, uint64_t& value) + { + return decodeValue(buffer, bufferSize, value); + } + static size_t decodeFloat(const uint8_t* buffer, int64_t bufferSize, float& value) + { + return decodeValue(buffer, bufferSize, value); + } + static size_t decodeDouble(const uint8_t* buffer, int64_t bufferSize, double& value) + { + return decodeValue(buffer, bufferSize, value); + } + static size_t decodeBool(const uint8_t* buffer, int64_t bufferSize, bool& value) + { + return decodeValue(buffer, bufferSize, value); + } + + template<typename T> + static size_t decodeEnumValue(const uint8_t* buffer, size_t bufferSize, T& value) + { + uint32_t decodedValue; + size_t readByte = decodeValue(buffer, bufferSize, decodedValue); + value = static_cast<T>(decodedValue); + return readByte; + } + + static size_t decodeString( + const uint8_t* buffer, + int64_t bufferSize, + PointerDecoder<char*>& typeDecoder); + + static size_t decodePointer( + const uint8_t* buffer, + int64_t bufferSize, + PointerDecoder<void*>& pointerDecoder); + + static size_t decodeAddress( + const uint8_t* buffer, + int64_t bufferSize, + SlangRecord::AddressFormat& address) + { + return decodeValue(buffer, bufferSize, address); + } + static size_t decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::SessionDesc>& sessionDesc); + static size_t decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::PreprocessorMacroDesc>& desc); + static size_t decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::CompilerOptionEntry>& entry); + static size_t decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::CompilerOptionValue>& value); + static size_t decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::TargetDesc>& targetDesc); + static size_t decodeStruct( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<slang::SpecializationArg>& specializationArg); + + template<typename T> + static size_t decodeValueArray( + const uint8_t* buffer, + int64_t bufferSize, + ValueDecoder<T>* valueArray, + size_t count) + { + if (count == 0 && bufferSize == 0) { - uint32_t decodedValue; - size_t readByte = decodeValue(buffer, bufferSize, decodedValue); - value = static_cast<T>(decodedValue); - return readByte; + return 0; } - static size_t decodeString(const uint8_t* buffer, int64_t bufferSize, PointerDecoder<char*>& typeDecoder); - - static size_t decodePointer(const uint8_t* buffer, int64_t bufferSize, PointerDecoder<void*>& pointerDecoder); - - static size_t decodeAddress(const uint8_t* buffer, int64_t bufferSize, SlangRecord::AddressFormat& address) + size_t readByte = 0; + for (size_t i = 0; i < count; ++i) { - return decodeValue(buffer, bufferSize, address); + readByte += decodeValue(buffer + readByte, bufferSize - readByte, valueArray[i]); } - static size_t decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::SessionDesc>& sessionDesc); - static size_t decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::PreprocessorMacroDesc>& desc); - static size_t decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::CompilerOptionEntry>& entry); - static size_t decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::CompilerOptionValue>& value); - static size_t decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::TargetDesc>& targetDesc); - static size_t decodeStruct(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<slang::SpecializationArg>& specializationArg); - - template <typename T> - static size_t decodeValueArray(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<T>* valueArray, size_t count) + return readByte; + } + + static size_t decodeStringArray( + const uint8_t* buffer, + int64_t bufferSize, + char** outputArray, + size_t count) + { + if (count == 0 && bufferSize == 0) { - if (count == 0 && bufferSize == 0) - { - return 0; - } - - size_t readByte = 0; - for (size_t i = 0; i < count; ++i) - { - readByte += decodeValue(buffer + readByte, bufferSize - readByte, valueArray[i]); - } - return readByte; + return 0; } + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); + + size_t readByte = 0; + for (uint32_t i = 0; i < count; i++) + { + PointerDecoder<char*> item; + readByte += decodeString(buffer + readByte, bufferSize - readByte, item); - static size_t decodeStringArray(const uint8_t* buffer, int64_t bufferSize, char** outputArray, size_t count) + // Copy the search path + outputArray[i] = item.getPointer(); + } + return readByte; + } + + template<typename T> + static size_t decodeStructArray( + const uint8_t* buffer, + int64_t bufferSize, + T* outputArray, + size_t count) + { + if (count == 0 && bufferSize == 0) { - if (count == 0 && bufferSize == 0) - { - return 0; - } - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - - size_t readByte = 0; - for (uint32_t i = 0; i < count; i++) - { - PointerDecoder<char*> item; - readByte += decodeString(buffer + readByte, bufferSize - readByte, item); - - // Copy the search path - outputArray[i] = item.getPointer(); - } - return readByte; + return 0; } + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - template <typename T> - static size_t decodeStructArray(const uint8_t* buffer, int64_t bufferSize, T* outputArray, size_t count) + size_t bufferRead = 0; + for (size_t i = 0; i < count; ++i) + { + ValueDecoder<T> item; + bufferRead += decodeStruct(buffer + bufferRead, bufferSize - bufferRead, item); + outputArray[i] = item.getValue(); + } + return bufferRead; + } + + static size_t decodeAddressArray( + const uint8_t* buffer, + int64_t bufferSize, + uint64_t* addressArray, + size_t count) + { + if (count == 0 && bufferSize == 0) { - if (count == 0 && bufferSize == 0) - { - return 0; - } - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - - size_t bufferRead = 0; - for (size_t i = 0; i < count; ++i) - { - ValueDecoder<T> item; - bufferRead += decodeStruct(buffer + bufferRead, bufferSize - bufferRead, item); - outputArray[i] = item.getValue(); - } - return bufferRead; + return 0; } + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - static size_t decodeAddressArray(const uint8_t* buffer, int64_t bufferSize, uint64_t* addressArray, size_t count) + size_t bufferRead = 0; + for (size_t i = 0; i < count; ++i) { - if (count == 0 && bufferSize == 0) - { - return 0; - } - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - - size_t bufferRead = 0; - for (size_t i = 0; i < count; ++i) - { - bufferRead += decodeAddress(buffer + bufferRead, bufferSize - bufferRead, addressArray[i]); - } - - return bufferRead; + bufferRead += + decodeAddress(buffer + bufferRead, bufferSize - bufferRead, addressArray[i]); } + return bufferRead; + } - private: - template <typename T> - static size_t decodeValue(const uint8_t* buffer, int64_t bufferSize, T& value) - { - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - int64_t dataSize = sizeof(T); +private: + template<typename T> + static size_t decodeValue(const uint8_t* buffer, int64_t bufferSize, T& value) + { + SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); - SLANG_RECORD_ASSERT(bufferSize >= dataSize); + int64_t dataSize = sizeof(T); - size_t bytesRead = 0; - bytesRead = dataSize; - memcpy(&value, buffer, dataSize); + SLANG_RECORD_ASSERT(bufferSize >= dataSize); - return bytesRead; - } - }; + size_t bytesRead = 0; + bytesRead = dataSize; + memcpy(&value, buffer, dataSize); + + return bytesRead; + } +}; } // namespace SlangRecord #endif // PARAMETER_DECODER_H diff --git a/source/slang-record-replay/replay/recordFile-processor.cpp b/source/slang-record-replay/replay/recordFile-processor.cpp index bf3ea874b..4772a2711 100644 --- a/source/slang-record-replay/replay/recordFile-processor.cpp +++ b/source/slang-record-replay/replay/recordFile-processor.cpp @@ -1,146 +1,156 @@ #include "recordFile-processor.h" + #include "../util/record-format.h" #include "parameter-decoder.h" namespace SlangRecord { - RecordFileProcessor::RecordFileProcessor(const Slang::String& filePath) - { - Slang::FileMode fileMode = Slang::FileMode::Open; - Slang::FileAccess fileAccess = Slang::FileAccess::Read; - Slang::FileShare fileShare = Slang::FileShare::None; - - // Open the record file with read-only access - SlangResult res = m_inputStream.init(filePath, fileMode, fileAccess, fileShare); - - if (res != SLANG_OK) - { - SlangRecord::slangRecordLog(SlangRecord::LogLevel::Error, "Failed to open file %s\n", filePath.begin()); - std::abort(); - } +RecordFileProcessor::RecordFileProcessor(const Slang::String& filePath) +{ + Slang::FileMode fileMode = Slang::FileMode::Open; + Slang::FileAccess fileAccess = Slang::FileAccess::Read; + Slang::FileShare fileShare = Slang::FileShare::None; - // Enable log system - setLogLevel(); - } + // Open the record file with read-only access + SlangResult res = m_inputStream.init(filePath, fileMode, fileAccess, fileShare); - bool RecordFileProcessor::processNextBlock() + if (res != SLANG_OK) { - FunctionHeader header {}; - if (!processHeader(header)) - { - return false; - } - - ApiClassId classId = static_cast<ApiClassId>(getClassId(header.callId)); - - // capacity comparison will be performed in the reserve call, so we can safely call reserve - m_parameterBuffer.reserve(header.dataSizeInBytes); - - size_t readBytes = 0; - SlangResult res = SLANG_OK; + SlangRecord::slangRecordLog( + SlangRecord::LogLevel::Error, + "Failed to open file %s\n", + filePath.begin()); + std::abort(); + } - if (header.dataSizeInBytes) - { - res = m_inputStream.read(m_parameterBuffer.getBuffer(), header.dataSizeInBytes, readBytes); - } + // Enable log system + setLogLevel(); +} - if (res != SLANG_OK || readBytes != header.dataSizeInBytes) - { - return false; - } +bool RecordFileProcessor::processNextBlock() +{ + FunctionHeader header{}; + if (!processHeader(header)) + { + return false; + } - FunctionTailer tailer {}; - if (processTailer(tailer) == ERROR_BLOCK) - { - return false; - } + ApiClassId classId = static_cast<ApiClassId>(getClassId(header.callId)); - if (tailer.dataSizeInBytes) - { - m_outputBuffer.reserve(tailer.dataSizeInBytes); - res = m_inputStream.read(m_outputBuffer.getBuffer(), tailer.dataSizeInBytes, readBytes); + // capacity comparison will be performed in the reserve call, so we can safely call reserve + m_parameterBuffer.reserve(header.dataSizeInBytes); - if (res != SLANG_OK || readBytes != tailer.dataSizeInBytes) - { - return false; - } - } + size_t readBytes = 0; + SlangResult res = SLANG_OK; - bool ret = false; - SlangDecoder::ParameterBlock paramBlock {}; - paramBlock.parameterBuffer = m_parameterBuffer.getBuffer(); - paramBlock.parameterBufferSize = header.dataSizeInBytes; - paramBlock.outputBuffer = m_outputBuffer.getBuffer(); - paramBlock.outputBufferSize = tailer.dataSizeInBytes; + if (header.dataSizeInBytes) + { + res = m_inputStream.read(m_parameterBuffer.getBuffer(), header.dataSizeInBytes, readBytes); + } - if (classId == ApiClassId::GlobalFunction) - { - ret = m_decoder->processFunctionCall(header, paramBlock); - } - else - { - ret = m_decoder->processMethodCall(header, paramBlock); - } + if (res != SLANG_OK || readBytes != header.dataSizeInBytes) + { + return false; + } - m_parameterBuffer.clear(); - m_outputBuffer.clear(); - return ret; + FunctionTailer tailer{}; + if (processTailer(tailer) == ERROR_BLOCK) + { + return false; } - bool RecordFileProcessor::processHeader(FunctionHeader& header) + if (tailer.dataSizeInBytes) { - size_t readBytes = 0; - SlangResult res = m_inputStream.read(&header, sizeof(FunctionHeader), readBytes); + m_outputBuffer.reserve(tailer.dataSizeInBytes); + res = m_inputStream.read(m_outputBuffer.getBuffer(), tailer.dataSizeInBytes, readBytes); - if (res != SLANG_OK || readBytes != sizeof(FunctionHeader)) + if (res != SLANG_OK || readBytes != tailer.dataSizeInBytes) { return false; } + } - if (header.magic != MAGIC_HEADER || header.callId == ApiCallId::InvalidCallId) - { - return false; - } + bool ret = false; + SlangDecoder::ParameterBlock paramBlock{}; + paramBlock.parameterBuffer = m_parameterBuffer.getBuffer(); + paramBlock.parameterBufferSize = header.dataSizeInBytes; + paramBlock.outputBuffer = m_outputBuffer.getBuffer(); + paramBlock.outputBufferSize = tailer.dataSizeInBytes; - return true; + if (classId == ApiClassId::GlobalFunction) + { + ret = m_decoder->processFunctionCall(header, paramBlock); + } + else + { + ret = m_decoder->processMethodCall(header, paramBlock); } - RecordFileResultCode RecordFileProcessor::processTailer(FunctionTailer& tailer) + m_parameterBuffer.clear(); + m_outputBuffer.clear(); + return ret; +} + +bool RecordFileProcessor::processHeader(FunctionHeader& header) +{ + size_t readBytes = 0; + SlangResult res = m_inputStream.read(&header, sizeof(FunctionHeader), readBytes); + + if (res != SLANG_OK || readBytes != sizeof(FunctionHeader)) { - size_t readBytes = 0; - SlangResult res = m_inputStream.read(&tailer, sizeof(FunctionTailer), readBytes); + return false; + } - if (res != SLANG_OK || readBytes != sizeof(FunctionTailer)) - { - return ERROR_BLOCK; - } + if (header.magic != MAGIC_HEADER || header.callId == ApiCallId::InvalidCallId) + { + return false; + } - // If we don't read a valid tailer, but the magic is bit is a header, it indicates that - // there is no tailer for this block, but it's still a valid block. - if (tailer.magic == MAGIC_HEADER) - { - // revert back to last read position, and clear tailer - int64_t offset = -(int64_t)sizeof(FunctionTailer); - m_inputStream.seek(Slang::SeekOrigin::Current, offset); - memset(&tailer, 0, sizeof(FunctionTailer)); - return NOT_EXSIT; - } + return true; +} - if (tailer.magic != MAGIC_TAILER) - { - return ERROR_BLOCK; - } +RecordFileResultCode RecordFileProcessor::processTailer(FunctionTailer& tailer) +{ + size_t readBytes = 0; + SlangResult res = m_inputStream.read(&tailer, sizeof(FunctionTailer), readBytes); - return RESULT_OK; + if (res != SLANG_OK || readBytes != sizeof(FunctionTailer)) + { + return ERROR_BLOCK; } - bool RecordFileProcessor::processMethod(FunctionHeader const& header, const uint8_t* parameterBuffer, int64_t bufferSize) + // If we don't read a valid tailer, but the magic is bit is a header, it indicates that + // there is no tailer for this block, but it's still a valid block. + if (tailer.magic == MAGIC_HEADER) { - return false; + // revert back to last read position, and clear tailer + int64_t offset = -(int64_t)sizeof(FunctionTailer); + m_inputStream.seek(Slang::SeekOrigin::Current, offset); + memset(&tailer, 0, sizeof(FunctionTailer)); + return NOT_EXSIT; } - bool RecordFileProcessor::processFunction(FunctionHeader const& header, const uint8_t* parameterBuffer, int64_t bufferSize) + if (tailer.magic != MAGIC_TAILER) { - return false; + return ERROR_BLOCK; } + + return RESULT_OK; +} + +bool RecordFileProcessor::processMethod( + FunctionHeader const& header, + const uint8_t* parameterBuffer, + int64_t bufferSize) +{ + return false; +} + +bool RecordFileProcessor::processFunction( + FunctionHeader const& header, + const uint8_t* parameterBuffer, + int64_t bufferSize) +{ + return false; +} }; // namespace SlangRecord diff --git a/source/slang-record-replay/replay/recordFile-processor.h b/source/slang-record-replay/replay/recordFile-processor.h index 6c27d231d..ebc1070eb 100644 --- a/source/slang-record-replay/replay/recordFile-processor.h +++ b/source/slang-record-replay/replay/recordFile-processor.h @@ -1,50 +1,52 @@ #ifndef FILE_PROCESSOR_H #define FILE_PROCESSOR_H -#include <cstdlib> #include "../../core/slang-stream.h" #include "../util/record-utility.h" #include "slang-decoder.h" +#include <cstdlib> + namespace SlangRecord { - enum RecordFileResultCode - { - RESULT_OK = 0x00, - NOT_EXSIT = 0x01, - ERROR_BLOCK = 0x02 - }; +enum RecordFileResultCode +{ + RESULT_OK = 0x00, + NOT_EXSIT = 0x01, + ERROR_BLOCK = 0x02 +}; - class RecordFileProcessor - { - public: - RecordFileProcessor(const Slang::String& filePath); +class RecordFileProcessor +{ +public: + RecordFileProcessor(const Slang::String& filePath); - bool addDecoder(SlangDecoder* pDecoder) + bool addDecoder(SlangDecoder* pDecoder) + { + if (pDecoder == nullptr) { - if (pDecoder == nullptr) - { - slangRecordLog(LogLevel::Error, "Decoder is nullptr\n"); - return false; - } - m_decoder = pDecoder; - return true; + slangRecordLog(LogLevel::Error, "Decoder is nullptr\n"); + return false; } + m_decoder = pDecoder; + return true; + } + + bool processNextBlock(); + bool processHeader(FunctionHeader& header); + RecordFileResultCode processTailer(FunctionTailer& tailer); + bool processMethod(FunctionHeader const& header, const uint8_t* buffer, int64_t bufferSize); + bool processFunction(FunctionHeader const& header, const uint8_t* buffer, int64_t bufferSize); - bool processNextBlock(); - bool processHeader(FunctionHeader& header); - RecordFileResultCode processTailer(FunctionTailer& tailer); - bool processMethod(FunctionHeader const& header, const uint8_t* buffer, int64_t bufferSize); - bool processFunction(FunctionHeader const& header, const uint8_t* buffer, int64_t bufferSize); - private: - Slang::FileStream m_inputStream; - Slang::List<uint8_t> m_parameterBuffer; - Slang::List<uint8_t> m_outputBuffer; +private: + Slang::FileStream m_inputStream; + Slang::List<uint8_t> m_parameterBuffer; + Slang::List<uint8_t> m_outputBuffer; - SlangDecoder* m_decoder = nullptr; - }; + SlangDecoder* m_decoder = nullptr; +}; -} // namespace SlangRecord; +} // namespace SlangRecord #endif // FILE_PROCESSOR_H diff --git a/source/slang-record-replay/replay/replay-consumer.cpp b/source/slang-record-replay/replay/replay-consumer.cpp index 3ef2ae97d..9dd087e63 100644 --- a/source/slang-record-replay/replay/replay-consumer.cpp +++ b/source/slang-record-replay/replay/replay-consumer.cpp @@ -1,1240 +1,1786 @@ #include "replay-consumer.h" + #include "../../core/slang-string-util.h" namespace SlangRecord { -#define OutputObjectSanityCheck(objId) \ - do { \ - if(m_objectMap.tryGetValue((objId))) { \ - slangRecordLog(LogLevel::Error, "Output object 0x%X already exists! %s:%d\n", objId, __PRETTY_FUNCTION__, __LINE__); \ - std::abort(); \ - } \ - } while(0) - -#define InputObjectSanityCheck(objId) \ - do { \ - if(!m_objectMap.tryGetValue((objId))) { \ - slangRecordLog(LogLevel::Error, "Input object 0x%X has not been allocated yet! %s:%d\n", objId, __PRETTY_FUNCTION__, __LINE__); \ - std::abort(); \ - } \ - } while(0) - -#define FAIL_WITH_LOG(funcName) \ - do { \ - if (SLANG_FAILED(res)) { \ - slangRecordLog(LogLevel::Error, #funcName" fails, ret: 0x%X, this: 0x%X\n", res, objectId); \ - } \ +#define OutputObjectSanityCheck(objId) \ + do \ + { \ + if (m_objectMap.tryGetValue((objId))) \ + { \ + slangRecordLog( \ + LogLevel::Error, \ + "Output object 0x%X already exists! %s:%d\n", \ + objId, \ + __PRETTY_FUNCTION__, \ + __LINE__); \ + std::abort(); \ + } \ } while (0) - SlangResult CommonInterfaceReplayer::getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) - { - InputObjectSanityCheck(objectId); +#define InputObjectSanityCheck(objId) \ + do \ + { \ + if (!m_objectMap.tryGetValue((objId))) \ + { \ + slangRecordLog( \ + LogLevel::Error, \ + "Input object 0x%X has not been allocated yet! %s:%d\n", \ + objId, \ + __PRETTY_FUNCTION__, \ + __LINE__); \ + std::abort(); \ + } \ + } while (0) - slang::IComponentType* pObj = getObjectPointer(objectId); - slang::IBlob* outDiagnostics {}; - slang::ProgramLayout* outProgramLayout {}; +#define FAIL_WITH_LOG(funcName) \ + do \ + { \ + if (SLANG_FAILED(res)) \ + { \ + slangRecordLog( \ + LogLevel::Error, \ + #funcName " fails, ret: 0x%X, this: 0x%X\n", \ + res, \ + objectId); \ + } \ + } while (0) - SlangResult res = SLANG_OK; - outProgramLayout = pObj->getLayout(targetIndex, &outDiagnostics); +SlangResult CommonInterfaceReplayer::getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) +{ + InputObjectSanityCheck(objectId); - if (outProgramLayout) - { - m_objectMap.addIfNotExists(retProgramLayoutId, outProgramLayout); - } - else - { - res = SLANG_FAIL; - } - return res; - } + slang::IComponentType* pObj = getObjectPointer(objectId); + slang::IBlob* outDiagnostics{}; + slang::ProgramLayout* outProgramLayout{}; - SlangResult CommonInterfaceReplayer::getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) + SlangResult res = SLANG_OK; + outProgramLayout = pObj->getLayout(targetIndex, &outDiagnostics); + + if (outProgramLayout) + { + m_objectMap.addIfNotExists(retProgramLayoutId, outProgramLayout); + } + else { - InputObjectSanityCheck(objectId); + res = SLANG_FAIL; + } + return res; +} - slang::IComponentType* pObj = getObjectPointer(objectId); - slang::IBlob* outCode {}; - slang::IBlob* outDiagnostics {}; +SlangResult CommonInterfaceReplayer::getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + InputObjectSanityCheck(objectId); - SlangResult res = pObj->getEntryPointCode(entryPointIndex, targetIndex, &outCode, &outDiagnostics); + slang::IComponentType* pObj = getObjectPointer(objectId); + slang::IBlob* outCode{}; + slang::IBlob* outDiagnostics{}; - if (outCode && SLANG_SUCCEEDED(res)) - { - m_objectMap.addIfNotExists(outCodeId, outCode); - } + SlangResult res = + pObj->getEntryPointCode(entryPointIndex, targetIndex, &outCode, &outDiagnostics); - ReplayConsumer::printDiagnosticMessage(outDiagnostics); - return res; + if (outCode && SLANG_SUCCEEDED(res)) + { + m_objectMap.addIfNotExists(outCodeId, outCode); } - SlangResult CommonInterfaceReplayer::getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - InputObjectSanityCheck(objectId); + ReplayConsumer::printDiagnosticMessage(outDiagnostics); + return res; +} - slang::IComponentType* pObj = getObjectPointer(objectId); - slang::IBlob* outCode {}; - slang::IBlob* outDiagnostics {}; +SlangResult CommonInterfaceReplayer::getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + InputObjectSanityCheck(objectId); - SlangResult res = pObj->getTargetCode(targetIndex, &outCode, &outDiagnostics); + slang::IComponentType* pObj = getObjectPointer(objectId); + slang::IBlob* outCode{}; + slang::IBlob* outDiagnostics{}; - if (outCode && SLANG_SUCCEEDED(res)) - { - m_objectMap.addIfNotExists(outCodeId, outCode); - } + SlangResult res = pObj->getTargetCode(targetIndex, &outCode, &outDiagnostics); - ReplayConsumer::printDiagnosticMessage(outDiagnostics); - return res; + if (outCode && SLANG_SUCCEEDED(res)) + { + m_objectMap.addIfNotExists(outCodeId, outCode); } - SlangResult CommonInterfaceReplayer::getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystemId) - { - InputObjectSanityCheck(objectId); - OutputObjectSanityCheck(outFileSystemId); + ReplayConsumer::printDiagnosticMessage(outDiagnostics); + return res; +} - slang::IComponentType* pObj = getObjectPointer(objectId); - ISlangMutableFileSystem* outFileSystem {}; - SlangResult res = pObj->getResultAsFileSystem(entryPointIndex, targetIndex, &outFileSystem); +SlangResult CommonInterfaceReplayer::getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystemId) +{ + InputObjectSanityCheck(objectId); + OutputObjectSanityCheck(outFileSystemId); - if (outFileSystem && SLANG_SUCCEEDED(res)) - { - m_objectMap.add(outFileSystemId, outFileSystem); - } - return res; - } + slang::IComponentType* pObj = getObjectPointer(objectId); + ISlangMutableFileSystem* outFileSystem{}; + SlangResult res = pObj->getResultAsFileSystem(entryPointIndex, targetIndex, &outFileSystem); - SlangResult CommonInterfaceReplayer::getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) + if (outFileSystem && SLANG_SUCCEEDED(res)) { - InputObjectSanityCheck(objectId); + m_objectMap.add(outFileSystemId, outFileSystem); + } + return res; +} + +SlangResult CommonInterfaceReplayer::getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) +{ + InputObjectSanityCheck(objectId); - SlangResult res = SLANG_OK; - slang::IComponentType* pObj = getObjectPointer(objectId); - slang::IBlob* outHash {}; - pObj->getEntryPointHash(entryPointIndex, targetIndex, &outHash); + SlangResult res = SLANG_OK; + slang::IComponentType* pObj = getObjectPointer(objectId); + slang::IBlob* outHash{}; + pObj->getEntryPointHash(entryPointIndex, targetIndex, &outHash); - if (outHash) + if (outHash) + { + if (outHash->getBufferSize()) { - if (outHash->getBufferSize()) - { - uint8_t* buffer = (uint8_t*)outHash->getBufferPointer(); - Slang::StringBuilder strBuilder; - strBuilder << "callIdx: " << m_globalCounter << ", entrypoint: "<< entryPointIndex << ", target: " << targetIndex << ", hash: "; - m_globalCounter++; - - for (size_t i = 0; i < outHash->getBufferSize(); i++) - { - strBuilder<<Slang::StringUtil::makeStringWithFormat("%.2X", buffer[i]); - } - slangRecordLog(LogLevel::Verbose, "%s\n", strBuilder.begin()); - } - else + uint8_t* buffer = (uint8_t*)outHash->getBufferPointer(); + Slang::StringBuilder strBuilder; + strBuilder << "callIdx: " << m_globalCounter << ", entrypoint: " << entryPointIndex + << ", target: " << targetIndex << ", hash: "; + m_globalCounter++; + + for (size_t i = 0; i < outHash->getBufferSize(); i++) { - res = SLANG_FAIL; + strBuilder << Slang::StringUtil::makeStringWithFormat("%.2X", buffer[i]); } + slangRecordLog(LogLevel::Verbose, "%s\n", strBuilder.begin()); } else { res = SLANG_FAIL; } - return res; } - - SlangResult CommonInterfaceReplayer::specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) + else { - InputObjectSanityCheck(objectId); - - for (SlangInt i = 0; i < specializationArgCount; i++) - { - if (specializationArgs[i].type != nullptr) - { - slangRecordLog(LogLevel::Error, "We only support nullptr for 'type' as reflection is not supported yet, %s:%d\n", objectId, __PRETTY_FUNCTION__, __LINE__); - return SLANG_FAIL; - } - } + res = SLANG_FAIL; + } + return res; +} - slang::IComponentType* pObj = getObjectPointer(objectId); - slang::IComponentType* outSpecializedComponentType {}; - slang::IBlob* outDiagnostics {}; +SlangResult CommonInterfaceReplayer::specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) +{ + InputObjectSanityCheck(objectId); - SlangResult res = pObj->specialize(specializationArgs, specializationArgCount, &outSpecializedComponentType, &outDiagnostics); - if (outSpecializedComponentType && SLANG_SUCCEEDED(res)) + for (SlangInt i = 0; i < specializationArgCount; i++) + { + if (specializationArgs[i].type != nullptr) { - m_objectMap.addIfNotExists(outSpecializedComponentTypeId, outSpecializedComponentType); + slangRecordLog( + LogLevel::Error, + "We only support nullptr for 'type' as reflection is not supported yet, %s:%d\n", + objectId, + __PRETTY_FUNCTION__, + __LINE__); + return SLANG_FAIL; } - - ReplayConsumer::printDiagnosticMessage(outDiagnostics); - return res; } - SlangResult CommonInterfaceReplayer::link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) + slang::IComponentType* pObj = getObjectPointer(objectId); + slang::IComponentType* outSpecializedComponentType{}; + slang::IBlob* outDiagnostics{}; + + SlangResult res = pObj->specialize( + specializationArgs, + specializationArgCount, + &outSpecializedComponentType, + &outDiagnostics); + if (outSpecializedComponentType && SLANG_SUCCEEDED(res)) { - InputObjectSanityCheck(objectId); + m_objectMap.addIfNotExists(outSpecializedComponentTypeId, outSpecializedComponentType); + } - slang::IComponentType* pObj = getObjectPointer(objectId); - slang::IComponentType* outLinkedComponentType {}; - slang::IBlob* outDiagnostics {}; + ReplayConsumer::printDiagnosticMessage(outDiagnostics); + return res; +} - SlangResult res = pObj->link(&outLinkedComponentType, &outDiagnostics); +SlangResult CommonInterfaceReplayer::link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) +{ + InputObjectSanityCheck(objectId); - if (outLinkedComponentType && SLANG_SUCCEEDED(res)) - { - m_objectMap.addIfNotExists(outLinkedComponentTypeId, outLinkedComponentType); - } + slang::IComponentType* pObj = getObjectPointer(objectId); + slang::IComponentType* outLinkedComponentType{}; + slang::IBlob* outDiagnostics{}; - ReplayConsumer::printDiagnosticMessage(outDiagnostics); - return res; - } + SlangResult res = pObj->link(&outLinkedComponentType, &outDiagnostics); - SlangResult CommonInterfaceReplayer::getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibraryId, - ObjectID outDiagnosticsId) + if (outLinkedComponentType && SLANG_SUCCEEDED(res)) { - InputObjectSanityCheck(objectId); + m_objectMap.addIfNotExists(outLinkedComponentTypeId, outLinkedComponentType); + } - slang::IComponentType* pObj = getObjectPointer(objectId); - ISlangSharedLibrary* outSharedLib {}; - slang::IBlob* outDiagnosticsBlob {}; + ReplayConsumer::printDiagnosticMessage(outDiagnostics); + return res; +} - SlangResult res = pObj->getEntryPointHostCallable(entryPointIndex, targetIndex, &outSharedLib, &outDiagnosticsBlob); +SlangResult CommonInterfaceReplayer::getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibraryId, + ObjectID outDiagnosticsId) +{ + InputObjectSanityCheck(objectId); - if (outSharedLib && SLANG_SUCCEEDED(res)) - { - m_objectMap.addIfNotExists(outSharedLibraryId, outSharedLib); - } + slang::IComponentType* pObj = getObjectPointer(objectId); + ISlangSharedLibrary* outSharedLib{}; + slang::IBlob* outDiagnosticsBlob{}; - ReplayConsumer::printDiagnosticMessage(outDiagnosticsBlob); - return res; - } + SlangResult res = pObj->getEntryPointHostCallable( + entryPointIndex, + targetIndex, + &outSharedLib, + &outDiagnosticsBlob); - SlangResult CommonInterfaceReplayer::renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) + if (outSharedLib && SLANG_SUCCEEDED(res)) { - InputObjectSanityCheck(objectId); - - slang::IComponentType* pObj = getObjectPointer(objectId); - slang::IComponentType* outEntryPoint {}; - SlangResult res = pObj->renameEntryPoint(newName, &outEntryPoint); - - if (outEntryPoint && SLANG_SUCCEEDED(res)) - { - m_objectMap.addIfNotExists(outEntryPointId, outEntryPoint); - } - return res; + m_objectMap.addIfNotExists(outSharedLibraryId, outSharedLib); } - SlangResult CommonInterfaceReplayer::linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) - { - InputObjectSanityCheck(objectId); - - slang::IComponentType* pObj = getObjectPointer(objectId); - slang::IComponentType* outLinkedComponentType {}; - slang::IBlob* outDiagnostics {}; + ReplayConsumer::printDiagnosticMessage(outDiagnosticsBlob); + return res; +} - SlangResult res = pObj->linkWithOptions(&outLinkedComponentType, compilerOptionEntryCount, compilerOptionEntries, &outDiagnostics); +SlangResult CommonInterfaceReplayer::renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) +{ + InputObjectSanityCheck(objectId); - if (outLinkedComponentType && SLANG_SUCCEEDED(res)) - { - m_objectMap.addIfNotExists(outLinkedComponentTypeId, outLinkedComponentType); - } + slang::IComponentType* pObj = getObjectPointer(objectId); + slang::IComponentType* outEntryPoint{}; + SlangResult res = pObj->renameEntryPoint(newName, &outEntryPoint); - ReplayConsumer::printDiagnosticMessage(outDiagnostics); - return res; + if (outEntryPoint && SLANG_SUCCEEDED(res)) + { + m_objectMap.addIfNotExists(outEntryPointId, outEntryPoint); } + return res; +} + +SlangResult CommonInterfaceReplayer::linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) +{ + InputObjectSanityCheck(objectId); + + slang::IComponentType* pObj = getObjectPointer(objectId); + slang::IComponentType* outLinkedComponentType{}; + slang::IBlob* outDiagnostics{}; + SlangResult res = pObj->linkWithOptions( + &outLinkedComponentType, + compilerOptionEntryCount, + compilerOptionEntries, + &outDiagnostics); - void ReplayConsumer::printDiagnosticMessage(slang::IBlob* diagnosticsBlob) + if (outLinkedComponentType && SLANG_SUCCEEDED(res)) { - if (diagnosticsBlob) - { - const char* diagnostics = (const char*)diagnosticsBlob->getBufferPointer(); - slangRecordLog(LogLevel::Error, "Replayer: %s\n", diagnostics); - } + m_objectMap.addIfNotExists(outLinkedComponentTypeId, outLinkedComponentType); } - void ReplayConsumer::CreateGlobalSession(ObjectID outGlobalSessionId) - { - OutputObjectSanityCheck(outGlobalSessionId); + ReplayConsumer::printDiagnosticMessage(outDiagnostics); + return res; +} - slang::IGlobalSession* outGlobalSession {}; - slang::createGlobalSession(&outGlobalSession); - if (outGlobalSession) - { - m_objectMap.add(outGlobalSessionId, outGlobalSession); - slangRecordLog(LogLevel::Verbose, "createGlobalSession, capture: 0x%X, new: 0x%X\n", - outGlobalSessionId, reinterpret_cast<AddressFormat>(outGlobalSession)); - } - else - { - slangRecordLog(LogLevel::Error, "createGlobalSession fails, outGlobalSessionId: 0x%X\n", outGlobalSessionId); - } +void ReplayConsumer::printDiagnosticMessage(slang::IBlob* diagnosticsBlob) +{ + if (diagnosticsBlob) + { + const char* diagnostics = (const char*)diagnosticsBlob->getBufferPointer(); + slangRecordLog(LogLevel::Error, "Replayer: %s\n", diagnostics); } +} - void ReplayConsumer::IGlobalSession_createSession(ObjectID objectId, slang::SessionDesc const& desc, ObjectID outSessionId) - { - InputObjectSanityCheck(objectId); - OutputObjectSanityCheck(outSessionId); +void ReplayConsumer::CreateGlobalSession(ObjectID outGlobalSessionId) +{ + OutputObjectSanityCheck(outGlobalSessionId); - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - slang::ISession* outSession {}; - SlangResult res = globalSession->createSession(desc, &outSession); + slang::IGlobalSession* outGlobalSession{}; + slang::createGlobalSession(&outGlobalSession); - if (outSession && SLANG_SUCCEEDED(res)) - { - m_objectMap.add(outSessionId, outSession); - } - else - { - slangRecordLog(LogLevel::Error, "IGlobalSession::createSession fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } + if (outGlobalSession) + { + m_objectMap.add(outGlobalSessionId, outGlobalSession); + slangRecordLog( + LogLevel::Verbose, + "createGlobalSession, capture: 0x%X, new: 0x%X\n", + outGlobalSessionId, + reinterpret_cast<AddressFormat>(outGlobalSession)); } - - - void ReplayConsumer::IGlobalSession_findProfile(ObjectID objectId, char const* name) + else { - InputObjectSanityCheck(objectId); - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - globalSession->findProfile(name); + slangRecordLog( + LogLevel::Error, + "createGlobalSession fails, outGlobalSessionId: 0x%X\n", + outGlobalSessionId); } +} + +void ReplayConsumer::IGlobalSession_createSession( + ObjectID objectId, + slang::SessionDesc const& desc, + ObjectID outSessionId) +{ + InputObjectSanityCheck(objectId); + OutputObjectSanityCheck(outSessionId); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + slang::ISession* outSession{}; + SlangResult res = globalSession->createSession(desc, &outSession); - void ReplayConsumer::IGlobalSession_setDownstreamCompilerPath(ObjectID objectId, SlangPassThrough passThrough, char const* path) + if (outSession && SLANG_SUCCEEDED(res)) { - InputObjectSanityCheck(objectId); - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - globalSession->setDownstreamCompilerPath(passThrough, path); + m_objectMap.add(outSessionId, outSession); } - - - void ReplayConsumer::IGlobalSession_setDownstreamCompilerPrelude(ObjectID objectId, SlangPassThrough inPassThrough, char const* prelude) + else { - InputObjectSanityCheck(objectId); - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - globalSession->setDownstreamCompilerPrelude(inPassThrough, prelude); + slangRecordLog( + LogLevel::Error, + "IGlobalSession::createSession fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::IGlobalSession_getDownstreamCompilerPrelude(ObjectID objectId, SlangPassThrough inPassThrough, ObjectID outPreludeId) - { - InputObjectSanityCheck(objectId); - OutputObjectSanityCheck(outPreludeId); +void ReplayConsumer::IGlobalSession_findProfile(ObjectID objectId, char const* name) +{ + InputObjectSanityCheck(objectId); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + globalSession->findProfile(name); +} - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - ISlangBlob* outPrelude {}; - globalSession->getDownstreamCompilerPrelude(inPassThrough, &outPrelude); - if (outPrelude) - { - m_objectMap.add(outPreludeId, outPrelude); - } - } +void ReplayConsumer::IGlobalSession_setDownstreamCompilerPath( + ObjectID objectId, + SlangPassThrough passThrough, + char const* path) +{ + InputObjectSanityCheck(objectId); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + globalSession->setDownstreamCompilerPath(passThrough, path); +} - void ReplayConsumer::IGlobalSession_setDefaultDownstreamCompiler(ObjectID objectId, SlangSourceLanguage sourceLanguage, SlangPassThrough defaultCompiler) - { - InputObjectSanityCheck(objectId); +void ReplayConsumer::IGlobalSession_setDownstreamCompilerPrelude( + ObjectID objectId, + SlangPassThrough inPassThrough, + char const* prelude) +{ + InputObjectSanityCheck(objectId); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + globalSession->setDownstreamCompilerPrelude(inPassThrough, prelude); +} - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - SlangResult res = globalSession->setDefaultDownstreamCompiler(sourceLanguage, defaultCompiler); - if (SLANG_FAILED(res)) - { - slangRecordLog(LogLevel::Error, "IGlobalSession::setDefaultDownstreamCompiler fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } - } +void ReplayConsumer::IGlobalSession_getDownstreamCompilerPrelude( + ObjectID objectId, + SlangPassThrough inPassThrough, + ObjectID outPreludeId) +{ + InputObjectSanityCheck(objectId); + OutputObjectSanityCheck(outPreludeId); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - void ReplayConsumer::IGlobalSession_getDefaultDownstreamCompiler(ObjectID objectId, SlangSourceLanguage sourceLanguage) + ISlangBlob* outPrelude{}; + globalSession->getDownstreamCompilerPrelude(inPassThrough, &outPrelude); + if (outPrelude) { - InputObjectSanityCheck(objectId); - - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - globalSession->getDefaultDownstreamCompiler(sourceLanguage); + m_objectMap.add(outPreludeId, outPrelude); } +} - void ReplayConsumer::IGlobalSession_setLanguagePrelude(ObjectID objectId, SlangSourceLanguage inSourceLanguage, char const* prelude) - { - InputObjectSanityCheck(objectId); +void ReplayConsumer::IGlobalSession_setDefaultDownstreamCompiler( + ObjectID objectId, + SlangSourceLanguage sourceLanguage, + SlangPassThrough defaultCompiler) +{ + InputObjectSanityCheck(objectId); - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - globalSession->setLanguagePrelude(inSourceLanguage, prelude); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + SlangResult res = globalSession->setDefaultDownstreamCompiler(sourceLanguage, defaultCompiler); + + if (SLANG_FAILED(res)) + { + slangRecordLog( + LogLevel::Error, + "IGlobalSession::setDefaultDownstreamCompiler fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::IGlobalSession_getLanguagePrelude(ObjectID objectId, SlangSourceLanguage inSourceLanguage, ObjectID outPreludeId) - { - InputObjectSanityCheck(objectId); - OutputObjectSanityCheck(outPreludeId); +void ReplayConsumer::IGlobalSession_getDefaultDownstreamCompiler( + ObjectID objectId, + SlangSourceLanguage sourceLanguage) +{ + InputObjectSanityCheck(objectId); - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + globalSession->getDefaultDownstreamCompiler(sourceLanguage); +} - ISlangBlob* outPrelude {}; - globalSession->getLanguagePrelude(inSourceLanguage, &outPrelude); - if (outPrelude) - { - m_objectMap.add(outPreludeId, outPrelude); - } - } +void ReplayConsumer::IGlobalSession_setLanguagePrelude( + ObjectID objectId, + SlangSourceLanguage inSourceLanguage, + char const* prelude) +{ + InputObjectSanityCheck(objectId); - void ReplayConsumer::IGlobalSession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequest) - { - InputObjectSanityCheck(objectId); - OutputObjectSanityCheck(outCompileRequest); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + globalSession->setLanguagePrelude(inSourceLanguage, prelude); +} - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - slang::ICompileRequest* outRequest {}; - SLANG_ALLOW_DEPRECATED_BEGIN - SlangResult res = globalSession->createCompileRequest(&outRequest); - SLANG_ALLOW_DEPRECATED_END - if (outRequest && SLANG_SUCCEEDED(res)) - { - m_objectMap.add(outCompileRequest, outRequest); - } - else - { - slangRecordLog(LogLevel::Error, "IGlobalSession::createCompileRequest fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } - } +void ReplayConsumer::IGlobalSession_getLanguagePrelude( + ObjectID objectId, + SlangSourceLanguage inSourceLanguage, + ObjectID outPreludeId) +{ + InputObjectSanityCheck(objectId); + OutputObjectSanityCheck(outPreludeId); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - void ReplayConsumer::IGlobalSession_addBuiltins(ObjectID objectId, char const* sourcePath, char const* sourceString) + ISlangBlob* outPrelude{}; + globalSession->getLanguagePrelude(inSourceLanguage, &outPrelude); + if (outPrelude) { - InputObjectSanityCheck(objectId); - - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - globalSession->addBuiltins(sourcePath, sourceString); + m_objectMap.add(outPreludeId, outPrelude); } +} - void ReplayConsumer::IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ObjectID loaderId) - { - InputObjectSanityCheck(objectId); - InputObjectSanityCheck(loaderId); - - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - ISlangSharedLibraryLoader* loader = getObjectPointer<ISlangSharedLibraryLoader>(loaderId); - globalSession->setSharedLibraryLoader(loader); - } +void ReplayConsumer::IGlobalSession_createCompileRequest( + ObjectID objectId, + ObjectID outCompileRequest) +{ + InputObjectSanityCheck(objectId); + OutputObjectSanityCheck(outCompileRequest); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + slang::ICompileRequest* outRequest{}; + SLANG_ALLOW_DEPRECATED_BEGIN + SlangResult res = globalSession->createCompileRequest(&outRequest); + SLANG_ALLOW_DEPRECATED_END - void ReplayConsumer::IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) + if (outRequest && SLANG_SUCCEEDED(res)) { - InputObjectSanityCheck(objectId); - OutputObjectSanityCheck(outLoaderId); - - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - ISlangSharedLibraryLoader* loader = globalSession->getSharedLibraryLoader(); - if (loader) - { - m_objectMap.add(outLoaderId, loader); - } - else - { - slangRecordLog(LogLevel::Error, "IGlobalSession::getSharedLibraryLoader fails, this: 0x%X\n", objectId); - } + m_objectMap.add(outCompileRequest, outRequest); } - - - void ReplayConsumer::IGlobalSession_checkCompileTargetSupport(ObjectID objectId, SlangCompileTarget target) + else { - InputObjectSanityCheck(objectId); - - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - SlangResult res = globalSession->checkCompileTargetSupport(target); - - if (SLANG_FAILED(res)) - { - slangRecordLog(LogLevel::Error, "IGlobalSession::checkCompileTargetSupport fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } + slangRecordLog( + LogLevel::Error, + "IGlobalSession::createCompileRequest fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::IGlobalSession_checkPassThroughSupport(ObjectID objectId, SlangPassThrough passThrough) - { - InputObjectSanityCheck(objectId); - - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - SlangResult res = globalSession->checkPassThroughSupport(passThrough); +void ReplayConsumer::IGlobalSession_addBuiltins( + ObjectID objectId, + char const* sourcePath, + char const* sourceString) +{ + InputObjectSanityCheck(objectId); - if (SLANG_FAILED(res)) - { - slangRecordLog(LogLevel::Error, "IGlobalSession::checkPassThroughSupport fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } - } + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + globalSession->addBuiltins(sourcePath, sourceString); +} - void ReplayConsumer::IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) - { - InputObjectSanityCheck(objectId); +void ReplayConsumer::IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ObjectID loaderId) +{ + InputObjectSanityCheck(objectId); + InputObjectSanityCheck(loaderId); - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - SlangResult res = globalSession->compileCoreModule(flags); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + ISlangSharedLibraryLoader* loader = getObjectPointer<ISlangSharedLibraryLoader>(loaderId); + globalSession->setSharedLibraryLoader(loader); +} - if (SLANG_FAILED(res)) - { - slangRecordLog(LogLevel::Error, "IGlobalSession::compileCoreModule fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } - } +void ReplayConsumer::IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) +{ + InputObjectSanityCheck(objectId); + OutputObjectSanityCheck(outLoaderId); - void ReplayConsumer::IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + ISlangSharedLibraryLoader* loader = globalSession->getSharedLibraryLoader(); + if (loader) { - InputObjectSanityCheck(objectId); - - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - SlangResult res = globalSession->loadCoreModule(coreModule, coreModuleSizeInBytes); - - if (SLANG_FAILED(res)) - { - slangRecordLog(LogLevel::Error, "IGlobalSession::loadCoreModule fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } + m_objectMap.add(outLoaderId, loader); } - - - void ReplayConsumer::IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) + else { - InputObjectSanityCheck(objectId); - OutputObjectSanityCheck(outBlobId); + slangRecordLog( + LogLevel::Error, + "IGlobalSession::getSharedLibraryLoader fails, this: 0x%X\n", + objectId); + } +} - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - ISlangBlob* outBlob {}; - SlangResult res = globalSession->saveCoreModule(archiveType, &outBlob); - if (outBlob && SLANG_SUCCEEDED(res)) - { - m_objectMap.add(outBlobId, outBlob); - } - else - { - slangRecordLog(LogLevel::Error, "IGlobalSession::saveCoreModule fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } - } +void ReplayConsumer::IGlobalSession_checkCompileTargetSupport( + ObjectID objectId, + SlangCompileTarget target) +{ + InputObjectSanityCheck(objectId); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + SlangResult res = globalSession->checkCompileTargetSupport(target); - void ReplayConsumer::IGlobalSession_findCapability(ObjectID objectId, char const* name) + if (SLANG_FAILED(res)) { - InputObjectSanityCheck(objectId); - - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - globalSession->findCapability(name); + slangRecordLog( + LogLevel::Error, + "IGlobalSession::checkCompileTargetSupport fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) - { - InputObjectSanityCheck(objectId); - - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - globalSession->setDownstreamCompilerForTransition(source, target, compiler); - } +void ReplayConsumer::IGlobalSession_checkPassThroughSupport( + ObjectID objectId, + SlangPassThrough passThrough) +{ + InputObjectSanityCheck(objectId); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + SlangResult res = globalSession->checkPassThroughSupport(passThrough); - void ReplayConsumer::IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target) + if (SLANG_FAILED(res)) { - InputObjectSanityCheck(objectId); - - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - globalSession->getDownstreamCompilerForTransition(source, target); + slangRecordLog( + LogLevel::Error, + "IGlobalSession::checkPassThroughSupport fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, char const* jsonPath) - { - InputObjectSanityCheck(objectId); +void ReplayConsumer::IGlobalSession_compileCoreModule( + ObjectID objectId, + slang::CompileCoreModuleFlags flags) +{ + InputObjectSanityCheck(objectId); - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - SlangResult res = globalSession->setSPIRVCoreGrammar(jsonPath); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + SlangResult res = globalSession->compileCoreModule(flags); - if (SLANG_FAILED(res)) - { - slangRecordLog(LogLevel::Error, "IGlobalSession::setSPIRVCoreGrammar fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } + if (SLANG_FAILED(res)) + { + slangRecordLog( + LogLevel::Error, + "IGlobalSession::compileCoreModule fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::IGlobalSession_parseCommandLineArguments(ObjectID objectId, int argc, const char* const* argv, ObjectID outSessionDescId, ObjectID outAllocationId) - { - InputObjectSanityCheck(objectId); - OutputObjectSanityCheck(outAllocationId); - - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - slang::SessionDesc sessionDesc {}; - ISlangUnknown* allocation {}; +void ReplayConsumer::IGlobalSession_loadCoreModule( + ObjectID objectId, + const void* coreModule, + size_t coreModuleSizeInBytes) +{ + InputObjectSanityCheck(objectId); - // Note: we don't save the sessionDesc here, because it's an output to user, but we do need to save the allocation, because - // it holds the auxiliary data for the sessionDesc. So if use provide the same sessionDesc to slang, we won't hit any segfault. - SlangResult res = globalSession->parseCommandLineArguments(argc, argv, &sessionDesc, &allocation); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + SlangResult res = globalSession->loadCoreModule(coreModule, coreModuleSizeInBytes); - if (SLANG_SUCCEEDED(res)) - { - m_objectMap.add(outAllocationId, allocation); - } - else - { - slangRecordLog(LogLevel::Debug, "IGlobalSession::parseCommandLineArguments fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } + if (SLANG_FAILED(res)) + { + slangRecordLog( + LogLevel::Error, + "IGlobalSession::loadCoreModule fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::IGlobalSession_getSessionDescDigest(ObjectID objectId, slang::SessionDesc* sessionDesc, ObjectID outBlobId) - { - InputObjectSanityCheck(objectId); - OutputObjectSanityCheck(outBlobId); +void ReplayConsumer::IGlobalSession_saveCoreModule( + ObjectID objectId, + SlangArchiveType archiveType, + ObjectID outBlobId) +{ + InputObjectSanityCheck(objectId); + OutputObjectSanityCheck(outBlobId); - slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); - ISlangBlob* outBlob {}; - SlangResult res = globalSession->getSessionDescDigest(sessionDesc, &outBlob); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + ISlangBlob* outBlob{}; + SlangResult res = globalSession->saveCoreModule(archiveType, &outBlob); - if (outBlob && SLANG_SUCCEEDED(res)) - { - m_objectMap.add(outBlobId, outBlob); - } - else - { - slangRecordLog(LogLevel::Error, "IGlobalSession::getSessionDescDigest fails, ret:0x%X, this: 0x%X\n", res, objectId); - } + if (outBlob && SLANG_SUCCEEDED(res)) + { + m_objectMap.add(outBlobId, outBlob); } - - - - // ISession - void ReplayConsumer::ISession_getGlobalSession(ObjectID objectId, ObjectID outGlobalSessionId) + else { - // No need to replay this function + slangRecordLog( + LogLevel::Error, + "IGlobalSession::saveCoreModule fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::ISession_loadModule(ObjectID objectId, const char* moduleName, ObjectID outDiagnosticsId, ObjectID outModuleId) - { - InputObjectSanityCheck(objectId); - - slang::ISession* session = getObjectPointer<slang::ISession>(objectId); - slang::IModule* outModule {}; - slang::IBlob* outDiagnostics {}; +void ReplayConsumer::IGlobalSession_findCapability(ObjectID objectId, char const* name) +{ + InputObjectSanityCheck(objectId); - // loadModule could return a new module or an existing module, so can't use OutputObjectSanityCheck here - outModule = session->loadModule(moduleName, &outDiagnostics); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + globalSession->findCapability(name); +} - if (outModule) - { - // Save the module if it's not being tracked - m_objectMap.addIfNotExists(outModuleId, outModule); - } - else - { - slangRecordLog(LogLevel::Error, "ISession::loadModule returns nullptr, this: 0x%X\n", objectId); - } - printDiagnosticMessage(outDiagnostics); - } +void ReplayConsumer::IGlobalSession_setDownstreamCompilerForTransition( + ObjectID objectId, + SlangCompileTarget source, + SlangCompileTarget target, + SlangPassThrough compiler) +{ + InputObjectSanityCheck(objectId); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + globalSession->setDownstreamCompilerForTransition(source, target, compiler); +} - void ReplayConsumer::ISession_loadModuleFromIRBlob(ObjectID objectId, const char* moduleName, - const char* path, slang::IBlob* source, ObjectID outDiagnosticsId, ObjectID outModuleId) - { - InputObjectSanityCheck(objectId); - slang::ISession* session = getObjectPointer<slang::ISession>(objectId); - slang::IModule* outModule {}; - slang::IBlob* outDiagnostics {}; +void ReplayConsumer::IGlobalSession_getDownstreamCompilerForTransition( + ObjectID objectId, + SlangCompileTarget source, + SlangCompileTarget target) +{ + InputObjectSanityCheck(objectId); - outModule = session->loadModuleFromIRBlob(moduleName, path, source, &outDiagnostics); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + globalSession->getDownstreamCompilerForTransition(source, target); +} - if (outModule) - { - // Save the module if it's not being tracked - m_objectMap.addIfNotExists(outModuleId, outModule); - } - else - { - slangRecordLog(LogLevel::Error, "ISession::loadModule returns nullptr, this: 0x%X\n", objectId); - } - printDiagnosticMessage(outDiagnostics); - } +void ReplayConsumer::IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, char const* jsonPath) +{ + InputObjectSanityCheck(objectId); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + SlangResult res = globalSession->setSPIRVCoreGrammar(jsonPath); - void ReplayConsumer::ISession_loadModuleFromSource(ObjectID objectId, const char* moduleName, - const char* path, slang::IBlob* source, ObjectID outDiagnosticsId, ObjectID outModuleId) + if (SLANG_FAILED(res)) { - slang::ISession* session = getObjectPointer<slang::ISession>(objectId); - slang::IModule* outModule {}; - slang::IBlob* outDiagnostics {}; - - outModule = session->loadModuleFromSource(moduleName, path, source, &outDiagnostics); - - if (outModule) - { - // Save the module if it's not being tracked - m_objectMap.addIfNotExists(outModuleId, outModule); - } - else - { - slangRecordLog(LogLevel::Error, "ISession::loadModule returns nullptr, this: 0x%X\n", objectId); - } - - printDiagnosticMessage(outDiagnostics); + slangRecordLog( + LogLevel::Error, + "IGlobalSession::setSPIRVCoreGrammar fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::ISession_loadModuleFromSourceString(ObjectID objectId, const char* moduleName, - const char* path, const char* string, ObjectID outDiagnosticsId, ObjectID outModuleId) - { - slang::ISession* session = getObjectPointer<slang::ISession>(objectId); - slang::IModule* outModule {}; - slang::IBlob* outDiagnostics {}; +void ReplayConsumer::IGlobalSession_parseCommandLineArguments( + ObjectID objectId, + int argc, + const char* const* argv, + ObjectID outSessionDescId, + ObjectID outAllocationId) +{ + InputObjectSanityCheck(objectId); + OutputObjectSanityCheck(outAllocationId); - outModule = session->loadModuleFromSourceString(moduleName, path, string, &outDiagnostics); + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + slang::SessionDesc sessionDesc{}; + ISlangUnknown* allocation{}; - if (outModule) - { - // Save the module if it's not being tracked - m_objectMap.addIfNotExists(outModuleId, outModule); - } - else - { - slangRecordLog(LogLevel::Error, "ISession::loadModule returns nullptr, this: 0x%X\n", objectId); - } + // Note: we don't save the sessionDesc here, because it's an output to user, but we do need to + // save the allocation, because it holds the auxiliary data for the sessionDesc. So if use + // provide the same sessionDesc to slang, we won't hit any segfault. + SlangResult res = + globalSession->parseCommandLineArguments(argc, argv, &sessionDesc, &allocation); - printDiagnosticMessage(outDiagnostics); + if (SLANG_SUCCEEDED(res)) + { + m_objectMap.add(outAllocationId, allocation); + } + else + { + slangRecordLog( + LogLevel::Debug, + "IGlobalSession::parseCommandLineArguments fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::ISession_createCompositeComponentType(ObjectID objectId, ObjectID* componentTypeIds, - SlangInt componentTypeCount, ObjectID outCompositeComponentTypeId, ObjectID outDiagnosticsId) - { - InputObjectSanityCheck(objectId); - for (SlangInt i = 0; i < componentTypeCount; i++) - { - InputObjectSanityCheck(componentTypeIds[i]); - } +void ReplayConsumer::IGlobalSession_getSessionDescDigest( + ObjectID objectId, + slang::SessionDesc* sessionDesc, + ObjectID outBlobId) +{ + InputObjectSanityCheck(objectId); + OutputObjectSanityCheck(outBlobId); - // We don't need to check existence of outCompositeComponentTypeId, because it could be the same object - // as the input one + slang::IGlobalSession* globalSession = getObjectPointer<slang::IGlobalSession>(objectId); + ISlangBlob* outBlob{}; + SlangResult res = globalSession->getSessionDescDigest(sessionDesc, &outBlob); - slang::ISession* session = getObjectPointer<slang::ISession>(objectId); + if (outBlob && SLANG_SUCCEEDED(res)) + { + m_objectMap.add(outBlobId, outBlob); + } + else + { + slangRecordLog( + LogLevel::Error, + "IGlobalSession::getSessionDescDigest fails, ret:0x%X, this: 0x%X\n", + res, + objectId); + } +} - Slang::List<slang::IComponentType*> componentTypes; - componentTypes.reserve(componentTypeCount); - for (SlangInt i = 0; i < componentTypeCount; i++) - { - componentTypes.add(getObjectPointer<slang::IComponentType>(componentTypeIds[i])); - } +// ISession +void ReplayConsumer::ISession_getGlobalSession(ObjectID objectId, ObjectID outGlobalSessionId) +{ + // No need to replay this function +} - slang::IComponentType* outCompositeComponentType {}; - slang::IBlob* outDiagnostics {}; - SlangResult res = session->createCompositeComponentType(componentTypes.getBuffer(), componentTypeCount, &outCompositeComponentType, &outDiagnostics); +void ReplayConsumer::ISession_loadModule( + ObjectID objectId, + const char* moduleName, + ObjectID outDiagnosticsId, + ObjectID outModuleId) +{ + InputObjectSanityCheck(objectId); - if (outCompositeComponentType && SLANG_SUCCEEDED(res)) - { - m_objectMap.addIfNotExists(outCompositeComponentTypeId, outCompositeComponentType); - } - else - { - slangRecordLog(LogLevel::Error, "ISession::createCompositeComponentType fails, ret: 0x%X, this: 0x%X\n", objectId); - } + slang::ISession* session = getObjectPointer<slang::ISession>(objectId); + slang::IModule* outModule{}; + slang::IBlob* outDiagnostics{}; - printDiagnosticMessage(outDiagnostics); - } + // loadModule could return a new module or an existing module, so can't use + // OutputObjectSanityCheck here + outModule = session->loadModule(moduleName, &outDiagnostics); - // TODO: implement those functions related to TypeReflection - void ReplayConsumer::ISession_specializeType(ObjectID objectId, ObjectID typeId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outDiagnosticsId, ObjectID outTypeReflectionId) + if (outModule) { + // Save the module if it's not being tracked + m_objectMap.addIfNotExists(outModuleId, outModule); } - - void ReplayConsumer::ISession_getTypeLayout(ObjectID objectId, ObjectID typeId, SlangInt targetIndex, - slang::LayoutRules rules, ObjectID outDiagnosticsId, ObjectID outTypeLayoutReflection) + else { + slangRecordLog( + LogLevel::Error, + "ISession::loadModule returns nullptr, this: 0x%X\n", + objectId); } - void ReplayConsumer::ISession_getContainerType(ObjectID objectId, ObjectID elementType, - slang::ContainerType containerType, ObjectID outDiagnosticsId, ObjectID outTypeReflectionId) - { - } + printDiagnosticMessage(outDiagnostics); +} - void ReplayConsumer::ISession_getDynamicType(ObjectID objectId, ObjectID outTypeReflectionId) - { - } - void ReplayConsumer::ISession_getTypeRTTIMangledName(ObjectID objectId, ObjectID typeId, ObjectID outNameBlobId) - { - } +void ReplayConsumer::ISession_loadModuleFromIRBlob( + ObjectID objectId, + const char* moduleName, + const char* path, + slang::IBlob* source, + ObjectID outDiagnosticsId, + ObjectID outModuleId) +{ + InputObjectSanityCheck(objectId); - void ReplayConsumer::ISession_getTypeConformanceWitnessMangledName(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, ObjectID outNameBlobId) - { - } + slang::ISession* session = getObjectPointer<slang::ISession>(objectId); + slang::IModule* outModule{}; + slang::IBlob* outDiagnostics{}; + outModule = session->loadModuleFromIRBlob(moduleName, path, source, &outDiagnostics); - void ReplayConsumer::ISession_getTypeConformanceWitnessSequentialID(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, uint32_t outId) + if (outModule) { + // Save the module if it's not being tracked + m_objectMap.addIfNotExists(outModuleId, outModule); } - - void ReplayConsumer::ISession_createTypeConformanceComponentType(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, ObjectID outConformanceId, - SlangInt conformanceIdOverride, ObjectID outDiagnosticsId) + else { + slangRecordLog( + LogLevel::Error, + "ISession::loadModule returns nullptr, this: 0x%X\n", + objectId); } - // End of TODO + printDiagnosticMessage(outDiagnostics); +} - void ReplayConsumer::ISession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequestId) - { - InputObjectSanityCheck(objectId); - OutputObjectSanityCheck(outCompileRequestId); - - slang::ISession* session = getObjectPointer<slang::ISession>(objectId); - slang::ICompileRequest* outRequest {}; - SlangResult res = session->createCompileRequest(&outRequest); - - if (outRequest && SLANG_SUCCEEDED(res)) - { - m_objectMap.add(outCompileRequestId, outRequest); - } - else - { - slangRecordLog(LogLevel::Error, "ISession::createCompileRequest fails, ret:0x%X, this: 0x%X\n", res, objectId); - } - } +void ReplayConsumer::ISession_loadModuleFromSource( + ObjectID objectId, + const char* moduleName, + const char* path, + slang::IBlob* source, + ObjectID outDiagnosticsId, + ObjectID outModuleId) +{ + slang::ISession* session = getObjectPointer<slang::ISession>(objectId); + slang::IModule* outModule{}; + slang::IBlob* outDiagnostics{}; + outModule = session->loadModuleFromSource(moduleName, path, source, &outDiagnostics); - void ReplayConsumer::ISession_getLoadedModule(ObjectID objectId, SlangInt index, ObjectID outModuleId) + if (outModule) { - InputObjectSanityCheck(objectId); - - slang::ISession* session = getObjectPointer<slang::ISession>(objectId); - slang::IModule* outModule = session->getLoadedModule(index); - - if (!m_objectMap.tryGetValue(outModuleId)) - { - // This module should already be tracked during loadModule() call, if not this should be a bug in the replayer or record. - slangRecordLog(LogLevel::Error, "ISession::getLoadedModule: this: 0x%X, module 0x%X is not tracked \n", objectId, outModuleId); - m_objectMap.add(outModuleId, outModule); - } - - if (!outModule) - { - slangRecordLog(LogLevel::Error, "ISession::getLoadedModule returns nullptr, this: 0x%X\n", objectId); - } + // Save the module if it's not being tracked + m_objectMap.addIfNotExists(outModuleId, outModule); } - - - // IModule - void ReplayConsumer::IModule_findEntryPointByName(ObjectID objectId, char const* name, ObjectID outEntryPointId) + else { - InputObjectSanityCheck(objectId); - - slang::IModule* module = getObjectPointer<slang::IModule>(objectId); - slang::IEntryPoint* outEntryPoint {}; - SlangResult res = module->findEntryPointByName(name, &outEntryPoint); - - if (outEntryPoint && SLANG_SUCCEEDED(res)) - { - m_objectMap.addIfNotExists(outEntryPointId, outEntryPoint); - } - else - { - slangRecordLog(LogLevel::Error, "IModule::findEntryPointByName fails, ret: 0x%X, this: 0x%X\n", objectId); - } + slangRecordLog( + LogLevel::Error, + "ISession::loadModule returns nullptr, this: 0x%X\n", + objectId); } + printDiagnosticMessage(outDiagnostics); +} - void ReplayConsumer::IModule_getDefinedEntryPoint(ObjectID objectId, SlangInt32 index, ObjectID outEntryPointId) - { - InputObjectSanityCheck(objectId); - - slang::IModule* module = getObjectPointer<slang::IModule>(objectId); - slang::IEntryPoint* outEntryPoint {}; - SlangResult res = module->getDefinedEntryPoint(index, &outEntryPoint); - if (outEntryPoint && SLANG_SUCCEEDED(res)) - { - m_objectMap.addIfNotExists(outEntryPointId, outEntryPoint); - } - else - { - slangRecordLog(LogLevel::Error, "IModule::getDefinedEntryPoint returns nullptr, this: 0x%X\n", objectId); - } - } +void ReplayConsumer::ISession_loadModuleFromSourceString( + ObjectID objectId, + const char* moduleName, + const char* path, + const char* string, + ObjectID outDiagnosticsId, + ObjectID outModuleId) +{ + slang::ISession* session = getObjectPointer<slang::ISession>(objectId); + slang::IModule* outModule{}; + slang::IBlob* outDiagnostics{}; + outModule = session->loadModuleFromSourceString(moduleName, path, string, &outDiagnostics); - void ReplayConsumer::IModule_serialize(ObjectID objectId, ObjectID outSerializedBlobId) + if (outModule) { - InputObjectSanityCheck(objectId); - OutputObjectSanityCheck(outSerializedBlobId); - - slang::IModule* module = getObjectPointer<slang::IModule>(objectId); - slang::IBlob* outBlob {}; - SlangResult res = module->serialize(&outBlob); - - if (outBlob && SLANG_SUCCEEDED(res)) - { - m_objectMap.add(outSerializedBlobId, outBlob); - } - else - { - slangRecordLog(LogLevel::Error, "IModule::serialize fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } + // Save the module if it's not being tracked + m_objectMap.addIfNotExists(outModuleId, outModule); } - - - void ReplayConsumer::IModule_writeToFile(ObjectID objectId, char const* fileName) + else { - InputObjectSanityCheck(objectId); - - slang::IModule* module = getObjectPointer<slang::IModule>(objectId); - SlangResult res = module->writeToFile(fileName); - - if (SLANG_FAILED(res)) - { - slangRecordLog(LogLevel::Error, "IModule::writeToFile fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } + slangRecordLog( + LogLevel::Error, + "ISession::loadModule returns nullptr, this: 0x%X\n", + objectId); } + printDiagnosticMessage(outDiagnostics); +} + - void ReplayConsumer::IModule_findAndCheckEntryPoint(ObjectID objectId, char const* name, SlangStage stage, ObjectID outEntryPointId, ObjectID outDiagnosticsId) +void ReplayConsumer::ISession_createCompositeComponentType( + ObjectID objectId, + ObjectID* componentTypeIds, + SlangInt componentTypeCount, + ObjectID outCompositeComponentTypeId, + ObjectID outDiagnosticsId) +{ + InputObjectSanityCheck(objectId); + for (SlangInt i = 0; i < componentTypeCount; i++) { - InputObjectSanityCheck(objectId); + InputObjectSanityCheck(componentTypeIds[i]); + } - slang::IModule* module = getObjectPointer<slang::IModule>(objectId); - slang::IEntryPoint* outEntryPoint {}; - slang::IBlob* outDiagnostics {}; + // We don't need to check existence of outCompositeComponentTypeId, because it could be the same + // object as the input one - SlangResult res = module->findAndCheckEntryPoint(name, stage, &outEntryPoint, &outDiagnostics); + slang::ISession* session = getObjectPointer<slang::ISession>(objectId); - if (outEntryPoint && SLANG_SUCCEEDED(res)) - { - m_objectMap.addIfNotExists(outEntryPointId, outEntryPoint); - } - else - { - slangRecordLog(LogLevel::Error, "IModule::findAndCheckEntryPoint fails, ret: 0x%X, this: 0x%X\n", res, objectId); - } + Slang::List<slang::IComponentType*> componentTypes; + componentTypes.reserve(componentTypeCount); - printDiagnosticMessage(outDiagnostics); + for (SlangInt i = 0; i < componentTypeCount; i++) + { + componentTypes.add(getObjectPointer<slang::IComponentType>(componentTypeIds[i])); } + slang::IComponentType* outCompositeComponentType{}; + slang::IBlob* outDiagnostics{}; + + SlangResult res = session->createCompositeComponentType( + componentTypes.getBuffer(), + componentTypeCount, + &outCompositeComponentType, + &outDiagnostics); - void ReplayConsumer::IModule_getSession(ObjectID objectId, ObjectID outSessionId) + if (outCompositeComponentType && SLANG_SUCCEEDED(res)) { - // No need to replay this function + m_objectMap.addIfNotExists(outCompositeComponentTypeId, outCompositeComponentType); } - - void ReplayConsumer::IModule_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) + else { - SlangResult res = m_commonReplayer.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); - FAIL_WITH_LOG(IModule::getLayout); + slangRecordLog( + LogLevel::Error, + "ISession::createCompositeComponentType fails, ret: 0x%X, this: 0x%X\n", + objectId); } + printDiagnosticMessage(outDiagnostics); +} - void ReplayConsumer::IModule_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - SlangResult res = m_commonReplayer.getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); - FAIL_WITH_LOG(IModule::getEntryPointCode); - } +// TODO: implement those functions related to TypeReflection +void ReplayConsumer::ISession_specializeType( + ObjectID objectId, + ObjectID typeId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outDiagnosticsId, + ObjectID outTypeReflectionId) +{ +} + +void ReplayConsumer::ISession_getTypeLayout( + ObjectID objectId, + ObjectID typeId, + SlangInt targetIndex, + slang::LayoutRules rules, + ObjectID outDiagnosticsId, + ObjectID outTypeLayoutReflection) +{ +} + +void ReplayConsumer::ISession_getContainerType( + ObjectID objectId, + ObjectID elementType, + slang::ContainerType containerType, + ObjectID outDiagnosticsId, + ObjectID outTypeReflectionId) +{ +} +void ReplayConsumer::ISession_getDynamicType(ObjectID objectId, ObjectID outTypeReflectionId) {} - void ReplayConsumer::IModule_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) - { - SlangResult res = m_commonReplayer.getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); - FAIL_WITH_LOG(IModule::getTargetCode); - } +void ReplayConsumer::ISession_getTypeRTTIMangledName( + ObjectID objectId, + ObjectID typeId, + ObjectID outNameBlobId) +{ +} +void ReplayConsumer::ISession_getTypeConformanceWitnessMangledName( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + ObjectID outNameBlobId) +{ +} - void ReplayConsumer::IModule_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystemId) - { - SlangResult res = m_commonReplayer.getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystemId); - FAIL_WITH_LOG(IModule::getResultAsFileSystem); - } +void ReplayConsumer::ISession_getTypeConformanceWitnessSequentialID( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + uint32_t outId) +{ +} + +void ReplayConsumer::ISession_createTypeConformanceComponentType( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + ObjectID outConformanceId, + SlangInt conformanceIdOverride, + ObjectID outDiagnosticsId) +{ +} +// End of TODO - void ReplayConsumer::IModule_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) - { - SlangResult res = m_commonReplayer.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); - FAIL_WITH_LOG(IModule::getEntryPointHash); - } +void ReplayConsumer::ISession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequestId) +{ + InputObjectSanityCheck(objectId); + OutputObjectSanityCheck(outCompileRequestId); + + slang::ISession* session = getObjectPointer<slang::ISession>(objectId); + slang::ICompileRequest* outRequest{}; + SlangResult res = session->createCompileRequest(&outRequest); - void ReplayConsumer::IModule_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) + if (outRequest && SLANG_SUCCEEDED(res)) { - SlangResult res = m_commonReplayer.specialize(objectId, specializationArgs, specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - FAIL_WITH_LOG(IModule::specialize); + m_objectMap.add(outCompileRequestId, outRequest); } - - - void ReplayConsumer::IModule_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) + else { - SlangResult res = m_commonReplayer.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - FAIL_WITH_LOG(IModule::link); + slangRecordLog( + LogLevel::Error, + "ISession::createCompileRequest fails, ret:0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::IModule_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) - { - SlangResult res = m_commonReplayer.getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics); - FAIL_WITH_LOG(IModule::getEntryPointHostCallable); - } +void ReplayConsumer::ISession_getLoadedModule( + ObjectID objectId, + SlangInt index, + ObjectID outModuleId) +{ + InputObjectSanityCheck(objectId); + slang::ISession* session = getObjectPointer<slang::ISession>(objectId); + slang::IModule* outModule = session->getLoadedModule(index); - void ReplayConsumer::IModule_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) + if (!m_objectMap.tryGetValue(outModuleId)) { - SlangResult res = m_commonReplayer.renameEntryPoint(objectId, newName, outEntryPointId); - FAIL_WITH_LOG(IModule::renameEntryPoint); + // This module should already be tracked during loadModule() call, if not this should be a + // bug in the replayer or record. + slangRecordLog( + LogLevel::Error, + "ISession::getLoadedModule: this: 0x%X, module 0x%X is not tracked \n", + objectId, + outModuleId); + m_objectMap.add(outModuleId, outModule); } - - void ReplayConsumer::IModule_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) + if (!outModule) { - SlangResult res = m_commonReplayer.linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries, outDiagnosticsId); - FAIL_WITH_LOG(IModule::linkWithOptions); + slangRecordLog( + LogLevel::Error, + "ISession::getLoadedModule returns nullptr, this: 0x%X\n", + objectId); } +} +// IModule +void ReplayConsumer::IModule_findEntryPointByName( + ObjectID objectId, + char const* name, + ObjectID outEntryPointId) +{ + InputObjectSanityCheck(objectId); - // IEntryPoint - void ReplayConsumer::IEntryPoint_getSession(ObjectID objectId, ObjectID outSessionId) - { - } - + slang::IModule* module = getObjectPointer<slang::IModule>(objectId); + slang::IEntryPoint* outEntryPoint{}; + SlangResult res = module->findEntryPointByName(name, &outEntryPoint); - void ReplayConsumer::IEntryPoint_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) + if (outEntryPoint && SLANG_SUCCEEDED(res)) { - SlangResult res = m_commonReplayer.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); - FAIL_WITH_LOG(IEntryPoint::getLayout); + m_objectMap.addIfNotExists(outEntryPointId, outEntryPoint); } - - - void ReplayConsumer::IEntryPoint_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCode, ObjectID outDiagnostics) + else { - SlangResult res = m_commonReplayer.getEntryPointCode(objectId, entryPointIndex, targetIndex, outCode, outDiagnostics); - FAIL_WITH_LOG(IEntryPoint::getEntryPointCode); + slangRecordLog( + LogLevel::Error, + "IModule::findEntryPointByName fails, ret: 0x%X, this: 0x%X\n", + objectId); } +} - void ReplayConsumer::IEntryPoint_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCode, ObjectID outDiagnostics) - { - SlangResult res = m_commonReplayer.getTargetCode(objectId, targetIndex, outCode, outDiagnostics); - FAIL_WITH_LOG(IEntryPoint::getTargetCode); - } +void ReplayConsumer::IModule_getDefinedEntryPoint( + ObjectID objectId, + SlangInt32 index, + ObjectID outEntryPointId) +{ + InputObjectSanityCheck(objectId); + slang::IModule* module = getObjectPointer<slang::IModule>(objectId); + slang::IEntryPoint* outEntryPoint{}; + SlangResult res = module->getDefinedEntryPoint(index, &outEntryPoint); - void ReplayConsumer::IEntryPoint_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) + if (outEntryPoint && SLANG_SUCCEEDED(res)) { - SlangResult res = m_commonReplayer.getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystem); - FAIL_WITH_LOG(IEntryPoint::getResultAsFileSystem); + m_objectMap.addIfNotExists(outEntryPointId, outEntryPoint); } - - - void ReplayConsumer::IEntryPoint_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) + else { - SlangResult res = m_commonReplayer.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); - FAIL_WITH_LOG(IEntryPoint::getEntryPointHash); + slangRecordLog( + LogLevel::Error, + "IModule::getDefinedEntryPoint returns nullptr, this: 0x%X\n", + objectId); } +} - void ReplayConsumer::IEntryPoint_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) - { - SlangResult res = m_commonReplayer.specialize(objectId, specializationArgs, specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - FAIL_WITH_LOG(IModule::specialize); - } +void ReplayConsumer::IModule_serialize(ObjectID objectId, ObjectID outSerializedBlobId) +{ + InputObjectSanityCheck(objectId); + OutputObjectSanityCheck(outSerializedBlobId); + slang::IModule* module = getObjectPointer<slang::IModule>(objectId); + slang::IBlob* outBlob{}; + SlangResult res = module->serialize(&outBlob); - void ReplayConsumer::IEntryPoint_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) + if (outBlob && SLANG_SUCCEEDED(res)) { - SlangResult res = m_commonReplayer.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - FAIL_WITH_LOG(IEntryPoint::link); + m_objectMap.add(outSerializedBlobId, outBlob); } - - - void ReplayConsumer::IEntryPoint_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) + else { - SlangResult res = m_commonReplayer.getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics); - FAIL_WITH_LOG(IEntryPoint::getEntryPointHostCallable); + slangRecordLog( + LogLevel::Error, + "IModule::serialize fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} - void ReplayConsumer::IEntryPoint_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) - { - SlangResult res = m_commonReplayer.renameEntryPoint(objectId, newName, outEntryPointId); - FAIL_WITH_LOG(IEntryPoint::renameEntryPoint); - } +void ReplayConsumer::IModule_writeToFile(ObjectID objectId, char const* fileName) +{ + InputObjectSanityCheck(objectId); + slang::IModule* module = getObjectPointer<slang::IModule>(objectId); + SlangResult res = module->writeToFile(fileName); - void ReplayConsumer::IEntryPoint_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) + if (SLANG_FAILED(res)) { - SlangResult res = m_commonReplayer.linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries, outDiagnosticsId); - FAIL_WITH_LOG(IEntryPoint::linkWithOptions); + slangRecordLog( + LogLevel::Error, + "IModule::writeToFile fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } +} +void ReplayConsumer::IModule_findAndCheckEntryPoint( + ObjectID objectId, + char const* name, + SlangStage stage, + ObjectID outEntryPointId, + ObjectID outDiagnosticsId) +{ + InputObjectSanityCheck(objectId); - // ICompositeComponentType - void ReplayConsumer::ICompositeComponentType_getSession(ObjectID objectId, ObjectID outSessionId) - { - } + slang::IModule* module = getObjectPointer<slang::IModule>(objectId); + slang::IEntryPoint* outEntryPoint{}; + slang::IBlob* outDiagnostics{}; + SlangResult res = module->findAndCheckEntryPoint(name, stage, &outEntryPoint, &outDiagnostics); - void ReplayConsumer::ICompositeComponentType_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) + if (outEntryPoint && SLANG_SUCCEEDED(res)) { - SlangResult res = m_commonReplayer.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); - FAIL_WITH_LOG(ICompositeComponentType::getLayout); + m_objectMap.addIfNotExists(outEntryPointId, outEntryPoint); } - - - void ReplayConsumer::ICompositeComponentType_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCode, ObjectID outDiagnostics) + else { - SlangResult res = m_commonReplayer.getEntryPointCode(objectId, entryPointIndex, targetIndex, outCode, outDiagnostics); - FAIL_WITH_LOG(ICompositeComponentType::getEntryPointCode); + slangRecordLog( + LogLevel::Error, + "IModule::findAndCheckEntryPoint fails, ret: 0x%X, this: 0x%X\n", + res, + objectId); } + printDiagnosticMessage(outDiagnostics); +} - void ReplayConsumer::ICompositeComponentType_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCode, ObjectID outDiagnostics) - { - SlangResult res = m_commonReplayer.getTargetCode(objectId, targetIndex, outCode, outDiagnostics); - FAIL_WITH_LOG(ICompositeComponentType::getTargetCode); - } +void ReplayConsumer::IModule_getSession(ObjectID objectId, ObjectID outSessionId) +{ + // No need to replay this function +} + +void ReplayConsumer::IModule_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) +{ + SlangResult res = + m_commonReplayer.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); + FAIL_WITH_LOG(IModule::getLayout); +} + + +void ReplayConsumer::IModule_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + SlangResult res = + m_commonReplayer + .getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); + FAIL_WITH_LOG(IModule::getEntryPointCode); +} + + +void ReplayConsumer::IModule_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) +{ + SlangResult res = + m_commonReplayer.getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); + FAIL_WITH_LOG(IModule::getTargetCode); +} - void ReplayConsumer::ICompositeComponentType_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) - { - SlangResult res = m_commonReplayer.getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystem); - FAIL_WITH_LOG(ICompositeComponentType::getResultAsFileSystem); - } +void ReplayConsumer::IModule_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystemId) +{ + SlangResult res = m_commonReplayer.getResultAsFileSystem( + objectId, + entryPointIndex, + targetIndex, + outFileSystemId); + FAIL_WITH_LOG(IModule::getResultAsFileSystem); +} + + +void ReplayConsumer::IModule_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) +{ + SlangResult res = + m_commonReplayer.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); + FAIL_WITH_LOG(IModule::getEntryPointHash); +} + + +void ReplayConsumer::IModule_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.specialize( + objectId, + specializationArgs, + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); + FAIL_WITH_LOG(IModule::specialize); +} + + +void ReplayConsumer::IModule_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); + FAIL_WITH_LOG(IModule::link); +} - void ReplayConsumer::ICompositeComponentType_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) - { - SlangResult res = m_commonReplayer.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); - FAIL_WITH_LOG(ICompositeComponentType::getEntryPointHash); - } +void ReplayConsumer::IModule_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) +{ + SlangResult res = m_commonReplayer.getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibrary, + outDiagnostics); + FAIL_WITH_LOG(IModule::getEntryPointHostCallable); +} + + +void ReplayConsumer::IModule_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) +{ + SlangResult res = m_commonReplayer.renameEntryPoint(objectId, newName, outEntryPointId); + FAIL_WITH_LOG(IModule::renameEntryPoint); +} - void ReplayConsumer::ICompositeComponentType_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) - { - SlangResult res = m_commonReplayer.specialize(objectId, specializationArgs, specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - FAIL_WITH_LOG(IModule::specialize); - } +void ReplayConsumer::IModule_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnosticsId); + FAIL_WITH_LOG(IModule::linkWithOptions); +} - void ReplayConsumer::ICompositeComponentType_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) - { - SlangResult res = m_commonReplayer.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - FAIL_WITH_LOG(ICompositeComponentType::link); - } +// IEntryPoint +void ReplayConsumer::IEntryPoint_getSession(ObjectID objectId, ObjectID outSessionId) {} - void ReplayConsumer::ICompositeComponentType_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) - { - SlangResult res = m_commonReplayer.getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics); - FAIL_WITH_LOG(ICompositeComponentType::getEntryPointHostCallable); - } +void ReplayConsumer::IEntryPoint_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) +{ + SlangResult res = + m_commonReplayer.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); + FAIL_WITH_LOG(IEntryPoint::getLayout); +} + + +void ReplayConsumer::IEntryPoint_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCode, + ObjectID outDiagnostics) +{ + SlangResult res = + m_commonReplayer + .getEntryPointCode(objectId, entryPointIndex, targetIndex, outCode, outDiagnostics); + FAIL_WITH_LOG(IEntryPoint::getEntryPointCode); +} + + +void ReplayConsumer::IEntryPoint_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCode, + ObjectID outDiagnostics) +{ + SlangResult res = + m_commonReplayer.getTargetCode(objectId, targetIndex, outCode, outDiagnostics); + FAIL_WITH_LOG(IEntryPoint::getTargetCode); +} - void ReplayConsumer::ICompositeComponentType_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) - { - SlangResult res = m_commonReplayer.renameEntryPoint(objectId, newName, outEntryPointId); - FAIL_WITH_LOG(ICompositeComponentType::renameEntryPoint); - } +void ReplayConsumer::IEntryPoint_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) +{ + SlangResult res = m_commonReplayer.getResultAsFileSystem( + objectId, + entryPointIndex, + targetIndex, + outFileSystem); + FAIL_WITH_LOG(IEntryPoint::getResultAsFileSystem); +} + + +void ReplayConsumer::IEntryPoint_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) +{ + SlangResult res = + m_commonReplayer.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); + FAIL_WITH_LOG(IEntryPoint::getEntryPointHash); +} + + +void ReplayConsumer::IEntryPoint_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.specialize( + objectId, + specializationArgs, + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); + FAIL_WITH_LOG(IModule::specialize); +} + + +void ReplayConsumer::IEntryPoint_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); + FAIL_WITH_LOG(IEntryPoint::link); +} - void ReplayConsumer::ICompositeComponentType_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) - { - SlangResult res = m_commonReplayer.linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries, outDiagnosticsId); - FAIL_WITH_LOG(ICompositeComponentType::linkWithOptions); - } +void ReplayConsumer::IEntryPoint_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) +{ + SlangResult res = m_commonReplayer.getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibrary, + outDiagnostics); + FAIL_WITH_LOG(IEntryPoint::getEntryPointHostCallable); +} + + +void ReplayConsumer::IEntryPoint_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) +{ + SlangResult res = m_commonReplayer.renameEntryPoint(objectId, newName, outEntryPointId); + FAIL_WITH_LOG(IEntryPoint::renameEntryPoint); +} - // ITypeConformance - void ReplayConsumer::ITypeConformance_getSession(ObjectID objectId, ObjectID outSessionId) - { - } +void ReplayConsumer::IEntryPoint_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnosticsId); + FAIL_WITH_LOG(IEntryPoint::linkWithOptions); +} - void ReplayConsumer::ITypeConformance_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) - { - SlangResult res = m_commonReplayer.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); - FAIL_WITH_LOG(ITypeConformance::getLayout); - } +// ICompositeComponentType +void ReplayConsumer::ICompositeComponentType_getSession(ObjectID objectId, ObjectID outSessionId) {} - void ReplayConsumer::ITypeConformance_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCode, ObjectID outDiagnostics) - { - SlangResult res = m_commonReplayer.getEntryPointCode(objectId, entryPointIndex, targetIndex, outCode, outDiagnostics); - FAIL_WITH_LOG(ITypeConformance::getEntryPointCode); - } +void ReplayConsumer::ICompositeComponentType_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) +{ + SlangResult res = + m_commonReplayer.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); + FAIL_WITH_LOG(ICompositeComponentType::getLayout); +} + + +void ReplayConsumer::ICompositeComponentType_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCode, + ObjectID outDiagnostics) +{ + SlangResult res = + m_commonReplayer + .getEntryPointCode(objectId, entryPointIndex, targetIndex, outCode, outDiagnostics); + FAIL_WITH_LOG(ICompositeComponentType::getEntryPointCode); +} + + +void ReplayConsumer::ICompositeComponentType_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCode, + ObjectID outDiagnostics) +{ + SlangResult res = + m_commonReplayer.getTargetCode(objectId, targetIndex, outCode, outDiagnostics); + FAIL_WITH_LOG(ICompositeComponentType::getTargetCode); +} - void ReplayConsumer::ITypeConformance_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCode, ObjectID outDiagnostics) - { - SlangResult res = m_commonReplayer.getTargetCode(objectId, targetIndex, outCode, outDiagnostics); - FAIL_WITH_LOG(ITypeConformance::getTargetCode); - } +void ReplayConsumer::ICompositeComponentType_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) +{ + SlangResult res = m_commonReplayer.getResultAsFileSystem( + objectId, + entryPointIndex, + targetIndex, + outFileSystem); + FAIL_WITH_LOG(ICompositeComponentType::getResultAsFileSystem); +} + + +void ReplayConsumer::ICompositeComponentType_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) +{ + SlangResult res = + m_commonReplayer.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); + FAIL_WITH_LOG(ICompositeComponentType::getEntryPointHash); +} + + +void ReplayConsumer::ICompositeComponentType_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.specialize( + objectId, + specializationArgs, + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); + FAIL_WITH_LOG(IModule::specialize); +} + + +void ReplayConsumer::ICompositeComponentType_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); + FAIL_WITH_LOG(ICompositeComponentType::link); +} - void ReplayConsumer::ITypeConformance_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) - { - SlangResult res = m_commonReplayer.getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystem); - FAIL_WITH_LOG(ITypeConformance::getResultAsFileSystem); - } +void ReplayConsumer::ICompositeComponentType_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) +{ + SlangResult res = m_commonReplayer.getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibrary, + outDiagnostics); + FAIL_WITH_LOG(ICompositeComponentType::getEntryPointHostCallable); +} + + +void ReplayConsumer::ICompositeComponentType_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) +{ + SlangResult res = m_commonReplayer.renameEntryPoint(objectId, newName, outEntryPointId); + FAIL_WITH_LOG(ICompositeComponentType::renameEntryPoint); +} - void ReplayConsumer::ITypeConformance_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) - { - SlangResult res = m_commonReplayer.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); - FAIL_WITH_LOG(ITypeConformance::getEntryPointHash); - } +void ReplayConsumer::ICompositeComponentType_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnosticsId); + FAIL_WITH_LOG(ICompositeComponentType::linkWithOptions); +} - void ReplayConsumer::ITypeConformance_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) - { - SlangResult res = m_commonReplayer.specialize(objectId, specializationArgs, specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - FAIL_WITH_LOG(IModule::specialize); - } +// ITypeConformance +void ReplayConsumer::ITypeConformance_getSession(ObjectID objectId, ObjectID outSessionId) {} - void ReplayConsumer::ITypeConformance_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) - { - SlangResult res = m_commonReplayer.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - FAIL_WITH_LOG(ITypeConformance::link); - } +void ReplayConsumer::ITypeConformance_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) +{ + SlangResult res = + m_commonReplayer.getLayout(objectId, targetIndex, outDiagnosticsId, retProgramLayoutId); + FAIL_WITH_LOG(ITypeConformance::getLayout); +} + + +void ReplayConsumer::ITypeConformance_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCode, + ObjectID outDiagnostics) +{ + SlangResult res = + m_commonReplayer + .getEntryPointCode(objectId, entryPointIndex, targetIndex, outCode, outDiagnostics); + FAIL_WITH_LOG(ITypeConformance::getEntryPointCode); +} + + +void ReplayConsumer::ITypeConformance_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCode, + ObjectID outDiagnostics) +{ + SlangResult res = + m_commonReplayer.getTargetCode(objectId, targetIndex, outCode, outDiagnostics); + FAIL_WITH_LOG(ITypeConformance::getTargetCode); +} - void ReplayConsumer::ITypeConformance_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) - { - SlangResult res = m_commonReplayer.getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibrary, outDiagnostics); - FAIL_WITH_LOG(ITypeConformance::getEntryPointHostCallable); - } +void ReplayConsumer::ITypeConformance_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) +{ + SlangResult res = m_commonReplayer.getResultAsFileSystem( + objectId, + entryPointIndex, + targetIndex, + outFileSystem); + FAIL_WITH_LOG(ITypeConformance::getResultAsFileSystem); +} + + +void ReplayConsumer::ITypeConformance_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) +{ + SlangResult res = + m_commonReplayer.getEntryPointHash(objectId, entryPointIndex, targetIndex, outHashId); + FAIL_WITH_LOG(ITypeConformance::getEntryPointHash); +} + + +void ReplayConsumer::ITypeConformance_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.specialize( + objectId, + specializationArgs, + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); + FAIL_WITH_LOG(IModule::specialize); +} + + +void ReplayConsumer::ITypeConformance_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.link(objectId, outLinkedComponentTypeId, outDiagnosticsId); + FAIL_WITH_LOG(ITypeConformance::link); +} - void ReplayConsumer::ITypeConformance_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) - { - SlangResult res = m_commonReplayer.renameEntryPoint(objectId, newName, outEntryPointId); - FAIL_WITH_LOG(ITypeConformance::renameEntryPoint); - } +void ReplayConsumer::ITypeConformance_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) +{ + SlangResult res = m_commonReplayer.getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibrary, + outDiagnostics); + FAIL_WITH_LOG(ITypeConformance::getEntryPointHostCallable); +} + + +void ReplayConsumer::ITypeConformance_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) +{ + SlangResult res = m_commonReplayer.renameEntryPoint(objectId, newName, outEntryPointId); + FAIL_WITH_LOG(ITypeConformance::renameEntryPoint); +} - void ReplayConsumer::ITypeConformance_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) - { - SlangResult res = m_commonReplayer.linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries, outDiagnosticsId); - FAIL_WITH_LOG(ITypeConformance::linkWithOptions); - } +void ReplayConsumer::ITypeConformance_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) +{ + SlangResult res = m_commonReplayer.linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries, + outDiagnosticsId); + FAIL_WITH_LOG(ITypeConformance::linkWithOptions); +} }; // namespace SlangRecord diff --git a/source/slang-record-replay/replay/replay-consumer.h b/source/slang-record-replay/replay/replay-consumer.h index 8a0260c82..7f4c3b5e1 100644 --- a/source/slang-record-replay/replay/replay-consumer.h +++ b/source/slang-record-replay/replay/replay-consumer.h @@ -1,248 +1,581 @@ #ifndef REPLAY_CONSUMER_H #define REPLAY_CONSUMER_H -#include <unordered_map> #include "../../core/slang-stream.h" #include "../util/record-format.h" #include "../util/record-utility.h" #include "decoder-consumer.h" +#include <unordered_map> + namespace SlangRecord { - // class CommonInterfaceReplayer; +// class CommonInterfaceReplayer; - class CommonInterfaceReplayer +class CommonInterfaceReplayer +{ +public: + CommonInterfaceReplayer(Slang::Dictionary<ObjectID, void*>& pObjectMap) + : m_objectMap(pObjectMap) + { + } + virtual ~CommonInterfaceReplayer() = default; + + SlangResult getSession(ObjectID objectId, ObjectID outSessionId) { return SLANG_FAIL; } + + SlangResult getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId); + SlangResult getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId); + SlangResult getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId); + SlangResult getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystemId); + SlangResult getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId); + SlangResult specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId); + SlangResult link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId); + SlangResult getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibraryId, + ObjectID outDiagnosticsId); + SlangResult renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId); + SlangResult linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId); + +private: + inline slang::IComponentType* getObjectPointer(ObjectID objectId) { - public: - CommonInterfaceReplayer(Slang::Dictionary<ObjectID, void*>& pObjectMap) - : m_objectMap(pObjectMap) - {} - virtual ~CommonInterfaceReplayer() = default; - - SlangResult getSession(ObjectID objectId, ObjectID outSessionId) { return SLANG_FAIL; } - - SlangResult getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId); - SlangResult getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId); - SlangResult getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId); - SlangResult getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystemId); - SlangResult getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId); - SlangResult specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId); - SlangResult link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId); - SlangResult getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibraryId, - ObjectID outDiagnosticsId); - SlangResult renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId); - SlangResult linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId); - private: - inline slang::IComponentType* getObjectPointer(ObjectID objectId) + void* objPtr = nullptr; + + // If the object is not found, there must be something wrong with the record/replay + // logic, so report an error. + if (!m_objectMap.tryGetValue(objectId, objPtr)) { - void* objPtr = nullptr; + slangRecordLog(LogLevel::Error, "Object not found in the object map: %d\n", objectId); + std::abort(); + } - // If the object is not found, there must be something wrong with the record/replay - // logic, so report an error. - if (!m_objectMap.tryGetValue(objectId, objPtr)) - { - slangRecordLog(LogLevel::Error, "Object not found in the object map: %d\n", objectId); - std::abort(); - } + return static_cast<slang::IComponentType*>(objPtr); + } - return static_cast<slang::IComponentType*>(objPtr); - } + Slang::Dictionary<ObjectID, void*>& m_objectMap; + uint32_t m_globalCounter = 0; +}; + +class ReplayConsumer : public IDecoderConsumer, public Slang::RefObject +{ +public: + virtual void CreateGlobalSession(ObjectID outGlobalSessionId) override; + virtual void IGlobalSession_createSession( + ObjectID objectId, + slang::SessionDesc const& desc, + ObjectID outSessionId) override; + virtual void IGlobalSession_findProfile(ObjectID objectId, char const* name) override; + virtual void IGlobalSession_setDownstreamCompilerPath( + ObjectID objectId, + SlangPassThrough passThrough, + char const* path) override; + virtual void IGlobalSession_setDownstreamCompilerPrelude( + ObjectID objectId, + SlangPassThrough inPassThrough, + char const* prelude) override; + virtual void IGlobalSession_getDownstreamCompilerPrelude( + ObjectID objectId, + SlangPassThrough inPassThrough, + ObjectID outPreludeId) override; + + virtual void IGlobalSession_getBuildTagString(ObjectID objectId) override { (void)objectId; } + + virtual void IGlobalSession_setDefaultDownstreamCompiler( + ObjectID objectId, + SlangSourceLanguage sourceLanguage, + SlangPassThrough defaultCompiler) override; + virtual void IGlobalSession_getDefaultDownstreamCompiler( + ObjectID objectId, + SlangSourceLanguage sourceLanguage) override; + virtual void IGlobalSession_setLanguagePrelude( + ObjectID objectId, + SlangSourceLanguage inSourceLanguage, + char const* prelude) override; + virtual void IGlobalSession_getLanguagePrelude( + ObjectID objectId, + SlangSourceLanguage inSourceLanguage, + ObjectID outPreludeId) override; + virtual void IGlobalSession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequest) + override; + virtual void IGlobalSession_addBuiltins( + ObjectID objectId, + char const* sourcePath, + char const* sourceString) override; + virtual void IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ObjectID loaderId) + override; + virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) + override; + virtual void IGlobalSession_checkCompileTargetSupport( + ObjectID objectId, + SlangCompileTarget target) override; + virtual void IGlobalSession_checkPassThroughSupport( + ObjectID objectId, + SlangPassThrough passThrough) override; + virtual void IGlobalSession_compileCoreModule( + ObjectID objectId, + slang::CompileCoreModuleFlags flags) override; + virtual void IGlobalSession_loadCoreModule( + ObjectID objectId, + const void* coreModule, + size_t coreModuleSizeInBytes) override; + virtual void IGlobalSession_saveCoreModule( + ObjectID objectId, + SlangArchiveType archiveType, + ObjectID outBlobId) override; + virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name) override; + virtual void IGlobalSession_setDownstreamCompilerForTransition( + ObjectID objectId, + SlangCompileTarget source, + SlangCompileTarget target, + SlangPassThrough compiler) override; + virtual void IGlobalSession_getDownstreamCompilerForTransition( + ObjectID objectId, + SlangCompileTarget source, + SlangCompileTarget target) override; + + virtual void IGlobalSession_getCompilerElapsedTime(ObjectID objectId) override + { + (void)objectId; + } + + virtual void IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, char const* jsonPath) + override; + virtual void IGlobalSession_parseCommandLineArguments( + ObjectID objectId, + int argc, + const char* const* argv, + ObjectID outSessionDescId, + ObjectID outAllocationId) override; + virtual void IGlobalSession_getSessionDescDigest( + ObjectID objectId, + slang::SessionDesc* sessionDesc, + ObjectID outBlobId) override; + + // ISession + virtual void ISession_getGlobalSession(ObjectID objectId, ObjectID outGlobalSessionId) override; + virtual void ISession_loadModule( + ObjectID objectId, + const char* moduleName, + ObjectID outDiagnostics, + ObjectID outModuleId) override; + + virtual void ISession_loadModuleFromIRBlob( + ObjectID objectId, + const char* moduleName, + const char* path, + slang::IBlob* source, + ObjectID outDiagnosticsId, + ObjectID outModuleId) override; + virtual void ISession_loadModuleFromSource( + ObjectID objectId, + const char* moduleName, + const char* path, + slang::IBlob* source, + ObjectID outDiagnosticsId, + ObjectID outModuleId) override; + virtual void ISession_loadModuleFromSourceString( + ObjectID objectId, + const char* moduleName, + const char* path, + const char* string, + ObjectID outDiagnosticsId, + ObjectID outModuleId) override; + virtual void ISession_createCompositeComponentType( + ObjectID objectId, + ObjectID* componentTypeIds, + SlangInt componentTypeCount, + ObjectID outCompositeComponentTypeIds, + ObjectID outDiagnosticsId) override; + + virtual void ISession_specializeType( + ObjectID objectId, + ObjectID typeId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outDiagnosticsId, + ObjectID outTypeReflectionId) override; + + virtual void ISession_getTypeLayout( + ObjectID objectId, + ObjectID typeId, + SlangInt targetIndex, + slang::LayoutRules rules, + ObjectID outDiagnosticsId, + ObjectID outTypeLayoutReflection) override; + + virtual void ISession_getContainerType( + ObjectID objectId, + ObjectID elementType, + slang::ContainerType containerType, + ObjectID outDiagnosticsId, + ObjectID outTypeReflectionId) override; + + virtual void ISession_getDynamicType(ObjectID objectId, ObjectID outTypeReflectionId) override; + + virtual void ISession_getTypeRTTIMangledName( + ObjectID objectId, + ObjectID typeId, + ObjectID outNameBlobId) override; + + virtual void ISession_getTypeConformanceWitnessMangledName( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + ObjectID outNameBlobId) override; + + virtual void ISession_getTypeConformanceWitnessSequentialID( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + uint32_t outId) override; + + virtual void ISession_createTypeConformanceComponentType( + ObjectID objectId, + ObjectID typeId, + ObjectID interfaceTypeId, + ObjectID outConformanceId, + SlangInt conformanceIdOverride, + ObjectID outDiagnosticsId) override; + + virtual void ISession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequestId) + override; + + virtual void ISession_getLoadedModuleCount(ObjectID objectId) override { (void)objectId; } + + virtual void ISession_getLoadedModule(ObjectID objectId, SlangInt index, ObjectID outModuleId) + override; + + virtual void ISession_isBinaryModuleUpToDate(ObjectID objectId) override { (void)objectId; } + + // IModule + virtual void IModule_findEntryPointByName( + ObjectID objectId, + char const* name, + ObjectID outEntryPointId) override; + + virtual void IModule_getDefinedEntryPointCount(ObjectID objectId) override { (void)objectId; } + + virtual void IModule_getDefinedEntryPoint( + ObjectID objectId, + SlangInt32 index, + ObjectID outEntryPointId) override; + virtual void IModule_serialize(ObjectID objectId, ObjectID outSerializedBlobId) override; + virtual void IModule_writeToFile(ObjectID objectId, char const* fileName) override; + + virtual void IModule_getName(ObjectID objectId) override { (void)objectId; } + virtual void IModule_getFilePath(ObjectID objectId) override { (void)objectId; } + virtual void IModule_getUniqueIdentity(ObjectID objectId) override { (void)objectId; } + + virtual void IModule_findAndCheckEntryPoint( + ObjectID objectId, + char const* name, + SlangStage stage, + ObjectID outEntryPointId, + ObjectID outDiagnostics) override; + + virtual void IModule_getSession(ObjectID objectId, ObjectID outSessionId) override; + virtual void IModule_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) override; + + virtual void IModule_getSpecializationParamCount(ObjectID objectId) override { (void)objectId; } + + virtual void IModule_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) override; + virtual void IModule_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) override; + virtual void IModule_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) override; + virtual void IModule_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) override; + virtual void IModule_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) override; + virtual void IModule_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) override; + virtual void IModule_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) override; + virtual void IModule_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) override; + virtual void IModule_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) override; + + // IEntryPoint + virtual void IEntryPoint_getSession(ObjectID objectId, ObjectID outSessionId) override; + virtual void IEntryPoint_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) override; + + virtual void IEntryPoint_getSpecializationParamCount(ObjectID objectId) override + { + (void)objectId; + }; - Slang::Dictionary<ObjectID, void*>& m_objectMap; - uint32_t m_globalCounter = 0; + virtual void IEntryPoint_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) override; + virtual void IEntryPoint_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) override; + virtual void IEntryPoint_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) override; + virtual void IEntryPoint_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) override; + virtual void IEntryPoint_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) override; + virtual void IEntryPoint_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) override; + virtual void IEntryPoint_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) override; + virtual void IEntryPoint_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) override; + virtual void IEntryPoint_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) override; + + // ICompositeComponentType + virtual void ICompositeComponentType_getSession(ObjectID objectId, ObjectID outSessionId) + override; + virtual void ICompositeComponentType_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) override; + + virtual void ICompositeComponentType_getSpecializationParamCount(ObjectID objectId) override + { + (void)objectId; }; - class ReplayConsumer : public IDecoderConsumer, public Slang::RefObject + virtual void ICompositeComponentType_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) override; + virtual void ICompositeComponentType_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) override; + virtual void ICompositeComponentType_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) override; + virtual void ICompositeComponentType_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) override; + virtual void ICompositeComponentType_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) override; + virtual void ICompositeComponentType_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) override; + virtual void ICompositeComponentType_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) override; + virtual void ICompositeComponentType_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) override; + virtual void ICompositeComponentType_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) override; + + // ITypeConformance + virtual void ITypeConformance_getSession(ObjectID objectId, ObjectID outSessionId) override; + virtual void ITypeConformance_getLayout( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outDiagnosticsId, + ObjectID retProgramLayoutId) override; + + virtual void ITypeConformance_getSpecializationParamCount(ObjectID objectId) override { - public: - virtual void CreateGlobalSession(ObjectID outGlobalSessionId) override; - virtual void IGlobalSession_createSession(ObjectID objectId, slang::SessionDesc const& desc, ObjectID outSessionId) override; - virtual void IGlobalSession_findProfile(ObjectID objectId, char const* name) override; - virtual void IGlobalSession_setDownstreamCompilerPath(ObjectID objectId, SlangPassThrough passThrough, char const* path) override; - virtual void IGlobalSession_setDownstreamCompilerPrelude(ObjectID objectId, SlangPassThrough inPassThrough, char const* prelude) override; - virtual void IGlobalSession_getDownstreamCompilerPrelude(ObjectID objectId, SlangPassThrough inPassThrough, ObjectID outPreludeId) override; - - virtual void IGlobalSession_getBuildTagString(ObjectID objectId) override { (void) objectId; } + (void)objectId; + }; - virtual void IGlobalSession_setDefaultDownstreamCompiler(ObjectID objectId, SlangSourceLanguage sourceLanguage, SlangPassThrough defaultCompiler) override; - virtual void IGlobalSession_getDefaultDownstreamCompiler(ObjectID objectId, SlangSourceLanguage sourceLanguage) override; - virtual void IGlobalSession_setLanguagePrelude(ObjectID objectId, SlangSourceLanguage inSourceLanguage, char const* prelude) override; - virtual void IGlobalSession_getLanguagePrelude(ObjectID objectId, SlangSourceLanguage inSourceLanguage, ObjectID outPreludeId) override; - virtual void IGlobalSession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequest) override; - virtual void IGlobalSession_addBuiltins(ObjectID objectId, char const* sourcePath, char const* sourceString) override; - virtual void IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ObjectID loaderId) override; - virtual void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ObjectID outLoaderId) override; - virtual void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, SlangCompileTarget target) override; - virtual void IGlobalSession_checkPassThroughSupport(ObjectID objectId, SlangPassThrough passThrough) override; - virtual void IGlobalSession_compileCoreModule(ObjectID objectId, slang::CompileCoreModuleFlags flags) override; - virtual void IGlobalSession_loadCoreModule(ObjectID objectId, const void* coreModule, size_t coreModuleSizeInBytes) override; - virtual void IGlobalSession_saveCoreModule(ObjectID objectId, SlangArchiveType archiveType, ObjectID outBlobId) override; - virtual void IGlobalSession_findCapability(ObjectID objectId, char const* name) override; - virtual void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target, SlangPassThrough compiler) override; - virtual void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, SlangCompileTarget source, SlangCompileTarget target) override; - - virtual void IGlobalSession_getCompilerElapsedTime(ObjectID objectId) override { (void) objectId; } - - virtual void IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, char const* jsonPath) override; - virtual void IGlobalSession_parseCommandLineArguments(ObjectID objectId, int argc, const char* const* argv, ObjectID outSessionDescId, ObjectID outAllocationId) override; - virtual void IGlobalSession_getSessionDescDigest(ObjectID objectId, slang::SessionDesc* sessionDesc, ObjectID outBlobId) override; - - // ISession - virtual void ISession_getGlobalSession(ObjectID objectId, ObjectID outGlobalSessionId) override; - virtual void ISession_loadModule(ObjectID objectId, const char* moduleName, ObjectID outDiagnostics, ObjectID outModuleId) override; - - virtual void ISession_loadModuleFromIRBlob(ObjectID objectId, const char* moduleName, - const char* path, slang::IBlob* source, ObjectID outDiagnosticsId, ObjectID outModuleId) override; - virtual void ISession_loadModuleFromSource(ObjectID objectId, const char* moduleName, - const char* path, slang::IBlob* source, ObjectID outDiagnosticsId, ObjectID outModuleId) override; - virtual void ISession_loadModuleFromSourceString(ObjectID objectId, const char* moduleName, - const char* path, const char* string, ObjectID outDiagnosticsId, ObjectID outModuleId) override; - virtual void ISession_createCompositeComponentType(ObjectID objectId, ObjectID* componentTypeIds, - SlangInt componentTypeCount, ObjectID outCompositeComponentTypeIds, ObjectID outDiagnosticsId) override; - - virtual void ISession_specializeType(ObjectID objectId, ObjectID typeId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outDiagnosticsId, ObjectID outTypeReflectionId) override; - - virtual void ISession_getTypeLayout(ObjectID objectId, ObjectID typeId, SlangInt targetIndex, - slang::LayoutRules rules, ObjectID outDiagnosticsId, ObjectID outTypeLayoutReflection) override; - - virtual void ISession_getContainerType(ObjectID objectId, ObjectID elementType, - slang::ContainerType containerType, ObjectID outDiagnosticsId, ObjectID outTypeReflectionId) override; - - virtual void ISession_getDynamicType(ObjectID objectId, ObjectID outTypeReflectionId) override; - - virtual void ISession_getTypeRTTIMangledName(ObjectID objectId, ObjectID typeId, ObjectID outNameBlobId) override; - - virtual void ISession_getTypeConformanceWitnessMangledName(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, ObjectID outNameBlobId) override; - - virtual void ISession_getTypeConformanceWitnessSequentialID(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, uint32_t outId) override; - - virtual void ISession_createTypeConformanceComponentType(ObjectID objectId, ObjectID typeId, - ObjectID interfaceTypeId, ObjectID outConformanceId, - SlangInt conformanceIdOverride, ObjectID outDiagnosticsId) override; - - virtual void ISession_createCompileRequest(ObjectID objectId, ObjectID outCompileRequestId) override; - - virtual void ISession_getLoadedModuleCount(ObjectID objectId) override { (void) objectId; } - - virtual void ISession_getLoadedModule(ObjectID objectId, SlangInt index, ObjectID outModuleId) override; - - virtual void ISession_isBinaryModuleUpToDate(ObjectID objectId) override { (void) objectId; } - - // IModule - virtual void IModule_findEntryPointByName(ObjectID objectId, char const* name, ObjectID outEntryPointId) override; - - virtual void IModule_getDefinedEntryPointCount(ObjectID objectId) override { (void) objectId; } - - virtual void IModule_getDefinedEntryPoint(ObjectID objectId, SlangInt32 index, ObjectID outEntryPointId) override; - virtual void IModule_serialize(ObjectID objectId, ObjectID outSerializedBlobId) override; - virtual void IModule_writeToFile(ObjectID objectId, char const* fileName) override; - - virtual void IModule_getName(ObjectID objectId) override { (void) objectId; } - virtual void IModule_getFilePath(ObjectID objectId) override { (void) objectId; } - virtual void IModule_getUniqueIdentity(ObjectID objectId) override { (void) objectId; } - - virtual void IModule_findAndCheckEntryPoint(ObjectID objectId, char const* name, SlangStage stage, ObjectID outEntryPointId, ObjectID outDiagnostics) override; - - virtual void IModule_getSession(ObjectID objectId, ObjectID outSessionId) override; - virtual void IModule_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) override; - - virtual void IModule_getSpecializationParamCount(ObjectID objectId) override { (void) objectId; } - - virtual void IModule_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) override; - virtual void IModule_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) override; - virtual void IModule_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) override; - virtual void IModule_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) override; - virtual void IModule_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) override; - virtual void IModule_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) override; - virtual void IModule_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) override; - virtual void IModule_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) override; - virtual void IModule_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) override; - - // IEntryPoint - virtual void IEntryPoint_getSession(ObjectID objectId, ObjectID outSessionId) override; - virtual void IEntryPoint_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) override; - - virtual void IEntryPoint_getSpecializationParamCount(ObjectID objectId) override { (void) objectId; }; - - virtual void IEntryPoint_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) override; - virtual void IEntryPoint_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) override; - virtual void IEntryPoint_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) override; - virtual void IEntryPoint_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) override; - virtual void IEntryPoint_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) override; - virtual void IEntryPoint_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) override; - virtual void IEntryPoint_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) override; - virtual void IEntryPoint_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) override; - virtual void IEntryPoint_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) override; - - // ICompositeComponentType - virtual void ICompositeComponentType_getSession(ObjectID objectId, ObjectID outSessionId) override; - virtual void ICompositeComponentType_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) override; - - virtual void ICompositeComponentType_getSpecializationParamCount(ObjectID objectId) override { (void) objectId; }; - - virtual void ICompositeComponentType_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) override; - virtual void ICompositeComponentType_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) override; - virtual void ICompositeComponentType_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) override; - virtual void ICompositeComponentType_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) override; - virtual void ICompositeComponentType_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) override; - virtual void ICompositeComponentType_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) override; - virtual void ICompositeComponentType_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) override; - virtual void ICompositeComponentType_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) override; - virtual void ICompositeComponentType_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) override; - - // ITypeConformance - virtual void ITypeConformance_getSession(ObjectID objectId, ObjectID outSessionId) override; - virtual void ITypeConformance_getLayout(ObjectID objectId, SlangInt targetIndex, ObjectID outDiagnosticsId, ObjectID retProgramLayoutId) override; - - virtual void ITypeConformance_getSpecializationParamCount(ObjectID objectId) override { (void) objectId; }; - - virtual void ITypeConformance_getEntryPointCode(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) override; - virtual void ITypeConformance_getTargetCode(ObjectID objectId, SlangInt targetIndex, ObjectID outCodeId, ObjectID outDiagnosticsId) override; - virtual void ITypeConformance_getResultAsFileSystem(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outFileSystem) override; - virtual void ITypeConformance_getEntryPointHash(ObjectID objectId, SlangInt entryPointIndex, SlangInt targetIndex, ObjectID outHashId) override; - virtual void ITypeConformance_specialize(ObjectID objectId, slang::SpecializationArg const* specializationArgs, - SlangInt specializationArgCount, ObjectID outSpecializedComponentTypeId, ObjectID outDiagnosticsId) override; - virtual void ITypeConformance_link(ObjectID objectId, ObjectID outLinkedComponentTypeId, ObjectID outDiagnosticsId) override; - virtual void ITypeConformance_getEntryPointHostCallable(ObjectID objectId, int entryPointIndex, int targetIndex, ObjectID outSharedLibrary, ObjectID outDiagnostics) override; - virtual void ITypeConformance_renameEntryPoint(ObjectID objectId, const char* newName, ObjectID outEntryPointId) override; - virtual void ITypeConformance_linkWithOptions(ObjectID objectId, ObjectID outLinkedComponentTypeId, - uint32_t compilerOptionEntryCount, slang::CompilerOptionEntry* compilerOptionEntries, ObjectID outDiagnosticsId) override; - - static void printDiagnosticMessage(slang::IBlob* diagnosticsBlob); - private: - // Map of the address of the object allocated by slang during record to - // the address of the object allocated by the replay. - // We need to have this map because we never save the content of the object - // allocated by slang. Because those are just opaque objects or handles, we - // only need to provide them to the corresponding replay function or call the - // methods on the correct object. - Slang::Dictionary<ObjectID, void*> m_objectMap; - - template<typename T> - inline T* getObjectPointer(ObjectID objectId) + virtual void ITypeConformance_getEntryPointCode( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) override; + virtual void ITypeConformance_getTargetCode( + ObjectID objectId, + SlangInt targetIndex, + ObjectID outCodeId, + ObjectID outDiagnosticsId) override; + virtual void ITypeConformance_getResultAsFileSystem( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outFileSystem) override; + virtual void ITypeConformance_getEntryPointHash( + ObjectID objectId, + SlangInt entryPointIndex, + SlangInt targetIndex, + ObjectID outHashId) override; + virtual void ITypeConformance_specialize( + ObjectID objectId, + slang::SpecializationArg const* specializationArgs, + SlangInt specializationArgCount, + ObjectID outSpecializedComponentTypeId, + ObjectID outDiagnosticsId) override; + virtual void ITypeConformance_link( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + ObjectID outDiagnosticsId) override; + virtual void ITypeConformance_getEntryPointHostCallable( + ObjectID objectId, + int entryPointIndex, + int targetIndex, + ObjectID outSharedLibrary, + ObjectID outDiagnostics) override; + virtual void ITypeConformance_renameEntryPoint( + ObjectID objectId, + const char* newName, + ObjectID outEntryPointId) override; + virtual void ITypeConformance_linkWithOptions( + ObjectID objectId, + ObjectID outLinkedComponentTypeId, + uint32_t compilerOptionEntryCount, + slang::CompilerOptionEntry* compilerOptionEntries, + ObjectID outDiagnosticsId) override; + + static void printDiagnosticMessage(slang::IBlob* diagnosticsBlob); + +private: + // Map of the address of the object allocated by slang during record to + // the address of the object allocated by the replay. + // We need to have this map because we never save the content of the object + // allocated by slang. Because those are just opaque objects or handles, we + // only need to provide them to the corresponding replay function or call the + // methods on the correct object. + Slang::Dictionary<ObjectID, void*> m_objectMap; + + template<typename T> + inline T* getObjectPointer(ObjectID objectId) + { + void* objPtr = nullptr; + if (!m_objectMap.tryGetValue(objectId, objPtr)) { - void* objPtr = nullptr; - if (!m_objectMap.tryGetValue(objectId, objPtr)) - { - slangRecordLog(LogLevel::Error, "Object not found in the object map: %d\n", objectId); - std::abort(); - } - - return static_cast<T*>(objPtr); + slangRecordLog(LogLevel::Error, "Object not found in the object map: %d\n", objectId); + std::abort(); } - CommonInterfaceReplayer m_commonReplayer {m_objectMap}; - }; -} + return static_cast<T*>(objPtr); + } + + CommonInterfaceReplayer m_commonReplayer{m_objectMap}; +}; +} // namespace SlangRecord #endif // REPLAY_CONSUMER_H diff --git a/source/slang-record-replay/replay/slang-decoder.cpp b/source/slang-record-replay/replay/slang-decoder.cpp index 6eb4ac8f5..a0ae842ea 100644 --- a/source/slang-record-replay/replay/slang-decoder.cpp +++ b/source/slang-record-replay/replay/slang-decoder.cpp @@ -1,1987 +1,3118 @@ #include "slang-decoder.h" -#include "parameter-decoder.h" -#include "decoder-helper.h" + #include "../util/record-utility.h" +#include "decoder-helper.h" +#include "parameter-decoder.h" namespace SlangRecord { - bool SlangDecoder::processMethodCall(FunctionHeader const& header, ParameterBlock const& parameterBlock) - { - ApiClassId classId = static_cast<ApiClassId>(getClassId(header.callId)); - ObjectID objectId = header.handleId; - switch(classId) - { - default: - slangRecordLog(LogLevel::Error, "Unhandled Slang Class Id: %d\n", classId); - return false; - case ApiClassId::Class_IGlobalSession: - return processIGlobalSessionMethods(header.callId, objectId, parameterBlock); - break; - case ApiClassId::Class_ISession: - return processISessionMethods(header.callId, objectId, parameterBlock); - break; - case ApiClassId::Class_IModule: - return processIModuleMethods(header.callId, objectId, parameterBlock); - break; - case ApiClassId::Class_IEntryPoint: - return processIEntryPointMethods(header.callId, objectId, parameterBlock); - break; - case ApiClassId::Class_ICompositeComponentType: - return processICompositeComponentTypeMethods(header.callId, objectId, parameterBlock); - break; - case ApiClassId::Class_ITypeConformance: - return processITypeConformanceMethods(header.callId, objectId, parameterBlock); - break; - } - } - - bool SlangDecoder::processIGlobalSessionMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock) - { - switch(callId) - { - default: - slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); - break; - case ApiCallId::IGlobalSession_createSession: - IGlobalSession_createSession(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_findProfile: - IGlobalSession_findProfile(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_setDownstreamCompilerPath: - IGlobalSession_setDownstreamCompilerPath(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_setDownstreamCompilerPrelude: - IGlobalSession_setDownstreamCompilerPrelude(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_getDownstreamCompilerPrelude: - IGlobalSession_getDownstreamCompilerPrelude(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_getBuildTagString: - IGlobalSession_getBuildTagString(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_setDefaultDownstreamCompiler: - IGlobalSession_setDefaultDownstreamCompiler(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_getDefaultDownstreamCompiler: - IGlobalSession_getDefaultDownstreamCompiler(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_setLanguagePrelude: - IGlobalSession_setLanguagePrelude(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_getLanguagePrelude: - IGlobalSession_getLanguagePrelude(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_createCompileRequest: - IGlobalSession_createCompileRequest(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_addBuiltins: - IGlobalSession_addBuiltins(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_setSharedLibraryLoader: - IGlobalSession_setSharedLibraryLoader(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_getSharedLibraryLoader: - IGlobalSession_getSharedLibraryLoader(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_checkCompileTargetSupport: - IGlobalSession_checkCompileTargetSupport(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_checkPassThroughSupport: - IGlobalSession_checkPassThroughSupport(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_compileCoreModule: - IGlobalSession_compileCoreModule(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_loadCoreModule: - IGlobalSession_loadCoreModule(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_saveCoreModule: - IGlobalSession_saveCoreModule(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_findCapability: - IGlobalSession_findCapability(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_setDownstreamCompilerForTransition: - IGlobalSession_setDownstreamCompilerForTransition(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_getDownstreamCompilerForTransition: - IGlobalSession_getDownstreamCompilerForTransition(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_getCompilerElapsedTime: - IGlobalSession_getCompilerElapsedTime(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_setSPIRVCoreGrammar: - IGlobalSession_setSPIRVCoreGrammar(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_parseCommandLineArguments: - IGlobalSession_parseCommandLineArguments(objectId, parameterBlock); - break; - case ApiCallId::IGlobalSession_getSessionDescDigest: - IGlobalSession_getSessionDescDigest(objectId, parameterBlock); - break; - } - return true; - } - - - bool SlangDecoder::processISessionMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock) - { - switch(callId) - { - default: - slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); - return false; - case ApiCallId::ISession_getGlobalSession: - ISession_getGlobalSession(objectId, parameterBlock); - break; - case ApiCallId::ISession_loadModule: - ISession_loadModule(objectId, parameterBlock); - break; - case ApiCallId::ISession_loadModuleFromIRBlob: - ISession_loadModuleFromIRBlob(objectId, parameterBlock); - break; - case ApiCallId::ISession_loadModuleFromSource: - ISession_loadModuleFromSource(objectId, parameterBlock); - break; - case ApiCallId::ISession_loadModuleFromSourceString: - ISession_loadModuleFromSourceString(objectId, parameterBlock); - break; - case ApiCallId::ISession_createCompositeComponentType: - ISession_createCompositeComponentType(objectId, parameterBlock); - break; - case ApiCallId::ISession_specializeType: - ISession_specializeType(objectId, parameterBlock); - break; - case ApiCallId::ISession_getTypeLayout: - ISession_getTypeLayout(objectId, parameterBlock); - break; - case ApiCallId::ISession_getContainerType: - ISession_getContainerType(objectId, parameterBlock); - break; - case ApiCallId::ISession_getDynamicType: - ISession_getDynamicType(objectId, parameterBlock); - break; - case ApiCallId::ISession_getTypeRTTIMangledName: - ISession_getTypeRTTIMangledName(objectId, parameterBlock); - break; - case ApiCallId::ISession_getTypeConformanceWitnessMangledName: - ISession_getTypeConformanceWitnessMangledName(objectId, parameterBlock); - break; - case ApiCallId::ISession_getTypeConformanceWitnessSequentialID: - ISession_getTypeConformanceWitnessSequentialID(objectId, parameterBlock); - break; - case ApiCallId::ISession_createTypeConformanceComponentType: - ISession_createTypeConformanceComponentType(objectId, parameterBlock); - break; - case ApiCallId::ISession_createCompileRequest: - ISession_createCompileRequest(objectId, parameterBlock); - break; - case ApiCallId::ISession_getLoadedModuleCount: - ISession_getLoadedModuleCount(objectId, parameterBlock); - break; - case ApiCallId::ISession_getLoadedModule: - ISession_getLoadedModule(objectId, parameterBlock); - break; - case ApiCallId::ISession_isBinaryModuleUpToDate: - ISession_isBinaryModuleUpToDate(objectId, parameterBlock); - break; - } - return true; - } - - bool SlangDecoder::processIModuleMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock) - { - switch(callId) - { - default: - slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); - return false; - case ApiCallId::IModule_findEntryPointByName: - IModule_findEntryPointByName(objectId, parameterBlock); - break; - case ApiCallId::IModule_getDefinedEntryPointCount: - IModule_getDefinedEntryPointCount(objectId, parameterBlock); - break; - case ApiCallId::IModule_getDefinedEntryPoint: - IModule_getDefinedEntryPoint(objectId, parameterBlock); - break; - case ApiCallId::IModule_serialize: - IModule_serialize(objectId, parameterBlock); - break; - case ApiCallId::IModule_writeToFile: - IModule_writeToFile(objectId, parameterBlock); - break; - case ApiCallId::IModule_getName: - IModule_getName(objectId, parameterBlock); - break; - case ApiCallId::IModule_getFilePath: - IModule_getFilePath(objectId, parameterBlock); - break; - case ApiCallId::IModule_getUniqueIdentity: - IModule_getUniqueIdentity(objectId, parameterBlock); - break; - case ApiCallId::IModule_findAndCheckEntryPoint: - IModule_findAndCheckEntryPoint(objectId, parameterBlock); - break; - case ApiCallId::IModule_getSession: - IModule_getSession(objectId, parameterBlock); - break; - case ApiCallId::IModule_getLayout: - IModule_getLayout(objectId, parameterBlock); - break; - case ApiCallId::IModule_getSpecializationParamCount: - IModule_getSpecializationParamCount(objectId, parameterBlock); - break; - case ApiCallId::IModule_getEntryPointCode: - IModule_getEntryPointCode(objectId, parameterBlock); - break; - case ApiCallId::IModule_getTargetCode: - IModule_getTargetCode(objectId, parameterBlock); - break; - case ApiCallId::IModule_getResultAsFileSystem: - IModule_getResultAsFileSystem(objectId, parameterBlock); - break; - case ApiCallId::IModule_getEntryPointHash: - IModule_getEntryPointHash(objectId, parameterBlock); - break; - case ApiCallId::IModule_specialize: - IModule_specialize(objectId, parameterBlock); - break; - case ApiCallId::IModule_link: - IModule_link(objectId, parameterBlock); - break; - case ApiCallId::IModule_getEntryPointHostCallable: - IModule_getEntryPointHostCallable(objectId, parameterBlock); - break; - case ApiCallId::IModule_renameEntryPoint: - IModule_renameEntryPoint(objectId, parameterBlock); - break; - case ApiCallId::IModule_linkWithOptions: - IModule_linkWithOptions(objectId, parameterBlock); - break; - } - return true; - } - - bool SlangDecoder::processIEntryPointMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock) - { - switch(callId) - { - default: - slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); - return false; - case ApiCallId::IEntryPoint_getSession: - IEntryPoint_getSession(objectId, parameterBlock); - break; - case ApiCallId::IEntryPoint_getLayout: - IEntryPoint_getLayout(objectId, parameterBlock); - break; - case ApiCallId::IEntryPoint_getSpecializationParamCount: - IEntryPoint_getSpecializationParamCount(objectId, parameterBlock); - break; - case ApiCallId::IEntryPoint_getEntryPointCode: - IEntryPoint_getEntryPointCode(objectId, parameterBlock); - break; - case ApiCallId::IEntryPoint_getTargetCode: - IEntryPoint_getTargetCode(objectId, parameterBlock); - break; - case ApiCallId::IEntryPoint_getResultAsFileSystem: - IEntryPoint_getResultAsFileSystem(objectId, parameterBlock); - break; - case ApiCallId::IEntryPoint_getEntryPointHash: - IEntryPoint_getEntryPointHash(objectId, parameterBlock); - break; - case ApiCallId::IEntryPoint_specialize: - IEntryPoint_specialize(objectId, parameterBlock); - break; - case ApiCallId::IEntryPoint_link: - IEntryPoint_link(objectId, parameterBlock); - break; - case ApiCallId::IEntryPoint_getEntryPointHostCallable: - IEntryPoint_getEntryPointHostCallable(objectId, parameterBlock); - break; - case ApiCallId::IEntryPoint_renameEntryPoint: - IEntryPoint_renameEntryPoint(objectId, parameterBlock); - break; - case ApiCallId::IEntryPoint_linkWithOptions: - IEntryPoint_linkWithOptions(objectId, parameterBlock); - break; - } - return true; - } - - bool SlangDecoder::processICompositeComponentTypeMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock) - { - switch(callId) - { - default: - slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); - break; - case ApiCallId::ICompositeComponentType_getSession: - ICompositeComponentType_getSession(objectId, parameterBlock); - break; - case ApiCallId::ICompositeComponentType_getLayout: - ICompositeComponentType_getLayout(objectId, parameterBlock); - break; - case ApiCallId::ICompositeComponentType_getSpecializationParamCount: - ICompositeComponentType_getSpecializationParamCount(objectId, parameterBlock); - break; - case ApiCallId::ICompositeComponentType_getEntryPointCode: - ICompositeComponentType_getEntryPointCode(objectId, parameterBlock); - break; - case ApiCallId::ICompositeComponentType_getTargetCode: - ICompositeComponentType_getTargetCode(objectId, parameterBlock); - break; - case ApiCallId::ICompositeComponentType_getResultAsFileSystem: - ICompositeComponentType_getResultAsFileSystem(objectId, parameterBlock); - break; - case ApiCallId::ICompositeComponentType_getEntryPointHash: - ICompositeComponentType_getEntryPointHash(objectId, parameterBlock); - break; - case ApiCallId::ICompositeComponentType_specialize: - ICompositeComponentType_specialize(objectId, parameterBlock); - break; - case ApiCallId::ICompositeComponentType_link: - ICompositeComponentType_link(objectId, parameterBlock); - break; - case ApiCallId::ICompositeComponentType_getEntryPointHostCallable: - ICompositeComponentType_getEntryPointHostCallable(objectId, parameterBlock); - break; - case ApiCallId::ICompositeComponentType_renameEntryPoint: - ICompositeComponentType_renameEntryPoint(objectId, parameterBlock); - break; - case ApiCallId::ICompositeComponentType_linkWithOptions: - ICompositeComponentType_linkWithOptions(objectId, parameterBlock); - break; - } - return true; - } - - bool SlangDecoder::processITypeConformanceMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock) - { - switch(callId) - { - default: - slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); - return false; - case ApiCallId::ITypeConformance_getSession: - ITypeConformance_getSession(objectId, parameterBlock); - break; - case ApiCallId::ITypeConformance_getLayout: - ITypeConformance_getLayout(objectId, parameterBlock); - break; - case ApiCallId::ITypeConformance_getSpecializationParamCount: - ITypeConformance_getSpecializationParamCount(objectId, parameterBlock); - break; - case ApiCallId::ITypeConformance_getEntryPointCode: - ITypeConformance_getEntryPointCode(objectId, parameterBlock); - break; - case ApiCallId::ITypeConformance_getTargetCode: - ITypeConformance_getTargetCode(objectId, parameterBlock); - break; - case ApiCallId::ITypeConformance_getResultAsFileSystem: - ITypeConformance_getResultAsFileSystem(objectId, parameterBlock); - break; - case ApiCallId::ITypeConformance_getEntryPointHash: - ITypeConformance_getEntryPointHash(objectId, parameterBlock); - break; - case ApiCallId::ITypeConformance_specialize: - ITypeConformance_specialize(objectId, parameterBlock); - break; - case ApiCallId::ITypeConformance_link: - ITypeConformance_link(objectId, parameterBlock); - break; - case ApiCallId::ITypeConformance_getEntryPointHostCallable: - ITypeConformance_getEntryPointHostCallable(objectId, parameterBlock); - break; - case ApiCallId::ITypeConformance_renameEntryPoint: - ITypeConformance_renameEntryPoint(objectId, parameterBlock); - break; - case ApiCallId::ITypeConformance_linkWithOptions: - ITypeConformance_linkWithOptions(objectId, parameterBlock); - break; - } - return true; - } - - bool SlangDecoder::processFunctionCall(FunctionHeader const& header, ParameterBlock const& parameterBlock) - { - switch(header.callId) - { - default: - slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", header.callId); - return false; - case ApiCallId::CreateGlobalSession: - CreateGlobalSession(parameterBlock); - break; - } - return true; - } - - - bool SlangDecoder::CreateGlobalSession(ParameterBlock const& parameterBlock) - { - ObjectID outGlobalSessionId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outGlobalSessionId); - - for (auto consumer: m_consumers) - { - consumer->CreateGlobalSession(outGlobalSessionId); - } - return true; - } - - bool SlangDecoder::IGlobalSession_createSession(ObjectID objectId, ParameterBlock const& parameterBlock) - { - StructDecoder<slang::SessionDesc> sessionDesc; - sessionDesc.decode(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize); - - ObjectID outSessionId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outSessionId); - - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_createSession(objectId, sessionDesc.getValue(), outSessionId); - } - - return true; - } - - void SlangDecoder::IGlobalSession_findProfile(ObjectID objectId, ParameterBlock const& parameterBlock) - { - StringDecoder name; - ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, name); - - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_findProfile(objectId, name.getPointer()); - } +bool SlangDecoder::processMethodCall( + FunctionHeader const& header, + ParameterBlock const& parameterBlock) +{ + ApiClassId classId = static_cast<ApiClassId>(getClassId(header.callId)); + ObjectID objectId = header.handleId; + switch (classId) + { + default: + slangRecordLog(LogLevel::Error, "Unhandled Slang Class Id: %d\n", classId); + return false; + case ApiClassId::Class_IGlobalSession: + return processIGlobalSessionMethods(header.callId, objectId, parameterBlock); + break; + case ApiClassId::Class_ISession: + return processISessionMethods(header.callId, objectId, parameterBlock); + break; + case ApiClassId::Class_IModule: + return processIModuleMethods(header.callId, objectId, parameterBlock); + break; + case ApiClassId::Class_IEntryPoint: + return processIEntryPointMethods(header.callId, objectId, parameterBlock); + break; + case ApiClassId::Class_ICompositeComponentType: + return processICompositeComponentTypeMethods(header.callId, objectId, parameterBlock); + break; + case ApiClassId::Class_ITypeConformance: + return processITypeConformanceMethods(header.callId, objectId, parameterBlock); + break; } +} - void SlangDecoder::IGlobalSession_setDownstreamCompilerPath(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - SlangPassThrough passThrough {}; - readByte = ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, passThrough); - StringDecoder path; - readByte += ParameterDecoder::decodeString(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, path); +bool SlangDecoder::processIGlobalSessionMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + switch (callId) + { + default: slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); break; + case ApiCallId::IGlobalSession_createSession: + IGlobalSession_createSession(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_findProfile: + IGlobalSession_findProfile(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_setDownstreamCompilerPath: + IGlobalSession_setDownstreamCompilerPath(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_setDownstreamCompilerPrelude: + IGlobalSession_setDownstreamCompilerPrelude(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_getDownstreamCompilerPrelude: + IGlobalSession_getDownstreamCompilerPrelude(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_getBuildTagString: + IGlobalSession_getBuildTagString(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_setDefaultDownstreamCompiler: + IGlobalSession_setDefaultDownstreamCompiler(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_getDefaultDownstreamCompiler: + IGlobalSession_getDefaultDownstreamCompiler(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_setLanguagePrelude: + IGlobalSession_setLanguagePrelude(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_getLanguagePrelude: + IGlobalSession_getLanguagePrelude(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_createCompileRequest: + IGlobalSession_createCompileRequest(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_addBuiltins: + IGlobalSession_addBuiltins(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_setSharedLibraryLoader: + IGlobalSession_setSharedLibraryLoader(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_getSharedLibraryLoader: + IGlobalSession_getSharedLibraryLoader(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_checkCompileTargetSupport: + IGlobalSession_checkCompileTargetSupport(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_checkPassThroughSupport: + IGlobalSession_checkPassThroughSupport(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_compileCoreModule: + IGlobalSession_compileCoreModule(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_loadCoreModule: + IGlobalSession_loadCoreModule(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_saveCoreModule: + IGlobalSession_saveCoreModule(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_findCapability: + IGlobalSession_findCapability(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_setDownstreamCompilerForTransition: + IGlobalSession_setDownstreamCompilerForTransition(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_getDownstreamCompilerForTransition: + IGlobalSession_getDownstreamCompilerForTransition(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_getCompilerElapsedTime: + IGlobalSession_getCompilerElapsedTime(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_setSPIRVCoreGrammar: + IGlobalSession_setSPIRVCoreGrammar(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_parseCommandLineArguments: + IGlobalSession_parseCommandLineArguments(objectId, parameterBlock); + break; + case ApiCallId::IGlobalSession_getSessionDescDigest: + IGlobalSession_getSessionDescDigest(objectId, parameterBlock); + break; + } + return true; +} - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_setDownstreamCompilerPath(objectId, passThrough, path.getPointer()); - } - } - void SlangDecoder::IGlobalSession_setDownstreamCompilerPrelude(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - SlangPassThrough passThrough {}; - readByte = ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, passThrough); - StringDecoder prelude; - readByte += ParameterDecoder::decodeString(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, prelude); +bool SlangDecoder::processISessionMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + switch (callId) + { + default: + slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); + return false; + case ApiCallId::ISession_getGlobalSession: + ISession_getGlobalSession(objectId, parameterBlock); + break; + case ApiCallId::ISession_loadModule: ISession_loadModule(objectId, parameterBlock); break; + case ApiCallId::ISession_loadModuleFromIRBlob: + ISession_loadModuleFromIRBlob(objectId, parameterBlock); + break; + case ApiCallId::ISession_loadModuleFromSource: + ISession_loadModuleFromSource(objectId, parameterBlock); + break; + case ApiCallId::ISession_loadModuleFromSourceString: + ISession_loadModuleFromSourceString(objectId, parameterBlock); + break; + case ApiCallId::ISession_createCompositeComponentType: + ISession_createCompositeComponentType(objectId, parameterBlock); + break; + case ApiCallId::ISession_specializeType: + ISession_specializeType(objectId, parameterBlock); + break; + case ApiCallId::ISession_getTypeLayout: ISession_getTypeLayout(objectId, parameterBlock); break; + case ApiCallId::ISession_getContainerType: + ISession_getContainerType(objectId, parameterBlock); + break; + case ApiCallId::ISession_getDynamicType: + ISession_getDynamicType(objectId, parameterBlock); + break; + case ApiCallId::ISession_getTypeRTTIMangledName: + ISession_getTypeRTTIMangledName(objectId, parameterBlock); + break; + case ApiCallId::ISession_getTypeConformanceWitnessMangledName: + ISession_getTypeConformanceWitnessMangledName(objectId, parameterBlock); + break; + case ApiCallId::ISession_getTypeConformanceWitnessSequentialID: + ISession_getTypeConformanceWitnessSequentialID(objectId, parameterBlock); + break; + case ApiCallId::ISession_createTypeConformanceComponentType: + ISession_createTypeConformanceComponentType(objectId, parameterBlock); + break; + case ApiCallId::ISession_createCompileRequest: + ISession_createCompileRequest(objectId, parameterBlock); + break; + case ApiCallId::ISession_getLoadedModuleCount: + ISession_getLoadedModuleCount(objectId, parameterBlock); + break; + case ApiCallId::ISession_getLoadedModule: + ISession_getLoadedModule(objectId, parameterBlock); + break; + case ApiCallId::ISession_isBinaryModuleUpToDate: + ISession_isBinaryModuleUpToDate(objectId, parameterBlock); + break; + } + return true; +} - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_setDownstreamCompilerPrelude(objectId, passThrough, prelude.getPointer()); - } - } +bool SlangDecoder::processIModuleMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + switch (callId) + { + default: + slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); + return false; + case ApiCallId::IModule_findEntryPointByName: + IModule_findEntryPointByName(objectId, parameterBlock); + break; + case ApiCallId::IModule_getDefinedEntryPointCount: + IModule_getDefinedEntryPointCount(objectId, parameterBlock); + break; + case ApiCallId::IModule_getDefinedEntryPoint: + IModule_getDefinedEntryPoint(objectId, parameterBlock); + break; + case ApiCallId::IModule_serialize: IModule_serialize(objectId, parameterBlock); break; + case ApiCallId::IModule_writeToFile: IModule_writeToFile(objectId, parameterBlock); break; + case ApiCallId::IModule_getName: IModule_getName(objectId, parameterBlock); break; + case ApiCallId::IModule_getFilePath: IModule_getFilePath(objectId, parameterBlock); break; + case ApiCallId::IModule_getUniqueIdentity: + IModule_getUniqueIdentity(objectId, parameterBlock); + break; + case ApiCallId::IModule_findAndCheckEntryPoint: + IModule_findAndCheckEntryPoint(objectId, parameterBlock); + break; + case ApiCallId::IModule_getSession: IModule_getSession(objectId, parameterBlock); break; + case ApiCallId::IModule_getLayout: IModule_getLayout(objectId, parameterBlock); break; + case ApiCallId::IModule_getSpecializationParamCount: + IModule_getSpecializationParamCount(objectId, parameterBlock); + break; + case ApiCallId::IModule_getEntryPointCode: + IModule_getEntryPointCode(objectId, parameterBlock); + break; + case ApiCallId::IModule_getTargetCode: IModule_getTargetCode(objectId, parameterBlock); break; + case ApiCallId::IModule_getResultAsFileSystem: + IModule_getResultAsFileSystem(objectId, parameterBlock); + break; + case ApiCallId::IModule_getEntryPointHash: + IModule_getEntryPointHash(objectId, parameterBlock); + break; + case ApiCallId::IModule_specialize: IModule_specialize(objectId, parameterBlock); break; + case ApiCallId::IModule_link: IModule_link(objectId, parameterBlock); break; + case ApiCallId::IModule_getEntryPointHostCallable: + IModule_getEntryPointHostCallable(objectId, parameterBlock); + break; + case ApiCallId::IModule_renameEntryPoint: + IModule_renameEntryPoint(objectId, parameterBlock); + break; + case ApiCallId::IModule_linkWithOptions: + IModule_linkWithOptions(objectId, parameterBlock); + break; + } + return true; +} - void SlangDecoder::IGlobalSession_getDownstreamCompilerPrelude(ObjectID objectId, ParameterBlock const& parameterBlock) - { - SlangPassThrough passThrough {}; - ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, passThrough); +bool SlangDecoder::processIEntryPointMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + switch (callId) + { + default: + slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); + return false; + case ApiCallId::IEntryPoint_getSession: IEntryPoint_getSession(objectId, parameterBlock); break; + case ApiCallId::IEntryPoint_getLayout: IEntryPoint_getLayout(objectId, parameterBlock); break; + case ApiCallId::IEntryPoint_getSpecializationParamCount: + IEntryPoint_getSpecializationParamCount(objectId, parameterBlock); + break; + case ApiCallId::IEntryPoint_getEntryPointCode: + IEntryPoint_getEntryPointCode(objectId, parameterBlock); + break; + case ApiCallId::IEntryPoint_getTargetCode: + IEntryPoint_getTargetCode(objectId, parameterBlock); + break; + case ApiCallId::IEntryPoint_getResultAsFileSystem: + IEntryPoint_getResultAsFileSystem(objectId, parameterBlock); + break; + case ApiCallId::IEntryPoint_getEntryPointHash: + IEntryPoint_getEntryPointHash(objectId, parameterBlock); + break; + case ApiCallId::IEntryPoint_specialize: IEntryPoint_specialize(objectId, parameterBlock); break; + case ApiCallId::IEntryPoint_link: IEntryPoint_link(objectId, parameterBlock); break; + case ApiCallId::IEntryPoint_getEntryPointHostCallable: + IEntryPoint_getEntryPointHostCallable(objectId, parameterBlock); + break; + case ApiCallId::IEntryPoint_renameEntryPoint: + IEntryPoint_renameEntryPoint(objectId, parameterBlock); + break; + case ApiCallId::IEntryPoint_linkWithOptions: + IEntryPoint_linkWithOptions(objectId, parameterBlock); + break; + } + return true; +} - ObjectID outPreludeId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outPreludeId); +bool SlangDecoder::processICompositeComponentTypeMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + switch (callId) + { + default: slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); break; + case ApiCallId::ICompositeComponentType_getSession: + ICompositeComponentType_getSession(objectId, parameterBlock); + break; + case ApiCallId::ICompositeComponentType_getLayout: + ICompositeComponentType_getLayout(objectId, parameterBlock); + break; + case ApiCallId::ICompositeComponentType_getSpecializationParamCount: + ICompositeComponentType_getSpecializationParamCount(objectId, parameterBlock); + break; + case ApiCallId::ICompositeComponentType_getEntryPointCode: + ICompositeComponentType_getEntryPointCode(objectId, parameterBlock); + break; + case ApiCallId::ICompositeComponentType_getTargetCode: + ICompositeComponentType_getTargetCode(objectId, parameterBlock); + break; + case ApiCallId::ICompositeComponentType_getResultAsFileSystem: + ICompositeComponentType_getResultAsFileSystem(objectId, parameterBlock); + break; + case ApiCallId::ICompositeComponentType_getEntryPointHash: + ICompositeComponentType_getEntryPointHash(objectId, parameterBlock); + break; + case ApiCallId::ICompositeComponentType_specialize: + ICompositeComponentType_specialize(objectId, parameterBlock); + break; + case ApiCallId::ICompositeComponentType_link: + ICompositeComponentType_link(objectId, parameterBlock); + break; + case ApiCallId::ICompositeComponentType_getEntryPointHostCallable: + ICompositeComponentType_getEntryPointHostCallable(objectId, parameterBlock); + break; + case ApiCallId::ICompositeComponentType_renameEntryPoint: + ICompositeComponentType_renameEntryPoint(objectId, parameterBlock); + break; + case ApiCallId::ICompositeComponentType_linkWithOptions: + ICompositeComponentType_linkWithOptions(objectId, parameterBlock); + break; + } + return true; +} - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_getDownstreamCompilerPrelude(objectId, passThrough, outPreludeId); - } - } +bool SlangDecoder::processITypeConformanceMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + switch (callId) + { + default: + slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", callId); + return false; + case ApiCallId::ITypeConformance_getSession: + ITypeConformance_getSession(objectId, parameterBlock); + break; + case ApiCallId::ITypeConformance_getLayout: + ITypeConformance_getLayout(objectId, parameterBlock); + break; + case ApiCallId::ITypeConformance_getSpecializationParamCount: + ITypeConformance_getSpecializationParamCount(objectId, parameterBlock); + break; + case ApiCallId::ITypeConformance_getEntryPointCode: + ITypeConformance_getEntryPointCode(objectId, parameterBlock); + break; + case ApiCallId::ITypeConformance_getTargetCode: + ITypeConformance_getTargetCode(objectId, parameterBlock); + break; + case ApiCallId::ITypeConformance_getResultAsFileSystem: + ITypeConformance_getResultAsFileSystem(objectId, parameterBlock); + break; + case ApiCallId::ITypeConformance_getEntryPointHash: + ITypeConformance_getEntryPointHash(objectId, parameterBlock); + break; + case ApiCallId::ITypeConformance_specialize: + ITypeConformance_specialize(objectId, parameterBlock); + break; + case ApiCallId::ITypeConformance_link: ITypeConformance_link(objectId, parameterBlock); break; + case ApiCallId::ITypeConformance_getEntryPointHostCallable: + ITypeConformance_getEntryPointHostCallable(objectId, parameterBlock); + break; + case ApiCallId::ITypeConformance_renameEntryPoint: + ITypeConformance_renameEntryPoint(objectId, parameterBlock); + break; + case ApiCallId::ITypeConformance_linkWithOptions: + ITypeConformance_linkWithOptions(objectId, parameterBlock); + break; + } + return true; +} - void SlangDecoder::IGlobalSession_getBuildTagString(ObjectID objectId, ParameterBlock const& parameterBlock) +bool SlangDecoder::processFunctionCall( + FunctionHeader const& header, + ParameterBlock const& parameterBlock) +{ + switch (header.callId) { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); + default: + slangRecordLog(LogLevel::Error, "Unhandled Slang API call: %d\n", header.callId); + return false; + case ApiCallId::CreateGlobalSession: CreateGlobalSession(parameterBlock); break; } + return true; +} - void SlangDecoder::IGlobalSession_setDefaultDownstreamCompiler(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - SlangSourceLanguage sourceLanguage {}; - SlangPassThrough defaultCompiler {}; - readByte = ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, sourceLanguage); - readByte += ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, defaultCompiler); - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_setDefaultDownstreamCompiler(objectId, sourceLanguage, defaultCompiler); - } - } +bool SlangDecoder::CreateGlobalSession(ParameterBlock const& parameterBlock) +{ + ObjectID outGlobalSessionId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outGlobalSessionId); - void SlangDecoder::IGlobalSession_getDefaultDownstreamCompiler(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - SlangSourceLanguage sourceLanguage {}; - ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, sourceLanguage); - - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_getDefaultDownstreamCompiler(objectId, sourceLanguage); - } + consumer->CreateGlobalSession(outGlobalSessionId); } + return true; +} - void SlangDecoder::IGlobalSession_setLanguagePrelude(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - SlangSourceLanguage sourceLanguage {}; - StringDecoder prelude; - readByte = ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, sourceLanguage); - readByte += ParameterDecoder::decodeString(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, prelude); +bool SlangDecoder::IGlobalSession_createSession( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + StructDecoder<slang::SessionDesc> sessionDesc; + sessionDesc.decode(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize); - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_setLanguagePrelude(objectId, sourceLanguage, prelude.getPointer()); - } - } + ObjectID outSessionId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outSessionId); - void SlangDecoder::IGlobalSession_getLanguagePrelude(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - SlangSourceLanguage sourceLanguage {}; - ObjectID outPreludeId = 0; - ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, sourceLanguage); - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outPreludeId); - - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_getLanguagePrelude(objectId, sourceLanguage, outPreludeId); - } + consumer->IGlobalSession_createSession(objectId, sessionDesc.getValue(), outSessionId); } - void SlangDecoder::IGlobalSession_createCompileRequest(ObjectID objectId, ParameterBlock const& parameterBlock) - { - ObjectID outCompileRequestId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outCompileRequestId); + return true; +} - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_createCompileRequest(objectId, outCompileRequestId); - } - } +void SlangDecoder::IGlobalSession_findProfile( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + StringDecoder name; + ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + name); - void SlangDecoder::IGlobalSession_addBuiltins(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - size_t readBytes = 0; - StringDecoder sourcePath; - StringDecoder sourceString; - readBytes = ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, sourcePath); - readBytes += ParameterDecoder::decodeString(parameterBlock.parameterBuffer + readBytes, parameterBlock.parameterBufferSize - readBytes, sourceString); - - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_addBuiltins(objectId, sourcePath.getPointer(), sourceString.getPointer()); - } + consumer->IGlobalSession_findProfile(objectId, name.getPointer()); } +} - void SlangDecoder::IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ParameterBlock const& parameterBlock) - { - // TODO: Not sure if we need to record 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 record it there. - slangRecordLog(LogLevel::Error, "%s should not be called\n", __PRETTY_FUNCTION__); +void SlangDecoder::IGlobalSession_setDownstreamCompilerPath( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + SlangPassThrough passThrough{}; + readByte = ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + passThrough); + StringDecoder path; + readByte += ParameterDecoder::decodeString( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + path); + + for (auto consumer : m_consumers) + { + consumer->IGlobalSession_setDownstreamCompilerPath( + objectId, + passThrough, + path.getPointer()); } +} - void SlangDecoder::IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ParameterBlock const& parameterBlock) - { - ObjectID outLoaderId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outLoaderId); - - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_getSharedLibraryLoader(objectId, outLoaderId); - } +void SlangDecoder::IGlobalSession_setDownstreamCompilerPrelude( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + SlangPassThrough passThrough{}; + readByte = ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + passThrough); + StringDecoder prelude; + readByte += ParameterDecoder::decodeString( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + prelude); + + for (auto consumer : m_consumers) + { + consumer->IGlobalSession_setDownstreamCompilerPrelude( + objectId, + passThrough, + prelude.getPointer()); } +} - void SlangDecoder::IGlobalSession_checkCompileTargetSupport(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); - } +void SlangDecoder::IGlobalSession_getDownstreamCompilerPrelude( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + SlangPassThrough passThrough{}; + ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + passThrough); - void SlangDecoder::IGlobalSession_checkPassThroughSupport(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); - } + ObjectID outPreludeId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outPreludeId); - void SlangDecoder::IGlobalSession_compileCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - slang::CompileCoreModuleFlags flags {}; - ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, flags); - - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_compileCoreModule(objectId, flags); - } + consumer->IGlobalSession_getDownstreamCompilerPrelude(objectId, passThrough, outPreludeId); } +} - void SlangDecoder::IGlobalSession_loadCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock) - { - PointerDecoder<void*> coreModule; - ParameterDecoder::decodePointer(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, coreModule); +void SlangDecoder::IGlobalSession_getBuildTagString( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_loadCoreModule(objectId, coreModule.getPointer(), coreModule.getDataSize()); - } +void SlangDecoder::IGlobalSession_setDefaultDownstreamCompiler( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + SlangSourceLanguage sourceLanguage{}; + SlangPassThrough defaultCompiler{}; + readByte = ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + sourceLanguage); + readByte += ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + defaultCompiler); + + for (auto consumer : m_consumers) + { + consumer->IGlobalSession_setDefaultDownstreamCompiler( + objectId, + sourceLanguage, + defaultCompiler); } +} - void SlangDecoder::IGlobalSession_saveCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock) - { - SlangArchiveType archiveType {}; - ObjectID outBlobId = 0; - ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, archiveType); - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outBlobId); - - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_saveCoreModule(objectId, archiveType, outBlobId); - } - } +void SlangDecoder::IGlobalSession_getDefaultDownstreamCompiler( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + SlangSourceLanguage sourceLanguage{}; + ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + sourceLanguage); - void SlangDecoder::IGlobalSession_findCapability(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); + consumer->IGlobalSession_getDefaultDownstreamCompiler(objectId, sourceLanguage); } +} - void SlangDecoder::IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - SlangCompileTarget source {}; - SlangCompileTarget target {}; - SlangPassThrough compiler {}; - - readByte = ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, source); - readByte += ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, target); - readByte += ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, compiler); - - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_setDownstreamCompilerForTransition(objectId, source, target, compiler); - } +void SlangDecoder::IGlobalSession_setLanguagePrelude( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + SlangSourceLanguage sourceLanguage{}; + StringDecoder prelude; + readByte = ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + sourceLanguage); + readByte += ParameterDecoder::decodeString( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + prelude); + + for (auto consumer : m_consumers) + { + consumer->IGlobalSession_setLanguagePrelude(objectId, sourceLanguage, prelude.getPointer()); } +} - void SlangDecoder::IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); - } +void SlangDecoder::IGlobalSession_getLanguagePrelude( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + SlangSourceLanguage sourceLanguage{}; + ObjectID outPreludeId = 0; + ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + sourceLanguage); + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outPreludeId); - void SlangDecoder::IGlobalSession_getCompilerElapsedTime(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); + consumer->IGlobalSession_getLanguagePrelude(objectId, sourceLanguage, outPreludeId); } +} - void SlangDecoder::IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); - } +void SlangDecoder::IGlobalSession_createCompileRequest( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + ObjectID outCompileRequestId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outCompileRequestId); - void SlangDecoder::IGlobalSession_parseCommandLineArguments(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - int argc = 0; - size_t readByte = 0; - readByte = ParameterDecoder::decodeInt32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, argc); - std::vector<char*> argv; - - if (argc > 0) - { - uint32_t arrayCount = 0; - readByte += ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, arrayCount); - - SLANG_RECORD_ASSERT(arrayCount == (uint32_t)argc); - argv.resize(arrayCount); - - readByte += ParameterDecoder::decodeStringArray(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, argv.data(), arrayCount); - } - - ObjectID outSessionDescId = 0; - ObjectID outAllocationId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outSessionDescId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outAllocationId); - - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_parseCommandLineArguments(objectId, argc, argv.data(), outSessionDescId, outAllocationId); - } + consumer->IGlobalSession_createCompileRequest(objectId, outCompileRequestId); } +} - void SlangDecoder::IGlobalSession_getSessionDescDigest(ObjectID objectId, ParameterBlock const& parameterBlock) - { - StructDecoder<slang::SessionDesc> sessionDesc; - ObjectID outBlobId = 0; - size_t readByte = 0; - sessionDesc.decode(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize); - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outBlobId); - - for (auto consumer: m_consumers) - { - consumer->IGlobalSession_getSessionDescDigest(objectId, &sessionDesc.getValue(), outBlobId); - } +void SlangDecoder::IGlobalSession_addBuiltins( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readBytes = 0; + StringDecoder sourcePath; + StringDecoder sourceString; + readBytes = ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + sourcePath); + readBytes += ParameterDecoder::decodeString( + parameterBlock.parameterBuffer + readBytes, + parameterBlock.parameterBufferSize - readBytes, + sourceString); + + for (auto consumer : m_consumers) + { + consumer->IGlobalSession_addBuiltins( + objectId, + sourcePath.getPointer(), + sourceString.getPointer()); } +} +void SlangDecoder::IGlobalSession_setSharedLibraryLoader( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + // TODO: Not sure if we need to record 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 record it there. + slangRecordLog(LogLevel::Error, "%s should not be called\n", __PRETTY_FUNCTION__); +} - void SlangDecoder::ISession_getGlobalSession(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); - } +void SlangDecoder::IGlobalSession_getSharedLibraryLoader( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + ObjectID outLoaderId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outLoaderId); - void SlangDecoder::ISession_loadModule(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - size_t readByte = 0; - StringDecoder moduleName; - readByte += ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, moduleName); - - ObjectID outDiagnosticsId = 0; - ObjectID outModuleId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outDiagnosticsId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outModuleId); - - for (auto consumer: m_consumers) - { - consumer->ISession_loadModule(objectId, moduleName.getPointer(), outDiagnosticsId, outModuleId); - } + consumer->IGlobalSession_getSharedLibraryLoader(objectId, outLoaderId); } +} - void SlangDecoder::ISession_loadModuleFromIRBlob(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - StringDecoder moduleName; - StringDecoder path; - BlobDecoder source; - readByte = ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, moduleName); - readByte += ParameterDecoder::decodeString(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, path); - readByte += source.decode(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte); +void SlangDecoder::IGlobalSession_checkCompileTargetSupport( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - ObjectID outDiagnosticsId = 0; - ObjectID outModuleId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outDiagnosticsId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outModuleId); +void SlangDecoder::IGlobalSession_checkPassThroughSupport( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->ISession_loadModuleFromIRBlob(objectId, moduleName.getPointer(), path.getPointer(), source.getBlob(), outDiagnosticsId, outModuleId); - } - } +void SlangDecoder::IGlobalSession_compileCoreModule( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + slang::CompileCoreModuleFlags flags{}; + ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + flags); - void SlangDecoder::ISession_loadModuleFromSource(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - size_t readByte = 0; - StringDecoder moduleName; - StringDecoder path; - BlobDecoder source; - readByte = ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, moduleName); - readByte += ParameterDecoder::decodeString(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, path); - readByte += source.decode(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte); - - ObjectID outDiagnosticsId = 0; - ObjectID outModuleId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outDiagnosticsId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outModuleId); - - for (auto consumer: m_consumers) - { - consumer->ISession_loadModuleFromSource(objectId, moduleName.getPointer(), path.getPointer(), source.getBlob(), outDiagnosticsId, outModuleId); - } + consumer->IGlobalSession_compileCoreModule(objectId, flags); } +} - void SlangDecoder::ISession_loadModuleFromSourceString(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - StringDecoder moduleName; - StringDecoder path; - StringDecoder source; - readByte = ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, moduleName); - readByte += ParameterDecoder::decodeString(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, path); - readByte += ParameterDecoder::decodeString(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, source); - - ObjectID outDiagnosticsId = 0; - ObjectID outModuleId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outDiagnosticsId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outModuleId); - - for (auto consumer: m_consumers) - { - consumer->ISession_loadModuleFromSourceString(objectId, moduleName.getPointer(), path.getPointer(), source.getPointer(), outDiagnosticsId, outModuleId); - } - } +void SlangDecoder::IGlobalSession_loadCoreModule( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + PointerDecoder<void*> coreModule; + ParameterDecoder::decodePointer( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + coreModule); - void SlangDecoder::ISession_createCompositeComponentType(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - size_t readByte = 0; - std::vector<ObjectID> componentTypeIdList; - uint32_t arrayCount = 0; - readByte = ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, arrayCount); - - componentTypeIdList.resize(arrayCount); - readByte += ParameterDecoder::decodeAddressArray(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, componentTypeIdList.data(), arrayCount); - - ObjectID outCompositeComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outCompositeComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->ISession_createCompositeComponentType(objectId, componentTypeIdList.data(), componentTypeIdList.size(), outCompositeComponentTypeId, outDiagnosticsId); - } - + consumer->IGlobalSession_loadCoreModule( + objectId, + coreModule.getPointer(), + coreModule.getDataSize()); } +} - // TODO: See https://github.com/shader-slang/slang/issues/4624 for more details - void SlangDecoder::ISession_specializeType(ObjectID objectId, ParameterBlock const& parameterBlock) - { - slangRecordLog(LogLevel::Error, "%s: The shader reflection app is not recordd\n", __PRETTY_FUNCTION__); - - size_t readByte = 0; - ObjectID typeId = 0; - uint32_t arrayCount = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, typeId); - readByte += ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, arrayCount); - - std::vector<slang::SpecializationArg> specializationArgs; - specializationArgs.resize(arrayCount); - readByte += ParameterDecoder::decodeStructArray(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, specializationArgs.data(), arrayCount); - - ObjectID outDiagnosticsId = 0; - ObjectID outTypeReflectionId = 0; - - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize, outDiagnosticsId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outTypeReflectionId); - - for (auto consumer: m_consumers) - { - consumer->ISession_specializeType(objectId, typeId, specializationArgs.data(), specializationArgs.size(), outDiagnosticsId, outTypeReflectionId); - } - } +void SlangDecoder::IGlobalSession_saveCoreModule( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + SlangArchiveType archiveType{}; + ObjectID outBlobId = 0; + ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + archiveType); + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outBlobId); - void SlangDecoder::ISession_getTypeLayout(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - slangRecordLog(LogLevel::Error, "%s: The shader reflection app is not recordd\n", __PRETTY_FUNCTION__); - - size_t readByte = 0; - ObjectID typeId = 0; - int64_t targetIndex = 0; - slang::LayoutRules rules {}; - readByte = ParameterDecoder::decodeAddress(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, typeId); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - readByte += ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, rules); + consumer->IGlobalSession_saveCoreModule(objectId, archiveType, outBlobId); + } +} - ObjectID outDiagnosticsId = 0; - ObjectID outTypeLayoutReflectionId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize, outDiagnosticsId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outTypeLayoutReflectionId); +void SlangDecoder::IGlobalSession_findCapability( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->ISession_getTypeLayout(objectId, typeId, targetIndex, rules, outDiagnosticsId, outTypeLayoutReflectionId); - } +void SlangDecoder::IGlobalSession_setDownstreamCompilerForTransition( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + SlangCompileTarget source{}; + SlangCompileTarget target{}; + SlangPassThrough compiler{}; + + readByte = ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + source); + readByte += ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + target); + readByte += ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + compiler); + + for (auto consumer : m_consumers) + { + consumer + ->IGlobalSession_setDownstreamCompilerForTransition(objectId, source, target, compiler); } +} - void SlangDecoder::ISession_getContainerType(ObjectID objectId, ParameterBlock const& parameterBlock) - { - slangRecordLog(LogLevel::Error, "%s: The shader reflection app is not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::IGlobalSession_getDownstreamCompilerForTransition( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - size_t readByte = 0; - ObjectID elementType = 0; - slang::ContainerType containerType {}; - readByte = ParameterDecoder::decodeAddress(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, elementType); - readByte += ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, containerType); +void SlangDecoder::IGlobalSession_getCompilerElapsedTime( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - ObjectID outDiagnosticsId = 0; - ObjectID outTypeReflectionId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize, outDiagnosticsId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.parameterBufferSize - readByte, outTypeReflectionId); +void SlangDecoder::IGlobalSession_setSPIRVCoreGrammar( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->ISession_getContainerType(objectId, elementType, containerType, outDiagnosticsId, outTypeReflectionId); - } - } +void SlangDecoder::IGlobalSession_parseCommandLineArguments( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + int argc = 0; + size_t readByte = 0; + readByte = ParameterDecoder::decodeInt32( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + argc); + std::vector<char*> argv; - void SlangDecoder::ISession_getDynamicType(ObjectID objectId, ParameterBlock const& parameterBlock) + if (argc > 0) { - slangRecordLog(LogLevel::Error, "%s: The shader reflection app is not recordd\n", __PRETTY_FUNCTION__); - - ObjectID outTypeReflectionId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outTypeReflectionId); - - for (auto consumer: m_consumers) - { - consumer->ISession_getDynamicType(objectId, outTypeReflectionId); - } + uint32_t arrayCount = 0; + readByte += ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + arrayCount); + + SLANG_RECORD_ASSERT(arrayCount == (uint32_t)argc); + argv.resize(arrayCount); + + readByte += ParameterDecoder::decodeStringArray( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + argv.data(), + arrayCount); + } + + ObjectID outSessionDescId = 0; + ObjectID outAllocationId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outSessionDescId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outAllocationId); + + for (auto consumer : m_consumers) + { + consumer->IGlobalSession_parseCommandLineArguments( + objectId, + argc, + argv.data(), + outSessionDescId, + outAllocationId); } +} - void SlangDecoder::ISession_getTypeRTTIMangledName(ObjectID objectId, ParameterBlock const& parameterBlock) - { - slangRecordLog(LogLevel::Error, "%s: The shader reflection app is not recordd\n", __PRETTY_FUNCTION__); - - ObjectID typeId = 0; - ObjectID outNameBlobId = 0; - ParameterDecoder::decodeAddress(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, typeId); - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outNameBlobId); - - for (auto consumer: m_consumers) - { - consumer->ISession_getTypeRTTIMangledName(objectId, typeId, outNameBlobId); - } - } +void SlangDecoder::IGlobalSession_getSessionDescDigest( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + StructDecoder<slang::SessionDesc> sessionDesc; + ObjectID outBlobId = 0; + size_t readByte = 0; + sessionDesc.decode(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize); + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outBlobId); - void SlangDecoder::ISession_getTypeConformanceWitnessMangledName(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - slangRecordLog(LogLevel::Error, "%s: The shader reflection app is not recordd\n", __PRETTY_FUNCTION__); - - size_t readByte = 0; - ObjectID typeId = 0; - ObjectID interfaceTypeId = 0; - ObjectID outNameBlobId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, typeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, interfaceTypeId); - - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outNameBlobId); - - for (auto consumer: m_consumers) - { - consumer->ISession_getTypeConformanceWitnessMangledName(objectId, typeId, interfaceTypeId, outNameBlobId); - } + consumer->IGlobalSession_getSessionDescDigest(objectId, &sessionDesc.getValue(), outBlobId); } +} - void SlangDecoder::ISession_getTypeConformanceWitnessSequentialID(ObjectID objectId, ParameterBlock const& parameterBlock) - { - slangRecordLog(LogLevel::Error, "%s: The shader reflection app is not recordd\n", __PRETTY_FUNCTION__); - - size_t readByte = 0; - - ObjectID typeId = 0; - ObjectID interfaceTypeId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, typeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, interfaceTypeId); +void SlangDecoder::ISession_getGlobalSession( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - uint32_t outSequentialId = 0; - for (auto consumer: m_consumers) - { - consumer->ISession_getTypeConformanceWitnessSequentialID(objectId, typeId, interfaceTypeId, outSequentialId); - } +void SlangDecoder::ISession_loadModule(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + StringDecoder moduleName; + readByte += ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + moduleName); + + ObjectID outDiagnosticsId = 0; + ObjectID outModuleId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outModuleId); + + for (auto consumer : m_consumers) + { + consumer + ->ISession_loadModule(objectId, moduleName.getPointer(), outDiagnosticsId, outModuleId); } +} - void SlangDecoder::ISession_createTypeConformanceComponentType(ObjectID objectId, ParameterBlock const& parameterBlock) - { - slangRecordLog(LogLevel::Error, "%s: The shader reflection app is not recordd\n", __PRETTY_FUNCTION__); - - size_t readByte = 0; - ObjectID typeId = 0; - ObjectID interfaceTypeId = 0; - int64_t conformanceIdOverride = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, typeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, interfaceTypeId); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, conformanceIdOverride); - - ObjectID outDiagnosticsId = 0; - ObjectID outConformanceId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize, outConformanceId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->ISession_createTypeConformanceComponentType(objectId, typeId, interfaceTypeId, conformanceIdOverride, outConformanceId, outDiagnosticsId); - } +void SlangDecoder::ISession_loadModuleFromIRBlob( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + StringDecoder moduleName; + StringDecoder path; + BlobDecoder source; + readByte = ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + moduleName); + readByte += ParameterDecoder::decodeString( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + path); + readByte += source.decode( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte); + + ObjectID outDiagnosticsId = 0; + ObjectID outModuleId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outModuleId); + + for (auto consumer : m_consumers) + { + consumer->ISession_loadModuleFromIRBlob( + objectId, + moduleName.getPointer(), + path.getPointer(), + source.getBlob(), + outDiagnosticsId, + outModuleId); } +} - void SlangDecoder::ISession_createCompileRequest(ObjectID objectId, ParameterBlock const& parameterBlock) - { - ObjectID outCompileRequestId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outCompileRequestId); - - for (auto consumer: m_consumers) - { - consumer->ISession_createCompileRequest(objectId, outCompileRequestId); - } +void SlangDecoder::ISession_loadModuleFromSource( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + StringDecoder moduleName; + StringDecoder path; + BlobDecoder source; + readByte = ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + moduleName); + readByte += ParameterDecoder::decodeString( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + path); + readByte += source.decode( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte); + + ObjectID outDiagnosticsId = 0; + ObjectID outModuleId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outModuleId); + + for (auto consumer : m_consumers) + { + consumer->ISession_loadModuleFromSource( + objectId, + moduleName.getPointer(), + path.getPointer(), + source.getBlob(), + outDiagnosticsId, + outModuleId); } +} - void SlangDecoder::ISession_getLoadedModuleCount(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::ISession_loadModuleFromSourceString( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + StringDecoder moduleName; + StringDecoder path; + StringDecoder source; + readByte = ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + moduleName); + readByte += ParameterDecoder::decodeString( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + path); + readByte += ParameterDecoder::decodeString( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + source); + + ObjectID outDiagnosticsId = 0; + ObjectID outModuleId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outModuleId); + + for (auto consumer : m_consumers) + { + consumer->ISession_loadModuleFromSourceString( + objectId, + moduleName.getPointer(), + path.getPointer(), + source.getPointer(), + outDiagnosticsId, + outModuleId); } +} - void SlangDecoder::ISession_getLoadedModule(ObjectID objectId, ParameterBlock const& parameterBlock) - { - int64_t index = 0; - ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, index); - - ObjectID outModuleId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outModuleId); - - for (auto consumer: m_consumers) - { - consumer->ISession_getLoadedModule(objectId, index, outModuleId); - } +void SlangDecoder::ISession_createCompositeComponentType( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + std::vector<ObjectID> componentTypeIdList; + uint32_t arrayCount = 0; + readByte = ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + arrayCount); + + componentTypeIdList.resize(arrayCount); + readByte += ParameterDecoder::decodeAddressArray( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + componentTypeIdList.data(), + arrayCount); + + ObjectID outCompositeComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outCompositeComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ISession_createCompositeComponentType( + objectId, + componentTypeIdList.data(), + componentTypeIdList.size(), + outCompositeComponentTypeId, + outDiagnosticsId); } +} - void SlangDecoder::ISession_isBinaryModuleUpToDate(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +// TODO: See https://github.com/shader-slang/slang/issues/4624 for more details +void SlangDecoder::ISession_specializeType(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection app is not recordd\n", + __PRETTY_FUNCTION__); + + size_t readByte = 0; + ObjectID typeId = 0; + uint32_t arrayCount = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + typeId); + readByte += ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + arrayCount); + + std::vector<slang::SpecializationArg> specializationArgs; + specializationArgs.resize(arrayCount); + readByte += ParameterDecoder::decodeStructArray( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + specializationArgs.data(), + arrayCount); + + ObjectID outDiagnosticsId = 0; + ObjectID outTypeReflectionId = 0; + + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize, + outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outTypeReflectionId); + + for (auto consumer : m_consumers) + { + consumer->ISession_specializeType( + objectId, + typeId, + specializationArgs.data(), + specializationArgs.size(), + outDiagnosticsId, + outTypeReflectionId); } +} - - void SlangDecoder::IModule_findEntryPointByName(ObjectID objectId, ParameterBlock const& parameterBlock) - { - StringDecoder name; - ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, name); - - ObjectID outEntryPointId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outEntryPointId); - - for (auto consumer: m_consumers) - { - consumer->IModule_findEntryPointByName(objectId, name.getPointer(), outEntryPointId); - } +void SlangDecoder::ISession_getTypeLayout(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection app is not recordd\n", + __PRETTY_FUNCTION__); + + size_t readByte = 0; + ObjectID typeId = 0; + int64_t targetIndex = 0; + slang::LayoutRules rules{}; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + typeId); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + readByte += ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + rules); + + ObjectID outDiagnosticsId = 0; + ObjectID outTypeLayoutReflectionId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize, + outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outTypeLayoutReflectionId); + + for (auto consumer : m_consumers) + { + consumer->ISession_getTypeLayout( + objectId, + typeId, + targetIndex, + rules, + outDiagnosticsId, + outTypeLayoutReflectionId); } +} - void SlangDecoder::IModule_getDefinedEntryPointCount(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::ISession_getContainerType( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection app is not recordd\n", + __PRETTY_FUNCTION__); + + size_t readByte = 0; + ObjectID elementType = 0; + slang::ContainerType containerType{}; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + elementType); + readByte += ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + containerType); + + ObjectID outDiagnosticsId = 0; + ObjectID outTypeReflectionId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize, + outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + outTypeReflectionId); + + for (auto consumer : m_consumers) + { + consumer->ISession_getContainerType( + objectId, + elementType, + containerType, + outDiagnosticsId, + outTypeReflectionId); } +} - void SlangDecoder::IModule_getDefinedEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock) - { - int32_t index; - ObjectID outEntryPointId = 0; - ParameterDecoder::decodeInt32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, index); - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outEntryPointId); +void SlangDecoder::ISession_getDynamicType(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection app is not recordd\n", + __PRETTY_FUNCTION__); - for (auto consumer: m_consumers) - { - consumer->IModule_getDefinedEntryPoint(objectId, index, outEntryPointId); - } - } + ObjectID outTypeReflectionId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outTypeReflectionId); - void SlangDecoder::IModule_serialize(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - ObjectID outSerializedBlobId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outSerializedBlobId); - - for (auto consumer: m_consumers) - { - consumer->IModule_serialize(objectId, outSerializedBlobId); - } + consumer->ISession_getDynamicType(objectId, outTypeReflectionId); } +} - void SlangDecoder::IModule_writeToFile(ObjectID objectId, ParameterBlock const& parameterBlock) - { - StringDecoder fileName; - ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, fileName); - - for (auto consumer: m_consumers) - { - consumer->IModule_writeToFile(objectId, fileName.getPointer()); - } +void SlangDecoder::ISession_getTypeRTTIMangledName( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection app is not recordd\n", + __PRETTY_FUNCTION__); + + ObjectID typeId = 0; + ObjectID outNameBlobId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + typeId); + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outNameBlobId); + + for (auto consumer : m_consumers) + { + consumer->ISession_getTypeRTTIMangledName(objectId, typeId, outNameBlobId); } +} - void SlangDecoder::IModule_getName(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::ISession_getTypeConformanceWitnessMangledName( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection app is not recordd\n", + __PRETTY_FUNCTION__); + + size_t readByte = 0; + ObjectID typeId = 0; + ObjectID interfaceTypeId = 0; + ObjectID outNameBlobId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + typeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + interfaceTypeId); + + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outNameBlobId); + + for (auto consumer : m_consumers) + { + consumer->ISession_getTypeConformanceWitnessMangledName( + objectId, + typeId, + interfaceTypeId, + outNameBlobId); } +} - void SlangDecoder::IModule_getFilePath(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::ISession_getTypeConformanceWitnessSequentialID( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection app is not recordd\n", + __PRETTY_FUNCTION__); + + size_t readByte = 0; + + ObjectID typeId = 0; + ObjectID interfaceTypeId = 0; + + readByte = ParameterDecoder::decodeAddress( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + typeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + interfaceTypeId); + + uint32_t outSequentialId = 0; + for (auto consumer : m_consumers) + { + consumer->ISession_getTypeConformanceWitnessSequentialID( + objectId, + typeId, + interfaceTypeId, + outSequentialId); } +} - void SlangDecoder::IModule_getUniqueIdentity(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::ISession_createTypeConformanceComponentType( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection app is not recordd\n", + __PRETTY_FUNCTION__); + + size_t readByte = 0; + ObjectID typeId = 0; + ObjectID interfaceTypeId = 0; + int64_t conformanceIdOverride = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + typeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + interfaceTypeId); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + conformanceIdOverride); + + ObjectID outDiagnosticsId = 0; + ObjectID outConformanceId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize, + outConformanceId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ISession_createTypeConformanceComponentType( + objectId, + typeId, + interfaceTypeId, + conformanceIdOverride, + outConformanceId, + outDiagnosticsId); } +} - void SlangDecoder::IModule_findAndCheckEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock) - { - StringDecoder name; - SlangStage stage {}; - size_t readByte = 0; - readByte = ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, name); - readByte += ParameterDecoder::decodeEnumValue(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, stage); - - ObjectID outEntryPointId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outEntryPointId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->IModule_findAndCheckEntryPoint(objectId, name.getPointer(), stage, outEntryPointId, outDiagnosticsId); - } - } +void SlangDecoder::ISession_createCompileRequest( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + ObjectID outCompileRequestId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outCompileRequestId); - void SlangDecoder::IModule_getSession(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); + consumer->ISession_createCompileRequest(objectId, outCompileRequestId); } +} - void SlangDecoder::IModule_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock) - { - int64_t targetIndex = 0; - ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, targetIndex); - ObjectID outDiagnosticsId = 0; - ObjectID programLayoutId = 0; +void SlangDecoder::ISession_getLoadedModuleCount( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - size_t readByte = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outDiagnosticsId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, programLayoutId); +void SlangDecoder::ISession_getLoadedModule(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + int64_t index = 0; + ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + index); - for (auto consumer: m_consumers) - { - consumer->IModule_getLayout(objectId, targetIndex, outDiagnosticsId, programLayoutId); - } - } + ObjectID outModuleId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outModuleId); - void SlangDecoder::IModule_getSpecializationParamCount(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); + consumer->ISession_getLoadedModule(objectId, index, outModuleId); } +} - void SlangDecoder::IModule_getEntryPointCode(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outCodeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outCodeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); +void SlangDecoder::ISession_isBinaryModuleUpToDate( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->IModule_getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); - } - } - void SlangDecoder::IModule_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, targetIndex); +void SlangDecoder::IModule_findEntryPointByName( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + StringDecoder name; + ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + name); - ObjectID outCodeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outCodeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); + ObjectID outEntryPointId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outEntryPointId); - for (auto consumer: m_consumers) - { - consumer->IModule_getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); - } - } - - void SlangDecoder::IModule_getResultAsFileSystem(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outFileSystemId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outFileSystemId); - - for (auto consumer: m_consumers) - { - consumer->IModule_getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystemId); - } + consumer->IModule_findEntryPointByName(objectId, name.getPointer(), outEntryPointId); } +} - void SlangDecoder::IModule_getEntryPointHash(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); +void SlangDecoder::IModule_getDefinedEntryPointCount( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - ObjectID outBlobId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outBlobId); +void SlangDecoder::IModule_getDefinedEntryPoint( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + int32_t index; + ObjectID outEntryPointId = 0; + ParameterDecoder::decodeInt32( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + index); + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outEntryPointId); - for (auto consumer: m_consumers) - { - consumer->IModule_getEntryPointHash(objectId, entryPointIndex, targetIndex, outBlobId); - } + for (auto consumer : m_consumers) + { + consumer->IModule_getDefinedEntryPoint(objectId, index, outEntryPointId); } +} - void SlangDecoder::IModule_specialize(ObjectID objectId, ParameterBlock const& parameterBlock) - { - slangRecordLog(LogLevel::Error, "%s: The shader reflection interfaces are not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::IModule_serialize(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + ObjectID outSerializedBlobId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outSerializedBlobId); - size_t readByte = 0; - int64_t specializationArgCount = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); + for (auto consumer : m_consumers) + { + consumer->IModule_serialize(objectId, outSerializedBlobId); + } +} - std::vector<slang::SpecializationArg> specializationArgs; +void SlangDecoder::IModule_writeToFile(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + StringDecoder fileName; + ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + fileName); - uint32_t arraySize = 0; - readByte += ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, arraySize); + for (auto consumer : m_consumers) + { + consumer->IModule_writeToFile(objectId, fileName.getPointer()); + } +} - SLANG_RECORD_ASSERT(arraySize == specializationArgCount); +void SlangDecoder::IModule_getName(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - specializationArgs.resize(specializationArgCount); - readByte += ParameterDecoder::decodeStructArray(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, specializationArgs.data(), specializationArgCount); +void SlangDecoder::IModule_getFilePath(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - ObjectID outSpecializedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outSpecializedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); +void SlangDecoder::IModule_getUniqueIdentity( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->IModule_specialize(objectId, specializationArgs.data(), specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - } +void SlangDecoder::IModule_findAndCheckEntryPoint( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + StringDecoder name; + SlangStage stage{}; + size_t readByte = 0; + readByte = ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + name); + readByte += ParameterDecoder::decodeEnumValue( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + stage); + + ObjectID outEntryPointId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outEntryPointId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IModule_findAndCheckEntryPoint( + objectId, + name.getPointer(), + stage, + outEntryPointId, + outDiagnosticsId); } +} - void SlangDecoder::IModule_link(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - ObjectID outLinkedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outLinkedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); +void SlangDecoder::IModule_getSession(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->IModule_link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - } +void SlangDecoder::IModule_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + int64_t targetIndex = 0; + ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + targetIndex); + ObjectID outDiagnosticsId = 0; + ObjectID programLayoutId = 0; + + size_t readByte = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + programLayoutId); + + for (auto consumer : m_consumers) + { + consumer->IModule_getLayout(objectId, targetIndex, outDiagnosticsId, programLayoutId); } +} - void SlangDecoder::IModule_getEntryPointHostCallable(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int32_t entryPointIndex = 0; - int32_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt32(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outSharedLibraryId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outSharedLibraryId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); +void SlangDecoder::IModule_getSpecializationParamCount( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->IModule_getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibraryId, outDiagnosticsId); - } +void SlangDecoder::IModule_getEntryPointCode( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outCodeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outCodeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IModule_getEntryPointCode( + objectId, + entryPointIndex, + targetIndex, + outCodeId, + outDiagnosticsId); } +} - void SlangDecoder::IModule_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock) - { - StringDecoder newName; - ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, newName); - - ObjectID outEntryPointId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outEntryPointId); - - for (auto consumer: m_consumers) - { - consumer->IModule_renameEntryPoint(objectId, newName.getPointer(), outEntryPointId); - } +void SlangDecoder::IModule_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + targetIndex); + + ObjectID outCodeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outCodeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IModule_getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); } +} - void SlangDecoder::IModule_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - uint32_t compilerOptionEntryCount = 0; - readByte = ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, compilerOptionEntryCount); - - std::vector<slang::CompilerOptionEntry> compilerOptionEntries; - - uint32_t arrayCount = 0; - readByte += ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, arrayCount); - - SLANG_RECORD_ASSERT(arrayCount == compilerOptionEntryCount); - compilerOptionEntries.resize(compilerOptionEntryCount); - - readByte += ParameterDecoder::decodeStructArray(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, compilerOptionEntries.data(), compilerOptionEntryCount); - - ObjectID outLinkedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outLinkedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->IModule_linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries.data(), outDiagnosticsId); - } +void SlangDecoder::IModule_getResultAsFileSystem( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outFileSystemId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outFileSystemId); + + for (auto consumer : m_consumers) + { + consumer->IModule_getResultAsFileSystem( + objectId, + entryPointIndex, + targetIndex, + outFileSystemId); } +} - void SlangDecoder::IEntryPoint_getSession(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::IModule_getEntryPointHash( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outBlobId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outBlobId); + + for (auto consumer : m_consumers) + { + consumer->IModule_getEntryPointHash(objectId, entryPointIndex, targetIndex, outBlobId); } +} - void SlangDecoder::IEntryPoint_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock) - { - int64_t targetIndex = 0; - ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, targetIndex); - - ObjectID outDiagnosticsId = 0; - ObjectID programLayoutId = 0; - - size_t readByte = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outDiagnosticsId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, programLayoutId); - - for (auto consumer: m_consumers) - { - consumer->IEntryPoint_getLayout(objectId, targetIndex, outDiagnosticsId, programLayoutId); - } +void SlangDecoder::IModule_specialize(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection interfaces are not recordd\n", + __PRETTY_FUNCTION__); + + size_t readByte = 0; + int64_t specializationArgCount = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + specializationArgCount); + + std::vector<slang::SpecializationArg> specializationArgs; + + uint32_t arraySize = 0; + readByte += ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + arraySize); + + SLANG_RECORD_ASSERT(arraySize == specializationArgCount); + + specializationArgs.resize(specializationArgCount); + readByte += ParameterDecoder::decodeStructArray( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + specializationArgs.data(), + specializationArgCount); + + ObjectID outSpecializedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outSpecializedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IModule_specialize( + objectId, + specializationArgs.data(), + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); } +} - void SlangDecoder::IEntryPoint_getSpecializationParamCount(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::IModule_link(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + ObjectID outLinkedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outLinkedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IModule_link(objectId, outLinkedComponentTypeId, outDiagnosticsId); } +} - void SlangDecoder::IEntryPoint_getEntryPointCode(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outCodeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outCodeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->IEntryPoint_getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); - } +void SlangDecoder::IModule_getEntryPointHostCallable( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int32_t entryPointIndex = 0; + int32_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt32( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outSharedLibraryId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outSharedLibraryId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IModule_getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibraryId, + outDiagnosticsId); } +} - void SlangDecoder::IEntryPoint_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, targetIndex); - - ObjectID outCodeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outCodeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); +void SlangDecoder::IModule_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + StringDecoder newName; + ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + newName); - for (auto consumer: m_consumers) - { - consumer->IEntryPoint_getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); - } - } + ObjectID outEntryPointId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outEntryPointId); - void SlangDecoder::IEntryPoint_getResultAsFileSystem(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outFileSystemId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outFileSystemId); - - for (auto consumer: m_consumers) - { - consumer->IEntryPoint_getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystemId); - } + consumer->IModule_renameEntryPoint(objectId, newName.getPointer(), outEntryPointId); } +} - void SlangDecoder::IEntryPoint_getEntryPointHash(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outBlobId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outBlobId); - - for (auto consumer: m_consumers) - { - consumer->IEntryPoint_getEntryPointHash(objectId, entryPointIndex, targetIndex, outBlobId); - } +void SlangDecoder::IModule_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + uint32_t compilerOptionEntryCount = 0; + readByte = ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + compilerOptionEntryCount); + + std::vector<slang::CompilerOptionEntry> compilerOptionEntries; + + uint32_t arrayCount = 0; + readByte += ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + arrayCount); + + SLANG_RECORD_ASSERT(arrayCount == compilerOptionEntryCount); + compilerOptionEntries.resize(compilerOptionEntryCount); + + readByte += ParameterDecoder::decodeStructArray( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + compilerOptionEntries.data(), + compilerOptionEntryCount); + + ObjectID outLinkedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outLinkedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IModule_linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries.data(), + outDiagnosticsId); } +} - void SlangDecoder::IEntryPoint_specialize(ObjectID objectId, ParameterBlock const& parameterBlock) - { - slangRecordLog(LogLevel::Error, "%s: The shader reflection interfaces are not recordd\n", __PRETTY_FUNCTION__); - - size_t readByte = 0; - int64_t specializationArgCount = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); - - std::vector<slang::SpecializationArg> specializationArgs; - - uint32_t arraySize = 0; - readByte += ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, arraySize); - - SLANG_RECORD_ASSERT(arraySize == specializationArgCount); +void SlangDecoder::IEntryPoint_getSession(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - specializationArgs.resize(specializationArgCount); - readByte += ParameterDecoder::decodeStructArray(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, specializationArgs.data(), specializationArgCount); +void SlangDecoder::IEntryPoint_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + int64_t targetIndex = 0; + ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + targetIndex); - ObjectID outSpecializedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outSpecializedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); + ObjectID outDiagnosticsId = 0; + ObjectID programLayoutId = 0; - for (auto consumer: m_consumers) - { - consumer->IEntryPoint_specialize(objectId, specializationArgs.data(), specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - } - } + size_t readByte = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + programLayoutId); - void SlangDecoder::IEntryPoint_link(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - size_t readByte = 0; - ObjectID outLinkedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outLinkedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->IEntryPoint_link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - } + consumer->IEntryPoint_getLayout(objectId, targetIndex, outDiagnosticsId, programLayoutId); } +} - void SlangDecoder::IEntryPoint_getEntryPointHostCallable(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int32_t entryPointIndex = 0; - int32_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt32(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outSharedLibraryId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outSharedLibraryId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); +void SlangDecoder::IEntryPoint_getSpecializationParamCount( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->IEntryPoint_getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibraryId, outDiagnosticsId); - } +void SlangDecoder::IEntryPoint_getEntryPointCode( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outCodeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outCodeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IEntryPoint_getEntryPointCode( + objectId, + entryPointIndex, + targetIndex, + outCodeId, + outDiagnosticsId); } +} - void SlangDecoder::IEntryPoint_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock) - { - StringDecoder newName; - ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, newName); - - ObjectID outEntryPointId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outEntryPointId); - - for (auto consumer: m_consumers) - { - consumer->IEntryPoint_renameEntryPoint(objectId, newName.getPointer(), outEntryPointId); - } +void SlangDecoder::IEntryPoint_getTargetCode( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + targetIndex); + + ObjectID outCodeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outCodeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IEntryPoint_getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); } +} - void SlangDecoder::IEntryPoint_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - uint32_t compilerOptionEntryCount = 0; - readByte = ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, compilerOptionEntryCount); - - std::vector<slang::CompilerOptionEntry> compilerOptionEntries; - - uint32_t arrayCount = 0; - readByte += ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, arrayCount); - - SLANG_RECORD_ASSERT(arrayCount == compilerOptionEntryCount); - compilerOptionEntries.resize(compilerOptionEntryCount); - - readByte += ParameterDecoder::decodeStructArray(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, compilerOptionEntries.data(), compilerOptionEntryCount); - - ObjectID outLinkedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outLinkedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->IEntryPoint_linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries.data(), outDiagnosticsId); - } +void SlangDecoder::IEntryPoint_getResultAsFileSystem( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outFileSystemId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outFileSystemId); + + for (auto consumer : m_consumers) + { + consumer->IEntryPoint_getResultAsFileSystem( + objectId, + entryPointIndex, + targetIndex, + outFileSystemId); } +} - - void SlangDecoder::ICompositeComponentType_getSession(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::IEntryPoint_getEntryPointHash( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outBlobId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outBlobId); + + for (auto consumer : m_consumers) + { + consumer->IEntryPoint_getEntryPointHash(objectId, entryPointIndex, targetIndex, outBlobId); } +} - void SlangDecoder::ICompositeComponentType_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock) - { - int64_t targetIndex = 0; - ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, targetIndex); - ObjectID outDiagnosticsId = 0; - ObjectID programLayoutId = 0; - - size_t readByte = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outDiagnosticsId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, programLayoutId); - - for (auto consumer: m_consumers) - { - consumer->ICompositeComponentType_getLayout(objectId, targetIndex, outDiagnosticsId, programLayoutId); - } +void SlangDecoder::IEntryPoint_specialize(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection interfaces are not recordd\n", + __PRETTY_FUNCTION__); + + size_t readByte = 0; + int64_t specializationArgCount = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + specializationArgCount); + + std::vector<slang::SpecializationArg> specializationArgs; + + uint32_t arraySize = 0; + readByte += ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + arraySize); + + SLANG_RECORD_ASSERT(arraySize == specializationArgCount); + + specializationArgs.resize(specializationArgCount); + readByte += ParameterDecoder::decodeStructArray( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + specializationArgs.data(), + specializationArgCount); + + ObjectID outSpecializedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outSpecializedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IEntryPoint_specialize( + objectId, + specializationArgs.data(), + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); } +} - void SlangDecoder::ICompositeComponentType_getSpecializationParamCount(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::IEntryPoint_link(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + ObjectID outLinkedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outLinkedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IEntryPoint_link(objectId, outLinkedComponentTypeId, outDiagnosticsId); } +} - void SlangDecoder::ICompositeComponentType_getEntryPointCode(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outCodeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outCodeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->ICompositeComponentType_getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); - } +void SlangDecoder::IEntryPoint_getEntryPointHostCallable( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int32_t entryPointIndex = 0; + int32_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt32( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outSharedLibraryId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outSharedLibraryId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IEntryPoint_getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibraryId, + outDiagnosticsId); } +} - void SlangDecoder::ICompositeComponentType_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, targetIndex); - - ObjectID outCodeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outCodeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); +void SlangDecoder::IEntryPoint_renameEntryPoint( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + StringDecoder newName; + ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + newName); - for (auto consumer: m_consumers) - { - consumer->ICompositeComponentType_getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); - } - } + ObjectID outEntryPointId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outEntryPointId); - void SlangDecoder::ICompositeComponentType_getResultAsFileSystem(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outFileSystemId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outFileSystemId); - - for (auto consumer: m_consumers) - { - consumer->ICompositeComponentType_getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystemId); - } + consumer->IEntryPoint_renameEntryPoint(objectId, newName.getPointer(), outEntryPointId); } +} - void SlangDecoder::ICompositeComponentType_getEntryPointHash(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outBlobId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outBlobId); - - for (auto consumer: m_consumers) - { - consumer->ICompositeComponentType_getEntryPointHash(objectId, entryPointIndex, targetIndex, outBlobId); - } +void SlangDecoder::IEntryPoint_linkWithOptions( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + uint32_t compilerOptionEntryCount = 0; + readByte = ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + compilerOptionEntryCount); + + std::vector<slang::CompilerOptionEntry> compilerOptionEntries; + + uint32_t arrayCount = 0; + readByte += ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + arrayCount); + + SLANG_RECORD_ASSERT(arrayCount == compilerOptionEntryCount); + compilerOptionEntries.resize(compilerOptionEntryCount); + + readByte += ParameterDecoder::decodeStructArray( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + compilerOptionEntries.data(), + compilerOptionEntryCount); + + ObjectID outLinkedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outLinkedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IEntryPoint_linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries.data(), + outDiagnosticsId); } +} - void SlangDecoder::ICompositeComponentType_specialize(ObjectID objectId, ParameterBlock const& parameterBlock) - { - slangRecordLog(LogLevel::Error, "%s: The shader reflection interfaces are not recordd\n", __PRETTY_FUNCTION__); - - size_t readByte = 0; - int64_t specializationArgCount = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); - - std::vector<slang::SpecializationArg> specializationArgs; - - uint32_t arraySize = 0; - readByte += ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, arraySize); - - SLANG_RECORD_ASSERT(arraySize == specializationArgCount); - - specializationArgs.resize(specializationArgCount); - readByte += ParameterDecoder::decodeStructArray(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, specializationArgs.data(), specializationArgCount); - ObjectID outSpecializedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outSpecializedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); +void SlangDecoder::ICompositeComponentType_getSession( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->ICompositeComponentType_specialize(objectId, specializationArgs.data(), specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - } +void SlangDecoder::ICompositeComponentType_getLayout( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + int64_t targetIndex = 0; + ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + targetIndex); + ObjectID outDiagnosticsId = 0; + ObjectID programLayoutId = 0; + + size_t readByte = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + programLayoutId); + + for (auto consumer : m_consumers) + { + consumer->ICompositeComponentType_getLayout( + objectId, + targetIndex, + outDiagnosticsId, + programLayoutId); } +} - void SlangDecoder::ICompositeComponentType_link(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - ObjectID outLinkedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outLinkedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); +void SlangDecoder::ICompositeComponentType_getSpecializationParamCount( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->ICompositeComponentType_link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - } +void SlangDecoder::ICompositeComponentType_getEntryPointCode( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outCodeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outCodeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ICompositeComponentType_getEntryPointCode( + objectId, + entryPointIndex, + targetIndex, + outCodeId, + outDiagnosticsId); } +} - void SlangDecoder::ICompositeComponentType_getEntryPointHostCallable(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int32_t entryPointIndex = 0; - int32_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt32(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outSharedLibraryId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outSharedLibraryId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->ICompositeComponentType_getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibraryId, outDiagnosticsId); - } +void SlangDecoder::ICompositeComponentType_getTargetCode( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + targetIndex); + + ObjectID outCodeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outCodeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ICompositeComponentType_getTargetCode( + objectId, + targetIndex, + outCodeId, + outDiagnosticsId); } +} - void SlangDecoder::ICompositeComponentType_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock) - { - StringDecoder newName; - ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, newName); - - ObjectID outEntryPointId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outEntryPointId); - - for (auto consumer: m_consumers) - { - consumer->ICompositeComponentType_renameEntryPoint(objectId, newName.getPointer(), outEntryPointId); - } +void SlangDecoder::ICompositeComponentType_getResultAsFileSystem( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outFileSystemId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outFileSystemId); + + for (auto consumer : m_consumers) + { + consumer->ICompositeComponentType_getResultAsFileSystem( + objectId, + entryPointIndex, + targetIndex, + outFileSystemId); } +} - void SlangDecoder::ICompositeComponentType_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - uint32_t compilerOptionEntryCount = 0; - readByte = ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, compilerOptionEntryCount); - - std::vector<slang::CompilerOptionEntry> compilerOptionEntries; - - uint32_t arrayCount = 0; - readByte += ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, arrayCount); - - SLANG_RECORD_ASSERT(arrayCount == compilerOptionEntryCount); - compilerOptionEntries.resize(compilerOptionEntryCount); - - readByte += ParameterDecoder::decodeStructArray(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, compilerOptionEntries.data(), compilerOptionEntryCount); - - ObjectID outLinkedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outLinkedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->ICompositeComponentType_linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries.data(), outDiagnosticsId); - } +void SlangDecoder::ICompositeComponentType_getEntryPointHash( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outBlobId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outBlobId); + + for (auto consumer : m_consumers) + { + consumer->ICompositeComponentType_getEntryPointHash( + objectId, + entryPointIndex, + targetIndex, + outBlobId); } +} - - void SlangDecoder::ITypeConformance_getSession(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::ICompositeComponentType_specialize( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection interfaces are not recordd\n", + __PRETTY_FUNCTION__); + + size_t readByte = 0; + int64_t specializationArgCount = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + specializationArgCount); + + std::vector<slang::SpecializationArg> specializationArgs; + + uint32_t arraySize = 0; + readByte += ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + arraySize); + + SLANG_RECORD_ASSERT(arraySize == specializationArgCount); + + specializationArgs.resize(specializationArgCount); + readByte += ParameterDecoder::decodeStructArray( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + specializationArgs.data(), + specializationArgCount); + + ObjectID outSpecializedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outSpecializedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ICompositeComponentType_specialize( + objectId, + specializationArgs.data(), + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); } +} - void SlangDecoder::ITypeConformance_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock) - { - int64_t targetIndex = 0; - ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, targetIndex); - ObjectID outDiagnosticsId = 0; - ObjectID programLayoutId = 0; - - size_t readByte = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outDiagnosticsId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, programLayoutId); - - for (auto consumer: m_consumers) - { - consumer->ITypeConformance_getLayout(objectId, targetIndex, outDiagnosticsId, programLayoutId); - } +void SlangDecoder::ICompositeComponentType_link( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + ObjectID outLinkedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outLinkedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ICompositeComponentType_link( + objectId, + outLinkedComponentTypeId, + outDiagnosticsId); } +} - void SlangDecoder::ITypeConformance_getSpecializationParamCount(ObjectID objectId, ParameterBlock const& parameterBlock) - { - (void)objectId; - (void)parameterBlock; - slangRecordLog(LogLevel::Debug, "%s should not be called, it'a not recordd\n", __PRETTY_FUNCTION__); +void SlangDecoder::ICompositeComponentType_getEntryPointHostCallable( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int32_t entryPointIndex = 0; + int32_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt32( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outSharedLibraryId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outSharedLibraryId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ICompositeComponentType_getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibraryId, + outDiagnosticsId); } +} - void SlangDecoder::ITypeConformance_getEntryPointCode(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outCodeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outCodeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); +void SlangDecoder::ICompositeComponentType_renameEntryPoint( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + StringDecoder newName; + ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + newName); - for (auto consumer: m_consumers) - { - consumer->ITypeConformance_getEntryPointCode(objectId, entryPointIndex, targetIndex, outCodeId, outDiagnosticsId); - } - } + ObjectID outEntryPointId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outEntryPointId); - void SlangDecoder::ITypeConformance_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock) + for (auto consumer : m_consumers) { - size_t readByte = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, targetIndex); - - ObjectID outCodeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outCodeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.parameterBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->ITypeConformance_getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); - } + consumer->ICompositeComponentType_renameEntryPoint( + objectId, + newName.getPointer(), + outEntryPointId); } +} - void SlangDecoder::ITypeConformance_getResultAsFileSystem(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outFileSystemId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outFileSystemId); - - for (auto consumer: m_consumers) - { - consumer->ITypeConformance_getResultAsFileSystem(objectId, entryPointIndex, targetIndex, outFileSystemId); - } +void SlangDecoder::ICompositeComponentType_linkWithOptions( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + uint32_t compilerOptionEntryCount = 0; + readByte = ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + compilerOptionEntryCount); + + std::vector<slang::CompilerOptionEntry> compilerOptionEntries; + + uint32_t arrayCount = 0; + readByte += ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + arrayCount); + + SLANG_RECORD_ASSERT(arrayCount == compilerOptionEntryCount); + compilerOptionEntries.resize(compilerOptionEntryCount); + + readByte += ParameterDecoder::decodeStructArray( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + compilerOptionEntries.data(), + compilerOptionEntryCount); + + ObjectID outLinkedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outLinkedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ICompositeComponentType_linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries.data(), + outDiagnosticsId); } +} - void SlangDecoder::ITypeConformance_getEntryPointHash(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int64_t entryPointIndex = 0; - int64_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - ObjectID outBlobId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outBlobId); +void SlangDecoder::ITypeConformance_getSession( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->ITypeConformance_getEntryPointHash(objectId, entryPointIndex, targetIndex, outBlobId); - } +void SlangDecoder::ITypeConformance_getLayout( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + int64_t targetIndex = 0; + ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + targetIndex); + ObjectID outDiagnosticsId = 0; + ObjectID programLayoutId = 0; + + size_t readByte = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + programLayoutId); + + for (auto consumer : m_consumers) + { + consumer + ->ITypeConformance_getLayout(objectId, targetIndex, outDiagnosticsId, programLayoutId); } +} - void SlangDecoder::ITypeConformance_specialize(ObjectID objectId, ParameterBlock const& parameterBlock) - { - slangRecordLog(LogLevel::Error, "%s: The shader reflection interfaces are not recordd\n", __PRETTY_FUNCTION__); - - size_t readByte = 0; - int64_t specializationArgCount = 0; - readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); - - std::vector<slang::SpecializationArg> specializationArgs; - - uint32_t arraySize = 0; - readByte += ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, arraySize); - - SLANG_RECORD_ASSERT(arraySize == specializationArgCount); - - specializationArgs.resize(specializationArgCount); - readByte += ParameterDecoder::decodeStructArray(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, specializationArgs.data(), specializationArgCount); - - ObjectID outSpecializedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outSpecializedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); +void SlangDecoder::ITypeConformance_getSpecializationParamCount( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + (void)objectId; + (void)parameterBlock; + slangRecordLog( + LogLevel::Debug, + "%s should not be called, it'a not recordd\n", + __PRETTY_FUNCTION__); +} - for (auto consumer: m_consumers) - { - consumer->IModule_specialize(objectId, specializationArgs.data(), specializationArgCount, outSpecializedComponentTypeId, outDiagnosticsId); - } +void SlangDecoder::ITypeConformance_getEntryPointCode( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outCodeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outCodeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ITypeConformance_getEntryPointCode( + objectId, + entryPointIndex, + targetIndex, + outCodeId, + outDiagnosticsId); } +} - void SlangDecoder::ITypeConformance_link(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - ObjectID outLinkedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outLinkedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->ITypeConformance_link(objectId, outLinkedComponentTypeId, outDiagnosticsId); - } +void SlangDecoder::ITypeConformance_getTargetCode( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + targetIndex); + + ObjectID outCodeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outCodeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer + ->ITypeConformance_getTargetCode(objectId, targetIndex, outCodeId, outDiagnosticsId); } +} - void SlangDecoder::ITypeConformance_getEntryPointHostCallable(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - int32_t entryPointIndex = 0; - int32_t targetIndex = 0; - readByte = ParameterDecoder::decodeInt32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, entryPointIndex); - readByte += ParameterDecoder::decodeInt32(parameterBlock.parameterBuffer + readByte, parameterBlock.parameterBufferSize - readByte, targetIndex); - - ObjectID outSharedLibraryId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outSharedLibraryId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); - - for (auto consumer: m_consumers) - { - consumer->ITypeConformance_getEntryPointHostCallable(objectId, entryPointIndex, targetIndex, outSharedLibraryId, outDiagnosticsId); - } +void SlangDecoder::ITypeConformance_getResultAsFileSystem( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outFileSystemId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outFileSystemId); + + for (auto consumer : m_consumers) + { + consumer->ITypeConformance_getResultAsFileSystem( + objectId, + entryPointIndex, + targetIndex, + outFileSystemId); } +} - void SlangDecoder::ITypeConformance_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock) - { - StringDecoder newName; - ParameterDecoder::decodeString(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, newName); - - ObjectID outEntryPointId = 0; - ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outEntryPointId); - - for (auto consumer: m_consumers) - { - consumer->ITypeConformance_renameEntryPoint(objectId, newName.getPointer(), outEntryPointId); - } +void SlangDecoder::ITypeConformance_getEntryPointHash( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int64_t entryPointIndex = 0; + int64_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outBlobId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outBlobId); + + for (auto consumer : m_consumers) + { + consumer + ->ITypeConformance_getEntryPointHash(objectId, entryPointIndex, targetIndex, outBlobId); } +} - void SlangDecoder::ITypeConformance_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock) - { - size_t readByte = 0; - uint32_t compilerOptionEntryCount = 0; - readByte = ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, compilerOptionEntryCount); +void SlangDecoder::ITypeConformance_specialize( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + slangRecordLog( + LogLevel::Error, + "%s: The shader reflection interfaces are not recordd\n", + __PRETTY_FUNCTION__); + + size_t readByte = 0; + int64_t specializationArgCount = 0; + readByte = ParameterDecoder::decodeInt64( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + specializationArgCount); + + std::vector<slang::SpecializationArg> specializationArgs; + + uint32_t arraySize = 0; + readByte += ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + arraySize); + + SLANG_RECORD_ASSERT(arraySize == specializationArgCount); + + specializationArgs.resize(specializationArgCount); + readByte += ParameterDecoder::decodeStructArray( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + specializationArgs.data(), + specializationArgCount); + + ObjectID outSpecializedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outSpecializedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->IModule_specialize( + objectId, + specializationArgs.data(), + specializationArgCount, + outSpecializedComponentTypeId, + outDiagnosticsId); + } +} - std::vector<slang::CompilerOptionEntry> compilerOptionEntries; +void SlangDecoder::ITypeConformance_link(ObjectID objectId, ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + ObjectID outLinkedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outLinkedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ITypeConformance_link(objectId, outLinkedComponentTypeId, outDiagnosticsId); + } +} - uint32_t arrayCount = 0; - readByte += ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, arrayCount); +void SlangDecoder::ITypeConformance_getEntryPointHostCallable( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + int32_t entryPointIndex = 0; + int32_t targetIndex = 0; + readByte = ParameterDecoder::decodeInt32( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + entryPointIndex); + readByte += ParameterDecoder::decodeInt32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + targetIndex); + + ObjectID outSharedLibraryId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outSharedLibraryId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ITypeConformance_getEntryPointHostCallable( + objectId, + entryPointIndex, + targetIndex, + outSharedLibraryId, + outDiagnosticsId); + } +} - SLANG_RECORD_ASSERT(arrayCount == compilerOptionEntryCount); - compilerOptionEntries.resize(compilerOptionEntryCount); +void SlangDecoder::ITypeConformance_renameEntryPoint( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + StringDecoder newName; + ParameterDecoder::decodeString( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + newName); - readByte += ParameterDecoder::decodeStructArray(parameterBlock.parameterBuffer + readByte, - parameterBlock.parameterBufferSize - readByte, compilerOptionEntries.data(), compilerOptionEntryCount); + ObjectID outEntryPointId = 0; + ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outEntryPointId); - ObjectID outLinkedComponentTypeId = 0; - ObjectID outDiagnosticsId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer, parameterBlock.outputBufferSize, outLinkedComponentTypeId); - readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); + for (auto consumer : m_consumers) + { + consumer->ITypeConformance_renameEntryPoint( + objectId, + newName.getPointer(), + outEntryPointId); + } +} - for (auto consumer: m_consumers) - { - consumer->ITypeConformance_linkWithOptions(objectId, outLinkedComponentTypeId, compilerOptionEntryCount, compilerOptionEntries.data(), outDiagnosticsId); - } +void SlangDecoder::ITypeConformance_linkWithOptions( + ObjectID objectId, + ParameterBlock const& parameterBlock) +{ + size_t readByte = 0; + uint32_t compilerOptionEntryCount = 0; + readByte = ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer, + parameterBlock.parameterBufferSize, + compilerOptionEntryCount); + + std::vector<slang::CompilerOptionEntry> compilerOptionEntries; + + uint32_t arrayCount = 0; + readByte += ParameterDecoder::decodeUint32( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + arrayCount); + + SLANG_RECORD_ASSERT(arrayCount == compilerOptionEntryCount); + compilerOptionEntries.resize(compilerOptionEntryCount); + + readByte += ParameterDecoder::decodeStructArray( + parameterBlock.parameterBuffer + readByte, + parameterBlock.parameterBufferSize - readByte, + compilerOptionEntries.data(), + compilerOptionEntryCount); + + ObjectID outLinkedComponentTypeId = 0; + ObjectID outDiagnosticsId = 0; + readByte = ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer, + parameterBlock.outputBufferSize, + outLinkedComponentTypeId); + readByte += ParameterDecoder::decodeAddress( + parameterBlock.outputBuffer + readByte, + parameterBlock.outputBufferSize - readByte, + outDiagnosticsId); + + for (auto consumer : m_consumers) + { + consumer->ITypeConformance_linkWithOptions( + objectId, + outLinkedComponentTypeId, + compilerOptionEntryCount, + compilerOptionEntries.data(), + outDiagnosticsId); } } +} // namespace SlangRecord diff --git a/source/slang-record-replay/replay/slang-decoder.h b/source/slang-record-replay/replay/slang-decoder.h index 03af6d842..d6cd7c09e 100644 --- a/source/slang-record-replay/replay/slang-decoder.h +++ b/source/slang-record-replay/replay/slang-decoder.h @@ -1,156 +1,254 @@ #ifndef SLANG_DECODER_H #define SLANG_DECODER_H -#include <vector> -#include <unordered_map> +#include "../../core/slang-list.h" #include "../util/record-format.h" #include "decoder-consumer.h" -#include "../../core/slang-list.h" + +#include <unordered_map> +#include <vector> namespace SlangRecord { - class SlangDecoder { - public: - struct ParameterBlock - { - const uint8_t* parameterBuffer = nullptr; - int64_t parameterBufferSize = 0; - - const uint8_t* outputBuffer = nullptr; - int64_t outputBufferSize = 0; - }; - - struct OutputObject - { - ObjectID recorddObjectId; - }; - - SlangDecoder() {}; - ~SlangDecoder() {}; - - void addConsumer(IDecoderConsumer* consumer) { m_consumers.add(consumer); } - - bool processMethodCall(FunctionHeader const& header, ParameterBlock const& parameterBlock); - bool processFunctionCall(FunctionHeader const& header, ParameterBlock const& parameterBlock); - - bool processIGlobalSessionMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock); - bool processISessionMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock); - bool processIModuleMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock); - bool processIEntryPointMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock); - bool processICompositeComponentTypeMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock); - bool processITypeConformanceMethods(ApiCallId callId, ObjectID objectId, ParameterBlock const& parameterBlock); - - bool CreateGlobalSession(ParameterBlock const& parameterBlock); - bool IGlobalSession_createSession(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_findProfile(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_setDownstreamCompilerPath(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_setDownstreamCompilerPrelude(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_getDownstreamCompilerPrelude(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_getBuildTagString(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_setDefaultDownstreamCompiler(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_getDefaultDownstreamCompiler(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_setLanguagePrelude(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_getLanguagePrelude(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_createCompileRequest(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_addBuiltins(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_setSharedLibraryLoader(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_getSharedLibraryLoader(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_checkCompileTargetSupport(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_checkPassThroughSupport(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_compileCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_loadCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_saveCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_findCapability(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_setDownstreamCompilerForTransition(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_getDownstreamCompilerForTransition(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_getCompilerElapsedTime(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_setSPIRVCoreGrammar(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_parseCommandLineArguments(ObjectID objectId, ParameterBlock const& parameterBlock); - void IGlobalSession_getSessionDescDigest(ObjectID objectId, ParameterBlock const& parameterBlock); - - void ISession_getGlobalSession(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_loadModule(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_loadModuleFromBlob(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_loadModuleFromIRBlob(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_loadModuleFromSource(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_loadModuleFromSourceString(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_createCompositeComponentType(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_specializeType(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_getTypeLayout(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_getContainerType(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_getDynamicType(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_getTypeRTTIMangledName(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_getTypeConformanceWitnessMangledName(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_getTypeConformanceWitnessSequentialID(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_createTypeConformanceComponentType(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_createCompileRequest(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_getLoadedModuleCount(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_getLoadedModule(ObjectID objectId, ParameterBlock const& parameterBlock); - void ISession_isBinaryModuleUpToDate(ObjectID objectId, ParameterBlock const& parameterBlock); - - void IModule_findEntryPointByName(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getDefinedEntryPointCount(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getDefinedEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_serialize(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_writeToFile(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getName(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getFilePath(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getUniqueIdentity(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_findAndCheckEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getSession(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getSpecializationParamCount(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getEntryPointCode(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getResultAsFileSystem(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getEntryPointHash(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_specialize(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_link(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_getEntryPointHostCallable(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock); - void IModule_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock); - - void IEntryPoint_getSession(ObjectID objectId, ParameterBlock const& parameterBlock); - void IEntryPoint_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock); - void IEntryPoint_getSpecializationParamCount(ObjectID objectId, ParameterBlock const& parameterBlock); - void IEntryPoint_getEntryPointCode(ObjectID objectId, ParameterBlock const& parameterBlock); - void IEntryPoint_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock); - void IEntryPoint_getResultAsFileSystem(ObjectID objectId, ParameterBlock const& parameterBlock); - void IEntryPoint_getEntryPointHash(ObjectID objectId, ParameterBlock const& parameterBlock); - void IEntryPoint_specialize(ObjectID objectId, ParameterBlock const& parameterBlock); - void IEntryPoint_link(ObjectID objectId, ParameterBlock const& parameterBlock); - void IEntryPoint_getEntryPointHostCallable(ObjectID objectId, ParameterBlock const& parameterBlock); - void IEntryPoint_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock); - void IEntryPoint_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock); - - void ICompositeComponentType_getSession(ObjectID objectId, ParameterBlock const& parameterBlock); - void ICompositeComponentType_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock); - void ICompositeComponentType_getSpecializationParamCount(ObjectID objectId, ParameterBlock const& parameterBlock); - void ICompositeComponentType_getEntryPointCode(ObjectID objectId, ParameterBlock const& parameterBlock); - void ICompositeComponentType_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock); - void ICompositeComponentType_getResultAsFileSystem(ObjectID objectId, ParameterBlock const& parameterBlock); - void ICompositeComponentType_getEntryPointHash(ObjectID objectId, ParameterBlock const& parameterBlock); - void ICompositeComponentType_specialize(ObjectID objectId, ParameterBlock const& parameterBlock); - void ICompositeComponentType_link(ObjectID objectId, ParameterBlock const& parameterBlock); - void ICompositeComponentType_getEntryPointHostCallable(ObjectID objectId, ParameterBlock const& parameterBlock); - void ICompositeComponentType_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock); - void ICompositeComponentType_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock); - - void ITypeConformance_getSession(ObjectID objectId, ParameterBlock const& parameterBlock); - void ITypeConformance_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock); - void ITypeConformance_getSpecializationParamCount(ObjectID objectId, ParameterBlock const& parameterBlock); - void ITypeConformance_getEntryPointCode(ObjectID objectId, ParameterBlock const& parameterBlock); - void ITypeConformance_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock); - void ITypeConformance_getResultAsFileSystem(ObjectID objectId, ParameterBlock const& parameterBlock); - void ITypeConformance_getEntryPointHash(ObjectID objectId, ParameterBlock const& parameterBlock); - void ITypeConformance_specialize(ObjectID objectId, ParameterBlock const& parameterBlock); - void ITypeConformance_link(ObjectID objectId, ParameterBlock const& parameterBlock); - void ITypeConformance_getEntryPointHostCallable(ObjectID objectId, ParameterBlock const& parameterBlock); - void ITypeConformance_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock); - void ITypeConformance_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock); - - private: - Slang::List<IDecoderConsumer*> m_consumers; +class SlangDecoder +{ +public: + struct ParameterBlock + { + const uint8_t* parameterBuffer = nullptr; + int64_t parameterBufferSize = 0; + + const uint8_t* outputBuffer = nullptr; + int64_t outputBufferSize = 0; + }; + + struct OutputObject + { + ObjectID recorddObjectId; }; -} + + SlangDecoder(){}; + ~SlangDecoder(){}; + + void addConsumer(IDecoderConsumer* consumer) { m_consumers.add(consumer); } + + bool processMethodCall(FunctionHeader const& header, ParameterBlock const& parameterBlock); + bool processFunctionCall(FunctionHeader const& header, ParameterBlock const& parameterBlock); + + bool processIGlobalSessionMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock); + bool processISessionMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock); + bool processIModuleMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock); + bool processIEntryPointMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock); + bool processICompositeComponentTypeMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock); + bool processITypeConformanceMethods( + ApiCallId callId, + ObjectID objectId, + ParameterBlock const& parameterBlock); + + bool CreateGlobalSession(ParameterBlock const& parameterBlock); + bool IGlobalSession_createSession(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_findProfile(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_setDownstreamCompilerPath( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_setDownstreamCompilerPrelude( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_getDownstreamCompilerPrelude( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_getBuildTagString(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_setDefaultDownstreamCompiler( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_getDefaultDownstreamCompiler( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_setLanguagePrelude(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_getLanguagePrelude(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_createCompileRequest( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_addBuiltins(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_setSharedLibraryLoader( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_getSharedLibraryLoader( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_checkCompileTargetSupport( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_checkPassThroughSupport( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_compileCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_loadCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_saveCoreModule(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_findCapability(ObjectID objectId, ParameterBlock const& parameterBlock); + void IGlobalSession_setDownstreamCompilerForTransition( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_getDownstreamCompilerForTransition( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_getCompilerElapsedTime( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_setSPIRVCoreGrammar( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_parseCommandLineArguments( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IGlobalSession_getSessionDescDigest( + ObjectID objectId, + ParameterBlock const& parameterBlock); + + void ISession_getGlobalSession(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_loadModule(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_loadModuleFromBlob(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_loadModuleFromIRBlob(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_loadModuleFromSource(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_loadModuleFromSourceString( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ISession_createCompositeComponentType( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ISession_specializeType(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_getTypeLayout(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_getContainerType(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_getDynamicType(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_getTypeRTTIMangledName(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_getTypeConformanceWitnessMangledName( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ISession_getTypeConformanceWitnessSequentialID( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ISession_createTypeConformanceComponentType( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ISession_createCompileRequest(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_getLoadedModuleCount(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_getLoadedModule(ObjectID objectId, ParameterBlock const& parameterBlock); + void ISession_isBinaryModuleUpToDate(ObjectID objectId, ParameterBlock const& parameterBlock); + + void IModule_findEntryPointByName(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getDefinedEntryPointCount(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getDefinedEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_serialize(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_writeToFile(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getName(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getFilePath(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getUniqueIdentity(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_findAndCheckEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getSession(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getSpecializationParamCount( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IModule_getEntryPointCode(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getResultAsFileSystem(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getEntryPointHash(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_specialize(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_link(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_getEntryPointHostCallable(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock); + void IModule_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock); + + void IEntryPoint_getSession(ObjectID objectId, ParameterBlock const& parameterBlock); + void IEntryPoint_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock); + void IEntryPoint_getSpecializationParamCount( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IEntryPoint_getEntryPointCode(ObjectID objectId, ParameterBlock const& parameterBlock); + void IEntryPoint_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock); + void IEntryPoint_getResultAsFileSystem(ObjectID objectId, ParameterBlock const& parameterBlock); + void IEntryPoint_getEntryPointHash(ObjectID objectId, ParameterBlock const& parameterBlock); + void IEntryPoint_specialize(ObjectID objectId, ParameterBlock const& parameterBlock); + void IEntryPoint_link(ObjectID objectId, ParameterBlock const& parameterBlock); + void IEntryPoint_getEntryPointHostCallable( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void IEntryPoint_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock); + void IEntryPoint_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock); + + void ICompositeComponentType_getSession( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ICompositeComponentType_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock); + void ICompositeComponentType_getSpecializationParamCount( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ICompositeComponentType_getEntryPointCode( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ICompositeComponentType_getTargetCode( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ICompositeComponentType_getResultAsFileSystem( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ICompositeComponentType_getEntryPointHash( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ICompositeComponentType_specialize( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ICompositeComponentType_link(ObjectID objectId, ParameterBlock const& parameterBlock); + void ICompositeComponentType_getEntryPointHostCallable( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ICompositeComponentType_renameEntryPoint( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ICompositeComponentType_linkWithOptions( + ObjectID objectId, + ParameterBlock const& parameterBlock); + + void ITypeConformance_getSession(ObjectID objectId, ParameterBlock const& parameterBlock); + void ITypeConformance_getLayout(ObjectID objectId, ParameterBlock const& parameterBlock); + void ITypeConformance_getSpecializationParamCount( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ITypeConformance_getEntryPointCode( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ITypeConformance_getTargetCode(ObjectID objectId, ParameterBlock const& parameterBlock); + void ITypeConformance_getResultAsFileSystem( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ITypeConformance_getEntryPointHash( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ITypeConformance_specialize(ObjectID objectId, ParameterBlock const& parameterBlock); + void ITypeConformance_link(ObjectID objectId, ParameterBlock const& parameterBlock); + void ITypeConformance_getEntryPointHostCallable( + ObjectID objectId, + ParameterBlock const& parameterBlock); + void ITypeConformance_renameEntryPoint(ObjectID objectId, ParameterBlock const& parameterBlock); + void ITypeConformance_linkWithOptions(ObjectID objectId, ParameterBlock const& parameterBlock); + +private: + Slang::List<IDecoderConsumer*> m_consumers; +}; +} // namespace SlangRecord #endif // SLANG_DECODER_H diff --git a/source/slang-record-replay/util/emum-to-string.h b/source/slang-record-replay/util/emum-to-string.h index 3b275399c..60e5e2416 100644 --- a/source/slang-record-replay/util/emum-to-string.h +++ b/source/slang-record-replay/util/emum-to-string.h @@ -2,12 +2,13 @@ namespace SlangRecord { - static Slang::String SlangCompileTargetToString(const SlangCompileTarget target) - { -#define CASE(x) case x: return #x +static Slang::String SlangCompileTargetToString(const SlangCompileTarget target) +{ +#define CASE(x) \ + case x: return #x - switch(target) - { + switch (target) + { CASE(SLANG_TARGET_UNKNOWN); CASE(SLANG_GLSL); CASE(SLANG_GLSL_VULKAN_DEPRECATED); @@ -36,91 +37,82 @@ namespace SlangRecord CASE(SLANG_HOST_SHARED_LIBRARY); CASE(SLANG_WGSL); CASE(SLANG_TARGET_COUNT_OF); - default: - Slang::StringBuilder str; - str << "Unknown SlangCompileTarget: " << static_cast<uint32_t>(target); - return str.toString(); - } -#undef CASE + default: + Slang::StringBuilder str; + str << "Unknown SlangCompileTarget: " << static_cast<uint32_t>(target); + return str.toString(); } +#undef CASE +} - static Slang::String SlangProfileIDToString(const SlangProfileID profile) +static Slang::String SlangProfileIDToString(const SlangProfileID profile) +{ + switch (profile) { - switch(profile) - { - case SLANG_PROFILE_UNKNOWN: - return "SLANG_PROFILE_UNKNOWN"; - default: - Slang::StringBuilder str; - str << "Unknown SlangProfileID: " << static_cast<uint32_t>(profile); - return str.toString(); - } + case SLANG_PROFILE_UNKNOWN: return "SLANG_PROFILE_UNKNOWN"; + default: + Slang::StringBuilder str; + str << "Unknown SlangProfileID: " << static_cast<uint32_t>(profile); + return str.toString(); } +} - static Slang::String SlangTargetFlagsToString(const SlangTargetFlags flags) +static Slang::String SlangTargetFlagsToString(const SlangTargetFlags flags) +{ + switch (flags) { - switch(flags) - { - case SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES: - return "SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES"; - case SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM: - return "SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM"; - case SLANG_TARGET_FLAG_DUMP_IR: - return "SLANG_TARGET_FLAG_DUMP_IR"; - case SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY: - return "SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY"; - default: - Slang::StringBuilder str; - str << "Unknown SlangTargetFlags: " << static_cast<uint32_t>(flags); - return str.toString(); - } + case SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES: + return "SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES"; + case SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM: + return "SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM"; + case SLANG_TARGET_FLAG_DUMP_IR: return "SLANG_TARGET_FLAG_DUMP_IR"; + case SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY: + return "SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY"; + default: + Slang::StringBuilder str; + str << "Unknown SlangTargetFlags: " << static_cast<uint32_t>(flags); + return str.toString(); } +} - static Slang::String SlangFloatingPointModeToString(const SlangFloatingPointMode mode) +static Slang::String SlangFloatingPointModeToString(const SlangFloatingPointMode mode) +{ + switch (mode) { - switch(mode) - { - case SLANG_FLOATING_POINT_MODE_DEFAULT: - return "SLANG_FLOATING_POINT_MODE_DEFAULT"; - case SLANG_FLOATING_POINT_MODE_FAST: - return "SLANG_FLOATING_POINT_MODE_FAST"; - case SLANG_FLOATING_POINT_MODE_PRECISE: - return "SLANG_FLOATING_POINT_MODE_PRECISE"; - default: - Slang::StringBuilder str; - str << "Unknown SlangFloatingPointMode: " << static_cast<uint32_t>(mode); - return str.toString(); - } + case SLANG_FLOATING_POINT_MODE_DEFAULT: return "SLANG_FLOATING_POINT_MODE_DEFAULT"; + case SLANG_FLOATING_POINT_MODE_FAST: return "SLANG_FLOATING_POINT_MODE_FAST"; + case SLANG_FLOATING_POINT_MODE_PRECISE: return "SLANG_FLOATING_POINT_MODE_PRECISE"; + default: + Slang::StringBuilder str; + str << "Unknown SlangFloatingPointMode: " << static_cast<uint32_t>(mode); + return str.toString(); } +} - static Slang::String SlangLineDirectiveModeToString(const SlangLineDirectiveMode mode) +static Slang::String SlangLineDirectiveModeToString(const SlangLineDirectiveMode mode) +{ + switch (mode) { - switch(mode) - { - case SLANG_LINE_DIRECTIVE_MODE_DEFAULT: - return "SLANG_LINE_DIRECTIVE_MODE_DEFAULT"; - case SLANG_LINE_DIRECTIVE_MODE_NONE: - return "SLANG_LINE_DIRECTIVE_MODE_NONE"; - case SLANG_LINE_DIRECTIVE_MODE_STANDARD: - return "SLANG_LINE_DIRECTIVE_MODE_STANDARD"; - case SLANG_LINE_DIRECTIVE_MODE_GLSL: - return "SLANG_LINE_DIRECTIVE_MODE_GLSL"; - case SLANG_LINE_DIRECTIVE_MODE_SOURCE_MAP: - return "SLANG_LINE_DIRECTIVE_MODE_SOURCE_MAP"; - default: - Slang::StringBuilder str; - str << "Unknown SlangLineDirectiveMode: " << static_cast<uint32_t>(mode); - return str.toString(); - } + case SLANG_LINE_DIRECTIVE_MODE_DEFAULT: return "SLANG_LINE_DIRECTIVE_MODE_DEFAULT"; + case SLANG_LINE_DIRECTIVE_MODE_NONE: return "SLANG_LINE_DIRECTIVE_MODE_NONE"; + case SLANG_LINE_DIRECTIVE_MODE_STANDARD: return "SLANG_LINE_DIRECTIVE_MODE_STANDARD"; + case SLANG_LINE_DIRECTIVE_MODE_GLSL: return "SLANG_LINE_DIRECTIVE_MODE_GLSL"; + case SLANG_LINE_DIRECTIVE_MODE_SOURCE_MAP: return "SLANG_LINE_DIRECTIVE_MODE_SOURCE_MAP"; + default: + Slang::StringBuilder str; + str << "Unknown SlangLineDirectiveMode: " << static_cast<uint32_t>(mode); + return str.toString(); } +} - static Slang::String CompilerOptionNameToString(const slang::CompilerOptionName name) - { -#define CASE(x) case CompilerOptionName::x: return #x +static Slang::String CompilerOptionNameToString(const slang::CompilerOptionName name) +{ +#define CASE(x) \ + case CompilerOptionName::x: return #x - using namespace slang; - switch(name) - { + using namespace slang; + switch (name) + { CASE(MacroDefine); CASE(DepFile); CASE(EntryPointName); @@ -230,63 +222,62 @@ namespace SlangRecord CASE(GenerateWholeProgram); CASE(UseUpToDateBinaryModule); CASE(CountOf); - default: - Slang::StringBuilder str; - str << "Unknown CompilerOptionName: " << static_cast<uint32_t>(name); - return str.toString(); - } -#undef CASE + default: + Slang::StringBuilder str; + str << "Unknown CompilerOptionName: " << static_cast<uint32_t>(name); + return str.toString(); } +#undef CASE +} - static Slang::String CompilerOptionValueKindToString(const slang::CompilerOptionValueKind kind) +static Slang::String CompilerOptionValueKindToString(const slang::CompilerOptionValueKind kind) +{ + using namespace slang; + switch (kind) { - using namespace slang; - switch(kind) - { - case CompilerOptionValueKind::Int: - return "Int"; - case CompilerOptionValueKind::String: - return "String"; - default: - Slang::StringBuilder str; - str << "Unknown CompilerOptionValueKind: " << static_cast<uint32_t>(kind); - return str.toString(); - } + case CompilerOptionValueKind::Int: return "Int"; + case CompilerOptionValueKind::String: return "String"; + default: + Slang::StringBuilder str; + str << "Unknown CompilerOptionValueKind: " << static_cast<uint32_t>(kind); + return str.toString(); } +} - static Slang::String SessionFlagsToString(const slang::SessionFlags flags) +static Slang::String SessionFlagsToString(const slang::SessionFlags flags) +{ + using namespace slang; + switch (flags) { - using namespace slang; - switch(flags) - { - case kSessionFlags_None: return "kSessionFlags_None"; - default: - Slang::StringBuilder str; - str << "Unknown SessionFlags: " << static_cast<uint32_t>(flags); - return str.toString(); - } + case kSessionFlags_None: return "kSessionFlags_None"; + default: + Slang::StringBuilder str; + str << "Unknown SessionFlags: " << static_cast<uint32_t>(flags); + return str.toString(); } +} - static Slang::String SlangMatrixLayoutModeToString(const SlangMatrixLayoutMode mode) +static Slang::String SlangMatrixLayoutModeToString(const SlangMatrixLayoutMode mode) +{ + switch (mode) { - switch(mode) - { - case SLANG_MATRIX_LAYOUT_MODE_UNKNOWN: return "SLANG_MATRIX_LAYOUT_MODE_UNKNOWN"; - case SLANG_MATRIX_LAYOUT_ROW_MAJOR: return "SLANG_MATRIX_LAYOUT_ROW_MAJOR"; - case SLANG_MATRIX_LAYOUT_COLUMN_MAJOR: return "SLANG_MATRIX_LAYOUT_COLUMN_MAJOR"; - default: - Slang::StringBuilder str; - str << "Unknown SlangMatrixLayoutMode: " << static_cast<uint32_t>(mode); - return str.toString(); - } + case SLANG_MATRIX_LAYOUT_MODE_UNKNOWN: return "SLANG_MATRIX_LAYOUT_MODE_UNKNOWN"; + case SLANG_MATRIX_LAYOUT_ROW_MAJOR: return "SLANG_MATRIX_LAYOUT_ROW_MAJOR"; + case SLANG_MATRIX_LAYOUT_COLUMN_MAJOR: return "SLANG_MATRIX_LAYOUT_COLUMN_MAJOR"; + default: + Slang::StringBuilder str; + str << "Unknown SlangMatrixLayoutMode: " << static_cast<uint32_t>(mode); + return str.toString(); } +} - static Slang::String SlangPassThroughToString(const SlangPassThrough passThrough) - { -#define CASE(x) case x: return #x +static Slang::String SlangPassThroughToString(const SlangPassThrough passThrough) +{ +#define CASE(x) \ + case x: return #x - switch(passThrough) - { + switch (passThrough) + { CASE(SLANG_PASS_THROUGH_NONE); CASE(SLANG_PASS_THROUGH_FXC); CASE(SLANG_PASS_THROUGH_DXC); @@ -301,20 +292,21 @@ namespace SlangRecord CASE(SLANG_PASS_THROUGH_SPIRV_OPT); CASE(SLANG_PASS_THROUGH_METAL); CASE(SLANG_PASS_THROUGH_COUNT_OF); - default: - Slang::StringBuilder str; - str << "Unknown SlangPassThrough: " << static_cast<uint32_t>(passThrough); - return str.toString(); - } -#undef CASE + default: + Slang::StringBuilder str; + str << "Unknown SlangPassThrough: " << static_cast<uint32_t>(passThrough); + return str.toString(); } +#undef CASE +} - static Slang::String SlangSourceLanguageToString(const SlangSourceLanguage language) - { -#define CASE(x) case x: return #x +static Slang::String SlangSourceLanguageToString(const SlangSourceLanguage language) +{ +#define CASE(x) \ + case x: return #x - switch(language) - { + switch (language) + { CASE(SLANG_SOURCE_LANGUAGE_UNKNOWN); CASE(SLANG_SOURCE_LANGUAGE_SLANG); CASE(SLANG_SOURCE_LANGUAGE_HLSL); @@ -325,78 +317,80 @@ namespace SlangRecord CASE(SLANG_SOURCE_LANGUAGE_SPIRV); CASE(SLANG_SOURCE_LANGUAGE_METAL); CASE(SLANG_SOURCE_LANGUAGE_COUNT_OF); - default: - Slang::StringBuilder str; - str << "Unknown SlangSourceLanguage: " << static_cast<uint32_t>(language); - return str.toString(); - } + default: + Slang::StringBuilder str; + str << "Unknown SlangSourceLanguage: " << static_cast<uint32_t>(language); + return str.toString(); } +} - static Slang::String CompileCoreModuleFlagsToString(const slang::CompileCoreModuleFlags flags) +static Slang::String CompileCoreModuleFlagsToString(const slang::CompileCoreModuleFlags flags) +{ + using namespace slang; + switch (flags) { - using namespace slang; - switch(flags) - { - case CompileCoreModuleFlag::WriteDocumentation: return "WriteDocumentation"; - default: - Slang::StringBuilder str; - str << "Unknown CompileCoreModuleFlags: " << static_cast<uint32_t>(flags); - return str.toString(); - } + case CompileCoreModuleFlag::WriteDocumentation: return "WriteDocumentation"; + default: + Slang::StringBuilder str; + str << "Unknown CompileCoreModuleFlags: " << static_cast<uint32_t>(flags); + return str.toString(); } +} - static Slang::String SlangArchiveTypeToString(const SlangArchiveType type) +static Slang::String SlangArchiveTypeToString(const SlangArchiveType type) +{ +#define CASE(x) \ + case x: return #x + switch (type) { -#define CASE(x) case x: return #x - switch(type) - { - CASE(SLANG_ARCHIVE_TYPE_UNDEFINED); - CASE(SLANG_ARCHIVE_TYPE_ZIP); - CASE(SLANG_ARCHIVE_TYPE_RIFF); - CASE(SLANG_ARCHIVE_TYPE_RIFF_DEFLATE); - CASE(SLANG_ARCHIVE_TYPE_RIFF_LZ4); - CASE(SLANG_ARCHIVE_TYPE_COUNT_OF); - default: - Slang::StringBuilder str; - str << "Unknown SlangArchiveType: " << static_cast<uint32_t>(type); - return str.toString(); - } + CASE(SLANG_ARCHIVE_TYPE_UNDEFINED); + CASE(SLANG_ARCHIVE_TYPE_ZIP); + CASE(SLANG_ARCHIVE_TYPE_RIFF); + CASE(SLANG_ARCHIVE_TYPE_RIFF_DEFLATE); + CASE(SLANG_ARCHIVE_TYPE_RIFF_LZ4); + CASE(SLANG_ARCHIVE_TYPE_COUNT_OF); + default: + Slang::StringBuilder str; + str << "Unknown SlangArchiveType: " << static_cast<uint32_t>(type); + return str.toString(); } +} - static Slang::String SpecializationArgKindToString(const slang::SpecializationArg::Kind kind) +static Slang::String SpecializationArgKindToString(const slang::SpecializationArg::Kind kind) +{ + using namespace slang; + switch (kind) { - using namespace slang; - switch(kind) - { - case SpecializationArg::Kind::Unknown: return "Unknown"; - case SpecializationArg::Kind::Type: return "Type"; - default: - Slang::StringBuilder str; - str << "Unknown SpecializationArg::Kind: " << static_cast<uint32_t>(kind); - return str.toString(); - } + case SpecializationArg::Kind::Unknown: return "Unknown"; + case SpecializationArg::Kind::Type: return "Type"; + default: + Slang::StringBuilder str; + str << "Unknown SpecializationArg::Kind: " << static_cast<uint32_t>(kind); + return str.toString(); } +} - static Slang::String LayoutRulesToString(const slang::LayoutRules rules) +static Slang::String LayoutRulesToString(const slang::LayoutRules rules) +{ + using namespace slang; + switch (rules) { - using namespace slang; - switch(rules) - { - case LayoutRules::Default: return "Default"; - case LayoutRules::MetalArgumentBufferTier2: return "MetalArgumentBufferTier2"; - default: - Slang::StringBuilder str; - str << "Unknown LayoutRules: " << static_cast<uint32_t>(rules); - return str.toString(); - } + case LayoutRules::Default: return "Default"; + case LayoutRules::MetalArgumentBufferTier2: return "MetalArgumentBufferTier2"; + default: + Slang::StringBuilder str; + str << "Unknown LayoutRules: " << static_cast<uint32_t>(rules); + return str.toString(); } +} - static Slang::String SlangStageToString(const SlangStage stage) - { -#define CASE(x) case x: return #x +static Slang::String SlangStageToString(const SlangStage stage) +{ +#define CASE(x) \ + case x: return #x - switch(stage) - { + switch (stage) + { CASE(SLANG_STAGE_NONE); CASE(SLANG_STAGE_VERTEX); CASE(SLANG_STAGE_HULL); @@ -412,28 +406,28 @@ namespace SlangRecord CASE(SLANG_STAGE_CALLABLE); CASE(SLANG_STAGE_MESH); CASE(SLANG_STAGE_AMPLIFICATION); - default: - Slang::StringBuilder str; - str << "Unknown SlangStage: " << static_cast<uint32_t>(stage); - return str.toString(); - } -#undef CASE + default: + Slang::StringBuilder str; + str << "Unknown SlangStage: " << static_cast<uint32_t>(stage); + return str.toString(); } +#undef CASE +} - static Slang::String ContainerTypeToString(const slang::ContainerType type) +static Slang::String ContainerTypeToString(const slang::ContainerType type) +{ + using namespace slang; + switch (type) { - using namespace slang; - switch(type) - { - case ContainerType::None: return "None"; - case ContainerType::UnsizedArray: return "UnsizedArray"; - case ContainerType::StructuredBuffer: return "StructuredBuffer"; - case ContainerType::ConstantBuffer: return "ConstantBuffer"; - case ContainerType::ParameterBlock: return "ParameterBlock"; - default: - Slang::StringBuilder str; - str << "Unknown ContainerType: " << static_cast<uint32_t>(type); - return str.toString(); - } + case ContainerType::None: return "None"; + case ContainerType::UnsizedArray: return "UnsizedArray"; + case ContainerType::StructuredBuffer: return "StructuredBuffer"; + case ContainerType::ConstantBuffer: return "ConstantBuffer"; + case ContainerType::ParameterBlock: return "ParameterBlock"; + default: + Slang::StringBuilder str; + str << "Unknown ContainerType: " << static_cast<uint32_t>(type); + return str.toString(); } } +} // namespace SlangRecord diff --git a/source/slang-record-replay/util/record-format.h b/source/slang-record-replay/util/record-format.h index 7c53044d6..2620b49f9 100644 --- a/source/slang-record-replay/util/record-format.h +++ b/source/slang-record-replay/util/record-format.h @@ -5,188 +5,228 @@ namespace SlangRecord { - 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, - Unknown = 0xFFFF - }; - - // Store the pointer value in a 64-bit integer - typedef uint64_t AddressFormat; - - // Use the address directly to represent the slang object. - typedef AddressFormat ObjectID; - - constexpr uint64_t g_globalFunctionHandle = 0; - constexpr uint32_t MAGIC_HEADER = 0x44414548; - constexpr uint32_t MAGIC_TAILER = 0x4C494154; - - enum IComponentTypeMethodId : uint16_t - { - getSession = 0x000A, - getLayout = 0x000B, - getSpecializationParamCount = 0x000C, - getEntryPointCode = 0x000D, - getTargetCode = 0x000E, - getResultAsFileSystem = 0x000F, - getEntryPointHash = 0x0010, - specialize = 0x0011, - link = 0x0012, - getEntryPointHostCallable = 0x0013, - renameEntryPoint = 0x0014, - linkWithOptions = 0x0015, - }; - - enum ApiCallId : uint32_t - { - InvalidCallId = 0x00000000, - CreateGlobalSession = 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_compileCoreModule = makeApiCallId(Class_IGlobalSession, 0x0011), - IGlobalSession_loadCoreModule = makeApiCallId(Class_IGlobalSession, 0x0012), - IGlobalSession_saveCoreModule = 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_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, IComponentTypeMethodId::getSession), - IModule_getLayout = makeApiCallId(Class_IModule, IComponentTypeMethodId::getLayout), - IModule_getSpecializationParamCount = makeApiCallId(Class_IModule, IComponentTypeMethodId::getSpecializationParamCount), - IModule_getEntryPointCode = makeApiCallId(Class_IModule, IComponentTypeMethodId::getEntryPointCode), - IModule_getTargetCode = makeApiCallId(Class_IModule, IComponentTypeMethodId::getTargetCode), - IModule_getResultAsFileSystem = makeApiCallId(Class_IModule, IComponentTypeMethodId::getResultAsFileSystem), - IModule_getEntryPointHash = makeApiCallId(Class_IModule, IComponentTypeMethodId::getEntryPointHash), - IModule_specialize = makeApiCallId(Class_IModule, IComponentTypeMethodId::specialize), - IModule_link = makeApiCallId(Class_IModule, IComponentTypeMethodId::link), - IModule_getEntryPointHostCallable = makeApiCallId(Class_IModule, IComponentTypeMethodId::getEntryPointHostCallable), - IModule_renameEntryPoint = makeApiCallId(Class_IModule, IComponentTypeMethodId::renameEntryPoint), - IModule_linkWithOptions = makeApiCallId(Class_IModule, IComponentTypeMethodId::linkWithOptions), - - - IEntryPoint_getSession = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getSession), - IEntryPoint_getLayout = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getLayout), - IEntryPoint_getSpecializationParamCount = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getSpecializationParamCount), - IEntryPoint_getEntryPointCode = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getEntryPointCode), - IEntryPoint_getTargetCode = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getTargetCode), - IEntryPoint_getResultAsFileSystem = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getResultAsFileSystem), - IEntryPoint_getEntryPointHash = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getEntryPointHash), - IEntryPoint_specialize = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::specialize), - IEntryPoint_link = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::link), - IEntryPoint_getEntryPointHostCallable = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getEntryPointHostCallable), - IEntryPoint_renameEntryPoint = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::renameEntryPoint), - IEntryPoint_linkWithOptions = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::linkWithOptions), - - ICompositeComponentType_getSession = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getSession), - ICompositeComponentType_getLayout = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getLayout), - ICompositeComponentType_getSpecializationParamCount = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getSpecializationParamCount), - ICompositeComponentType_getEntryPointCode = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getEntryPointCode), - ICompositeComponentType_getTargetCode = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getTargetCode), - ICompositeComponentType_getResultAsFileSystem = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getResultAsFileSystem), - ICompositeComponentType_getEntryPointHash = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getEntryPointHash), - ICompositeComponentType_specialize = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::specialize), - ICompositeComponentType_link = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::link), - ICompositeComponentType_getEntryPointHostCallable = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getEntryPointHostCallable), - ICompositeComponentType_renameEntryPoint = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::renameEntryPoint), - ICompositeComponentType_linkWithOptions = makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::linkWithOptions), - - ITypeConformance_getSession = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getSession), - ITypeConformance_getLayout = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getLayout), - ITypeConformance_getSpecializationParamCount = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getSpecializationParamCount), - ITypeConformance_getEntryPointCode = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getEntryPointCode), - ITypeConformance_getTargetCode = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getTargetCode), - ITypeConformance_getResultAsFileSystem = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getResultAsFileSystem), - ITypeConformance_getEntryPointHash = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getEntryPointHash), - ITypeConformance_specialize = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::specialize), - ITypeConformance_link = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::link), - ITypeConformance_getEntryPointHostCallable = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getEntryPointHostCallable), - ITypeConformance_renameEntryPoint = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::renameEntryPoint), - ITypeConformance_linkWithOptions = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::linkWithOptions), - }; - - struct FunctionHeader - { - uint32_t magic {MAGIC_HEADER}; - ApiCallId callId {InvalidCallId}; - ObjectID handleId {0}; - uint64_t dataSizeInBytes {0}; - uint64_t threadId {0}; - }; - - struct FunctionTailer - { - uint32_t magic {MAGIC_TAILER}; - uint32_t dataSizeInBytes {0}; - }; +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, + Unknown = 0xFFFF +}; + +// Store the pointer value in a 64-bit integer +typedef uint64_t AddressFormat; + +// Use the address directly to represent the slang object. +typedef AddressFormat ObjectID; + +constexpr uint64_t g_globalFunctionHandle = 0; +constexpr uint32_t MAGIC_HEADER = 0x44414548; +constexpr uint32_t MAGIC_TAILER = 0x4C494154; + +enum IComponentTypeMethodId : uint16_t +{ + getSession = 0x000A, + getLayout = 0x000B, + getSpecializationParamCount = 0x000C, + getEntryPointCode = 0x000D, + getTargetCode = 0x000E, + getResultAsFileSystem = 0x000F, + getEntryPointHash = 0x0010, + specialize = 0x0011, + link = 0x0012, + getEntryPointHostCallable = 0x0013, + renameEntryPoint = 0x0014, + linkWithOptions = 0x0015, +}; + +enum ApiCallId : uint32_t +{ + InvalidCallId = 0x00000000, + CreateGlobalSession = 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_compileCoreModule = makeApiCallId(Class_IGlobalSession, 0x0011), + IGlobalSession_loadCoreModule = makeApiCallId(Class_IGlobalSession, 0x0012), + IGlobalSession_saveCoreModule = 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_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, IComponentTypeMethodId::getSession), + IModule_getLayout = makeApiCallId(Class_IModule, IComponentTypeMethodId::getLayout), + IModule_getSpecializationParamCount = + makeApiCallId(Class_IModule, IComponentTypeMethodId::getSpecializationParamCount), + IModule_getEntryPointCode = + makeApiCallId(Class_IModule, IComponentTypeMethodId::getEntryPointCode), + IModule_getTargetCode = makeApiCallId(Class_IModule, IComponentTypeMethodId::getTargetCode), + IModule_getResultAsFileSystem = + makeApiCallId(Class_IModule, IComponentTypeMethodId::getResultAsFileSystem), + IModule_getEntryPointHash = + makeApiCallId(Class_IModule, IComponentTypeMethodId::getEntryPointHash), + IModule_specialize = makeApiCallId(Class_IModule, IComponentTypeMethodId::specialize), + IModule_link = makeApiCallId(Class_IModule, IComponentTypeMethodId::link), + IModule_getEntryPointHostCallable = + makeApiCallId(Class_IModule, IComponentTypeMethodId::getEntryPointHostCallable), + IModule_renameEntryPoint = + makeApiCallId(Class_IModule, IComponentTypeMethodId::renameEntryPoint), + IModule_linkWithOptions = makeApiCallId(Class_IModule, IComponentTypeMethodId::linkWithOptions), + + + IEntryPoint_getSession = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getSession), + IEntryPoint_getLayout = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getLayout), + IEntryPoint_getSpecializationParamCount = + makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getSpecializationParamCount), + IEntryPoint_getEntryPointCode = + makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getEntryPointCode), + IEntryPoint_getTargetCode = + makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getTargetCode), + IEntryPoint_getResultAsFileSystem = + makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getResultAsFileSystem), + IEntryPoint_getEntryPointHash = + makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getEntryPointHash), + IEntryPoint_specialize = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::specialize), + IEntryPoint_link = makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::link), + IEntryPoint_getEntryPointHostCallable = + makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::getEntryPointHostCallable), + IEntryPoint_renameEntryPoint = + makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::renameEntryPoint), + IEntryPoint_linkWithOptions = + makeApiCallId(Class_IEntryPoint, IComponentTypeMethodId::linkWithOptions), + + ICompositeComponentType_getSession = + makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getSession), + ICompositeComponentType_getLayout = + makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getLayout), + ICompositeComponentType_getSpecializationParamCount = makeApiCallId( + Class_ICompositeComponentType, + IComponentTypeMethodId::getSpecializationParamCount), + ICompositeComponentType_getEntryPointCode = + makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getEntryPointCode), + ICompositeComponentType_getTargetCode = + makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getTargetCode), + ICompositeComponentType_getResultAsFileSystem = + makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getResultAsFileSystem), + ICompositeComponentType_getEntryPointHash = + makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::getEntryPointHash), + ICompositeComponentType_specialize = + makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::specialize), + ICompositeComponentType_link = + makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::link), + ICompositeComponentType_getEntryPointHostCallable = makeApiCallId( + Class_ICompositeComponentType, + IComponentTypeMethodId::getEntryPointHostCallable), + ICompositeComponentType_renameEntryPoint = + makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::renameEntryPoint), + ICompositeComponentType_linkWithOptions = + makeApiCallId(Class_ICompositeComponentType, IComponentTypeMethodId::linkWithOptions), + + ITypeConformance_getSession = + makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getSession), + ITypeConformance_getLayout = + makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getLayout), + ITypeConformance_getSpecializationParamCount = + makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getSpecializationParamCount), + ITypeConformance_getEntryPointCode = + makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getEntryPointCode), + ITypeConformance_getTargetCode = + makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getTargetCode), + ITypeConformance_getResultAsFileSystem = + makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getResultAsFileSystem), + ITypeConformance_getEntryPointHash = + makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getEntryPointHash), + ITypeConformance_specialize = + makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::specialize), + ITypeConformance_link = makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::link), + ITypeConformance_getEntryPointHostCallable = + makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::getEntryPointHostCallable), + ITypeConformance_renameEntryPoint = + makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::renameEntryPoint), + ITypeConformance_linkWithOptions = + makeApiCallId(Class_ITypeConformance, IComponentTypeMethodId::linkWithOptions), +}; + +struct FunctionHeader +{ + uint32_t magic{MAGIC_HEADER}; + ApiCallId callId{InvalidCallId}; + ObjectID handleId{0}; + uint64_t dataSizeInBytes{0}; + uint64_t threadId{0}; +}; + +struct FunctionTailer +{ + uint32_t magic{MAGIC_TAILER}; + uint32_t dataSizeInBytes{0}; +}; + +} // namespace SlangRecord #endif diff --git a/source/slang-record-replay/util/record-utility.cpp b/source/slang-record-replay/util/record-utility.cpp index 8e3486ca5..e30e537c8 100644 --- a/source/slang-record-replay/util/record-utility.cpp +++ b/source/slang-record-replay/util/record-utility.cpp @@ -1,83 +1,84 @@ -#include <string.h> -#include <stdlib.h> -#include <stdarg.h> -#include <mutex> - #include "record-utility.h" -#include "../../core/slang-string.h" + #include "../../core/slang-string-util.h" +#include "../../core/slang-string.h" + +#include <mutex> +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> constexpr const char* kRecordLayerEnvVar = "SLANG_RECORD_LAYER"; constexpr const char* kRecordLayerLogLevel = "SLANG_RECORD_LOG_LEVEL"; namespace SlangRecord { - static thread_local unsigned int g_logLevel = LogLevel::Silent; +static thread_local unsigned int g_logLevel = LogLevel::Silent; - static bool getEnvironmentVariable(const char* name, Slang::String& out) - { +static bool getEnvironmentVariable(const char* name, Slang::String& out) +{ #ifdef _WIN32 - char* envVar = nullptr; - size_t sz = 0; - if (_dupenv_s(&envVar, &sz, name) == 0 && envVar != nullptr) - { - out = envVar; - free(envVar); - } + 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.getLength() > 0; + if (const char* envVar = std::getenv(name)) + { + out = envVar; } +#endif + return out.getLength() > 0; +} - bool isRecordLayerEnabled() +bool isRecordLayerEnabled() +{ + Slang::String envVarStr; + if (getEnvironmentVariable(kRecordLayerEnvVar, envVarStr)) { - Slang::String envVarStr; - if(getEnvironmentVariable(kRecordLayerEnvVar, envVarStr)) + if (envVarStr == "1") { - if (envVarStr == "1") - { - return true; - } + return true; } - return false; } + return false; +} - void setLogLevel() +void setLogLevel() +{ + // We only want to set the log level once + if (g_logLevel != LogLevel::Silent) { - // We only want to set the log level once - if (g_logLevel != LogLevel::Silent) - { - return; - } + return; + } - Slang::String envVarStr; - if (getEnvironmentVariable(kRecordLayerLogLevel, envVarStr)) - { - unsigned int logLevel = Slang::stringToUInt(envVarStr); - g_logLevel = std::min((unsigned int)(LogLevel::Verbose), logLevel); - return; - } + Slang::String envVarStr; + if (getEnvironmentVariable(kRecordLayerLogLevel, envVarStr)) + { + unsigned int logLevel = Slang::stringToUInt(envVarStr); + g_logLevel = std::min((unsigned int)(LogLevel::Verbose), logLevel); + return; } +} - void slangRecordLog(LogLevel logLevel, const char* fmt, ...) +void slangRecordLog(LogLevel logLevel, const char* fmt, ...) +{ + if (logLevel > g_logLevel) { - if (logLevel > g_logLevel) - { - return; - } + return; + } - Slang::StringBuilder builder; + Slang::StringBuilder builder; - va_list args; - va_start(args, fmt); - Slang::StringUtil::append(fmt, args, builder); - va_end(args); + va_list args; + va_start(args, fmt); + Slang::StringUtil::append(fmt, args, builder); + va_end(args); - fprintf(stdout, "[slang-record-replay]: %s", builder.begin()); - } + fprintf(stdout, "[slang-record-replay]: %s", builder.begin()); } +} // namespace SlangRecord diff --git a/source/slang-record-replay/util/record-utility.h b/source/slang-record-replay/util/record-utility.h index 33156a1f6..ad31ae2de 100644 --- a/source/slang-record-replay/util/record-utility.h +++ b/source/slang-record-replay/util/record-utility.h @@ -9,29 +9,37 @@ namespace SlangRecord { - enum LogLevel: unsigned int - { - Silent = 0, - Error = 1, - Debug = 2, - Verbose = 3, - }; +enum LogLevel : unsigned int +{ + Silent = 0, + Error = 1, + Debug = 2, + Verbose = 3, +}; - bool isRecordLayerEnabled(); - void slangRecordLog(LogLevel logLevel, const char* fmt, ...); - void setLogLevel(); -} +bool isRecordLayerEnabled(); +void slangRecordLog(LogLevel logLevel, const char* fmt, ...); +void setLogLevel(); +} // namespace SlangRecord -#define SLANG_RECORD_ASSERT(VALUE) \ - do { \ - if (!(VALUE)) { \ - SlangRecord::slangRecordLog(SlangRecord::LogLevel::Error, "Assertion failed: %s, %s, %d\n", #VALUE, __FILE__, __LINE__);\ - std::abort(); \ - } \ - } while(0) +#define SLANG_RECORD_ASSERT(VALUE) \ + do \ + { \ + if (!(VALUE)) \ + { \ + SlangRecord::slangRecordLog( \ + SlangRecord::LogLevel::Error, \ + "Assertion failed: %s, %s, %d\n", \ + #VALUE, \ + __FILE__, \ + __LINE__); \ + std::abort(); \ + } \ + } while (0) -#define SLANG_RECORD_CHECK(VALUE) \ - do { \ - SLANG_RECORD_ASSERT((VALUE) == SLANG_OK); \ - } while(0) +#define SLANG_RECORD_CHECK(VALUE) \ + do \ + { \ + SLANG_RECORD_ASSERT((VALUE) == SLANG_OK); \ + } while (0) #endif // RECORD_UTILITY_H |
