|
@@ -1215,23 +1215,7 @@ unsigned CGMSHLSLRuntime::AddTypeAnnotation(QualType Ty,
|
|
AddTypeAnnotation(GetHLSLResourceResultType(Ty), dxilTypeSys, arrayEltSize);
|
|
AddTypeAnnotation(GetHLSLResourceResultType(Ty), dxilTypeSys, arrayEltSize);
|
|
// Resources don't count towards cbuffer size.
|
|
// Resources don't count towards cbuffer size.
|
|
return 0;
|
|
return 0;
|
|
- } else if (const RecordType *RT = paramTy->getAsStructureType()) {
|
|
|
|
- RecordDecl *RD = RT->getDecl();
|
|
|
|
- llvm::StructType *ST = CGM.getTypes().ConvertRecordDeclType(RD);
|
|
|
|
- // Skip if already created.
|
|
|
|
- if (DxilStructAnnotation *annotation = dxilTypeSys.GetStructAnnotation(ST)) {
|
|
|
|
- unsigned structSize = annotation->GetCBufferSize();
|
|
|
|
- return structSize;
|
|
|
|
- }
|
|
|
|
- DxilStructAnnotation *annotation = dxilTypeSys.AddStructAnnotation(ST,
|
|
|
|
- GetNumTemplateArgsForRecordDecl(RT->getDecl()));
|
|
|
|
- DxilPayloadAnnotation *payloadAnnotation = nullptr;
|
|
|
|
- if (ValidatePayloadDecl(RT->getDecl(), *m_pHLModule->GetShaderModel(), CGM.getDiags(), CGM.getCodeGenOpts()))
|
|
|
|
- payloadAnnotation = dxilTypeSys.AddPayloadAnnotation(ST);
|
|
|
|
- unsigned size = ConstructStructAnnotation(annotation, payloadAnnotation, RD, dxilTypeSys);
|
|
|
|
- // Resources don't count towards cbuffer size.
|
|
|
|
- return IsHLSLResourceType(Ty) ? 0 : size;
|
|
|
|
- } else if (const RecordType *RT = dyn_cast<RecordType>(paramTy)) {
|
|
|
|
|
|
+ } else if (const RecordType *RT = paramTy->getAs<RecordType>()) {
|
|
// For this pointer.
|
|
// For this pointer.
|
|
RecordDecl *RD = RT->getDecl();
|
|
RecordDecl *RD = RT->getDecl();
|
|
llvm::StructType *ST = CGM.getTypes().ConvertRecordDeclType(RD);
|
|
llvm::StructType *ST = CGM.getTypes().ConvertRecordDeclType(RD);
|
|
@@ -1245,7 +1229,9 @@ unsigned CGMSHLSLRuntime::AddTypeAnnotation(QualType Ty,
|
|
DxilPayloadAnnotation* payloadAnnotation = nullptr;
|
|
DxilPayloadAnnotation* payloadAnnotation = nullptr;
|
|
if (ValidatePayloadDecl(RT->getDecl(), *m_pHLModule->GetShaderModel(), CGM.getDiags(), CGM.getCodeGenOpts()))
|
|
if (ValidatePayloadDecl(RT->getDecl(), *m_pHLModule->GetShaderModel(), CGM.getDiags(), CGM.getCodeGenOpts()))
|
|
payloadAnnotation = dxilTypeSys.AddPayloadAnnotation(ST);
|
|
payloadAnnotation = dxilTypeSys.AddPayloadAnnotation(ST);
|
|
- return ConstructStructAnnotation(annotation, payloadAnnotation, RD, dxilTypeSys);
|
|
|
|
|
|
+ unsigned size = ConstructStructAnnotation(annotation, payloadAnnotation, RD, dxilTypeSys);
|
|
|
|
+ // Resources don't count towards cbuffer size.
|
|
|
|
+ return IsHLSLResourceType(Ty) ? 0 : size;
|
|
} else if (IsStringType(Ty)) {
|
|
} else if (IsStringType(Ty)) {
|
|
// string won't be included in cbuffer
|
|
// string won't be included in cbuffer
|
|
return 0;
|
|
return 0;
|
|
@@ -3177,10 +3163,7 @@ static void CollectScalarTypes(std::vector<QualType> &ScalarTys, QualType Ty) {
|
|
CollectScalarTypes(ScalarTys, EltTy);
|
|
CollectScalarTypes(ScalarTys, EltTy);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- const RecordType *RT = Ty->getAsStructureType();
|
|
|
|
- // For CXXRecord.
|
|
|
|
- if (!RT)
|
|
|
|
- RT = Ty->getAs<RecordType>();
|
|
|
|
|
|
+ const RecordType *RT = Ty->getAs<RecordType>();
|
|
RecordDecl *RD = RT->getDecl();
|
|
RecordDecl *RD = RT->getDecl();
|
|
for (FieldDecl *field : RD->fields())
|
|
for (FieldDecl *field : RD->fields())
|
|
CollectScalarTypes(ScalarTys, field->getType());
|
|
CollectScalarTypes(ScalarTys, field->getType());
|
|
@@ -3994,7 +3977,7 @@ void CGMSHLSLRuntime::FlattenValToInitList(CodeGenFunction &CGF, SmallVector<Val
|
|
elts.emplace_back(Builder.CreateLoad(val));
|
|
elts.emplace_back(Builder.CreateLoad(val));
|
|
eltTys.emplace_back(Ty);
|
|
eltTys.emplace_back(Ty);
|
|
} else {
|
|
} else {
|
|
- RecordDecl *RD = Ty->getAsStructureType()->getDecl();
|
|
|
|
|
|
+ const RecordDecl *RD = Ty->getAs<RecordType>()->getDecl();
|
|
const CGRecordLayout& RL = CGF.getTypes().getCGRecordLayout(RD);
|
|
const CGRecordLayout& RL = CGF.getTypes().getCGRecordLayout(RD);
|
|
|
|
|
|
// Take care base.
|
|
// Take care base.
|
|
@@ -4124,10 +4107,7 @@ static void AddMissingCastOpsInInitList(SmallVector<Value *, 4> &elts, SmallVect
|
|
// Skip hlsl object.
|
|
// Skip hlsl object.
|
|
idx++;
|
|
idx++;
|
|
} else {
|
|
} else {
|
|
- const RecordType *RT = Ty->getAsStructureType();
|
|
|
|
- // For CXXRecord.
|
|
|
|
- if (!RT)
|
|
|
|
- RT = Ty->getAs<RecordType>();
|
|
|
|
|
|
+ const RecordType *RT = Ty->getAs<RecordType>();
|
|
RecordDecl *RD = RT->getDecl();
|
|
RecordDecl *RD = RT->getDecl();
|
|
// Take care base.
|
|
// Take care base.
|
|
if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
|
|
if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
|
|
@@ -4210,10 +4190,7 @@ static void StoreInitListToDestPtr(Value *DestPtr,
|
|
} else {
|
|
} else {
|
|
Constant *zero = Builder.getInt32(0);
|
|
Constant *zero = Builder.getInt32(0);
|
|
|
|
|
|
- const RecordType *RT = Type->getAsStructureType();
|
|
|
|
- // For CXXRecord.
|
|
|
|
- if (!RT)
|
|
|
|
- RT = Type->getAs<RecordType>();
|
|
|
|
|
|
+ const RecordType *RT = Type->getAs<RecordType>();
|
|
RecordDecl *RD = RT->getDecl();
|
|
RecordDecl *RD = RT->getDecl();
|
|
const CGRecordLayout &RL = Types.getCGRecordLayout(RD);
|
|
const CGRecordLayout &RL = Types.getCGRecordLayout(RD);
|
|
// Take care base.
|
|
// Take care base.
|
|
@@ -5353,7 +5330,7 @@ void CGMSHLSLRuntime::FlattenAggregatePtrToGepList(
|
|
EltTyList.push_back(Type);
|
|
EltTyList.push_back(Type);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- const clang::RecordType *RT = Type->getAsStructureType();
|
|
|
|
|
|
+ const clang::RecordType *RT = Type->getAs<RecordType>();
|
|
RecordDecl *RD = RT->getDecl();
|
|
RecordDecl *RD = RT->getDecl();
|
|
|
|
|
|
const CGRecordLayout &RL = CGF.getTypes().getCGRecordLayout(RD);
|
|
const CGRecordLayout &RL = CGF.getTypes().getCGRecordLayout(RD);
|
|
@@ -5802,7 +5779,7 @@ void CGMSHLSLRuntime::EmitHLSLSplat(
|
|
} else if (StructType *ST = dyn_cast<StructType>(Ty)) {
|
|
} else if (StructType *ST = dyn_cast<StructType>(Ty)) {
|
|
DXASSERT(!dxilutil::IsHLSLObjectType(ST), "cannot cast to hlsl object, Sema should reject");
|
|
DXASSERT(!dxilutil::IsHLSLObjectType(ST), "cannot cast to hlsl object, Sema should reject");
|
|
|
|
|
|
- const clang::RecordType *RT = Type->getAsStructureType();
|
|
|
|
|
|
+ const clang::RecordType *RT = Type->getAs<RecordType>();
|
|
RecordDecl *RD = RT->getDecl();
|
|
RecordDecl *RD = RT->getDecl();
|
|
|
|
|
|
const CGRecordLayout &RL = CGF.getTypes().getCGRecordLayout(RD);
|
|
const CGRecordLayout &RL = CGF.getTypes().getCGRecordLayout(RD);
|