@@ -1369,13 +1369,15 @@ CXXRecordDecl *hlsl::DeclareNodeOrRecordType(
13691369}
13701370
13711371#ifdef ENABLE_SPIRV_CODEGEN
1372- CXXRecordDecl *hlsl::DeclareVkSampledTexture2DType (
1373- ASTContext &context, DeclContext *declContext, QualType float2Type ,
1374- QualType defaultTextureType) {
1375- // TODO(https://github.com/microsoft/DirectXShaderCompiler/issues/7979): Later
1376- // generalize these to all SampledTexture types.
1372+ CXXRecordDecl *hlsl::DeclareVkSampledTexture2DType (ASTContext &context,
1373+ DeclContext *declContext,
1374+ QualType float2Type,
1375+ QualType int2Type,
1376+ QualType float4Type) {
13771377 BuiltinTypeDeclBuilder Builder (declContext, " SampledTexture2D" ,
13781378 TagDecl::TagKind::TTK_Struct);
1379+
1380+ QualType defaultTextureType = float4Type;
13791381 TemplateTypeParmDecl *TyParamDecl =
13801382 Builder.addTypeTemplateParam (" SampledTextureType" , defaultTextureType);
13811383
@@ -1384,8 +1386,10 @@ CXXRecordDecl *hlsl::DeclareVkSampledTexture2DType(
13841386 QualType paramType = QualType (TyParamDecl->getTypeForDecl (), 0 );
13851387 CXXRecordDecl *recordDecl = Builder.getRecordDecl ();
13861388
1389+ QualType floatType = context.FloatTy ;
1390+ QualType uintType = context.UnsignedIntTy ;
13871391 // Add Sample method
1388- // sampledtype Sample(float2 location)
1392+ // Sample(location)
13891393 CXXMethodDecl *sampleDecl = CreateObjectFunctionDeclarationWithParams (
13901394 context, recordDecl, paramType, ArrayRef<QualType>(float2Type),
13911395 ArrayRef<StringRef>(StringRef (" location" )),
@@ -1394,6 +1398,41 @@ CXXRecordDecl *hlsl::DeclareVkSampledTexture2DType(
13941398 sampleDecl->addAttr (HLSLIntrinsicAttr::CreateImplicit (
13951399 context, " op" , " " ,
13961400 static_cast <int >(hlsl::IntrinsicOp::MOP_Sample)));
1401+ sampleDecl->addAttr (HLSLCXXOverloadAttr::CreateImplicit (context));
1402+
1403+ // Sample(location, offset)
1404+ QualType params2[] = {float2Type, int2Type};
1405+ StringRef names2[] = {" location" , " offset" };
1406+ CXXMethodDecl *sampleDecl2 = CreateObjectFunctionDeclarationWithParams (
1407+ context, recordDecl, paramType, params2, names2,
1408+ context.DeclarationNames .getIdentifier (&context.Idents .get (" Sample" )),
1409+ /* isConst*/ true );
1410+ sampleDecl2->addAttr (HLSLIntrinsicAttr::CreateImplicit (
1411+ context, " op" , " " , static_cast <int >(hlsl::IntrinsicOp::MOP_Sample)));
1412+ sampleDecl2->addAttr (HLSLCXXOverloadAttr::CreateImplicit (context));
1413+
1414+ // Sample(location, offset, clamp)
1415+ QualType params3[] = {float2Type, int2Type, floatType};
1416+ StringRef names3[] = {" location" , " offset" , " clamp" };
1417+ CXXMethodDecl *sampleDecl3 = CreateObjectFunctionDeclarationWithParams (
1418+ context, recordDecl, paramType, params3, names3,
1419+ context.DeclarationNames .getIdentifier (&context.Idents .get (" Sample" )),
1420+ /* isConst*/ true );
1421+ sampleDecl3->addAttr (HLSLIntrinsicAttr::CreateImplicit (
1422+ context, " op" , " " , static_cast <int >(hlsl::IntrinsicOp::MOP_Sample)));
1423+ sampleDecl3->addAttr (HLSLCXXOverloadAttr::CreateImplicit (context));
1424+
1425+ // Sample(location, offset, clamp, status)
1426+ QualType params4[] = {float2Type, int2Type, floatType,
1427+ context.getLValueReferenceType (uintType)};
1428+ StringRef names4[] = {" location" , " offset" , " clamp" , " status" };
1429+ CXXMethodDecl *sampleDecl4 = CreateObjectFunctionDeclarationWithParams (
1430+ context, recordDecl, paramType, params4, names4,
1431+ context.DeclarationNames .getIdentifier (&context.Idents .get (" Sample" )),
1432+ /* isConst*/ true );
1433+ sampleDecl4->addAttr (HLSLIntrinsicAttr::CreateImplicit (
1434+ context, " op" , " " , static_cast <int >(hlsl::IntrinsicOp::MOP_Sample)));
1435+ sampleDecl4->addAttr (HLSLCXXOverloadAttr::CreateImplicit (context));
13971436
13981437 Builder.completeDefinition ();
13991438 return recordDecl;
0 commit comments