From 499b0253c224e68ceed6e5b6b1ee9cd7d65aad0f Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 30 Jan 2023 19:24:09 -0800 Subject: Make ArrayExpressionType a DeclRefType and define its autodiff extension in stdlib. (#2615) * Allow array parameters in forward diff. * Use type canonicalization instead of coersion. * Reimplement array type. * Fix. * Update test case. --------- Co-authored-by: Yong He --- source/slang/slang-reflection-api.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source/slang/slang-reflection-api.cpp') diff --git a/source/slang/slang-reflection-api.cpp b/source/slang/slang-reflection-api.cpp index 5c5773fec..9c1d48a28 100644 --- a/source/slang/slang-reflection-api.cpp +++ b/source/slang/slang-reflection-api.cpp @@ -149,7 +149,7 @@ static SlangParameterCategory maybeRemapParameterCategory( // of this variable? Type* type = typeLayout->getType(); while (auto arrayType = as(type)) - type = arrayType->baseType; + type = arrayType->getElementType(); switch (spReflectionType_GetKind(convert(type))) { case SLANG_TYPE_KIND_CONSTANT_BUFFER: @@ -462,7 +462,7 @@ SLANG_API size_t spReflectionType_GetElementCount(SlangReflectionType* inType) if(auto arrayType = as(type)) { - return arrayType->arrayLength ? (size_t) getIntVal(arrayType->arrayLength) : 0; + return !arrayType->isUnsized() ? (size_t)getIntVal(arrayType->getElementCount()) : 0; } else if( auto vectorType = as(type)) { @@ -479,7 +479,7 @@ SLANG_API SlangReflectionType* spReflectionType_GetElementType(SlangReflectionTy if(auto arrayType = as(type)) { - return (SlangReflectionType*) arrayType->baseType; + return (SlangReflectionType*) arrayType->getElementType(); } else if( auto parameterGroupType = as(type)) { @@ -631,7 +631,7 @@ SLANG_API SlangResourceShape spReflectionType_GetResourceShape(SlangReflectionTy while(auto arrayType = as(type)) { - type = arrayType->baseType; + type = arrayType->getElementType(); } if(auto textureType = as(type)) @@ -667,7 +667,7 @@ SLANG_API SlangResourceAccess spReflectionType_GetResourceAccess(SlangReflection while(auto arrayType = as(type)) { - type = arrayType->baseType; + type = arrayType->getElementType(); } if(auto textureType = as(type)) @@ -763,7 +763,7 @@ SLANG_API SlangReflectionType* spReflectionType_GetResourceResultType(SlangRefle while(auto arrayType = as(type)) { - type = arrayType->baseType; + type = arrayType->getElementType(); } if (auto textureType = as(type)) @@ -1492,9 +1492,9 @@ namespace Slang LayoutSize elementCount = LayoutSize::infinite(); if( auto arrayType = as(arrayTypeLayout->type) ) { - if( auto elementCountVal = arrayType->arrayLength ) + if( !arrayType->isUnsized()) { - elementCount = LayoutSize::RawValue(getIntVal(elementCountVal)); + elementCount = LayoutSize::RawValue(getIntVal(arrayType->getElementCount())); } } addRangesRec(elementTypeLayout, path, multiplier * elementCount); -- cgit v1.2.3