summaryrefslogtreecommitdiff
path: root/tools/gfx-util
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2021-01-26 13:32:03 -0800
committerGitHub <noreply@github.com>2021-01-26 13:32:03 -0800
commita90c850735664e2928e4cc961442a126c6859b97 (patch)
tree8b5e12113319ae87c57f5e616408eb955fe85a2c /tools/gfx-util
parent50676c741e10ffe6f710c5de86387eaacd274a9a (diff)
Integrate reflection more deeply into gfx layer (#1677)
Diffstat (limited to 'tools/gfx-util')
-rw-r--r--tools/gfx-util/shader-cursor.cpp4
-rw-r--r--tools/gfx-util/shader-cursor.h36
2 files changed, 28 insertions, 12 deletions
diff --git a/tools/gfx-util/shader-cursor.cpp b/tools/gfx-util/shader-cursor.cpp
index f80803bdd..769643e75 100644
--- a/tools/gfx-util/shader-cursor.cpp
+++ b/tools/gfx-util/shader-cursor.cpp
@@ -20,7 +20,7 @@ Result gfx::ShaderCursor::getDereferenced(ShaderCursor& outCursor) const
}
}
-Result ShaderCursor::getField(const char* name, const char* nameEnd, ShaderCursor& outCursor)
+Result ShaderCursor::getField(const char* name, const char* nameEnd, ShaderCursor& outCursor) const
{
// If this cursor is invalid, then can't possible fetch a field.
//
@@ -118,7 +118,7 @@ Result ShaderCursor::getField(const char* name, const char* nameEnd, ShaderCurso
return SLANG_E_INVALID_ARG;
}
-ShaderCursor ShaderCursor::getElement(SlangInt index)
+ShaderCursor ShaderCursor::getElement(SlangInt index) const
{
// TODO: need to auto-dereference various buffer types...
diff --git a/tools/gfx-util/shader-cursor.h b/tools/gfx-util/shader-cursor.h
index 3f5cfb090..04dddc3aa 100644
--- a/tools/gfx-util/shader-cursor.h
+++ b/tools/gfx-util/shader-cursor.h
@@ -42,7 +42,7 @@ struct ShaderCursor
Result getDereferenced(ShaderCursor& outCursor) const;
- ShaderCursor getDereferenced()
+ ShaderCursor getDereferenced() const
{
ShaderCursor result;
getDereferenced(result);
@@ -53,20 +53,20 @@ struct ShaderCursor
/// points at.
///
/// If the operation succeeds, then the field cursor is written to `outCursor`.
- Result getField(const char* nameBegin, const char* nameEnd, ShaderCursor& outCursor);
+ Result getField(const char* nameBegin, const char* nameEnd, ShaderCursor& outCursor) const;
- ShaderCursor getField(const char* name)
+ ShaderCursor getField(const char* name) const
{
ShaderCursor cursor;
getField(name, nullptr, cursor);
return cursor;
}
- ShaderCursor getElement(SlangInt index);
+ ShaderCursor getElement(SlangInt index) const;
static Result followPath(const char* path, ShaderCursor& ioCursor);
- ShaderCursor getPath(const char* path)
+ ShaderCursor getPath(const char* path) const
{
ShaderCursor result(*this);
followPath(path, result);
@@ -80,29 +80,45 @@ struct ShaderCursor
, m_typeLayout(object->getElementTypeLayout())
{}
- SlangResult setData(void const* data, size_t size)
+ SlangResult setData(void const* data, size_t size) const
{
return m_baseObject->setData(m_offset, data, size);
}
- SlangResult setObject(IShaderObject* object)
+ SlangResult setObject(IShaderObject* object) const
{
return m_baseObject->setObject(m_offset, object);
}
- SlangResult setResource(IResourceView* resourceView)
+ SlangResult setResource(IResourceView* resourceView) const
{
return m_baseObject->setResource(m_offset, resourceView);
}
- SlangResult setSampler(ISamplerState* sampler)
+ SlangResult setSampler(ISamplerState* sampler) const
{
return m_baseObject->setSampler(m_offset, sampler);
}
- SlangResult setCombinedTextureSampler(IResourceView* textureView, ISamplerState* sampler)
+ SlangResult setCombinedTextureSampler(IResourceView* textureView, ISamplerState* sampler) const
{
return m_baseObject->setCombinedTextureSampler(m_offset, textureView, sampler);
}
+
+ /// Produce a cursor to the field with the given `name`.
+ ///
+ /// This is a convenience wrapper around `getField()`.
+ ShaderCursor operator[](const char* name) const
+ {
+ return getField(name);
+ }
+
+ /// Produce a cursor to the element or field with the given `index`.
+ ///
+ /// This is a convenience wrapper around `getElement()`.
+ ShaderCursor operator[](SlangInt index) const
+ {
+ return getElement(index);
+ }
};
}