summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-artifact-representation-impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/compiler-core/slang-artifact-representation-impl.cpp')
-rw-r--r--source/compiler-core/slang-artifact-representation-impl.cpp52
1 files changed, 50 insertions, 2 deletions
diff --git a/source/compiler-core/slang-artifact-representation-impl.cpp b/source/compiler-core/slang-artifact-representation-impl.cpp
index 6ae2d646f..32ec055d8 100644
--- a/source/compiler-core/slang-artifact-representation-impl.cpp
+++ b/source/compiler-core/slang-artifact-representation-impl.cpp
@@ -178,10 +178,58 @@ void* PostEmitMetadataArtifactRepresentation::getObject(const Guid& uuid)
return nullptr;
}
+void* PostEmitMetadataArtifactRepresentation::castAs(const Guid& guid)
+{
+ if (auto ptr = getInterface(guid))
+ {
+ return ptr;
+ }
+ return getObject(guid);
+}
+
+
Slice<ShaderBindingRange> PostEmitMetadataArtifactRepresentation::getBindingRanges()
{
- return Slice<ShaderBindingRange>(m_usedBindings.getBuffer(), m_usedBindings.getCount());
+ return Slice<ShaderBindingRange>(m_metadata.usedBindings.getBuffer(), m_metadata.usedBindings.getCount());
+}
+
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PostEmitMetadataArtifactRepresentation !!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
+void* ObjectArtifactRepresentation::castAs(const Guid& guid)
+{
+
+ if (auto ptr = getInterface(guid))
+ {
+ return ptr;
+ }
+ return getObject(guid);
+}
+
+void* ObjectArtifactRepresentation::getInterface(const Guid& guid)
+{
+ if (guid == ISlangUnknown::getTypeGuid() ||
+ guid == ICastable::getTypeGuid() ||
+ guid == IArtifactRepresentation::getTypeGuid())
+ {
+ return static_cast<IArtifactRepresentation*>(this);
+ }
+ return nullptr;
+}
+
+void* ObjectArtifactRepresentation::getObject(const Guid& guid)
+{
+ if (guid == getTypeGuid())
+ {
+ return this;
+ }
+
+ // If matches the guid saved in the object, we return that
+ if (m_object && m_typeGuid == guid)
+ {
+ return m_object;
+ }
+
+ return nullptr;
}
-
} // namespace Slang