| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -ast-dump \ |
| 2 |
// RUN: -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-V1_1 |
| 3 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -ast-dump \ |
| 4 |
// RUN: -fdx-rootsignature-version=rootsig_1_0 \ |
| 5 |
// RUN: -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-V1_0 |
| 6 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -ast-dump \ |
| 7 |
// RUN: -fdx-rootsignature-version=rootsig_1_1 \ |
| 8 |
// RUN: -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-V1_1 |
| 9 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -ast-dump \ |
| 10 |
// RUN: -fdx-rootsignature-version=rootsig_1_2 \ |
| 11 |
// RUN: -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-V1_2 |
| 12 |
|
| 13 |
// This test ensures that the sample root signature is parsed without error and |
| 14 |
// the Attr AST Node is created succesfully. If an invalid root signature was |
| 15 |
// passed in then we would exit out of Sema before the Attr is created. |
| 16 |
|
| 17 |
#define SampleRS "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \ |
| 18 |
"DENY_VERTEX_SHADER_ROOT_ACCESS), " \ |
| 19 |
"CBV(b0, space = 1, flags = DATA_VOLATILE), " \ |
| 20 |
"SRV(t0), " \ |
| 21 |
"UAV(u0), " \ |
| 22 |
"DescriptorTable( CBV(b1), " \ |
| 23 |
"SRV(t1, numDescriptors = 8, " \ |
| 24 |
" flags = DATA_VOLATILE | DESCRIPTORS_VOLATILE), " \ |
| 25 |
"UAV(u1, numDescriptors = unbounded, " \ |
| 26 |
" flags = DATA_VOLATILE | DESCRIPTORS_VOLATILE)), " \ |
| 27 |
"DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \ |
| 28 |
"RootConstants(num32BitConstants=3, b10), " \ |
| 29 |
"StaticSampler(s1)," \ |
| 30 |
"StaticSampler(s2, " \ |
| 31 |
"addressU = TEXTURE_ADDRESS_CLAMP, " \ |
| 32 |
"filter = FILTER_MIN_MAG_MIP_LINEAR )" |
| 33 |
|
| 34 |
// CHECK: -HLSLRootSignatureDecl 0x{{.*}} {{.*}} implicit [[SAMPLE_RS_DECL:__hlsl_rootsig_decl_\d*]] |
| 35 |
// CHECK-V1_0: version: 1.0, |
| 36 |
// CHECK-V1_1: version: 1.1, |
| 37 |
// CHECK-V1_2: version: 1.2, |
| 38 |
// CHECK-SAME: RootElements{ |
| 39 |
// CHECK-SAME: RootFlags(AllowInputAssemblerInputLayout | DenyVertexShaderRootAccess), |
| 40 |
// CHECK-SAME: RootCBV(b0, |
| 41 |
// CHECK-SAME: space = 1, visibility = All, flags = DataVolatile |
| 42 |
// CHECK-SAME: ), |
| 43 |
// CHECK-SAME: RootSRV(t0, |
| 44 |
// CHECK-SAME: space = 0, visibility = All, |
| 45 |
// CHECK-V1_0-SAME: flags = DataVolatile |
| 46 |
// CHECK-V1_1-SAME: flags = DataStaticWhileSetAtExecute |
| 47 |
// CHECK-SAME: ), |
| 48 |
// CHECK-SAME: RootUAV( |
| 49 |
// CHECK-SAME: u0, space = 0, visibility = All, flags = DataVolatile |
| 50 |
// CHECK-SAME: ), |
| 51 |
// CHECK-SAME: CBV( |
| 52 |
// CHECK-SAME: b1, numDescriptors = 1, space = 0, offset = DescriptorTableOffsetAppend, |
| 53 |
// CHECK-V1_0-SAME: flags = DescriptorsVolatile | DataVolatile |
| 54 |
// CHECK-V1_1-SAME: flags = DataStaticWhileSetAtExecute |
| 55 |
// CHECK-SAME: ), |
| 56 |
// CHECK-SAME: SRV( |
| 57 |
// CHECK-SAME: t1, numDescriptors = 8, space = 0, offset = DescriptorTableOffsetAppend, flags = DescriptorsVolatile | DataVolatile |
| 58 |
// CHECK-SAME: ), |
| 59 |
// CHECK-SAME: UAV( |
| 60 |
// CHECK-SAME: u1, numDescriptors = unbounded, space = 0, offset = DescriptorTableOffsetAppend, flags = DescriptorsVolatile | DataVolatile |
| 61 |
// CHECK-SAME: ), |
| 62 |
// CHECK-SAME: DescriptorTable( |
| 63 |
// CHECK-SAME: numClauses = 3, visibility = All |
| 64 |
// CHECK-SAME: ), |
| 65 |
// CHECK-SAME: Sampler( |
| 66 |
// CHECK-SAME: s0, numDescriptors = 4, space = 1, offset = DescriptorTableOffsetAppend, |
| 67 |
// CHECK-V1_0-SAME: flags = DescriptorsVolatile |
| 68 |
// CHECK-V1_1-SAME: flags = None |
| 69 |
// CHECK-V1_2-SAME: flags = None |
| 70 |
// CHECK-SAME: ), |
| 71 |
// CHECK-SAME: DescriptorTable( |
| 72 |
// CHECK-SAME: numClauses = 1, visibility = All |
| 73 |
// CHECK-SAME: ), |
| 74 |
// CHECK-SAME: RootConstants( |
| 75 |
// CHECK-SAME: num32BitConstants = 3, b10, space = 0, visibility = All |
| 76 |
// CHECK-SAME: ), |
| 77 |
// CHECK-SAME: StaticSampler( |
| 78 |
// CHECK-SAME: s1, filter = Anisotropic, addressU = Wrap, addressV = Wrap, addressW = Wrap, |
| 79 |
// CHECK-SAME: mipLODBias = 0.000000e+00, maxAnisotropy = 16, comparisonFunc = LessEqual, |
| 80 |
// CHECK-SAME: borderColor = OpaqueWhite, minLOD = 0.000000e+00, maxLOD = 3.402823e+38, space = 0, visibility = All |
| 81 |
// CHECK-SAME: flags = None |
| 82 |
// CHECK-SAME: )} |
| 83 |
|
| 84 |
// CHECK: -RootSignatureAttr 0x{{.*}} {{.*}} [[SAMPLE_RS_DECL]] |
| 85 |
[RootSignature(SampleRS)] |
| 86 |
void rs_main() {} |
| 87 |
|
| 88 |
// Ensure that if multiple root signatures are specified at different entry |
| 89 |
// points that we point to the correct root signature |
| 90 |
|
| 91 |
// CHECK: -RootSignatureAttr 0x{{.*}} {{.*}} [[SAMPLE_RS_DECL]] |
| 92 |
[RootSignature(SampleRS)] |
| 93 |
void same_rs_main() {} |
| 94 |
|
| 95 |
// Define the same root signature to ensure that the entry point will still |
| 96 |
// link to the same root signature declaration |
| 97 |
|
| 98 |
#define SampleSameRS \ |
| 99 |
"RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | " \ |
| 100 |
"DENY_VERTEX_SHADER_ROOT_ACCESS), " \ |
| 101 |
"CBV(b0, space = 1, flags = DATA_VOLATILE), " \ |
| 102 |
"SRV(t0), " \ |
| 103 |
"UAV(u0), " \ |
| 104 |
"DescriptorTable( CBV(b1), " \ |
| 105 |
" SRV(t1, numDescriptors = 8, " \ |
| 106 |
" flags = DATA_VOLATILE | DESCRIPTORS_VOLATILE), " \ |
| 107 |
" UAV(u1, numDescriptors = unbounded, " \ |
| 108 |
" flags = DATA_VOLATILE | DESCRIPTORS_VOLATILE)), " \ |
| 109 |
"DescriptorTable(Sampler(s0, space=1, numDescriptors = 4)), " \ |
| 110 |
"RootConstants(num32BitConstants=3, b10), " \ |
| 111 |
"StaticSampler(s1)," \ |
| 112 |
"StaticSampler(s2, " \ |
| 113 |
"addressU = TEXTURE_ADDRESS_CLAMP, " \ |
| 114 |
"filter = FILTER_MIN_MAG_MIP_LINEAR )" |
| 115 |
|
| 116 |
// CHECK: -RootSignatureAttr 0x{{.*}} {{.*}} [[SAMPLE_RS_DECL]] |
| 117 |
[RootSignature(SampleSameRS)] |
| 118 |
void same_rs_string_main() {} |
| 119 |
|
| 120 |
#define SampleDifferentRS \ |
| 121 |
"DescriptorTable(Sampler(s0, numDescriptors = 4, space = 1))" |
| 122 |
|
| 123 |
// Ensure that when we define a different type root signature that it creates |
| 124 |
// a separate decl and identifier to reference |
| 125 |
|
| 126 |
// CHECK: -HLSLRootSignatureDecl 0x{{.*}} {{.*}} implicit [[DIFF_RS_DECL:__hlsl_rootsig_decl_\d*]] |
| 127 |
// CHECK-V1_0: version: 1.0, |
| 128 |
// CHECK-V1_1: version: 1.1, |
| 129 |
// CHECK-SAME: RootElements{ |
| 130 |
// CHECK-SAME: Sampler(s0, numDescriptors = 4, space = 1, offset = DescriptorTableOffsetAppend, |
| 131 |
// CHECK-V1_0-SAME: flags = DescriptorsVolatile |
| 132 |
// CHECK-V1_1-SAME: flags = None |
| 133 |
// CHECK-SAME: ), |
| 134 |
// CHECK-SAME: DescriptorTable(numClauses = 1, visibility = All) |
| 135 |
// CHECK-SAME: } |
| 136 |
|
| 137 |
// CHECK: -RootSignatureAttr 0x{{.*}} {{.*}} [[DIFF_RS_DECL]] |
| 138 |
[RootSignature(SampleDifferentRS)] |
| 139 |
void different_rs_string_main() {} |
| 140 |
|
| 141 |
#define SampleStaticSamplerRS \ |
| 142 |
"StaticSampler(s0, flags = NON_NORMALIZED_COORDINATES)" |
| 143 |
|
| 144 |
// Ensure that static samplers flags are correctly parsed in different versions |
| 145 |
|
| 146 |
// CHECK: -HLSLRootSignatureDecl 0x{{.*}} {{.*}} implicit [[DIFF_RS_DECL:__hlsl_rootsig_decl_\d*]] |
| 147 |
// CHECK-V1_0: version: 1.0, |
| 148 |
// CHECK-V1_1: version: 1.1, |
| 149 |
// CHECK-V1_2: version: 1.2, |
| 150 |
// CHECK-SAME: RootElements{ |
| 151 |
// CHECK-SAME: StaticSampler( |
| 152 |
// CHECK-SAME: s0, filter = Anisotropic, addressU = Wrap, addressV = Wrap, addressW = Wrap, |
| 153 |
// CHECK-SAME: mipLODBias = 0.000000e+00, maxAnisotropy = 16, comparisonFunc = LessEqual, |
| 154 |
// CHECK-SAME: borderColor = OpaqueWhite, minLOD = 0.000000e+00, maxLOD = 3.402823e+38, space = 0, visibility = All |
| 155 |
// CHECK-SAME: flags = NonNormalizedCoordinates |
| 156 |
// CHECK-SAME: )} |
| 157 |
|
| 158 |
// CHECK: -RootSignatureAttr 0x{{.*}} {{.*}} [[DIFF_RS_DECL]] |
| 159 |
[RootSignature(SampleStaticSamplerRS)] |
| 160 |
void statoc_sampler_v12_main() {} |