@@ -1388,6 +1388,8 @@ CXXRecordDecl *hlsl::DeclareVkSampledTexture2DType(ASTContext &context,
13881388
13891389 QualType floatType = context.FloatTy ;
13901390 QualType uintType = context.UnsignedIntTy ;
1391+ QualType intType = context.IntTy ;
1392+
13911393 // Add Sample method
13921394 // Sample(location)
13931395 CXXMethodDecl *sampleDecl = CreateObjectFunctionDeclarationWithParams (
@@ -1489,6 +1491,101 @@ CXXRecordDecl *hlsl::DeclareVkSampledTexture2DType(ASTContext &context,
14891491 context, " op" , " " , static_cast <int >(hlsl::IntrinsicOp::MOP_Gather)));
14901492 gatherDecl3->addAttr (HLSLCXXOverloadAttr::CreateImplicit (context));
14911493
1494+ // GetDimensions(width, height)
1495+ QualType getDimensionsParams2[] = {context.getLValueReferenceType (uintType),
1496+ context.getLValueReferenceType (uintType)};
1497+ StringRef getDimensionsNames2[] = {" width" , " height" };
1498+ CXXMethodDecl *getDimensionsDecl2 = CreateObjectFunctionDeclarationWithParams (
1499+ context, recordDecl, context.VoidTy , getDimensionsParams2,
1500+ getDimensionsNames2,
1501+ context.DeclarationNames .getIdentifier (
1502+ &context.Idents .get (" GetDimensions" )),
1503+ /* isConst*/ true );
1504+ getDimensionsDecl2->addAttr (HLSLIntrinsicAttr::CreateImplicit (
1505+ context, " op" , " " ,
1506+ static_cast <int >(hlsl::IntrinsicOp::MOP_GetDimensions)));
1507+ // GetDimensions(width, height) float version
1508+ QualType getDimensionsParams2Float[] = {
1509+ context.getLValueReferenceType (floatType),
1510+ context.getLValueReferenceType (floatType)};
1511+ StringRef getDimensionsNames2Float[] = {" width" , " height" };
1512+ CXXMethodDecl *getDimensionsDecl2Float =
1513+ CreateObjectFunctionDeclarationWithParams (
1514+ context, recordDecl, context.VoidTy , getDimensionsParams2Float,
1515+ getDimensionsNames2Float,
1516+ context.DeclarationNames .getIdentifier (
1517+ &context.Idents .get (" GetDimensions" )),
1518+ /* isConst*/ true );
1519+ getDimensionsDecl2Float->addAttr (HLSLIntrinsicAttr::CreateImplicit (
1520+ context, " op" , " " ,
1521+ static_cast <int >(hlsl::IntrinsicOp::MOP_GetDimensions)));
1522+ // GetDimensions(width, height) int version
1523+ QualType getDimensionsParams2Int[] = {
1524+ context.getLValueReferenceType (intType),
1525+ context.getLValueReferenceType (intType)};
1526+ StringRef getDimensionsNames2Int[] = {" width" , " height" };
1527+ CXXMethodDecl *getDimensionsDecl2Int =
1528+ CreateObjectFunctionDeclarationWithParams (
1529+ context, recordDecl, context.VoidTy , getDimensionsParams2Int,
1530+ getDimensionsNames2Int,
1531+ context.DeclarationNames .getIdentifier (
1532+ &context.Idents .get (" GetDimensions" )),
1533+ /* isConst*/ true );
1534+ getDimensionsDecl2Int->addAttr (HLSLIntrinsicAttr::CreateImplicit (
1535+ context, " op" , " " ,
1536+ static_cast <int >(hlsl::IntrinsicOp::MOP_GetDimensions)));
1537+
1538+ // GetDimensions(mipLevel, width, height, numLevels)
1539+ QualType getDimensionsParams4[] = {uintType,
1540+ context.getLValueReferenceType (uintType),
1541+ context.getLValueReferenceType (uintType),
1542+ context.getLValueReferenceType (uintType)};
1543+ StringRef getDimensionsNames4[] = {" mipLevel" , " width" , " height" ,
1544+ " numLevels" };
1545+ CXXMethodDecl *getDimensionsDecl4 = CreateObjectFunctionDeclarationWithParams (
1546+ context, recordDecl, context.VoidTy , getDimensionsParams4,
1547+ getDimensionsNames4,
1548+ context.DeclarationNames .getIdentifier (
1549+ &context.Idents .get (" GetDimensions" )),
1550+ /* isConst*/ true );
1551+ getDimensionsDecl4->addAttr (HLSLIntrinsicAttr::CreateImplicit (
1552+ context, " op" , " " ,
1553+ static_cast <int >(hlsl::IntrinsicOp::MOP_GetDimensions)));
1554+ // GetDimensions(mipLevel, width, height, numLevels) float version
1555+ QualType getDimensionsParams4Float[] = {
1556+ uintType, context.getLValueReferenceType (floatType),
1557+ context.getLValueReferenceType (floatType),
1558+ context.getLValueReferenceType (floatType)};
1559+ StringRef getDimensionsNames4Float[] = {" mipLevel" , " width" , " height" ,
1560+ " numLevels" };
1561+ CXXMethodDecl *getDimensionsDecl4Float =
1562+ CreateObjectFunctionDeclarationWithParams (
1563+ context, recordDecl, context.VoidTy , getDimensionsParams4Float,
1564+ getDimensionsNames4Float,
1565+ context.DeclarationNames .getIdentifier (
1566+ &context.Idents .get (" GetDimensions" )),
1567+ /* isConst*/ true );
1568+ getDimensionsDecl4Float->addAttr (HLSLIntrinsicAttr::CreateImplicit (
1569+ context, " op" , " " ,
1570+ static_cast <int >(hlsl::IntrinsicOp::MOP_GetDimensions)));
1571+ // GetDimensions(mipLevel, width, height, numLevels) int version
1572+ QualType getDimensionsParams4Int[] = {
1573+ uintType, context.getLValueReferenceType (intType),
1574+ context.getLValueReferenceType (intType),
1575+ context.getLValueReferenceType (intType)};
1576+ StringRef getDimensionsNames4Int[] = {" mipLevel" , " width" , " height" ,
1577+ " numLevels" };
1578+ CXXMethodDecl *getDimensionsDecl4Int =
1579+ CreateObjectFunctionDeclarationWithParams (
1580+ context, recordDecl, context.VoidTy , getDimensionsParams4Int,
1581+ getDimensionsNames4Int,
1582+ context.DeclarationNames .getIdentifier (
1583+ &context.Idents .get (" GetDimensions" )),
1584+ /* isConst*/ true );
1585+ getDimensionsDecl4Int->addAttr (HLSLIntrinsicAttr::CreateImplicit (
1586+ context, " op" , " " ,
1587+ static_cast <int >(hlsl::IntrinsicOp::MOP_GetDimensions)));
1588+
14921589 Builder.completeDefinition ();
14931590 return recordDecl;
14941591}
0 commit comments