@@ -1425,6 +1425,16 @@ static RefPtr<TypeLayout> processEntryPointParameter(
1425
1425
1426
1426
return structLayout;
1427
1427
}
1428
+ else if (auto globalGenericParam = declRef.As <GlobalGenericParamDecl>())
1429
+ {
1430
+ auto genParamTypeLayout = new GenericParamTypeLayout ();
1431
+ // we should have already populated ProgramLayout::genericEntryPointParams list at this point,
1432
+ // so we can find the index of this generic param decl in the list
1433
+ genParamTypeLayout->type = type;
1434
+ genParamTypeLayout->paramIndex = findGenericParam (context->shared ->programLayout ->globalGenericParams , globalGenericParam.getDecl ());
1435
+ genParamTypeLayout->findOrAddResourceInfo (LayoutResourceKind::GenericResource)->count ++;
1436
+ return genParamTypeLayout;
1437
+ }
1428
1438
else
1429
1439
{
1430
1440
SLANG_UNEXPECTED (" unhandled type kind" );
@@ -1442,7 +1452,8 @@ static RefPtr<TypeLayout> processEntryPointParameter(
1442
1452
1443
1453
static void collectEntryPointParameters (
1444
1454
ParameterBindingContext* context,
1445
- EntryPointRequest* entryPoint)
1455
+ EntryPointRequest* entryPoint,
1456
+ Substitutions* typeSubst)
1446
1457
{
1447
1458
FuncDecl* entryPointFuncDecl = entryPoint->decl ;
1448
1459
if (!entryPointFuncDecl)
@@ -1507,7 +1518,7 @@ static void collectEntryPointParameters(
1507
1518
auto paramTypeLayout = processEntryPointParameterWithPossibleSemantic (
1508
1519
context,
1509
1520
paramDecl.Ptr (),
1510
- paramDecl->type .type ,
1521
+ paramDecl->type .type -> Substitute (typeSubst). As <Type>() ,
1511
1522
state,
1512
1523
paramVarLayout);
1513
1524
@@ -1539,7 +1550,7 @@ static void collectEntryPointParameters(
1539
1550
auto resultTypeLayout = processEntryPointParameterWithPossibleSemantic (
1540
1551
context,
1541
1552
entryPointFuncDecl,
1542
- resultType,
1553
+ resultType-> Substitute (typeSubst). As <Type>() ,
1543
1554
state,
1544
1555
resultLayout);
1545
1556
@@ -1632,7 +1643,7 @@ static void collectParameters(
1632
1643
for ( auto & entryPoint : translationUnit->entryPoints )
1633
1644
{
1634
1645
context->stage = entryPoint->profile .GetStage ();
1635
- collectEntryPointParameters (context, entryPoint.Ptr ());
1646
+ collectEntryPointParameters (context, entryPoint.Ptr (), nullptr );
1636
1647
}
1637
1648
}
1638
1649
@@ -1891,13 +1902,7 @@ RefPtr<ProgramLayout> specializeProgramLayout(
1891
1902
newProgramLayout = new ProgramLayout ();
1892
1903
newProgramLayout->bindingForHackSampler = programLayout->bindingForHackSampler ;
1893
1904
newProgramLayout->hackSamplerVar = programLayout->hackSamplerVar ;
1894
- for (auto & entryPoint : programLayout->entryPoints )
1895
- {
1896
- RefPtr<EntryPointLayout> newEntryPoint = new EntryPointLayout (*entryPoint);
1897
- // TODO: for now just copy existing entry point layouts, but we eventually need to
1898
- // specialize these as well...
1899
- newProgramLayout->entryPoints .Add (newEntryPoint);
1900
- }
1905
+ newProgramLayout->globalGenericParams = programLayout->globalGenericParams ;
1901
1906
1902
1907
List<RefPtr<TypeLayout>> paramTypeLayouts;
1903
1908
auto globalStructLayout = getGlobalStructLayout (programLayout);
@@ -1919,7 +1924,7 @@ RefPtr<ProgramLayout> specializeProgramLayout(
1919
1924
SharedParameterBindingContext sharedContext;
1920
1925
sharedContext.compileRequest = targetReq->compileRequest ;
1921
1926
sharedContext.defaultLayoutRules = layoutContext.getRulesFamily ();
1922
- sharedContext.programLayout = programLayout ;
1927
+ sharedContext.programLayout = newProgramLayout ;
1923
1928
1924
1929
// Create a sub-context to collect parameters that get
1925
1930
// declared into the global scope
@@ -1928,6 +1933,15 @@ RefPtr<ProgramLayout> specializeProgramLayout(
1928
1933
context.translationUnit = nullptr ;
1929
1934
context.layoutContext = layoutContext;
1930
1935
1936
+
1937
+ for (auto & translationUnit : targetReq->compileRequest ->translationUnits )
1938
+ {
1939
+ for (auto & entryPoint : translationUnit->entryPoints )
1940
+ {
1941
+ collectEntryPointParameters (&context, entryPoint, typeSubst);
1942
+ }
1943
+ }
1944
+
1931
1945
auto constantBufferRules = context.getRulesFamily ()->getConstantBufferRules ();
1932
1946
structLayout->rules = constantBufferRules;
1933
1947
0 commit comments