summaryrefslogtreecommitdiffstats
path: root/source/compiler-core
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-09-30 12:50:30 -0700
committerGitHub <noreply@github.com>2024-09-30 12:50:30 -0700
commit15d1c6c51c5f24663d2567d7e56da62a2bca1c22 (patch)
tree78733e327dca1421f39ecff4073463d74500c14c /source/compiler-core
parentbc11579dd998224bcb429d88aeb07d49e2217a35 (diff)
Add COM API for querying metadata. (#5168)
* Add COM API for querying metadata. * Fix tests. * fix test.
Diffstat (limited to 'source/compiler-core')
-rw-r--r--source/compiler-core/slang-artifact-associated-impl.cpp20
-rw-r--r--source/compiler-core/slang-artifact-associated-impl.h8
-rw-r--r--source/compiler-core/slang-artifact-associated.h2
3 files changed, 29 insertions, 1 deletions
diff --git a/source/compiler-core/slang-artifact-associated-impl.cpp b/source/compiler-core/slang-artifact-associated-impl.cpp
index f29c0f596..07d69bf8e 100644
--- a/source/compiler-core/slang-artifact-associated-impl.cpp
+++ b/source/compiler-core/slang-artifact-associated-impl.cpp
@@ -313,4 +313,24 @@ Slice<String> ArtifactPostEmitMetadata::getExportedFunctionMangledNames()
return Slice<String>(m_exportedFunctionMangledNames.getBuffer(), m_exportedFunctionMangledNames.getCount());
}
+SlangResult ArtifactPostEmitMetadata::isParameterLocationUsed(
+ SlangParameterCategory category,
+ SlangUInt spaceIndex,
+ SlangUInt registerIndex,
+ bool& outUsed)
+{
+ for (const auto& range : getUsedBindingRanges())
+ {
+ if (range.containsBinding((slang::ParameterCategory)category, spaceIndex, registerIndex))
+ {
+ outUsed = true;
+ return SLANG_OK;
+ }
+ }
+
+ outUsed = false;
+ return SLANG_OK;
+}
+
+
} // namespace Slang
diff --git a/source/compiler-core/slang-artifact-associated-impl.h b/source/compiler-core/slang-artifact-associated-impl.h
index a6e323b0a..d11498604 100644
--- a/source/compiler-core/slang-artifact-associated-impl.h
+++ b/source/compiler-core/slang-artifact-associated-impl.h
@@ -134,6 +134,7 @@ struct ShaderBindingRange
case slang::ShaderResource:
case slang::UnorderedAccess:
case slang::SamplerState:
+ case slang::DescriptorTableSlot:
return true;
default:
return false;
@@ -157,6 +158,13 @@ public:
SLANG_NO_THROW virtual Slice<ShaderBindingRange> SLANG_MCALL getUsedBindingRanges() SLANG_OVERRIDE;
SLANG_NO_THROW virtual Slice<String> SLANG_MCALL getExportedFunctionMangledNames() SLANG_OVERRIDE;
+ // IMetadata
+ SLANG_NO_THROW virtual SlangResult SLANG_MCALL isParameterLocationUsed(
+ SlangParameterCategory category, // is this a `t` register? `s` register?
+ SlangUInt spaceIndex, // `space` for D3D12, `set` for Vulkan
+ SlangUInt registerIndex, // `register` for D3D12, `binding` for Vulkan
+ bool& outUsed) SLANG_OVERRIDE;
+
void* getInterface(const Guid& uuid);
void* getObject(const Guid& uuid);
diff --git a/source/compiler-core/slang-artifact-associated.h b/source/compiler-core/slang-artifact-associated.h
index 766494271..91ae09aab 100644
--- a/source/compiler-core/slang-artifact-associated.h
+++ b/source/compiler-core/slang-artifact-associated.h
@@ -117,7 +117,7 @@ public:
struct ShaderBindingRange;
-class IArtifactPostEmitMetadata : public ICastable
+class IArtifactPostEmitMetadata : public slang::IMetadata
{
public:
SLANG_COM_INTERFACE(0x5d03bce9, 0xafb1, 0x4fc8, { 0xa4, 0x6f, 0x3c, 0xe0, 0x7b, 0x6, 0x1b, 0x1b });