summaryrefslogtreecommitdiffstats
path: root/tools/gfx-util
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-05-21 16:38:33 -0700
committerGitHub <noreply@github.com>2021-05-21 16:38:33 -0700
commit7f8a9994d0bd99a171a1daa0bce46d92c02ccffd (patch)
tree0b187e63ab5b9ce6f5ab41266fedaec44091a217 /tools/gfx-util
parent172538fdb418f7a2faab1f5a410f3b2cb8e18ba5 (diff)
[gfx] Support StructuredBuffer<IInterface>. (#1851)
Co-authored-by: T. Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'tools/gfx-util')
-rw-r--r--tools/gfx-util/shader-cursor.cpp13
-rw-r--r--tools/gfx-util/shader-cursor.h14
2 files changed, 22 insertions, 5 deletions
diff --git a/tools/gfx-util/shader-cursor.cpp b/tools/gfx-util/shader-cursor.cpp
index b188901ec..afb1540d5 100644
--- a/tools/gfx-util/shader-cursor.cpp
+++ b/tools/gfx-util/shader-cursor.cpp
@@ -144,7 +144,18 @@ Result ShaderCursor::getField(const char* name, const char* nameEnd, ShaderCurso
ShaderCursor ShaderCursor::getElement(SlangInt index) const
{
- // TODO: need to auto-dereference various buffer types...
+ if (m_containerType != ShaderObjectContainerType::None)
+ {
+ ShaderCursor elementCursor;
+ elementCursor.m_baseObject = m_baseObject;
+ elementCursor.m_typeLayout = m_typeLayout->getElementTypeLayout();
+ elementCursor.m_containerType = m_containerType;
+ elementCursor.m_offset.uniformOffset = index * m_typeLayout->getStride();
+ elementCursor.m_offset.bindingRangeIndex = 0;
+ elementCursor.m_offset.bindingArrayIndex = index;
+ return elementCursor;
+ }
+
switch( m_typeLayout->getKind() )
{
case slang::TypeReflection::Kind::Array:
diff --git a/tools/gfx-util/shader-cursor.h b/tools/gfx-util/shader-cursor.h
index 24008cf24..7512c62ee 100644
--- a/tools/gfx-util/shader-cursor.h
+++ b/tools/gfx-util/shader-cursor.h
@@ -26,6 +26,7 @@ struct ShaderCursor
{
IShaderObject* m_baseObject = nullptr;
slang::TypeLayoutReflection* m_typeLayout = nullptr;
+ ShaderObjectContainerType m_containerType = ShaderObjectContainerType::None;
ShaderOffset m_offset;
/// Get the type (layout) of the value being pointed at by the cursor
@@ -78,6 +79,7 @@ struct ShaderCursor
ShaderCursor(IShaderObject* object)
: m_baseObject(object)
, m_typeLayout(object->getElementTypeLayout())
+ , m_containerType(object->getContainerType())
{}
SlangResult setData(void const* data, size_t size) const
@@ -116,9 +118,13 @@ struct ShaderCursor
/// 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);
- }
+ ShaderCursor operator[](int64_t index) const { return getElement((SlangInt)index); }
+ ShaderCursor operator[](uint64_t index) const { return getElement((SlangInt)index); }
+ ShaderCursor operator[](int32_t index) const { return getElement((SlangInt)index); }
+ ShaderCursor operator[](uint32_t index) const { return getElement((SlangInt)index); }
+ ShaderCursor operator[](int16_t index) const { return getElement((SlangInt)index); }
+ ShaderCursor operator[](uint16_t index) const { return getElement((SlangInt)index); }
+ ShaderCursor operator[](int8_t index) const { return getElement((SlangInt)index); }
+ ShaderCursor operator[](uint8_t index) const { return getElement((SlangInt)index); }
};
}