-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[HLSL] Add RasterizerOrderedStructuredBuffer definition to HLSLExternalSemaSource #113648
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b8a4722
[HLSL] Add RasterizerOrderedStructuredBuffer definition to HLSLExtern…
hekota 5d628ee
Add test case with user defined struct
hekota 4121b1e
Merge branch 'main' into sb4-rosb
hekota 862939d
Merge branch 'main' of https://github.com/llvm/llvm-project into sb4-…
hekota 0e28136
Update tests after merge
hekota 500b7f3
Merge branch 'sb4-rosb' of https://github.com/hekota/llvm-project int…
hekota 7206dfc
Change test prefix to DXIL to allow easier addition of SPIRV case
hekota 9b4a9c4
fix FileCheck name
hekota f72b448
remove change that should not be there
hekota File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
66 changes: 66 additions & 0 deletions
66
clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
This file contains hidden or 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,66 @@ | ||
| // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY %s | FileCheck -check-prefix=EMPTY %s | ||
| // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump %s | FileCheck %s | ||
|
|
||
|
|
||
| // This test tests two different AST generations. The "EMPTY" test mode verifies | ||
| // the AST generated by forward declaration of the HLSL types which happens on | ||
| // initializing the HLSL external AST with an AST Context. | ||
|
|
||
| // The non-empty mode has a use that requires the RasterizerOrderedStructuredBuffer type be complete, | ||
| // which results in the AST being populated by the external AST source. That | ||
| // case covers the full implementation of the template declaration and the | ||
| // instantiated specialization. | ||
|
|
||
| // EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RasterizerOrderedStructuredBuffer | ||
| // EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type | ||
| // EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit <undeserialized declarations> class RasterizerOrderedStructuredBuffer | ||
| // EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final | ||
|
|
||
| // There should be no more occurrences of RasterizerOrderedStructuredBuffer | ||
| // EMPTY-NOT: {{[^[:alnum:]]}}RasterizerOrderedStructuredBuffer | ||
|
|
||
| #ifndef EMPTY | ||
|
|
||
| RasterizerOrderedStructuredBuffer<int> Buffer; | ||
|
|
||
| #endif | ||
|
|
||
| // CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RasterizerOrderedStructuredBuffer | ||
| // CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type | ||
| // CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class RasterizerOrderedStructuredBuffer definition | ||
|
|
||
| // CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final | ||
| // CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h '__hlsl_resource_t | ||
| // CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] | ||
| // CHECK-SAME{LITERAL}: [[hlsl::is_rov]] | ||
| // CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]] | ||
| // CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]] | ||
| // CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit TypedBuffer | ||
|
|
||
| // CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'element_type &const (unsigned int) const' | ||
| // CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Idx 'unsigned int' | ||
| // CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> | ||
| // CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> | ||
| // CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' lvalue .e 0x{{[0-9A-Fa-f]+}} | ||
| // CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'const RasterizerOrderedStructuredBuffer<element_type>' lvalue implicit this | ||
| // CHECK-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline | ||
|
|
||
| // CHECK-NEXT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'element_type &(unsigned int)' | ||
| // CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Idx 'unsigned int' | ||
| // CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> | ||
| // CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> | ||
| // CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' lvalue .e 0x{{[0-9A-Fa-f]+}} | ||
| // CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'RasterizerOrderedStructuredBuffer<element_type>' lvalue implicit this | ||
| // CHECK-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline | ||
|
|
||
| // CHECK: ClassTemplateSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class RasterizerOrderedStructuredBuffer definition | ||
|
|
||
| // CHECK: TemplateArgument type 'int' | ||
| // CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'int' | ||
| // CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final | ||
| // CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h '__hlsl_resource_t | ||
| // CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]] | ||
| // CHECK-SAME{LITERAL}: [[hlsl::is_rov]] | ||
| // CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]] | ||
| // CHECK-SAME{LITERAL}: [[hlsl::contained_type(int)]] | ||
| // CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit TypedBuffer |
64 changes: 64 additions & 0 deletions
64
clang/test/CodeGenHLSL/builtins/RasterizerOrderedStructuredBuffer-elementtype.hlsl
This file contains hidden or 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,64 @@ | ||
| // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute -finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s -check-prefixes=DXIL | ||
|
|
||
| // NOTE: The number in type name and whether the struct is packed or not will mostly | ||
| // likely change once subscript operators are properly implemented (llvm/llvm-project#95956) | ||
| // and theinterim field of the contained type is removed. | ||
|
|
||
| struct MyStruct { | ||
| float4 a; | ||
| int2 b; | ||
| }; | ||
|
|
||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer" = type <{ target("dx.RawBuffer", i16, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.0" = type <{ target("dx.RawBuffer", i16, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.2" = type { target("dx.RawBuffer", i32, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.3" = type { target("dx.RawBuffer", i32, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.4" = type { target("dx.RawBuffer", i64, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.5" = type { target("dx.RawBuffer", i64, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.6" = type <{ target("dx.RawBuffer", half, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.8" = type { target("dx.RawBuffer", float, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.9" = type { target("dx.RawBuffer", double, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.10" = type { target("dx.RawBuffer", <4 x i16>, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.11" = type { target("dx.RawBuffer", <3 x i32>, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.12" = type { target("dx.RawBuffer", <2 x half>, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.13" = type { target("dx.RawBuffer", <3 x float>, 1, 1) | ||
| // DXIL: %"class.hlsl::RasterizerOrderedStructuredBuffer.14" = type { target("dx.RawBuffer", %struct.MyStruct = type { <4 x float>, <2 x i32>, [8 x i8] }, 1, 1) | ||
|
|
||
| RasterizerOrderedStructuredBuffer<int16_t> BufI16; | ||
| RasterizerOrderedStructuredBuffer<uint16_t> BufU16; | ||
| RasterizerOrderedStructuredBuffer<int> BufI32; | ||
| RasterizerOrderedStructuredBuffer<uint> BufU32; | ||
| RasterizerOrderedStructuredBuffer<int64_t> BufI64; | ||
| RasterizerOrderedStructuredBuffer<uint64_t> BufU64; | ||
| RasterizerOrderedStructuredBuffer<half> BufF16; | ||
| RasterizerOrderedStructuredBuffer<float> BufF32; | ||
| RasterizerOrderedStructuredBuffer<double> BufF64; | ||
| RasterizerOrderedStructuredBuffer< vector<int16_t, 4> > BufI16x4; | ||
| RasterizerOrderedStructuredBuffer< vector<uint, 3> > BufU32x3; | ||
| RasterizerOrderedStructuredBuffer<half2> BufF16x2; | ||
| RasterizerOrderedStructuredBuffer<float3> BufF32x3; | ||
| // TODO: RasterizerOrderedStructuredBuffer<snorm half> BufSNormF16; | ||
hekota marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // TODO: RasterizerOrderedStructuredBuffer<unorm half> BufUNormF16; | ||
| // TODO: RasterizerOrderedStructuredBuffer<snorm float> BufSNormF32; | ||
| // TODO: RasterizerOrderedStructuredBuffer<unorm float> BufUNormF32; | ||
| // TODO: RasterizerOrderedStructuredBuffer<snorm double> BufSNormF64; | ||
| // TODO: RasterizerOrderedStructuredBuffer<unorm double> BufUNormF64; | ||
| RasterizerOrderedStructuredBuffer<MyStruct> BufMyStruct; | ||
|
|
||
| [numthreads(1,1,1)] | ||
| void main(int GI : SV_GroupIndex) { | ||
| BufI16[GI] = 0; | ||
| BufU16[GI] = 0; | ||
| BufI32[GI] = 0; | ||
| BufU32[GI] = 0; | ||
| BufI64[GI] = 0; | ||
| BufU64[GI] = 0; | ||
| BufF16[GI] = 0; | ||
| BufF32[GI] = 0; | ||
| BufF64[GI] = 0; | ||
| BufI16x4[GI] = 0; | ||
| BufU32x3[GI] = 0; | ||
| BufF16x2[GI] = 0; | ||
| BufF32x3[GI] = 0; | ||
| BufMyStruct[GI] = {{0,0,0,0},{0,0}}; | ||
| } | ||
This file contains hidden or 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
6 changes: 4 additions & 2 deletions
6
clang/test/CodeGenHLSL/builtins/StructuredBuffers-subscripts.hlsl
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.