diff options
Diffstat (limited to 'source/slang/slang-parameter-binding.cpp')
| -rw-r--r-- | source/slang/slang-parameter-binding.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp index 4ba9e4e03..06d2b1f34 100644 --- a/source/slang/slang-parameter-binding.cpp +++ b/source/slang/slang-parameter-binding.cpp @@ -2216,7 +2216,13 @@ static RefPtr<TypeLayout> processEntryPointVaryingParameter( // A matrix is processed as if it was an array of rows else if (auto matrixType = as<MatrixExpressionType>(type)) { - auto rowCount = getIntVal(matrixType->getRowCount()); + auto foldedRowCountVal = + context->getTargetProgram()->getProgram()->tryFoldIntVal(matrixType->getRowCount()); + IntegerLiteralValue rowCount = 0; + if (!foldedRowCountVal) + { + rowCount = getIntVal(foldedRowCountVal); + } return processSimpleEntryPointParameter( context, matrixType, @@ -2228,10 +2234,15 @@ static RefPtr<TypeLayout> processEntryPointVaryingParameter( { // Note: Bad Things will happen if we have an array input // without a semantic already being enforced. + UInt elementCount = 0; - auto elementCount = (UInt)getIntVal(arrayType->getElementCount()); - if (arrayType->isUnsized()) - elementCount = 0; + if (!arrayType->isUnsized()) + { + auto intVal = context->getTargetProgram()->getProgram()->tryFoldIntVal( + arrayType->getElementCount()); + if (intVal) + elementCount = (UInt)getIntVal(intVal); + } // We use the first element to derive the layout for the element type auto elementTypeLayout = processEntryPointVaryingParameter( @@ -2456,7 +2467,11 @@ static RefPtr<TypeLayout> processEntryPointVaryingParameter( // for (auto fieldTypeResInfo : fieldTypeLayout->resourceInfos) { - SLANG_RELEASE_ASSERT(fieldTypeResInfo.count != 0); + // If the field is a Conditional<T, false> type, then it could have 0 size. + // We should skip this field if it has no use of layout units. + if (fieldTypeResInfo.count == 0) + continue; + auto kind = fieldTypeResInfo.kind; auto structTypeResInfo = structLayout->findOrAddResourceInfo(kind); |
