From bc6b82666fa4deda932c36cea93ee2059e0992b2 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 5 Sep 2025 22:37:34 -0700 Subject: 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. --- source/slang/slang-type-layout.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source/slang/slang-type-layout.cpp') 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(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(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(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); -- cgit v1.2.3