| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-compute -finclude-default-header \ |
| 2 |
// RUN: -emit-llvm -disable-llvm-passes -o - %s | llvm-cxxfilt | FileCheck %s |
| 3 |
// RUN: %clang_cc1 -finclude-default-header -triple spirv-unknown-vulkan-compute \ |
| 4 |
// RUN: -emit-llvm -disable-llvm-passes -o - %s | llvm-cxxfilt | FileCheck %s |
| 5 |
|
| 6 |
// CHECK: @[[BufB:.*]] = private unnamed_addr constant [2 x i8] c"B\00", align 1 |
| 7 |
// CHECK: @[[BufC:.*]] = private unnamed_addr constant [2 x i8] c"C\00", align 1 |
| 8 |
// CHECK: @[[BufD:.*]] = private unnamed_addr constant [2 x i8] c"D\00", align 1 |
| 9 |
|
| 10 |
RWBuffer<float> B[4][4] : register(u2); |
| 11 |
RWBuffer<int> C[2][2][5] : register(u10, space1); |
| 12 |
|
| 13 |
typedef RWBuffer<uint> RWBufferArrayTenByFive[10][5]; // test typedef for the resource array type |
| 14 |
RWBufferArrayTenByFive D; // implicit binding -> u18, space0 |
| 15 |
|
| 16 |
RWStructuredBuffer<float> Out; |
| 17 |
|
| 18 |
[numthreads(4,1,1)] |
| 19 |
void main() { |
| 20 |
// CHECK: define internal{{.*}} void @main() |
| 21 |
// CHECK: %[[Tmp0:.*]] = alloca %"class.hlsl::RWBuffer |
| 22 |
// CHECK: %[[Tmp1:.*]] = alloca %"class.hlsl::RWBuffer |
| 23 |
// CHECK: %[[Tmp2:.*]] = alloca %"class.hlsl::RWBuffer |
| 24 |
// CHECK: %[[Tmp3:.*]] = alloca %"class.hlsl::RWBuffer |
| 25 |
|
| 26 |
// Make sure that B[3][2] is translated to a RWBuffer<float>::__createFromBinding call (u2, space0) with range 16 and index 14 |
| 27 |
// CHECK: call void @hlsl::RWBuffer<float>::__createFromBinding(unsigned int, unsigned int, int, unsigned int, char const*) |
| 28 |
// CHECK-SAME: (ptr {{.*}} sret(%"class.hlsl::RWBuffer") align {{(4|8)}} %[[Tmp0]], |
| 29 |
// CHECK-SAME: i32 noundef 2, i32 noundef 0, i32 noundef 16, i32 noundef 14, ptr noundef @[[BufB]]) |
| 30 |
|
| 31 |
// Make sure that C[1][0][3] is translated to a RWBuffer<int>::__createFromBinding call (u10, space1) with range 20 and index 13 |
| 32 |
// CHECK: call void @hlsl::RWBuffer<int>::__createFromBinding(unsigned int, unsigned int, int, unsigned int, char const*) |
| 33 |
// CHECK-SAME: (ptr {{.*}} sret(%"class.hlsl::RWBuffer.0") align {{(4|8)}} %[[Tmp1]], |
| 34 |
// CHECK-SAME: i32 noundef 10, i32 noundef 1, i32 noundef 20, i32 noundef 13, ptr noundef @[[BufC]]) |
| 35 |
|
| 36 |
// Make sure that D[9][2] is translated to a RWBuffer<uint>::__createFromImplicitBinding call with range 50 and index 47 |
| 37 |
// CHECK: call void @hlsl::RWBuffer<unsigned int>::__createFromImplicitBinding(unsigned int, unsigned int, int, unsigned int, char const*) |
| 38 |
// CHECK-SAME: (ptr {{.*}} sret(%"class.hlsl::RWBuffer.1") align {{(4|8)}} %[[Tmp2]], |
| 39 |
// CHECK-SAME: i32 noundef 0, i32 noundef 0, i32 noundef 50, i32 noundef 47, ptr noundef @[[BufD]]) |
| 40 |
|
| 41 |
// Make sure that the second B[3][2] is translated to the same RWBuffer<float>::__createFromBinding call as the first B[3][2] subscript |
| 42 |
// CHECK: call void @hlsl::RWBuffer<float>::__createFromBinding(unsigned int, unsigned int, int, unsigned int, char const*) |
| 43 |
// CHECK-SAME: (ptr {{.*}} writable sret(%"class.hlsl::RWBuffer") align {{(4|8)}} %[[Tmp3]], |
| 44 |
// CHECK-SAME: i32 noundef 2, i32 noundef 0, i32 noundef 16, i32 noundef 14, ptr noundef @[[BufB]]) |
| 45 |
Out[0] = B[3][2][0] + (float)C[1][0][3][0] + (float)D[9][2][0] + B[3][2][1]; |
| 46 |
} |