summaryrefslogtreecommitdiff
path: root/source/slang-record-replay/record
diff options
context:
space:
mode:
authorjarcherNV <jarcher@nvidia.com>2025-08-21 11:42:49 -0700
committerGitHub <noreply@github.com>2025-08-21 18:42:49 +0000
commita5e6ddd006ecf72ad9a41961811e93e1e2f72e64 (patch)
tree869beb336a44dc1e96876a8f63818c4754c740ac /source/slang-record-replay/record
parent44815ba48c1d149137a2210ca3fccfe3bda2626e (diff)
Add record and replay support for IComponentType2 (#8215)
Add record and replay support for the IComponentType2 struct and its functions getTargetCompileResult and getEntryPointCompileResult.
Diffstat (limited to 'source/slang-record-replay/record')
-rw-r--r--source/slang-record-replay/record/parameter-recorder.h10
-rw-r--r--source/slang-record-replay/record/slang-component-type.cpp26
-rw-r--r--source/slang-record-replay/record/slang-component-type.h2
-rw-r--r--source/slang-record-replay/record/slang-component-type2.cpp91
-rw-r--r--source/slang-record-replay/record/slang-component-type2.h53
-rw-r--r--source/slang-record-replay/record/slang-composite-component-type.cpp27
6 files changed, 207 insertions, 2 deletions
diff --git a/source/slang-record-replay/record/parameter-recorder.h b/source/slang-record-replay/record/parameter-recorder.h
index 24617b7b8..9be2d876a 100644
--- a/source/slang-record-replay/record/parameter-recorder.h
+++ b/source/slang-record-replay/record/parameter-recorder.h
@@ -40,6 +40,16 @@ public:
{
recordValue(reinterpret_cast<SlangRecord::AddressFormat>(value));
}
+ void recordGuid(const SlangUUID& guid)
+ {
+ recordValue(guid.data1);
+ recordValue(guid.data2);
+ recordValue(guid.data3);
+ for (int i = 0; i < 8; i++)
+ {
+ recordValue(guid.data4[i]);
+ }
+ }
void recordStruct(SlangGlobalSessionDesc const& desc);
void recordStruct(slang::SessionDesc const& desc);
void recordStruct(slang::PreprocessorMacroDesc const& desc);
diff --git a/source/slang-record-replay/record/slang-component-type.cpp b/source/slang-record-replay/record/slang-component-type.cpp
index 05fd68691..061619e3b 100644
--- a/source/slang-record-replay/record/slang-component-type.cpp
+++ b/source/slang-record-replay/record/slang-component-type.cpp
@@ -1,6 +1,7 @@
#include "slang-component-type.h"
#include "../util/record-utility.h"
+#include "slang-component-type2.h"
#include "slang-composite-component-type.h"
#include "slang-session.h"
@@ -18,6 +19,31 @@ IComponentTypeRecorder::IComponentTypeRecorder(
slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, componentType);
}
+ISlangUnknown* IComponentTypeRecorder::getInterface(const Guid& guid)
+{
+ if (guid == IComponentTypeRecorder::getTypeGuid())
+ {
+ return static_cast<ISlangUnknown*>(this);
+ }
+
+ // Check if the underlying component type supports IComponentType2.
+ if (guid == slang::IComponentType2::getTypeGuid())
+ {
+ ComPtr<slang::IComponentType2> componentType2;
+ if (SLANG_SUCCEEDED(m_actualComponentType->queryInterface(
+ SLANG_IID_PPV_ARGS(componentType2.writeRef()))))
+ {
+ // Return a new IComponentType2Recorder that wraps the IComponentType2.
+ IComponentType2Recorder* recorder =
+ new IComponentType2Recorder(componentType2, m_recordManager);
+ auto res = static_cast<ISlangUnknown*>(recorder);
+ res->AddRef();
+ return res;
+ }
+ }
+ return nullptr;
+}
+
SLANG_NO_THROW slang::ISession* IComponentTypeRecorder::getSession()
{
slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
diff --git a/source/slang-record-replay/record/slang-component-type.h b/source/slang-record-replay/record/slang-component-type.h
index 2c854ee33..9f8006ca6 100644
--- a/source/slang-record-replay/record/slang-component-type.h
+++ b/source/slang-record-replay/record/slang-component-type.h
@@ -21,6 +21,8 @@ public:
slang::IComponentType* componentType,
RecordManager* recordManager);
+ ISlangUnknown* getInterface(const Guid& guid);
+
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;
diff --git a/source/slang-record-replay/record/slang-component-type2.cpp b/source/slang-record-replay/record/slang-component-type2.cpp
new file mode 100644
index 000000000..15a8c7071
--- /dev/null
+++ b/source/slang-record-replay/record/slang-component-type2.cpp
@@ -0,0 +1,91 @@
+#include "slang-component-type2.h"
+
+#include "../util/record-utility.h"
+#include "slang-composite-component-type.h"
+#include "slang-session.h"
+
+namespace SlangRecord
+{
+IComponentType2Recorder::IComponentType2Recorder(
+ slang::IComponentType2* componentType,
+ RecordManager* recordManager)
+ : m_actualComponentType2(componentType), m_recordManager(recordManager)
+{
+ SLANG_RECORD_ASSERT(m_actualComponentType2 != nullptr);
+ SLANG_RECORD_ASSERT(m_recordManager != nullptr);
+
+ m_componentType2Handle = reinterpret_cast<uint64_t>(m_actualComponentType2.get());
+ slangRecordLog(LogLevel::Verbose, "%s: %p\n", __PRETTY_FUNCTION__, componentType);
+}
+
+ISlangUnknown* IComponentType2Recorder::getInterface(const Guid& guid)
+{
+ if (guid == IComponentType2Recorder::getTypeGuid())
+ return static_cast<IComponentType2Recorder*>(this);
+ else
+ return nullptr;
+}
+
+SlangResult IComponentType2Recorder::getTargetCompileResult(
+ SlangInt targetIndex,
+ slang::ICompileResult** outCompileResult,
+ slang::IBlob** outDiagnostics)
+{
+ slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
+
+ ApiCallId callId = static_cast<ApiCallId>(
+ makeApiCallId(getClassId(), IComponentTypeMethodId::getTargetCompileResult));
+ ParameterRecorder* recorder{};
+ {
+ recorder = m_recordManager->beginMethodRecord(callId, m_componentType2Handle);
+ recorder->recordInt64(targetIndex);
+ recorder = m_recordManager->endMethodRecord();
+ }
+
+ SlangResult res = m_actualComponentType2->getTargetCompileResult(
+ targetIndex,
+ outCompileResult,
+ outDiagnostics);
+ {
+ recorder->recordAddress(*outCompileResult);
+ recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr);
+ m_recordManager->apendOutput();
+ }
+
+ return res;
+}
+
+SlangResult IComponentType2Recorder::getEntryPointCompileResult(
+ SlangInt entryPointIndex,
+ SlangInt targetIndex,
+ slang::ICompileResult** outCompileResult,
+ slang::IBlob** outDiagnostics)
+{
+ slangRecordLog(LogLevel::Verbose, "%s\n", __PRETTY_FUNCTION__);
+
+ ApiCallId callId = static_cast<ApiCallId>(
+ makeApiCallId(getClassId(), IComponentTypeMethodId::getEntryPointCompileResult));
+ ParameterRecorder* recorder{};
+ {
+ recorder = m_recordManager->beginMethodRecord(callId, m_componentType2Handle);
+ recorder->recordInt64(entryPointIndex);
+ recorder->recordInt64(targetIndex);
+ recorder = m_recordManager->endMethodRecord();
+ }
+
+ SlangResult res = m_actualComponentType2->getEntryPointCompileResult(
+ entryPointIndex,
+ targetIndex,
+ outCompileResult,
+ outDiagnostics);
+
+ {
+ recorder->recordAddress(*outCompileResult);
+ recorder->recordAddress(outDiagnostics ? *outDiagnostics : nullptr);
+ m_recordManager->apendOutput();
+ }
+
+ return res;
+}
+
+} // namespace SlangRecord
diff --git a/source/slang-record-replay/record/slang-component-type2.h b/source/slang-record-replay/record/slang-component-type2.h
new file mode 100644
index 000000000..d008f0a9c
--- /dev/null
+++ b/source/slang-record-replay/record/slang-component-type2.h
@@ -0,0 +1,53 @@
+#ifndef SLANG_COMPONENT_TYPE2_H
+#define SLANG_COMPONENT_TYPE2_H
+
+#include "../../core/slang-smart-pointer.h"
+#include "../../slang/slang-compiler.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 IComponentType2Recorder : public slang::IComponentType2, public RefObject
+{
+public:
+ SLANG_COM_INTERFACE(
+ 0x0c23c81d,
+ 0x7e08,
+ 0x4a71,
+ {0xa3, 0x0e, 0x90, 0xa2, 0xd7, 0x8a, 0xe4, 0x87})
+
+ SLANG_REF_OBJECT_IUNKNOWN_ALL
+ ISlangUnknown* getInterface(const Guid& guid);
+
+ explicit IComponentType2Recorder(
+ slang::IComponentType2* componentType,
+ RecordManager* recordManager);
+
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL getTargetCompileResult(
+ SlangInt targetIndex,
+ slang::ICompileResult** outCompileResult,
+ slang::IBlob** outDiagnostics = nullptr) override;
+ virtual SLANG_NO_THROW SlangResult SLANG_MCALL getEntryPointCompileResult(
+ SlangInt entryPointIndex,
+ SlangInt targetIndex,
+ slang::ICompileResult** outCompileResult,
+ slang::IBlob** outDiagnostics = nullptr) override;
+
+ slang::IComponentType2* getActualComponentType() const { return m_actualComponentType2; }
+
+protected:
+ virtual ApiClassId getClassId() { return ApiClassId::Class_IComponentType2; }
+
+ Slang::ComPtr<slang::IComponentType2> m_actualComponentType2;
+ uint64_t m_componentType2Handle = 0;
+ RecordManager* m_recordManager = nullptr;
+};
+} // namespace SlangRecord
+
+#endif // #ifndef SLANG_COMPONENT_TYPE2_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 da76175fd..edb33a05e 100644
--- a/source/slang-record-replay/record/slang-composite-component-type.cpp
+++ b/source/slang-record-replay/record/slang-composite-component-type.cpp
@@ -15,10 +15,33 @@ CompositeComponentTypeRecorder::CompositeComponentTypeRecorder(
ISlangUnknown* CompositeComponentTypeRecorder::getInterface(const Guid& guid)
{
+ // Record the queryInterface call
+ ApiCallId callId =
+ static_cast<ApiCallId>(makeApiCallId(getClassId(), IComponentTypeMethodId::queryInterface));
+ ParameterRecorder* recorder{};
+ {
+ recorder = m_recordManager->beginMethodRecord(callId, m_componentHandle);
+ recorder->recordGuid(guid);
+ recorder = m_recordManager->endMethodRecord();
+ }
+
+ ISlangUnknown* result = nullptr;
if (guid == CompositeComponentTypeRecorder::getTypeGuid())
{
- return static_cast<ISlangUnknown*>(this);
+ result = static_cast<ISlangUnknown*>(this);
+ }
+ else
+ {
+ // Delegate to the base class for IComponentType2 support.
+ result = IComponentTypeRecorder::getInterface(guid);
}
- return nullptr;
+
+ // Record the result
+ {
+ recorder->recordAddress(result);
+ m_recordManager->apendOutput();
+ }
+
+ return result;
}
} // namespace SlangRecord