diff options
Diffstat (limited to 'source')
9 files changed, 76 insertions, 55 deletions
diff --git a/source/slang-record-replay/record/slang-module.cpp b/source/slang-record-replay/record/slang-module.cpp index b116fa99b..3acda5d22 100644 --- a/source/slang-record-replay/record/slang-module.cpp +++ b/source/slang-record-replay/record/slang-module.cpp @@ -88,8 +88,9 @@ namespace SlangRecord if (*outEntryPoint) { - EntryPointRecorder* entryPointRecord = m_mapEntryPointToRecord.tryGetValue(*outEntryPoint); - if (!entryPointRecord) + EntryPointRecorder* entryPointRecord = nullptr; + bool ret = m_mapEntryPointToRecord.tryGetValue(*outEntryPoint, entryPointRecord); + if (!ret) { SLANG_RECORD_ASSERT(!"Entrypoint not found in mapEntryPointToRecord"); } @@ -490,12 +491,14 @@ namespace SlangRecord EntryPointRecorder* ModuleRecorder::getEntryPointRecorder(slang::IEntryPoint* entryPoint) { EntryPointRecorder* entryPointRecord = nullptr; - entryPointRecord = m_mapEntryPointToRecord.tryGetValue(entryPoint); - if (!entryPointRecord) + bool ret = m_mapEntryPointToRecord.tryGetValue(entryPoint, entryPointRecord); + if (!ret) { entryPointRecord = new EntryPointRecorder(entryPoint, m_recordManager); Slang::ComPtr<EntryPointRecorder> result(entryPointRecord); - m_mapEntryPointToRecord.add(entryPoint, *result.detach()); + + m_entryPointsRecordAllocation.add(result); + m_mapEntryPointToRecord.add(entryPoint, result.detach()); } return entryPointRecord; } diff --git a/source/slang-record-replay/record/slang-module.h b/source/slang-record-replay/record/slang-module.h index 1b1cc5de9..ed684c680 100644 --- a/source/slang-record-replay/record/slang-module.h +++ b/source/slang-record-replay/record/slang-module.h @@ -97,7 +97,8 @@ namespace SlangRecord // `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*, EntryPointRecorder> m_mapEntryPointToRecord; + Dictionary<slang::IEntryPoint*, EntryPointRecorder*> m_mapEntryPointToRecord; + List<ComPtr<EntryPointRecorder>> m_entryPointsRecordAllocation; }; } // namespace SlangRecord diff --git a/source/slang-record-replay/record/slang-session.cpp b/source/slang-record-replay/record/slang-session.cpp index 3eb944082..f38d18aa1 100644 --- a/source/slang-record-replay/record/slang-session.cpp +++ b/source/slang-record-replay/record/slang-session.cpp @@ -444,8 +444,9 @@ namespace SlangRecord if (pModule) { - ModuleRecorder* moduleRecord = m_mapModuleToRecord.tryGetValue(pModule); - if (!moduleRecord) + ModuleRecorder* moduleRecord = nullptr; + bool ret = m_mapModuleToRecord.tryGetValue(pModule, moduleRecord); + if (!ret) { SLANG_RECORD_ASSERT(!"Module not found in mapModuleToRecord"); } @@ -466,12 +467,13 @@ namespace SlangRecord ModuleRecorder* SessionRecorder::getModuleRecorder(slang::IModule* module) { ModuleRecorder* moduleRecord = nullptr; - moduleRecord = m_mapModuleToRecord.tryGetValue(module); - if (!moduleRecord) + bool ret = m_mapModuleToRecord.tryGetValue(module, moduleRecord); + if (!ret) { moduleRecord = new ModuleRecorder(module, m_recordManager); Slang::ComPtr<ModuleRecorder> result(moduleRecord); - m_mapModuleToRecord.add(module, *result.detach()); + m_moduleRecordersAlloation.add(result); + m_mapModuleToRecord.add(module, result.detach()); } return moduleRecord; } diff --git a/source/slang-record-replay/record/slang-session.h b/source/slang-record-replay/record/slang-session.h index bc56003a9..644c975ff 100644 --- a/source/slang-record-replay/record/slang-session.h +++ b/source/slang-record-replay/record/slang-session.h @@ -101,7 +101,8 @@ namespace SlangRecord Slang::ComPtr<slang::ISession> m_actualSession; uint64_t m_sessionHandle = 0; - Dictionary<slang::IModule*, ModuleRecorder> m_mapModuleToRecord; + Dictionary<slang::IModule*, ModuleRecorder*> m_mapModuleToRecord; + List<ComPtr<ModuleRecorder>> m_moduleRecordersAlloation; RecordManager* m_recordManager = nullptr; }; } diff --git a/source/slang-record-replay/replay/json-consumer.cpp b/source/slang-record-replay/replay/json-consumer.cpp index 456988bdb..455a36627 100644 --- a/source/slang-record-replay/replay/json-consumer.cpp +++ b/source/slang-record-replay/replay/json-consumer.cpp @@ -216,7 +216,7 @@ namespace SlangRecord for(int i = 0; i < specializationArgCount; i++) { bool isLastField = (i == specializationArgCount - 1); - ScopeWritterForKey scopeWritterForArg(&builder, &indent, Slang::StringUtil::makeStringWithFormat("[%d]\n", i), isLastField); + 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%X", specializationArgs[i].type)); @@ -473,13 +473,11 @@ namespace SlangRecord SANITY_CHECK(); Slang::StringBuilder builder; int indent = 0; - _writeString(builder, indent, "GlobalFunction::createGlobalSession: {\n"); + { - indent++; + ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::createGlobalSession"); _writePairNoComma(builder, indent, "outGlobalSession", Slang::StringUtil::makeStringWithFormat("0x%X", outGlobalSessionId)); - indent--; } - _writeString(builder, indent, "}\n"); m_fileStream.write(builder.produceString().begin(), builder.produceString().getLength()); m_fileStream.flush(); @@ -490,7 +488,6 @@ namespace SlangRecord SANITY_CHECK(); Slang::StringBuilder builder; int indent = 0; - _writeString(builder, indent, "IGlobalSession::createSession: {\n"); { ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::createSession"); @@ -633,14 +630,14 @@ namespace SlangRecord SANITY_CHECK(); Slang::StringBuilder builder; int indent = 0; - _writeString(builder, indent, "IGlobalSession::setLanguagePrelude: {\n"); { ScopeWritterForKey scopeWritter(&builder, &indent, "IGlobalSession::setLanguagePrelude"); { _writePair(builder, indent, "this", Slang::StringUtil::makeStringWithFormat("0x%X", objectId)); _writePair(builder, indent, "sourceLanguage", SlangSourceLanguageToString(inSourceLanguage)); - _writePairNoComma(builder, indent, "preludeText", (prelude != nullptr ? prelude : "nullptr")); + _writePairNoComma(builder, indent, "preludeText", Slang::StringUtil::makeStringWithFormat("\"%s\"", + prelude != nullptr ? prelude : "nullptr")); } } @@ -1231,7 +1228,7 @@ namespace SlangRecord _writePair(builder, indent, "type", Slang::StringUtil::makeStringWithFormat("0x%X", typeId)); _writePair(builder, indent, "rules", LayoutRulesToString(rules)); _writePair(builder, indent, "outDiagnostics", outDiagnosticsId); - _writePair(builder, indent, "retTypeReflectionId", outTypeLayoutReflectionId); + _writePairNoComma(builder, indent, "retTypeReflectionId", outTypeLayoutReflectionId); } } diff --git a/source/slang-record-replay/replay/parameter-decoder.h b/source/slang-record-replay/replay/parameter-decoder.h index 5d6f40987..d1deca3eb 100644 --- a/source/slang-record-replay/replay/parameter-decoder.h +++ b/source/slang-record-replay/replay/parameter-decoder.h @@ -54,7 +54,10 @@ namespace SlangRecord template <typename T> static size_t decodeValueArray(const uint8_t* buffer, int64_t bufferSize, ValueDecoder<T>* valueArray, size_t count) { - SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); + if (count == 0 && bufferSize == 0) + { + return 0; + } size_t readByte = 0; for (size_t i = 0; i < count; ++i) @@ -66,6 +69,10 @@ namespace SlangRecord static size_t decodeStringArray(const uint8_t* buffer, int64_t bufferSize, char** outputArray, size_t count) { + if (count == 0 && bufferSize == 0) + { + return 0; + } SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); size_t readByte = 0; @@ -83,6 +90,10 @@ namespace SlangRecord template <typename T> static size_t decodeStructArray(const uint8_t* buffer, int64_t bufferSize, T* outputArray, size_t count) { + if (count == 0 && bufferSize == 0) + { + return 0; + } SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); size_t bufferRead = 0; @@ -97,6 +108,10 @@ namespace SlangRecord static size_t decodeAddressArray(const uint8_t* buffer, int64_t bufferSize, uint64_t* addressArray, size_t count) { + if (count == 0 && bufferSize == 0) + { + return 0; + } SLANG_RECORD_ASSERT((buffer != nullptr) && (bufferSize > 0)); size_t bufferRead = 0; diff --git a/source/slang-record-replay/replay/replay-consumer.cpp b/source/slang-record-replay/replay/replay-consumer.cpp index 7710b50e9..01de2f828 100644 --- a/source/slang-record-replay/replay/replay-consumer.cpp +++ b/source/slang-record-replay/replay/replay-consumer.cpp @@ -118,7 +118,8 @@ namespace SlangRecord { uint8_t* buffer = (uint8_t*)outHash->getBufferPointer(); Slang::StringBuilder strBuilder; - strBuilder << "entrypoint: "<< entryPointIndex << ", target: " << targetIndex << ", hash: "; + strBuilder << "callIdx: " << m_globalCounter << ", entrypoint: "<< entryPointIndex << ", target: " << targetIndex << ", hash: "; + m_globalCounter++; for (size_t i = 0; i < outHash->getBufferSize(); i++) { diff --git a/source/slang-record-replay/replay/replay-consumer.h b/source/slang-record-replay/replay/replay-consumer.h index 8a38d6202..5618598e1 100644 --- a/source/slang-record-replay/replay/replay-consumer.h +++ b/source/slang-record-replay/replay/replay-consumer.h @@ -52,6 +52,7 @@ namespace SlangRecord } Slang::Dictionary<ObjectID, void*>& m_objectMap; + uint32_t m_globalCounter = 0; }; class ReplayConsumer : public IDecoderConsumer diff --git a/source/slang-record-replay/replay/slang-decoder.cpp b/source/slang-record-replay/replay/slang-decoder.cpp index e30bd4584..30d182729 100644 --- a/source/slang-record-replay/replay/slang-decoder.cpp +++ b/source/slang-record-replay/replay/slang-decoder.cpp @@ -872,7 +872,7 @@ namespace SlangRecord ObjectID outDiagnosticsId = 0; ObjectID outTypeReflectionId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); + readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize, outDiagnosticsId); readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outTypeReflectionId); for (auto consumer: m_consumers) @@ -895,7 +895,7 @@ namespace SlangRecord ObjectID outDiagnosticsId = 0; ObjectID outTypeLayoutReflectionId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); + readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize, outDiagnosticsId); readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outTypeLayoutReflectionId); for (auto consumer: m_consumers) @@ -916,7 +916,7 @@ namespace SlangRecord ObjectID outDiagnosticsId = 0; ObjectID outTypeReflectionId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); + readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize, outDiagnosticsId); readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.parameterBufferSize - readByte, outTypeReflectionId); for (auto consumer: m_consumers) @@ -1005,7 +1005,7 @@ namespace SlangRecord ObjectID outDiagnosticsId = 0; ObjectID outConformanceId = 0; - readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outConformanceId); + readByte = ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize, outConformanceId); readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); for (auto consumer: m_consumers) @@ -1256,8 +1256,8 @@ namespace SlangRecord slangRecordLog(LogLevel::Error, "%s: The shader reflection interfaces are not recordd\n", __PRETTY_FUNCTION__); size_t readByte = 0; - uint32_t specializationArgCount = 0; - readByte = ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); + int64_t specializationArgCount = 0; + readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); std::vector<slang::SpecializationArg> specializationArgs; @@ -1299,15 +1299,15 @@ namespace SlangRecord void SlangDecoder::IModule_getEntryPointHostCallable(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); + 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.parameterBufferSize - readByte, outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); for (auto consumer: m_consumers) { @@ -1465,8 +1465,8 @@ namespace SlangRecord slangRecordLog(LogLevel::Error, "%s: The shader reflection interfaces are not recordd\n", __PRETTY_FUNCTION__); size_t readByte = 0; - uint32_t specializationArgCount = 0; - readByte = ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); + int64_t specializationArgCount = 0; + readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); std::vector<slang::SpecializationArg> specializationArgs; @@ -1508,15 +1508,15 @@ namespace SlangRecord void SlangDecoder::IEntryPoint_getEntryPointHostCallable(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); + 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.parameterBufferSize - readByte, outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); for (auto consumer: m_consumers) { @@ -1674,8 +1674,8 @@ namespace SlangRecord slangRecordLog(LogLevel::Error, "%s: The shader reflection interfaces are not recordd\n", __PRETTY_FUNCTION__); size_t readByte = 0; - uint32_t specializationArgCount = 0; - readByte = ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); + int64_t specializationArgCount = 0; + readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); std::vector<slang::SpecializationArg> specializationArgs; @@ -1717,15 +1717,15 @@ namespace SlangRecord void SlangDecoder::ICompositeComponentType_getEntryPointHostCallable(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); + 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.parameterBufferSize - readByte, outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); for (auto consumer: m_consumers) { @@ -1883,8 +1883,8 @@ namespace SlangRecord slangRecordLog(LogLevel::Error, "%s: The shader reflection interfaces are not recordd\n", __PRETTY_FUNCTION__); size_t readByte = 0; - uint32_t specializationArgCount = 0; - readByte = ParameterDecoder::decodeUint32(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); + int64_t specializationArgCount = 0; + readByte = ParameterDecoder::decodeInt64(parameterBlock.parameterBuffer, parameterBlock.parameterBufferSize, specializationArgCount); std::vector<slang::SpecializationArg> specializationArgs; @@ -1926,15 +1926,15 @@ namespace SlangRecord void SlangDecoder::ITypeConformance_getEntryPointHostCallable(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); + 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.parameterBufferSize - readByte, outDiagnosticsId); + readByte += ParameterDecoder::decodeAddress(parameterBlock.outputBuffer + readByte, parameterBlock.outputBufferSize - readByte, outDiagnosticsId); for (auto consumer: m_consumers) { |
