summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-check-decl.cpp18
-rw-r--r--source/slang/slang-diagnostic-defs.h10
-rw-r--r--source/slang/slang-parameter-binding.cpp2
-rw-r--r--source/slang/slang-type-layout.cpp12
-rw-r--r--source/slang/slang-type-layout.h10
5 files changed, 18 insertions, 34 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 4711eaddd..4362f0926 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -2922,13 +2922,6 @@ void SemanticsDeclBodyVisitor::checkVarDeclCommon(VarDeclBase* varDecl)
if (auto elementType = getConstantBufferElementType(varDecl->getType()))
{
- if (doesTypeHaveTag(elementType, TypeTag::Incomplete))
- {
- getSink()->diagnose(
- varDecl->type.exp->loc,
- Diagnostics::incompleteTypeCannotBeUsedInBuffer,
- elementType);
- }
if (doesTypeHaveTag(elementType, TypeTag::Unsized))
{
// If the element type is unsized, it can only be an array of resource types that we can
@@ -2947,17 +2940,6 @@ void SemanticsDeclBodyVisitor::checkVarDeclCommon(VarDeclBase* varDecl)
}
}
}
- else if (varDecl->findModifier<HLSLUniformModifier>())
- {
- auto varType = varDecl->getType();
- if (doesTypeHaveTag(varType, TypeTag::Incomplete))
- {
- getSink()->diagnose(
- varDecl->type.exp->loc,
- Diagnostics::incompleteTypeCannotBeUsedInUniformParameter,
- varType);
- }
- }
maybeRegisterDifferentiableType(getASTBuilder(), varDecl->getType());
}
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h
index 2febd317e..64b1423ac 100644
--- a/source/slang/slang-diagnostic-defs.h
+++ b/source/slang/slang-diagnostic-defs.h
@@ -1455,16 +1455,6 @@ DIAGNOSTIC(
"modifier '$0' is redundant or conflicting with existing modifier '$1'")
DIAGNOSTIC(31203, Error, cannotExportIncompleteType, "cannot export incomplete type '$0'")
DIAGNOSTIC(
- 31204,
- Error,
- incompleteTypeCannotBeUsedInBuffer,
- "incomplete type '$0' cannot be used in a buffer")
-DIAGNOSTIC(
- 31205,
- Error,
- incompleteTypeCannotBeUsedInUniformParameter,
- "incomplete type '$0' cannot be used in a uniform parameter")
-DIAGNOSTIC(
31206,
Error,
memoryQualifierNotAllowedOnANonImageTypeParameter,
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp
index 4b91056fc..b79f96022 100644
--- a/source/slang/slang-parameter-binding.cpp
+++ b/source/slang/slang-parameter-binding.cpp
@@ -2420,7 +2420,7 @@ static RefPtr<TypeLayout> processEntryPointVaryingParameter(
if (auto structDeclRef = declRef.as<StructDecl>())
{
RefPtr<StructTypeLayout> structLayout = new StructTypeLayout();
- structLayout->type = type;
+ structLayout->type = declRefType;
// We will recursively walk the fields of a `struct` type
// to compute layouts for those fields.
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);
diff --git a/source/slang/slang-type-layout.h b/source/slang/slang-type-layout.h
index bcb842013..84840c043 100644
--- a/source/slang/slang-type-layout.h
+++ b/source/slang/slang-type-layout.h
@@ -1231,6 +1231,16 @@ struct TypeLayoutContext
}
return result;
}
+
+ IntVal* tryResolveLinkTimeVal(IntVal* inVal) const
+ {
+ if (!programLayout)
+ return inVal;
+ auto constIntVal = programLayout->getProgram()->tryFoldIntVal(inVal);
+ if (constIntVal)
+ return constIntVal;
+ return inVal;
+ }
};
//