diff options
| author | Yong He <yonghe@outlook.com> | 2018-01-20 02:48:12 -0500 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2018-01-20 02:48:12 -0500 |
| commit | 913f4d09b91e3fd7449468b135881c940cacb3c0 (patch) | |
| tree | 955ea56acc362f3b4ae071b93bbccfffc9799d3d | |
| parent | 6dd64fd9d31f29b07fcf63e743066efabbc1b092 (diff) | |
bug fixes
fixes #373
fixes bug that misses current translation unit's scope when resolving entry-point global type argument expression.
| -rw-r--r-- | source/slang/check.cpp | 8 | ||||
| -rw-r--r-- | source/slang/syntax.cpp | 2 | ||||
| -rw-r--r-- | tests/compute/array-param.slang | 19 | ||||
| -rw-r--r-- | tests/compute/array-param.slang.expected.txt | 8 |
4 files changed, 34 insertions, 3 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index 7cfb317fb..c4aa9bfba 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -6944,14 +6944,18 @@ namespace Slang entryPoint->decl = entryPointFuncDecl; // Lookup generic parameter types in global scope + List<RefPtr<Scope>> scopesToTry; + scopesToTry.Add(entryPoint->getTranslationUnit()->SyntaxNode->scope); + for (auto & module : entryPoint->compileRequest->loadedModulesList) + scopesToTry.Add(module->moduleDecl->scope); for (auto name : entryPoint->genericParameterTypeNames) { // parse type name RefPtr<Type> type; - for (auto & module : entryPoint->compileRequest->loadedModulesList) + for (auto & s : scopesToTry) { RefPtr<Expr> typeExpr = entryPoint->compileRequest->parseTypeString(entryPoint->getTranslationUnit(), - name, module->moduleDecl->scope); + name, s); DiagnosticSink nSink; SemanticsVisitor visitor( &nSink, diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp index 552f1dc56..85a702726 100644 --- a/source/slang/syntax.cpp +++ b/source/slang/syntax.cpp @@ -355,7 +355,7 @@ void Type::accept(IValVisitor* visitor, void* extra) auto arrType = type->AsArrayType(); if (!arrType) return false; - return (ArrayLength == arrType->ArrayLength && baseType->Equals(arrType->baseType.Ptr())); + return (ArrayLength->EqualsVal(arrType->ArrayLength) && baseType->Equals(arrType->baseType.Ptr())); } RefPtr<Val> ArrayExpressionType::SubstituteImpl(SubstitutionSet subst, int* ioDiff) diff --git a/tests/compute/array-param.slang b/tests/compute/array-param.slang new file mode 100644 index 000000000..78ca52518 --- /dev/null +++ b/tests/compute/array-param.slang @@ -0,0 +1,19 @@ +//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +RWStructuredBuffer<int> outputBuffer; +void writeArray(inout float3 a[4]) +{ + a[0] = float3(1, 1, 1); + a[1] = float3(1, 1, 1); + a[2] = float3(1, 1, 1); + a[3] = float3(1, 1, 1); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + float3 b[4]; + writeArray(b); + outputBuffer[dispatchThreadID.x] = b[0].x; +}
\ No newline at end of file diff --git a/tests/compute/array-param.slang.expected.txt b/tests/compute/array-param.slang.expected.txt new file mode 100644 index 000000000..61b9a3dcd --- /dev/null +++ b/tests/compute/array-param.slang.expected.txt @@ -0,0 +1,8 @@ +0 +3F80000 +0 +3F80000 +0 +3F80000 +0 +3F80000
\ No newline at end of file |
