summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-type-layout.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-09-05 22:37:34 -0700
committerGitHub <noreply@github.com>2025-09-05 22:37:34 -0700
commitbc6b82666fa4deda932c36cea93ee2059e0992b2 (patch)
tree6800fcd6839db782af056310653d35391b558c1e /source/slang/slang-type-layout.cpp
parentfe87a39e453b64e94446181a9ae5cbfc0f62bf0c (diff)
Relax restriction on using link-time types for shader parameters. (#8387)
This change relaxes a previous restriction on link-time types and constants, so that we now allow them to be used to define shader parameters. Doing so will result in a parameter layout that is incomplete prior to linking. The PR added a test to call the reflection API on a fully linked program and ensure that we can report correct binding info.
Diffstat (limited to 'source/slang/slang-type-layout.cpp')
-rw-r--r--source/slang/slang-type-layout.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index efd41bd86..fb40382c5 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -4918,7 +4918,8 @@ static TypeLayoutResult _createTypeLayout(TypeLayoutContext& context, Type* type
else if (auto vecType = as<VectorExpressionType>(type))
{
auto elementType = vecType->getElementType();
- size_t elementCount = (size_t)getIntVal(vecType->getElementCount());
+ size_t elementCount =
+ (size_t)getIntVal(context.tryResolveLinkTimeVal(vecType->getElementCount()));
auto element = _createTypeLayout(context, elementType);
@@ -4944,8 +4945,9 @@ static TypeLayoutResult _createTypeLayout(TypeLayoutContext& context, Type* type
}
else if (auto matType = as<MatrixExpressionType>(type))
{
- size_t rowCount = (size_t)getIntVal(matType->getRowCount());
- size_t colCount = (size_t)getIntVal(matType->getColumnCount());
+ size_t rowCount = (size_t)getIntVal(context.tryResolveLinkTimeVal(matType->getRowCount()));
+ size_t colCount =
+ (size_t)getIntVal(context.tryResolveLinkTimeVal(matType->getColumnCount()));
auto elementType = matType->getElementType();
auto elementResult = _createTypeLayout(context, elementType);
@@ -5031,7 +5033,7 @@ static TypeLayoutResult _createTypeLayout(TypeLayoutContext& context, Type* type
context,
arrayType,
arrayType->getElementType(),
- arrayType->getElementCount());
+ context.tryResolveLinkTimeVal(arrayType->getElementCount()));
}
else if (auto atomicType = as<AtomicType>(type))
{
@@ -5181,7 +5183,7 @@ static TypeLayoutResult _createTypeLayout(TypeLayoutContext& context, Type* type
StructTypeLayoutBuilder typeLayoutBuilder;
StructTypeLayoutBuilder pendingDataTypeLayoutBuilder;
- typeLayoutBuilder.beginLayout(type, rules);
+ typeLayoutBuilder.beginLayout(declRefType, rules);
auto typeLayout = typeLayoutBuilder.getTypeLayout();
_addLayout(context, type, typeLayout);