-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[HLSL] Introduce address space hlsl_constant(2)
for constant buffer declarations
#123411
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 |
---|---|---|
|
@@ -42,6 +42,7 @@ static const unsigned DirectXAddrSpaceMap[] = { | |
0, // ptr32_uptr | ||
0, // ptr64 | ||
3, // hlsl_groupshared | ||
2, // hlsl_constant | ||
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 we neither use the 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. Yes, not updating all of the maps produces a compile error. |
||
// Wasm address space values for this target are dummy values, | ||
// as it is only enabled for Wasm targets. | ||
20, // wasm_funcref | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %clang_cc1 -Wdocumentation -ast-dump=json -x hlsl -triple dxil-pc-shadermodel6.3-library %s | FileCheck %s --check-prefix=JSON | ||
// RUN: %clang_cc1 -Wdocumentation -ast-dump -x hlsl -triple dxil-pc-shadermodel6.3-library %s | FileCheck %s --check-prefix=AST | ||
|
||
// JSON:"kind": "HLSLBufferDecl", | ||
// JSON:"name": "A", | ||
// JSON-NEXT:"bufferKind": "cbuffer", | ||
// JSON:"kind": "TextComment", | ||
// JSON:"text": " CBuffer decl." | ||
|
||
/// CBuffer decl. | ||
cbuffer A { | ||
// JSON: "kind": "VarDecl", | ||
// JSON: "name": "a", | ||
// JSON: "qualType": "hlsl_constant float" | ||
float a; | ||
// JSON: "kind": "VarDecl", | ||
// JSON: "name": "b", | ||
// JSON: "qualType": "hlsl_constant int" | ||
int b; | ||
} | ||
|
||
// AST: HLSLBufferDecl {{.*}} line:11:9 cbuffer A | ||
// AST-NEXT: HLSLResourceClassAttr {{.*}} Implicit CBuffer | ||
// AST-NEXT: HLSLResourceAttr {{.*}} Implicit CBuffer | ||
// AST-NEXT: FullComment | ||
// AST-NEXT: ParagraphComment | ||
// AST-NEXT: TextComment {{.*}} Text=" CBuffer decl." | ||
// AST-NEXT: VarDecl {{.*}} a 'hlsl_constant float' | ||
// AST-NEXT: VarDecl {{.*}} b 'hlsl_constant int' | ||
// AST-NEXT: CXXRecordDecl {{.*}} implicit class __layout_A definition | ||
// AST: FieldDecl {{.*}} a 'float' | ||
// AST-NEXT: FieldDecl {{.*}} b 'int' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ struct TwoFloats { | |
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer | ||
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer | ||
cbuffer CB { | ||
// CHECK: VarDecl {{.*}} col:9 used a1 'float' | ||
// CHECK: VarDecl {{.*}} col:9 used a1 'hlsl_constant float' | ||
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. Will this also impact type names in diagnostics? 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. Probably, the address space is attached to |
||
float a1; | ||
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB definition | ||
// CHECK: FieldDecl {{.*}} a1 'float' | ||
|
@@ -60,15 +60,15 @@ _Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __layout | |
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer | ||
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer | ||
cbuffer CB { | ||
// CHECK: VarDecl {{.*}} col:9 used a2 'float' | ||
// CHECK: VarDecl {{.*}} col:9 used a2 'hlsl_constant float' | ||
float a2; | ||
// CHECK: VarDecl {{.*}} col:19 b2 'RWBuffer<float>':'hlsl::RWBuffer<float>' | ||
RWBuffer<float> b2; | ||
// CHECK: VarDecl {{.*}} col:15 c2 'EmptyStruct' | ||
EmptyStruct c2; | ||
// CHECK: VarDecl {{.*}} col:9 d2 'float[0]' | ||
float d2[0]; | ||
// CHECK: VarDecl {{.*}} col:9 e2 'float' | ||
// CHECK: VarDecl {{.*}} col:9 e2 'hlsl_constant float' | ||
float e2; | ||
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_1 definition | ||
// CHECK: FieldDecl {{.*}} a2 'float' | ||
|
@@ -81,11 +81,11 @@ _Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layou | |
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer | ||
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer | ||
cbuffer CB { | ||
// CHECK: VarDecl {{.*}} col:5 used s1 'A' | ||
// CHECK: VarDecl {{.*}} col:5 used s1 'hlsl_constant A' | ||
A s1; | ||
// CHECK: VarDecl {{.*}} col:5 s2 'B' | ||
// CHECK: VarDecl {{.*}} col:5 s2 'hlsl_constant B' | ||
B s2; | ||
// CHECK: VarDecl {{.*}} col:12 s3 'CTypedef':'C | ||
// CHECK: VarDecl {{.*}} col:12 s3 'CTypedef':'C' | ||
CTypedef s3; | ||
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_2 definition | ||
// CHECK: FieldDecl {{.*}} s1 'A' | ||
|
@@ -102,7 +102,7 @@ _Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layou | |
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer | ||
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer | ||
cbuffer CB { | ||
// CHECK: VarDecl {{.*}} s4 'D' | ||
// CHECK: VarDecl {{.*}} s4 'hlsl_constant D' | ||
D s4; | ||
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_3 definition | ||
// CHECK: FieldDecl {{.*}} s4 '__layout_D' | ||
|
@@ -120,9 +120,9 @@ _Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __layou | |
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer | ||
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer | ||
cbuffer CB { | ||
// CHECK: VarDecl {{.*}} s5 'E' | ||
// CHECK: VarDecl {{.*}} s5 'hlsl_constant E' | ||
E s5; | ||
// CHECK: VarDecl {{.*}} s6 'BTypedef':'B' | ||
// CHECK: VarDecl {{.*}} s6 'hlsl_constant BTypedef':'hlsl_constant B' | ||
BTypedef s6; | ||
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_4 definition | ||
// CHECK: FieldDecl {{.*}} s5 '__layout_E' | ||
|
@@ -158,7 +158,7 @@ cbuffer CB { | |
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer | ||
// CHECK: HLSLResourceAttr {{.*}} Implicit CBuffer | ||
cbuffer CB { | ||
// CHECK: VarDecl {{.*}} s8 'F' | ||
// CHECK: VarDecl {{.*}} s8 'hlsl_constant F' | ||
F s8; | ||
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_CB_6 definition | ||
// CHECK: FieldDecl {{.*}} s8 '__layout_F' | ||
|
@@ -182,15 +182,15 @@ cbuffer CB { | |
// CHECK: FieldDecl {{.*}} f 'RWBuffer<float>':'hlsl::RWBuffer<float>' | ||
RWBuffer<float> f; | ||
} s9; | ||
// CHECK: VarDecl {{.*}} s9 'struct (unnamed struct at {{.*}}cbuffer.hlsl:177:3 | ||
// CHECK: VarDecl {{.*}} s9 'hlsl_constant struct (unnamed struct at {{.*}}cbuffer.hlsl:177:3 | ||
// CHECK: CXXRecordDecl {{.*}} struct definition | ||
struct { | ||
// CHECK: FieldDecl {{.*}} g 'float' | ||
float g; | ||
// CHECK: FieldDecl {{.*}} f 'RWBuffer<float>':'hlsl::RWBuffer<float>' | ||
RWBuffer<float> f; | ||
} s10; | ||
// CHECK: VarDecl {{.*}} s10 'struct (unnamed struct at {{.*}}cbuffer.hlsl:187:3 | ||
// CHECK: VarDecl {{.*}} s10 'hlsl_constant struct (unnamed struct at {{.*}}cbuffer.hlsl:187:3 | ||
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_anon definition | ||
// CHECK: FieldDecl {{.*}} e 'float' | ||
// CHECK: CXXRecordDecl {{.*}} implicit referenced class __layout_anon_1 definition | ||
|
Uh oh!
There was an error while loading. Please reload this page.