-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[HLSL] Adding DXIL Storage type into TypedInfo
#164887
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 1 commit
c5bb883
fccbe5c
e417ac7
569631d
0c1e646
1e7a714
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 |
|---|---|---|
|
|
@@ -293,6 +293,8 @@ class ResourceTypeInfo { | |
|
|
||
| struct TypedInfo { | ||
| dxil::ElementType ElementTy; | ||
| // Some 64 byte types are treated as 32 byte types in DXIL. | ||
| dxil::ElementType DXILTargetTy; | ||
|
||
| uint32_t ElementCount; | ||
|
|
||
| bool operator==(const TypedInfo &RHS) const { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -206,6 +206,14 @@ static dxil::ElementType toDXILElementType(Type *Ty, bool IsSigned) { | |
| return ElementType::Invalid; | ||
| } | ||
|
|
||
| static dxil::ElementType toDXILTargetType(Type *Ty, bool IsSigned) { | ||
| // TODO: Handle unorm, snorm, and packed. | ||
|
||
| Type *ScalarTy = Ty->getScalarType(); | ||
| if (ScalarTy->isIntegerTy(64) || ScalarTy->isDoubleTy()) | ||
| return ElementType::U32; | ||
| return toDXILElementType(Ty, IsSigned); | ||
| } | ||
|
||
|
|
||
| ResourceTypeInfo::ResourceTypeInfo(TargetExtType *HandleTy, | ||
| const dxil::ResourceClass RC_, | ||
| const dxil::ResourceKind Kind_) | ||
|
|
@@ -569,10 +577,11 @@ ResourceTypeInfo::TypedInfo ResourceTypeInfo::getTyped() const { | |
|
|
||
| auto [ElTy, IsSigned] = getTypedElementType(Kind, HandleTy); | ||
| dxil::ElementType ET = toDXILElementType(ElTy, IsSigned); | ||
| dxil::ElementType DXILTargetTy = toDXILTargetType(ElTy, IsSigned); | ||
| uint32_t Count = 1; | ||
| if (auto *VTy = dyn_cast<FixedVectorType>(ElTy)) | ||
| Count = VTy->getNumElements(); | ||
| return {ET, Count}; | ||
| return {ET, DXILTargetTy, Count}; | ||
| } | ||
|
|
||
| dxil::SamplerFeedbackType ResourceTypeInfo::getFeedbackType() const { | ||
|
|
@@ -714,7 +723,8 @@ MDTuple *ResourceInfo::getAsMetadata(Module &M, | |
| Tags.push_back(getIntMD(RTI.getStruct(DL).Stride)); | ||
| } else if (RTI.isTyped()) { | ||
| Tags.push_back(getIntMD(llvm::to_underlying(ExtPropTags::ElementType))); | ||
| Tags.push_back(getIntMD(llvm::to_underlying(RTI.getTyped().ElementTy))); | ||
| Tags.push_back( | ||
| getIntMD(llvm::to_underlying(RTI.getTyped().DXILTargetTy))); | ||
| } else if (RTI.isFeedback()) { | ||
| Tags.push_back( | ||
| getIntMD(llvm::to_underlying(ExtPropTags::SamplerFeedbackKind))); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment adds a lot here - it would make more sense in the
toDXILTargetTypefunction, but that function is pretty self explanatory as is.