summaryrefslogtreecommitdiffstats
path: root/tools/gfx-util/shader-cursor.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-10-29 14:49:26 +0800
committerGitHub <noreply@github.com>2024-10-29 14:49:26 +0800
commitf65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch)
treeea1d61342cd29368e19135000ec2948813096205 /tools/gfx-util/shader-cursor.cpp
parenta729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff)
format
* format * Minor test fixes * enable checking cpp format in ci
Diffstat (limited to 'tools/gfx-util/shader-cursor.cpp')
-rw-r--r--tools/gfx-util/shader-cursor.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/tools/gfx-util/shader-cursor.cpp b/tools/gfx-util/shader-cursor.cpp
index c849673bf..7166ef66a 100644
--- a/tools/gfx-util/shader-cursor.cpp
+++ b/tools/gfx-util/shader-cursor.cpp
@@ -7,8 +7,7 @@ Result gfx::ShaderCursor::getDereferenced(ShaderCursor& outCursor) const
{
switch (m_typeLayout->getKind())
{
- default:
- return SLANG_E_INVALID_ARG;
+ default: return SLANG_E_INVALID_ARG;
case slang::TypeReflection::Kind::ConstantBuffer:
case slang::TypeReflection::Kind::ParameterBlock:
@@ -26,7 +25,7 @@ ShaderCursor ShaderCursor::getExplicitCounter() const
// The alternative to handling this here would be to augment IResourceView
// with a `getCounterResourceView()`, and set that also in `setResource`
- if(const auto counterVarLayout = m_typeLayout->getExplicitCounter())
+ if (const auto counterVarLayout = m_typeLayout->getExplicitCounter())
{
ShaderCursor counterCursor;
@@ -38,10 +37,11 @@ ShaderCursor ShaderCursor::getExplicitCounter() const
// The byte offset is the current offset plus the relative offset of the counter.
// The offset in binding ranges is computed similarly.
- counterCursor.m_offset.uniformOffset
- = m_offset.uniformOffset + SlangInt(counterVarLayout->getOffset());
- counterCursor.m_offset.bindingRangeIndex
- = m_offset.bindingRangeIndex + GfxIndex(m_typeLayout->getExplicitCounterBindingRangeOffset());
+ counterCursor.m_offset.uniformOffset =
+ m_offset.uniformOffset + SlangInt(counterVarLayout->getOffset());
+ counterCursor.m_offset.bindingRangeIndex =
+ m_offset.bindingRangeIndex +
+ GfxIndex(m_typeLayout->getExplicitCounterBindingRangeOffset());
// The index of the counter within any binding ranges will be the same
// as the index computed for the parent structure.
@@ -118,7 +118,8 @@ Result ShaderCursor::getField(const char* name, const char* nameEnd, ShaderCurso
//
fieldCursor.m_offset.uniformOffset = m_offset.uniformOffset + fieldLayout->getOffset();
fieldCursor.m_offset.bindingRangeIndex =
- m_offset.bindingRangeIndex + (GfxIndex)m_typeLayout->getFieldBindingRangeOffset(fieldIndex);
+ m_offset.bindingRangeIndex +
+ (GfxIndex)m_typeLayout->getFieldBindingRangeOffset(fieldIndex);
// The index of the field within any binding ranges will be the same
// as the index computed for the parent structure.
@@ -178,8 +179,8 @@ Result ShaderCursor::getField(const char* name, const char* nameEnd, ShaderCurso
//
// TODO: figure out whether we should support this long-term.
//
- auto entryPointCount = (GfxIndex) m_baseObject->getEntryPointCount();
- for( GfxIndex e = 0; e < entryPointCount; ++e )
+ auto entryPointCount = (GfxIndex)m_baseObject->getEntryPointCount();
+ for (GfxIndex e = 0; e < entryPointCount; ++e)
{
ComPtr<IShaderObject> entryPoint;
m_baseObject->getEntryPoint(e, entryPoint.writeRef());
@@ -187,7 +188,7 @@ Result ShaderCursor::getField(const char* name, const char* nameEnd, ShaderCurso
ShaderCursor entryPointCursor(entryPoint);
auto result = entryPointCursor.getField(name, nameEnd, outCursor);
- if(SLANG_SUCCEEDED(result))
+ if (SLANG_SUCCEEDED(result))
return result;
}
@@ -208,7 +209,7 @@ ShaderCursor ShaderCursor::getElement(GfxIndex index) const
return elementCursor;
}
- switch( m_typeLayout->getKind() )
+ switch (m_typeLayout->getKind())
{
case slang::TypeReflection::Kind::Array:
{
@@ -233,7 +234,7 @@ ShaderCursor ShaderCursor::getElement(GfxIndex index) const
auto fieldIndex = index;
slang::VariableLayoutReflection* fieldLayout =
m_typeLayout->getFieldByIndex((unsigned int)fieldIndex);
- if(!fieldLayout)
+ if (!fieldLayout)
return ShaderCursor();
ShaderCursor fieldCursor;
@@ -241,7 +242,8 @@ ShaderCursor ShaderCursor::getElement(GfxIndex index) const
fieldCursor.m_typeLayout = fieldLayout->getTypeLayout();
fieldCursor.m_offset.uniformOffset = m_offset.uniformOffset + fieldLayout->getOffset();
fieldCursor.m_offset.bindingRangeIndex =
- m_offset.bindingRangeIndex + (GfxIndex)m_typeLayout->getFieldBindingRangeOffset(fieldIndex);
+ m_offset.bindingRangeIndex +
+ (GfxIndex)m_typeLayout->getFieldBindingRangeOffset(fieldIndex);
fieldCursor.m_offset.bindingArrayIndex = m_offset.bindingArrayIndex;
return fieldCursor;
@@ -254,7 +256,9 @@ ShaderCursor ShaderCursor::getElement(GfxIndex index) const
ShaderCursor fieldCursor;
fieldCursor.m_baseObject = m_baseObject;
fieldCursor.m_typeLayout = m_typeLayout->getElementTypeLayout();
- fieldCursor.m_offset.uniformOffset = m_offset.uniformOffset + m_typeLayout->getElementStride(SLANG_PARAMETER_CATEGORY_UNIFORM) * index;
+ fieldCursor.m_offset.uniformOffset =
+ m_offset.uniformOffset +
+ m_typeLayout->getElementStride(SLANG_PARAMETER_CATEGORY_UNIFORM) * index;
fieldCursor.m_offset.bindingRangeIndex = m_offset.bindingRangeIndex;
fieldCursor.m_offset.bindingArrayIndex = m_offset.bindingArrayIndex;
return fieldCursor;
@@ -347,14 +351,11 @@ Result ShaderCursor::followPath(const char* path, ShaderCursor& ioCursor)
{
switch (_peek(rest))
{
- default:
- _get(rest);
- continue;
+ default: _get(rest); continue;
case -1:
case '.':
- case '[':
- break;
+ case '[': break;
}
break;
}