@@ -513,6 +513,17 @@ Modifier* SemanticsVisitor::validateAttribute(
513
513
514
514
inputAttachmentIndexLayoutAttribute->location = location->getValue ();
515
515
}
516
+ else if (auto locationLayoutAttr = as<GLSLLocationAttribute>(attr))
517
+ {
518
+ if (attr->args .getCount () != 1 )
519
+ return nullptr ;
520
+
521
+ auto location = checkConstantIntVal (attr->args [0 ]);
522
+ if (!location)
523
+ return nullptr ;
524
+
525
+ locationLayoutAttr->value = int32_t (location->getValue ());
526
+ }
516
527
else if (auto bindingAttr = as<GLSLBindingAttribute>(attr))
517
528
{
518
529
// This must be vk::binding or gl::binding (as specified in core.meta.slang under
@@ -1242,12 +1253,22 @@ ASTNodeType getModifierConflictGroupKind(ASTNodeType modifierType)
1242
1253
return ASTNodeType::OutModifier;
1243
1254
1244
1255
// Modifiers that are their own exclusive group.
1245
- case ASTNodeType::GLSLLayoutModifier:
1246
- case ASTNodeType::GLSLParsedLayoutModifier:
1247
- case ASTNodeType::GLSLLocationLayoutModifier:
1248
1256
case ASTNodeType::GLSLInputAttachmentIndexLayoutAttribute:
1249
1257
case ASTNodeType::GLSLOffsetLayoutAttribute:
1250
1258
case ASTNodeType::GLSLUnparsedLayoutModifier:
1259
+ case ASTNodeType::UncheckedGLSLBindingLayoutAttribute:
1260
+ case ASTNodeType::UncheckedGLSLSetLayoutAttribute:
1261
+ case ASTNodeType::UncheckedGLSLOffsetLayoutAttribute:
1262
+ case ASTNodeType::UncheckedGLSLInputAttachmentIndexLayoutAttribute:
1263
+ case ASTNodeType::UncheckedGLSLLocationLayoutAttribute:
1264
+ case ASTNodeType::UncheckedGLSLIndexLayoutAttribute:
1265
+ case ASTNodeType::UncheckedGLSLConstantIdAttribute:
1266
+ case ASTNodeType::UncheckedGLSLRayPayloadAttribute:
1267
+ case ASTNodeType::UncheckedGLSLRayPayloadInAttribute:
1268
+ case ASTNodeType::UncheckedGLSLHitObjectAttributesAttribute:
1269
+ case ASTNodeType::UncheckedGLSLCallablePayloadAttribute:
1270
+ case ASTNodeType::UncheckedGLSLCallablePayloadInAttribute:
1271
+ case ASTNodeType::GLSLBufferDataLayoutModifier:
1251
1272
case ASTNodeType::GLSLLayoutModifierGroupMarker:
1252
1273
case ASTNodeType::GLSLLayoutModifierGroupBegin:
1253
1274
case ASTNodeType::GLSLLayoutModifierGroupEnd:
@@ -1321,12 +1342,10 @@ bool isModifierAllowedOnDecl(bool isGLSLInput, ASTNodeType modifierType, Decl* d
1321
1342
case ASTNodeType::InModifier:
1322
1343
case ASTNodeType::InOutModifier:
1323
1344
case ASTNodeType::OutModifier:
1324
- case ASTNodeType::GLSLLayoutModifier:
1325
- case ASTNodeType::GLSLParsedLayoutModifier:
1326
- case ASTNodeType::GLSLLocationLayoutModifier:
1327
1345
case ASTNodeType::GLSLInputAttachmentIndexLayoutAttribute:
1328
1346
case ASTNodeType::GLSLOffsetLayoutAttribute:
1329
1347
case ASTNodeType::GLSLUnparsedLayoutModifier:
1348
+ case ASTNodeType::UncheckedGLSLLayoutAttribute:
1330
1349
case ASTNodeType::GLSLLayoutModifierGroupMarker:
1331
1350
case ASTNodeType::GLSLLayoutModifierGroupBegin:
1332
1351
case ASTNodeType::GLSLLayoutModifierGroupEnd:
@@ -1502,14 +1521,28 @@ AttributeBase* SemanticsVisitor::checkGLSLLayoutAttribute(
1502
1521
1503
1522
SLANG_ASSERT (uncheckedAttr->args .getCount () == 2 );
1504
1523
}
1505
- else if (as<UncheckedGLSLOffsetLayoutAttribute>(uncheckedAttr))
1506
- {
1507
- attr = m_astBuilder->create <GLSLOffsetLayoutAttribute>();
1524
+
1525
+ #define CASE (UncheckedType, CheckedType ) \
1526
+ else if (as<UncheckedType>(uncheckedAttr)) \
1527
+ { \
1528
+ attr = m_astBuilder->create <CheckedType>(); \
1508
1529
}
1530
+
1531
+ CASE (UncheckedGLSLOffsetLayoutAttribute, GLSLOffsetLayoutAttribute)
1532
+ CASE (UncheckedGLSLInputAttachmentIndexLayoutAttribute, GLSLInputAttachmentIndexLayoutAttribute)
1533
+ CASE (UncheckedGLSLLocationLayoutAttribute, GLSLLocationAttribute)
1534
+ CASE (UncheckedGLSLIndexLayoutAttribute, GLSLIndexAttribute)
1535
+ CASE (UncheckedGLSLConstantIdAttribute, VkConstantIdAttribute)
1536
+ CASE (UncheckedGLSLRayPayloadAttribute, VulkanRayPayloadAttribute)
1537
+ CASE (UncheckedGLSLRayPayloadInAttribute, VulkanRayPayloadInAttribute)
1538
+ CASE (UncheckedGLSLHitObjectAttributesAttribute, VulkanHitObjectAttributesAttribute)
1539
+ CASE (UncheckedGLSLCallablePayloadAttribute, VulkanCallablePayloadAttribute)
1540
+ CASE (UncheckedGLSLCallablePayloadInAttribute, VulkanCallablePayloadInAttribute)
1509
1541
else
1510
1542
{
1511
1543
getSink ()->diagnose (uncheckedAttr, Diagnostics::unrecognizedGLSLLayoutQualifier);
1512
1544
}
1545
+ #undef CASE
1513
1546
1514
1547
if (attr)
1515
1548
{
@@ -1559,21 +1592,6 @@ Modifier* SemanticsVisitor::checkModifier(
1559
1592
return checkedAttr;
1560
1593
}
1561
1594
1562
- if (auto glslLayoutAttribute = as<UncheckedGLSLLayoutAttribute>(m))
1563
- {
1564
- return checkGLSLLayoutAttribute (glslLayoutAttribute, syntaxNode);
1565
- }
1566
-
1567
- if (const auto glslImplicitOffsetAttribute = as<GLSLImplicitOffsetLayoutAttribute>(m))
1568
- {
1569
- auto offsetAttr = m_astBuilder->create <GLSLOffsetLayoutAttribute>();
1570
- offsetAttr->loc = glslImplicitOffsetAttribute->loc ;
1571
-
1572
- // Offset constant folding computation is deferred until all other modifiers are checked to
1573
- // ensure bindinig is checked first.
1574
- return offsetAttr;
1575
- }
1576
-
1577
1595
if (auto decl = as<Decl>(syntaxNode))
1578
1596
{
1579
1597
auto moduleDecl = getModuleDecl (decl);
@@ -1591,6 +1609,21 @@ Modifier* SemanticsVisitor::checkModifier(
1591
1609
}
1592
1610
}
1593
1611
1612
+ if (auto glslLayoutAttribute = as<UncheckedGLSLLayoutAttribute>(m))
1613
+ {
1614
+ return checkGLSLLayoutAttribute (glslLayoutAttribute, syntaxNode);
1615
+ }
1616
+
1617
+ if (const auto glslImplicitOffsetAttribute = as<GLSLImplicitOffsetLayoutAttribute>(m))
1618
+ {
1619
+ auto offsetAttr = m_astBuilder->create <GLSLOffsetLayoutAttribute>();
1620
+ offsetAttr->loc = glslImplicitOffsetAttribute->loc ;
1621
+
1622
+ // Offset constant folding computation is deferred until all other modifiers are checked to
1623
+ // ensure bindinig is checked first.
1624
+ return offsetAttr;
1625
+ }
1626
+
1594
1627
MemoryQualifierSetModifier::Flags::MemoryQualifiersBit memoryQualifierBit =
1595
1628
MemoryQualifierSetModifier::Flags::kNone ;
1596
1629
if (as<GloballyCoherentModifier>(m))
0 commit comments