-
Notifications
You must be signed in to change notification settings - Fork 849
[SM6.10] Make DxilStructAnnotation aware of target types #8282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e231f0b
20e6695
ac00a58
d0ad120
80f4b16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,14 +236,17 @@ void DxilStructAnnotation::SetCBufferSize(unsigned size) { | |
| void DxilStructAnnotation::MarkEmptyStruct() { | ||
| if (m_ResourcesContained == HasResources::True) | ||
| m_ResourcesContained = HasResources::Only; | ||
| else if (m_TargetTypesContained == HasTargetTypes::True) | ||
| m_TargetTypesContained = HasTargetTypes::Only; | ||
| else | ||
| m_FieldAnnotations.clear(); | ||
| } | ||
| bool DxilStructAnnotation::IsEmptyStruct() { | ||
| return m_FieldAnnotations.empty(); | ||
| } | ||
| bool DxilStructAnnotation::IsEmptyBesidesResources() { | ||
| bool DxilStructAnnotation::IsEmptyBesidesResourcesAndTargetTypes() const { | ||
| return m_ResourcesContained == HasResources::Only || | ||
| m_TargetTypesContained == HasTargetTypes::Only || | ||
| m_FieldAnnotations.empty(); | ||
| } | ||
|
|
||
|
|
@@ -256,6 +259,14 @@ bool DxilStructAnnotation::ContainsResources() const { | |
| return m_ResourcesContained != HasResources::False; | ||
| } | ||
|
|
||
| void DxilStructAnnotation::SetContainsTargetTypes() { | ||
| if (m_TargetTypesContained == HasTargetTypes::False) | ||
| m_TargetTypesContained = HasTargetTypes::True; | ||
| } | ||
| bool DxilStructAnnotation::ContainsTargetTypes() const { | ||
| return m_TargetTypesContained != HasTargetTypes::False; | ||
| } | ||
|
|
||
| // For template args, GetNumTemplateArgs() will return 0 if not a template | ||
| unsigned DxilStructAnnotation::GetNumTemplateArgs() const { | ||
| return (unsigned)m_TemplateAnnotations.size(); | ||
|
|
@@ -393,6 +404,13 @@ void DxilTypeSystem::FinishStructAnnotation(DxilStructAnnotation &SA) { | |
| SA.SetContainsResources(); | ||
| } | ||
|
|
||
| // Update target type containment | ||
| for (unsigned i = 0; i < SA.GetNumFields() && !SA.ContainsTargetTypes(); | ||
| i++) { | ||
| if (IsTargetTypeContained(ST->getElementType(i))) | ||
| SA.SetContainsTargetTypes(); | ||
| } | ||
|
|
||
| // Mark if empty | ||
| if (SA.GetCBufferSize() == 0) | ||
| SA.MarkEmptyStruct(); | ||
|
|
@@ -854,20 +872,36 @@ void DxilTypeSystem::SetMinPrecision(bool bMinPrecision) { | |
| m_LowPrecisionMode = mode; | ||
| } | ||
|
|
||
| bool DxilTypeSystem::IsResourceContained(llvm::Type *Ty) { | ||
| bool DxilTypeSystem::IsResourceContained(llvm::Type *Ty) const { | ||
| // strip pointer/array | ||
| if (Ty->isPointerTy()) | ||
| Ty = Ty->getPointerElementType(); | ||
| if (Ty->isArrayTy()) | ||
| Ty = Ty->getArrayElementType(); | ||
|
|
||
| if (auto ST = dyn_cast<StructType>(Ty)) { | ||
| if (dxilutil::IsHLSLResourceType(Ty)) { | ||
| if (auto *ST = dyn_cast<StructType>(Ty)) { | ||
| if (dxilutil::IsHLSLResourceType(Ty)) | ||
| return true; | ||
| } else if (auto SA = GetStructAnnotation(ST)) { | ||
| else if (auto *SA = GetStructAnnotation(ST)) | ||
| if (SA->ContainsResources()) | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| bool DxilTypeSystem::IsTargetTypeContained(llvm::Type *Ty) const { | ||
| // strip pointer/array | ||
| if (Ty->isPointerTy()) | ||
| Ty = Ty->getPointerElementType(); | ||
| if (Ty->isArrayTy()) | ||
| Ty = Ty->getArrayElementType(); | ||
|
Comment on lines
+894
to
+897
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it deliberate that this only handles pointers to arrays, and not arrays of pointers or other more complicated nestings?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so. We don't support array of pointers to resources or target types. |
||
|
|
||
| if (auto *ST = dyn_cast<StructType>(Ty)) { | ||
| if (dxilutil::IsHLSLKnownTargetType(Ty)) | ||
| return true; | ||
| else if (auto *SA = GetStructAnnotation(ST)) | ||
| if (SA->ContainsTargetTypes()) | ||
| return true; | ||
| } | ||
V-FEXrt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return false; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // REQUIRES: dxil-1-10 | ||
| // RUN: %dxc -T cs_6_10 -enable-16bit-types %s | FileCheck %s | ||
|
|
||
| using MyHandleT = __builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(9, 4, 4, 0, 1)]]; | ||
|
|
||
| class MyMatrix { | ||
| MyHandleT handle; | ||
|
|
||
| static MyMatrix Splat(float Val) { | ||
| MyMatrix Result; | ||
| __builtin_LinAlg_FillMatrix(Result.handle, Val); | ||
| return Result; | ||
| } | ||
| }; | ||
|
|
||
| [numthreads(4, 4, 4)] | ||
| void main() { | ||
| MyMatrix MatA = MyMatrix::Splat(1.0f); | ||
| } | ||
|
|
||
| // CHECK: call %dx.types.LinAlgMatrixC9M4N4U0S1 @dx.op.linAlgFillMatrix.mC9M4N4U0S1.f32(i32 -2147483636, float 1.000000e+00) ; LinAlgFillMatrix(value) | ||
| // CHECK-NOT: @llvm.trap() |
Uh oh!
There was an error while loading. Please reload this page.