summaryrefslogtreecommitdiff
path: root/tools/gfx/debug-layer.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-05-25 10:24:38 -0700
committerGitHub <noreply@github.com>2021-05-25 10:24:38 -0700
commitba24264275c640e0ac3732f0f5720e1f5816cded (patch)
tree9413b919498c700afe89d498ff3434eea9cf3c89 /tools/gfx/debug-layer.cpp
parentfbf00dd54d787c6e22b0f1785a64dfb2fb1e300a (diff)
Allow overriding specialization args via `IShaderObject`. (#1854)
* Allow overriding specialization args via `IShaderObject`. * Fixes. Co-authored-by: T. Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'tools/gfx/debug-layer.cpp')
-rw-r--r--tools/gfx/debug-layer.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/gfx/debug-layer.cpp b/tools/gfx/debug-layer.cpp
index 56ae4fdab..3fa2eee9d 100644
--- a/tools/gfx/debug-layer.cpp
+++ b/tools/gfx/debug-layer.cpp
@@ -385,6 +385,8 @@ Result DebugDevice::createShaderObject(
auto result =
baseObject->createShaderObject(type, containerType, outObject->baseObject.writeRef());
outObject->m_typeName = typeName;
+ outObject->m_device = this;
+ outObject->m_slangType = type;
if (SLANG_FAILED(result))
return result;
returnComPtr(outShaderObject, outObject);
@@ -952,10 +954,38 @@ Result DebugShaderObject::setCombinedTextureSampler(
offset, viewImpl->baseObject.get(), samplerImpl->baseObject.get());
}
+Result DebugShaderObject::setSpecializationArgs(
+ const slang::SpecializationArg* args,
+ uint32_t count)
+{
+ ComPtr<slang::ISession> session;
+ m_device->getSlangSession(session.writeRef());
+ auto expectedCount = (uint32_t)session->getTypeLayout(m_slangType)
+ ->getSize(SLANG_PARAMETER_CATEGORY_EXISTENTIAL_TYPE_PARAM);
+ if (expectedCount != count)
+ {
+ GFX_DIAGNOSE_ERROR_FORMAT(
+ "specialization argument count for shader object type %s mismatch: expecting %d but %d "
+ "provided.",
+ m_typeName.getBuffer(),
+ expectedCount,
+ count);
+ };
+ return baseObject->setSpecializationArgs(args, count);
+}
+
DebugObjectBase::DebugObjectBase()
{
static uint64_t uidCounter = 0;
uid = ++uidCounter;
}
+Result DebugRootShaderObject::setSpecializationArgs(
+ const slang::SpecializationArg* args,
+ uint32_t count)
+{
+ GFX_DIAGNOSE_ERROR("`setSpecializationArgs` should not be called directly on root objects.");
+ return baseObject->setSpecializationArgs(args, count);
+}
+
} // namespace gfx