-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HLSL] Split out resource class data from resource attribute (#98419)
The ability to spell out and specify the resource class is necessary for testing various resource binding behaviors. Though it is not intended for users to use this in customized HLSL source code, the ability to specify the resource class via an attribute is immensely helpful for writing thorough tests. This PR introduces a new attribute, hlsl::resource_attribute, that can only be applied on structs. This attribute only has 1 required argument, and must be one of: ``` SRV UAV CBuffer Sampler ``` By applying this attribute to a struct, the struct will have the `HLSLResourceClassAttr` attribute attached to it in the AST representation, which provides information on the type of resource class the struct is meant to be. The resource class data that was originally contained within the `HLSLResourceAttr` attribute has been removed in favor of this new attribute, and so certain ast-dump tests need to be modified so that the same information can be represented via 2 attributes instead of one. Fixes #98193 --------- Co-authored-by: Damyan Pepper <damyanp@microsoft.com>
- Loading branch information
Showing
10 changed files
with
105 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
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 { | ||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} | ||
struct [[hlsl::resource_class(gibberish)]] Eg2 { | ||
int i; | ||
}; | ||
|
||
Eg2 e2; |