Skip to content

Commit 913f4d0

Browse files
committed
bug fixes
fixes shader-slang#373 fixes bug that misses current translation unit's scope when resolving entry-point global type argument expression.
1 parent 6dd64fd commit 913f4d0

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

source/slang/check.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -6944,14 +6944,18 @@ namespace Slang
69446944
entryPoint->decl = entryPointFuncDecl;
69456945

69466946
// Lookup generic parameter types in global scope
6947+
List<RefPtr<Scope>> scopesToTry;
6948+
scopesToTry.Add(entryPoint->getTranslationUnit()->SyntaxNode->scope);
6949+
for (auto & module : entryPoint->compileRequest->loadedModulesList)
6950+
scopesToTry.Add(module->moduleDecl->scope);
69476951
for (auto name : entryPoint->genericParameterTypeNames)
69486952
{
69496953
// parse type name
69506954
RefPtr<Type> type;
6951-
for (auto & module : entryPoint->compileRequest->loadedModulesList)
6955+
for (auto & s : scopesToTry)
69526956
{
69536957
RefPtr<Expr> typeExpr = entryPoint->compileRequest->parseTypeString(entryPoint->getTranslationUnit(),
6954-
name, module->moduleDecl->scope);
6958+
name, s);
69556959
DiagnosticSink nSink;
69566960
SemanticsVisitor visitor(
69576961
&nSink,

source/slang/syntax.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
355355
auto arrType = type->AsArrayType();
356356
if (!arrType)
357357
return false;
358-
return (ArrayLength == arrType->ArrayLength && baseType->Equals(arrType->baseType.Ptr()));
358+
return (ArrayLength->EqualsVal(arrType->ArrayLength) && baseType->Equals(arrType->baseType.Ptr()));
359359
}
360360

361361
RefPtr<Val> ArrayExpressionType::SubstituteImpl(SubstitutionSet subst, int* ioDiff)

tests/compute/array-param.slang

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
2+
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
3+
4+
RWStructuredBuffer<int> outputBuffer;
5+
void writeArray(inout float3 a[4])
6+
{
7+
a[0] = float3(1, 1, 1);
8+
a[1] = float3(1, 1, 1);
9+
a[2] = float3(1, 1, 1);
10+
a[3] = float3(1, 1, 1);
11+
}
12+
13+
[numthreads(4, 1, 1)]
14+
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
15+
{
16+
float3 b[4];
17+
writeArray(b);
18+
outputBuffer[dispatchThreadID.x] = b[0].x;
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
0
2+
3F80000
3+
0
4+
3F80000
5+
0
6+
3F80000
7+
0
8+
3F80000

0 commit comments

Comments
 (0)