-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HLSL] Split out resource class data from resource attribute #98419
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
b740aa9
d5d4b00
8b12c39
65da73a
9cf74db
a9a02c4
30c3b4c
2539a08
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 |
---|---|---|
|
@@ -437,6 +437,28 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr &AL) { | |
D->addAttr(NewAttr); | ||
} | ||
|
||
void SemaHLSL::handleResourceClassAttr(Decl *D, const ParsedAttr &AL) { | ||
if (!AL.isArgIdent(0)) { | ||
Diag(AL.getLoc(), diag::err_attribute_argument_type) | ||
<< AL << AANT_ArgumentIdentifier; | ||
return; | ||
} | ||
|
||
IdentifierLoc *Loc = AL.getArgAsIdent(0); | ||
StringRef Identifier = Loc->Ident->getName(); | ||
SourceLocation ArgLoc = Loc->Loc; | ||
|
||
// Validate. | ||
llvm::dxil::ResourceClass RC; | ||
if (!HLSLResourceClassAttr::ConvertStrToResourceClass(Identifier, RC)) { | ||
Diag(ArgLoc, diag::warn_attribute_type_not_supported) | ||
<< "ResourceClass" << Identifier; | ||
return; | ||
} | ||
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. You should be able to use |
||
|
||
D->addAttr(HLSLResourceClassAttr::Create(getASTContext(), RC, ArgLoc)); | ||
} | ||
|
||
void SemaHLSL::handleResourceBindingAttr(Decl *D, const ParsedAttr &AL) { | ||
StringRef Space = "space0"; | ||
StringRef Slot = ""; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s | ||
|
||
|
||
// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} <col:31> SRV | ||
struct [[hlsl::resource_class(SRV)]] Eg1 { | ||
damyanp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int i; | ||
}; | ||
|
||
Eg1 e1; | ||
|
||
// CHECK: -CXXRecordDecl 0x{{[0-9a-f]+}} <line:13:1, line:15:1> line:13:38 referenced struct Eg2 definition | ||
// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} <col:31> UAV | ||
struct [[hlsl::resource_class(UAV)]] Eg2 { | ||
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'm surprised this has an invalid source location given that it's coming from the source. Did you use the right constructor for the attribute? 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. Added ArgLoc to the constructor, it was an optional arg |
||
int i; | ||
}; | ||
Eg2 e2; | ||
|
||
// CHECK: -CXXRecordDecl 0x{{[0-9a-f]+}} <line:20:1, line:22:1> line:20:42 referenced struct Eg3 definition | ||
// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} <col:31> CBuffer | ||
struct [[hlsl::resource_class(CBuffer)]] Eg3 { | ||
int i; | ||
}; | ||
Eg3 e3; | ||
|
||
// CHECK: -CXXRecordDecl 0x{{[0-9a-f]+}} <line:27:1, line:29:1> line:27:42 referenced struct Eg4 definition | ||
// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} <col:31> Sampler | ||
struct [[hlsl::resource_class(Sampler)]] Eg4 { | ||
int i; | ||
}; | ||
Eg4 e4; | ||
|
||
RWBuffer<int> In : register(u1); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s -verify | ||
|
||
// expected-error@+1{{'resource_class' attribute takes one argument}} | ||
struct [[hlsl::resource_class()]] Eg1 { | ||
int i; | ||
}; | ||
|
||
Eg1 e1; | ||
|
||
// expected-warning@+1{{ResourceClass attribute argument not supported: gibberish}} | ||
damyanp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
struct [[hlsl::resource_class(gibberish)]] Eg2 { | ||
int i; | ||
}; | ||
|
||
Eg2 e2; |
Uh oh!
There was an error while loading. Please reload this page.