@@ -103,31 +103,26 @@ bool IsHLSLNumericOrAggregateOfNumericType(clang::QualType type) {
103
103
BuiltinTy->getKind () != BuiltinType::Kind::Char_S;
104
104
}
105
105
106
- bool IsHLSLNumericUserDefinedType (clang::QualType type) {
107
- const clang::Type *Ty = type.getCanonicalType ().getTypePtr ();
106
+ // In some cases we need record types that are annotatable and trivially
107
+ // copyable from outside the shader. This excludes resource types which may be
108
+ // trivially copyable inside the shader, and builtin matrix and vector types
109
+ // which can't be annotated. But includes UDTs of trivially copyable data and
110
+ // the builtin trivially copyable raytracing structs.
111
+ bool IsHLSLCopyableAnnotatableRecord (clang::QualType QT) {
112
+ const clang::Type *Ty = QT.getCanonicalType ().getTypePtr ();
108
113
if (const RecordType *RT = dyn_cast<RecordType>(Ty)) {
109
114
const RecordDecl *RD = RT->getDecl ();
110
- if (!IsUserDefinedRecordType (type ))
115
+ if (!IsUserDefinedRecordType (QT ))
111
116
return false ;
112
- for (auto member : RD->fields ()) {
113
- if (!IsHLSLNumericOrAggregateOfNumericType (member ->getType ()))
117
+ for (auto Member : RD->fields ()) {
118
+ if (!IsHLSLNumericOrAggregateOfNumericType (Member ->getType ()))
114
119
return false ;
115
120
}
116
121
return true ;
117
122
}
118
123
return false ;
119
124
}
120
125
121
- // In some cases we need record types that are annotatable and trivially
122
- // copyable from outside the shader. This excludes resource types which may be
123
- // trivially copyable inside the shader, and builtin matrix and vector types
124
- // which can't be annotated. But includes UDTs of trivially copyable data and
125
- // the builtin trivially copyable raytracing structs.
126
- bool IsHLSLCopyableAnnotatableRecord (clang::QualType QT) {
127
- return IsHLSLNumericUserDefinedType (QT) ||
128
- IsHLSLBuiltinRayAttributeStruct (QT);
129
- }
130
-
131
126
bool IsHLSLBuiltinRayAttributeStruct (clang::QualType QT) {
132
127
QT = QT.getCanonicalType ();
133
128
const clang::Type *Ty = QT.getTypePtr ();
@@ -609,7 +604,8 @@ bool IsUserDefinedRecordType(clang::QualType QT) {
609
604
const clang::Type *Ty = QT.getCanonicalType ().getTypePtr ();
610
605
if (const RecordType *RT = dyn_cast<RecordType>(Ty)) {
611
606
const RecordDecl *RD = RT->getDecl ();
612
- if (RD->isImplicit ())
607
+ // Built-in ray tracing struct types are considered user defined types.
608
+ if (RD->isImplicit () && !IsHLSLBuiltinRayAttributeStruct (QT))
613
609
return false ;
614
610
if (auto TD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
615
611
if (TD->getSpecializedTemplate ()->isImplicit ())
0 commit comments