-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HLSL] Remove old resource annotations #130338
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
9953925
8076575
c574bed
2c57c89
7584ba6
216e6da
54bfdf0
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 |
---|---|---|
|
@@ -11,59 +11,9 @@ | |
//===----------------------------------------------------------------------===// | ||
|
||
#include "llvm/Frontend/HLSL/HLSLResource.h" | ||
#include "llvm/IR/IRBuilder.h" | ||
#include "llvm/IR/Metadata.h" | ||
|
||
using namespace llvm; | ||
using namespace llvm::hlsl; | ||
|
||
GlobalVariable *FrontendResource::getGlobalVariable() { | ||
return cast<GlobalVariable>( | ||
cast<ConstantAsMetadata>(Entry->getOperand(0))->getValue()); | ||
} | ||
|
||
ResourceKind FrontendResource::getResourceKind() { | ||
return static_cast<ResourceKind>( | ||
cast<ConstantInt>( | ||
cast<ConstantAsMetadata>(Entry->getOperand(1))->getValue()) | ||
->getLimitedValue()); | ||
} | ||
ElementType FrontendResource::getElementType() { | ||
return static_cast<ElementType>( | ||
cast<ConstantInt>( | ||
cast<ConstantAsMetadata>(Entry->getOperand(2))->getValue()) | ||
->getLimitedValue()); | ||
} | ||
bool FrontendResource::getIsROV() { | ||
return cast<ConstantInt>( | ||
cast<ConstantAsMetadata>(Entry->getOperand(3))->getValue()) | ||
->getLimitedValue(); | ||
} | ||
uint32_t FrontendResource::getResourceIndex() { | ||
return cast<ConstantInt>( | ||
cast<ConstantAsMetadata>(Entry->getOperand(4))->getValue()) | ||
->getLimitedValue(); | ||
} | ||
uint32_t FrontendResource::getSpace() { | ||
return cast<ConstantInt>( | ||
cast<ConstantAsMetadata>(Entry->getOperand(5))->getValue()) | ||
->getLimitedValue(); | ||
} | ||
|
||
FrontendResource::FrontendResource(MDNode *E) : Entry(E) { | ||
assert(Entry->getNumOperands() == 6 && "Unexpected metadata shape"); | ||
} | ||
|
||
FrontendResource::FrontendResource(GlobalVariable *GV, ResourceKind RK, | ||
ElementType ElTy, bool IsROV, | ||
uint32_t ResIndex, uint32_t Space) { | ||
auto &Ctx = GV->getContext(); | ||
IRBuilder<> B(Ctx); | ||
Entry = MDNode::get( | ||
Ctx, {ValueAsMetadata::get(GV), | ||
ConstantAsMetadata::get(B.getInt32(static_cast<int>(RK))), | ||
ConstantAsMetadata::get(B.getInt32(static_cast<int>(ElTy))), | ||
ConstantAsMetadata::get(B.getInt1(IsROV)), | ||
ConstantAsMetadata::get(B.getInt32(ResIndex)), | ||
ConstantAsMetadata::get(B.getInt32(Space))}); | ||
} | ||
// Intentionally empty; this file can be removed when more cpp files are added | ||
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. Would you mind explaining why more cpp files being added later justifies the removal of this file later instead of now? 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. HLSLResource.cpp is currently the only file in the FrontendHLSL library. If I remove it the library does not have any source files, and the compiler/linker is not happy about that. I don't want to remove the whole library because I know more changes are coming in here soon (#125131), so I have decided to just leave it in with a comment. |
||
// to the HLSLFrontend lib. |
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.
May I ask how the buffer register number
2
is being stored when this goes away?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.
The register number and space are used in the
llvm.dx.resource.handlefrombinding
intrinsic call when the code to initialize the resource is generated. Then in the LLVM backed theDXILResourceBindingAnalysis
analyzes the code and collects information about all the shader resources and their bindings based on these calls. This info is then used by other LLVM passes to make sure we generate the correct "dx.resources" metadata in the DXIL container.