-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[HLSL] Buffer handle globals should not be constants #130231
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
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 |
---|---|---|
|
@@ -31,7 +31,6 @@ | |
#include "llvm/IR/Type.h" | ||
#include "llvm/IR/Value.h" | ||
#include "llvm/Support/Alignment.h" | ||
|
||
#include "llvm/Support/ErrorHandling.h" | ||
#include "llvm/Support/FormatVariadic.h" | ||
|
||
|
@@ -245,12 +244,12 @@ void CGHLSLRuntime::addBuffer(const HLSLBufferDecl *BufDecl) { | |
llvm::TargetExtType *TargetTy = | ||
cast<llvm::TargetExtType>(convertHLSLSpecificType( | ||
ResHandleTy, BufDecl->hasValidPackoffset() ? &Layout : nullptr)); | ||
llvm::GlobalVariable *BufGV = | ||
new GlobalVariable(TargetTy, /*isConstant*/ true, | ||
GlobalValue::LinkageTypes::ExternalLinkage, nullptr, | ||
llvm::formatv("{0}{1}", BufDecl->getName(), | ||
BufDecl->isCBuffer() ? ".cb" : ".tb"), | ||
GlobalValue::NotThreadLocal); | ||
llvm::GlobalVariable *BufGV = new GlobalVariable( | ||
TargetTy, /*isConstant*/ false, | ||
GlobalValue::LinkageTypes::ExternalLinkage, PoisonValue::get(TargetTy), | ||
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. Why PoisonValue? Looking at the documentation it sounds like thats intended to be used for an erroneous operation. What am I missing? 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. The global BufGV will be initialized with a resource handle based on resource bindings at the start of the entry function (or in module init function). A resource class with uninitialized handle is an error state, so poison is the right choice here. |
||
llvm::formatv("{0}{1}", BufDecl->getName(), | ||
BufDecl->isCBuffer() ? ".cb" : ".tb"), | ||
GlobalValue::NotThreadLocal); | ||
CGM.getModule().insertGlobalVariable(BufGV); | ||
|
||
// Add globals for constant buffer elements and create metadata nodes | ||
|
Uh oh!
There was an error while loading. Please reload this page.