mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 11:02:04 +08:00
[HLSL][NFC] Add test coverage for Buffer (#161909)
Extending test coverage for `Buffer` resource class. Most of the typed buffer tests were using just `RWBuffer`. This change adds `Buffer` tests cases to existing `RWBuffer-*.test` files and renames them to `TypedBuffer-*.test`. The `Load` method test is separate into `TypedBuffers-methods.tests`.
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute -finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s -check-prefixes=DXIL
|
||||
// RUN: %clang_cc1 -triple spirv-pc-vulkan-compute -finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s -check-prefixes=SPIRV
|
||||
|
||||
// DXIL: %"class.hlsl::RWBuffer" = type { target("dx.TypedBuffer", i16, 1, 0, 1) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.0" = type { target("dx.TypedBuffer", i16, 1, 0, 0) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.1" = type { target("dx.TypedBuffer", i32, 1, 0, 1) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.2" = type { target("dx.TypedBuffer", i32, 1, 0, 0) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.3" = type { target("dx.TypedBuffer", i64, 1, 0, 1) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.4" = type { target("dx.TypedBuffer", i64, 1, 0, 0) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.5" = type { target("dx.TypedBuffer", half, 1, 0, 0) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.6" = type { target("dx.TypedBuffer", float, 1, 0, 0) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.7" = type { target("dx.TypedBuffer", double, 1, 0, 0) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.8" = type { target("dx.TypedBuffer", <4 x i16>, 1, 0, 1) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.9" = type { target("dx.TypedBuffer", <3 x i32>, 1, 0, 0) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.10" = type { target("dx.TypedBuffer", <2 x half>, 1, 0, 0) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.11" = type { target("dx.TypedBuffer", <3 x float>, 1, 0, 0) }
|
||||
// DXIL: %"class.hlsl::RWBuffer.12" = type { target("dx.TypedBuffer", <4 x i32>, 1, 0, 1) }
|
||||
|
||||
// SPIRV: %"class.hlsl::RWBuffer" = type { target("spirv.SignedImage", i16, 5, 2, 0, 0, 2, 0) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.0" = type { target("spirv.Image", i16, 5, 2, 0, 0, 2, 0) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.1" = type { target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 24) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.2" = type { target("spirv.Image", i32, 5, 2, 0, 0, 2, 33) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.3" = type { target("spirv.SignedImage", i64, 5, 2, 0, 0, 2, 41) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.4" = type { target("spirv.Image", i64, 5, 2, 0, 0, 2, 40) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.5" = type { target("spirv.Image", half, 5, 2, 0, 0, 2, 0) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.6" = type { target("spirv.Image", float, 5, 2, 0, 0, 2, 3) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.7" = type { target("spirv.Image", double, 5, 2, 0, 0, 2, 0) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.8" = type { target("spirv.SignedImage", i16, 5, 2, 0, 0, 2, 0) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.9" = type { target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.10" = type { target("spirv.Image", half, 5, 2, 0, 0, 2, 0) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.11" = type { target("spirv.Image", float, 5, 2, 0, 0, 2, 0) }
|
||||
// SPIRV: %"class.hlsl::RWBuffer.12" = type { target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 21) }
|
||||
|
||||
RWBuffer<int16_t> BufI16;
|
||||
RWBuffer<uint16_t> BufU16;
|
||||
RWBuffer<int> BufI32;
|
||||
RWBuffer<uint> BufU32;
|
||||
RWBuffer<int64_t> BufI64;
|
||||
RWBuffer<uint64_t> BufU64;
|
||||
RWBuffer<half> BufF16;
|
||||
RWBuffer<float> BufF32;
|
||||
RWBuffer<double> BufF64;
|
||||
RWBuffer< vector<int16_t, 4> > BufI16x4;
|
||||
RWBuffer< vector<uint, 3> > BufU32x3;
|
||||
RWBuffer<half2> BufF16x2;
|
||||
RWBuffer<float3> BufF32x3;
|
||||
RWBuffer<int4> BufI32x4;
|
||||
// TODO: RWBuffer<snorm half> BufSNormF16; -> 11
|
||||
// TODO: RWBuffer<unorm half> BufUNormF16; -> 12
|
||||
// TODO: RWBuffer<snorm float> BufSNormF32; -> 13
|
||||
// TODO: RWBuffer<unorm float> BufUNormF32; -> 14
|
||||
// TODO: RWBuffer<snorm double> BufSNormF64; -> 15
|
||||
// TODO: RWBuffer<unorm double> BufUNormF64; -> 16
|
||||
|
||||
[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;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -o - -O0 %s | FileCheck %s --check-prefixes=DXC,CHECK
|
||||
// RUN: %clang_cc1 -triple spirv1.6-pc-vulkan1.3-compute -fspv-use-unknown-image-format -emit-llvm -o - -O0 %s | FileCheck %s --check-prefixes=SPIRV,CHECK
|
||||
|
||||
RWBuffer<int> In;
|
||||
RWBuffer<int> Out;
|
||||
|
||||
[numthreads(1,1,1)]
|
||||
void main(unsigned GI : SV_GroupIndex) {
|
||||
// CHECK: define void @main()
|
||||
|
||||
// DXC: %[[INPTR:.*]] = call noundef nonnull align 4 dereferenceable(4) ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_i32_1_0_1t(target("dx.TypedBuffer", i32, 1, 0, 1) %{{.*}}, i32 %{{.*}})
|
||||
// SPIRV: %[[INPTR:.*]] = call noundef align 4 dereferenceable(4) ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.SignedImage_i32_5_2_0_0_2_0t(target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 0) %{{.*}}, i32 %{{.*}})
|
||||
// CHECK: %[[LOAD:.*]] = load i32, ptr {{.*}}%[[INPTR]]
|
||||
// DXC: %[[OUTPTR:.*]] = call noundef nonnull align 4 dereferenceable(4) ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_i32_1_0_1t(target("dx.TypedBuffer", i32, 1, 0, 1) %{{.*}}, i32 %{{.*}})
|
||||
// SPIRV: %[[OUTPTR:.*]] = call noundef align 4 dereferenceable(4) ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.SignedImage_i32_5_2_0_0_2_0t(target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 0) %{{.*}}, i32 %{{.*}})
|
||||
// CHECK: store i32 %[[LOAD]], ptr {{.*}}%[[OUTPTR]]
|
||||
Out[GI] = In[GI];
|
||||
|
||||
// DXC: %[[INPTR:.*]] = call ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_i32_1_0_1t(target("dx.TypedBuffer", i32, 1, 0, 1) %{{.*}}, i32 %{{.*}})
|
||||
// SPIRV: %[[INPTR:.*]] = call ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.SignedImage_i32_5_2_0_0_2_0t(target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 0) %{{.*}}, i32 %{{.*}})
|
||||
// CHECK: %[[LOAD:.*]] = load i32, ptr {{.*}}%[[INPTR]]
|
||||
// DXC: %[[OUTPTR:.*]] = call noundef nonnull align 4 dereferenceable(4) ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_i32_1_0_1t(target("dx.TypedBuffer", i32, 1, 0, 1) %{{.*}}, i32 %{{.*}})
|
||||
// SPIRV: %[[OUTPTR:.*]] = call noundef align 4 dereferenceable(4) ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.SignedImage_i32_5_2_0_0_2_0t(target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 0) %{{.*}}, i32 %{{.*}})
|
||||
// CHECK: store i32 %[[LOAD]], ptr {{.*}}%[[OUTPTR]]
|
||||
Out[GI] = In.Load(GI);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes -o - %s | \
|
||||
// RUN: llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK,CHECK-DXIL
|
||||
// RUN: llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK,CHECK-DXIL
|
||||
// FIXME: SPIR-V codegen of llvm.spv.resource.handlefrombinding and resource types is not yet implemented
|
||||
// RUN-DISABLED: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | \
|
||||
// llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV
|
||||
@@ -14,7 +14,7 @@
|
||||
RWBuffer<float> Buf1 : register(u5, space3);
|
||||
|
||||
// Resource with implicit binding
|
||||
RWBuffer<double> Buf2;
|
||||
Buffer<double> Buf2;
|
||||
|
||||
export void foo() {
|
||||
// Local resource declaration
|
||||
@@ -22,12 +22,12 @@ export void foo() {
|
||||
}
|
||||
|
||||
// CHECK: %"class.hlsl::RWBuffer" = type { target("dx.TypedBuffer", float, 1, 0, 0) }
|
||||
// CHECK: %"class.hlsl::RWBuffer.0" = type { target("dx.TypedBuffer", double, 1, 0, 0) }
|
||||
// CHECK: %"class.hlsl::RWBuffer.1" = type { target("dx.TypedBuffer", i32, 1, 0, 1) }
|
||||
// CHECK: %"class.hlsl::Buffer" = type { target("dx.TypedBuffer", double, 0, 0, 0) }
|
||||
// CHECK: %"class.hlsl::RWBuffer.0" = type { target("dx.TypedBuffer", i32, 1, 0, 1) }
|
||||
|
||||
// CHECK: @Buf1 = internal global %"class.hlsl::RWBuffer" poison, align 4
|
||||
// CHECK: @[[Buf1Str:.*]] = private unnamed_addr constant [5 x i8] c"Buf1\00", align 1
|
||||
// CHECK: @Buf2 = internal global %"class.hlsl::RWBuffer.0" poison, align 4
|
||||
// CHECK: @Buf2 = internal global %"class.hlsl::Buffer" poison, align 4
|
||||
// CHECK: @[[Buf2Str:.*]] = private unnamed_addr constant [5 x i8] c"Buf2\00", align 1
|
||||
|
||||
// Buf1 initialization part 1 - global init function that calls RWBuffer<float>::__createFromBinding
|
||||
@@ -50,24 +50,24 @@ export void foo() {
|
||||
// Buf2 initialization part 1 - global init function that RWBuffer<float>::__createFromImplicitBinding
|
||||
// CHECK: define internal void @__cxx_global_var_init.1()
|
||||
// CHECK-NEXT: entry:
|
||||
// CHECK-NEXT: call void @hlsl::RWBuffer<double>::__createFromImplicitBinding(unsigned int, unsigned int, int, unsigned int, char const*)
|
||||
// CHECK-NEXT: call void @hlsl::Buffer<double>::__createFromImplicitBinding(unsigned int, unsigned int, int, unsigned int, char const*)
|
||||
// CHECK-SAME: (ptr {{.*}} @Buf2, i32 noundef 0, i32 noundef 0, i32 noundef 1, i32 noundef 0, ptr noundef @[[Buf2Str]])
|
||||
|
||||
// Buf2 initialization part 2 - body of RWBuffer<float>::__createFromImplicitBinding call
|
||||
// CHECK: define linkonce_odr hidden void @hlsl::RWBuffer<double>::__createFromImplicitBinding(unsigned int, unsigned int, int, unsigned int, char const*)
|
||||
// CHECK-SAME: (ptr {{.*}} sret(%"class.hlsl::RWBuffer.0") align 4 %[[RetValue2:.*]], i32 noundef %orderId,
|
||||
// Buf2 initialization part 2 - body of Buffer<double>::__createFromImplicitBinding call
|
||||
// CHECK: define linkonce_odr hidden void @hlsl::Buffer<double>::__createFromImplicitBinding(unsigned int, unsigned int, int, unsigned int, char const*)
|
||||
// CHECK-SAME: (ptr {{.*}} sret(%"class.hlsl::Buffer") align 4 %[[RetValue2:.*]], i32 noundef %orderId,
|
||||
// CHECK-SAME: i32 noundef %spaceNo, i32 noundef %range, i32 noundef %index, ptr noundef %name)
|
||||
// CHECK: %[[Tmp2:.*]] = alloca %"class.hlsl::RWBuffer.0", align 4
|
||||
// CHECK: %[[Handle2:.*]] = call target("dx.TypedBuffer", double, 1, 0, 0)
|
||||
// CHECK-SAME: @llvm.dx.resource.handlefromimplicitbinding.tdx.TypedBuffer_f64_1_0_0t(
|
||||
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::RWBuffer.0", ptr %[[Tmp2]], i32 0, i32 0
|
||||
// CHECK-DXIL: store target("dx.TypedBuffer", double, 1, 0, 0) %[[Handle2]], ptr %__handle, align 4
|
||||
// CHECK: call void @hlsl::RWBuffer<double>::RWBuffer(hlsl::RWBuffer<double> const&)(ptr {{.*}} %[[RetValue2]], ptr {{.*}} %[[Tmp2]])
|
||||
// CHECK: %[[Tmp2:.*]] = alloca %"class.hlsl::Buffer", align 4
|
||||
// CHECK: %[[Handle2:.*]] = call target("dx.TypedBuffer", double, 0, 0, 0)
|
||||
// CHECK-SAME: @llvm.dx.resource.handlefromimplicitbinding.tdx.TypedBuffer_f64_0_0_0t(
|
||||
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::Buffer", ptr %[[Tmp2]], i32 0, i32 0
|
||||
// CHECK-DXIL: store target("dx.TypedBuffer", double, 0, 0, 0) %[[Handle2]], ptr %__handle, align 4
|
||||
// CHECK: call void @hlsl::Buffer<double>::Buffer(hlsl::Buffer<double> const&)(ptr {{.*}} %[[RetValue2]], ptr {{.*}} %[[Tmp2]])
|
||||
|
||||
// Buf3 initialization part 1 - local variable declared in function foo() is initialized by RWBuffer<int> C1 default constructor
|
||||
// CHECK: define void @foo()
|
||||
// CHECK-NEXT: entry:
|
||||
// CHECK-NEXT: %Buf3 = alloca %"class.hlsl::RWBuffer.1", align 4
|
||||
// CHECK-NEXT: %Buf3 = alloca %"class.hlsl::RWBuffer.0", align 4
|
||||
// CHECK-NEXT: call void @hlsl::RWBuffer<int>::RWBuffer()(ptr {{.*}} %Buf3)
|
||||
|
||||
// Buf3 initialization part 2 - body of RWBuffer<int> default C1 constructor that calls the default C2 constructor
|
||||
@@ -76,11 +76,11 @@ export void foo() {
|
||||
|
||||
// Buf3 initialization part 3 - body of RWBuffer<int> default C2 constructor that initializes handle to poison
|
||||
// CHECK: define linkonce_odr hidden void @hlsl::RWBuffer<int>::RWBuffer()(ptr {{.*}} %this)
|
||||
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::RWBuffer.1", ptr %{{.*}}, i32 0, i32 0
|
||||
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::RWBuffer.0", ptr %{{.*}}, i32 0, i32 0
|
||||
// CHECK-NEXT: store target("dx.TypedBuffer", i32, 1, 0, 1) poison, ptr %__handle, align 4
|
||||
|
||||
// Module initialization
|
||||
// CHECK: define internal void @_GLOBAL__sub_I_RWBuffer_constructor.hlsl()
|
||||
// CHECK: define internal void @_GLOBAL__sub_I_TypedBuffers_constructor.hlsl()
|
||||
// CHECK-NEXT: entry:
|
||||
// CHECK-NEXT: call void @__cxx_global_var_init()
|
||||
// CHECK-NEXT: call void @__cxx_global_var_init.1()
|
||||
@@ -0,0 +1,94 @@
|
||||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute -finclude-default-header -fnative-half-type \
|
||||
// RUN: -emit-llvm -o - -DRESOURCE=Buffer %s | FileCheck %s -DRESOURCE=Buffer -DRW=0 -check-prefixes=DXIL
|
||||
|
||||
// RUN: %clang_cc1 -triple spirv-pc-vulkan-compute -finclude-default-header -fnative-half-type \
|
||||
// RUN: -emit-llvm -o - -DRESOURCE=Buffer %s | FileCheck %s -DRESOURCE=Buffer -DRW=1 -check-prefixes=SPV-RO
|
||||
|
||||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute -finclude-default-header -fnative-half-type \
|
||||
// RUN: -emit-llvm -o - -DRESOURCE=RWBuffer %s | FileCheck %s -DRESOURCE=RWBuffer -DRW=1 -check-prefixes=DXIL
|
||||
|
||||
// RUN: %clang_cc1 -triple spirv-pc-vulkan-compute -finclude-default-header -fnative-half-type \
|
||||
// RUN: -emit-llvm -o - -DRESOURCE=RWBuffer %s | FileCheck %s -DRESOURCE=RWBuffer --DRW=2 -check-prefixes=SPV-RW
|
||||
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]]" = type { target("dx.TypedBuffer", i16, [[RW]], 0, 1) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].0" = type { target("dx.TypedBuffer", i16, [[RW]], 0, 0) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].1" = type { target("dx.TypedBuffer", i32, [[RW]], 0, 1) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].2" = type { target("dx.TypedBuffer", i32, [[RW]], 0, 0) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].3" = type { target("dx.TypedBuffer", i64, [[RW]], 0, 1) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].4" = type { target("dx.TypedBuffer", i64, [[RW]], 0, 0) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].5" = type { target("dx.TypedBuffer", half, [[RW]], 0, 0) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].6" = type { target("dx.TypedBuffer", float, [[RW]], 0, 0) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].7" = type { target("dx.TypedBuffer", double, [[RW]], 0, 0) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].8" = type { target("dx.TypedBuffer", <4 x i16>, [[RW]], 0, 1) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].9" = type { target("dx.TypedBuffer", <3 x i32>, [[RW]], 0, 0) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].10" = type { target("dx.TypedBuffer", <2 x half>, [[RW]], 0, 0) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].11" = type { target("dx.TypedBuffer", <3 x float>, [[RW]], 0, 0) }
|
||||
// DXIL: %"class.hlsl::[[RESOURCE]].12" = type { target("dx.TypedBuffer", <4 x i32>, [[RW]], 0, 1) }
|
||||
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]]" = type { target("spirv.SignedImage", i16, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].0" = type { target("spirv.Image", i16, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].1" = type { target("spirv.SignedImage", i32, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].2" = type { target("spirv.Image", i32, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].3" = type { target("spirv.SignedImage", i64, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].4" = type { target("spirv.Image", i64, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].5" = type { target("spirv.Image", half, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].6" = type { target("spirv.Image", float, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].7" = type { target("spirv.Image", double, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].8" = type { target("spirv.SignedImage", i16, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].9" = type { target("spirv.Image", i32, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].10" = type { target("spirv.Image", half, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].11" = type { target("spirv.Image", float, 5, 2, 0, 0, 1, 0) }
|
||||
// SPV-RO: %"class.hlsl::[[RESOURCE]].12" = type { target("spirv.SignedImage", i32, 5, 2, 0, 0, 1, 0) }
|
||||
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]]" = type { target("spirv.SignedImage", i16, 5, 2, 0, 0, 2, 0) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].0" = type { target("spirv.Image", i16, 5, 2, 0, 0, 2, 0) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].1" = type { target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 24) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].2" = type { target("spirv.Image", i32, 5, 2, 0, 0, 2, 33) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].3" = type { target("spirv.SignedImage", i64, 5, 2, 0, 0, 2, 41) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].4" = type { target("spirv.Image", i64, 5, 2, 0, 0, 2, 40) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].5" = type { target("spirv.Image", half, 5, 2, 0, 0, 2, 0) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].6" = type { target("spirv.Image", float, 5, 2, 0, 0, 2, 3) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].7" = type { target("spirv.Image", double, 5, 2, 0, 0, 2, 0) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].8" = type { target("spirv.SignedImage", i16, 5, 2, 0, 0, 2, 0) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].9" = type { target("spirv.Image", i32, 5, 2, 0, 0, 2, 0) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].10" = type { target("spirv.Image", half, 5, 2, 0, 0, 2, 0) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].11" = type { target("spirv.Image", float, 5, 2, 0, 0, 2, 0) }
|
||||
// SPV-RW: %"class.hlsl::[[RESOURCE]].12" = type { target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 21) }
|
||||
|
||||
RESOURCE<int16_t> BufI16;
|
||||
RESOURCE<uint16_t> BufU16;
|
||||
RESOURCE<int> BufI32;
|
||||
RESOURCE<uint> BufU32;
|
||||
RESOURCE<int64_t> BufI64;
|
||||
RESOURCE<uint64_t> BufU64;
|
||||
RESOURCE<half> BufF16;
|
||||
RESOURCE<float> BufF32;
|
||||
RESOURCE<double> BufF64;
|
||||
RESOURCE< vector<int16_t, 4> > BufI16x4;
|
||||
RESOURCE< vector<uint, 3> > BufU32x3;
|
||||
RESOURCE<half2> BufF16x2;
|
||||
RESOURCE<float3> BufF32x3;
|
||||
RESOURCE<int4> BufI32x4;
|
||||
// TODO: RESOURCE<snorm half> BufSNormF16; -> 11
|
||||
// TODO: RESOURCE<unorm half> BufUNormF16; -> 12
|
||||
// TODO: RESOURCE<snorm float> BufSNormF32; -> 13
|
||||
// TODO: RESOURCE<unorm float> BufUNormF32; -> 14
|
||||
// TODO: RESOURCE<snorm double> BufSNormF64; -> 15
|
||||
// TODO: RESOURCE<unorm double> BufUNormF64; -> 16
|
||||
|
||||
[numthreads(1,1,1)]
|
||||
void main(int GI : SV_GroupIndex) {
|
||||
int16_t v1 = BufI16[GI];
|
||||
uint16_t v2 = BufU16[GI];
|
||||
int v3 = BufI32[GI];
|
||||
uint v4 = BufU32[GI];
|
||||
int64_t v5 = BufI64[GI];
|
||||
uint64_t v6 = BufU64[GI];
|
||||
half v7 = BufF16[GI];
|
||||
float v8 = BufF32[GI];
|
||||
double v9 = BufF64[GI];
|
||||
vector<int16_t,4> v10 = BufI16x4[GI];
|
||||
vector<int, 3> v11 = BufU32x3[GI];
|
||||
half2 v12 = BufF16x2[GI];
|
||||
float3 v13 = BufF32x3[GI];
|
||||
}
|
||||
42
clang/test/CodeGenHLSL/resources/TypedBuffers-methods.hlsl
Normal file
42
clang/test/CodeGenHLSL/resources/TypedBuffers-methods.hlsl
Normal file
@@ -0,0 +1,42 @@
|
||||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -finclude-default-header -emit-llvm -disable-llvm-passes -o - %s | llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK,DXIL
|
||||
// RUN-DISABLED: %clang_cc1 -triple spirv-vulkan-library -finclude-default-header -emit-llvm -disable-llvm-passes -o - %s | llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK,SPIRV
|
||||
|
||||
// NOTE: SPIRV codegen for resource methods is not yet implemented
|
||||
|
||||
Buffer<float> Buf : register(t0);
|
||||
RWBuffer<uint4> RWBuf : register(u0);
|
||||
|
||||
// DXIL: %"class.hlsl::Buffer" = type { target("dx.TypedBuffer", float, 0, 0, 0) }
|
||||
// DXIL: %"class.hlsl::RWBuffer" = type { target("dx.TypedBuffer", <4 x i32>, 1, 0, 0) }
|
||||
|
||||
// DXIL: @Buf = internal global %"class.hlsl::Buffer" poison
|
||||
// DXIL: @RWBuf = internal global %"class.hlsl::RWBuffer" poison
|
||||
|
||||
export float TestLoad() {
|
||||
return Buf.Load(1) + RWBuf.Load(2).y;
|
||||
}
|
||||
|
||||
// CHECK: define noundef nofpclass(nan inf) float @TestLoad()()
|
||||
// CHECK: call {{.*}} float @hlsl::Buffer<float>::Load(unsigned int)(ptr {{.*}} @Buf, i32 noundef 1)
|
||||
// CHECK: call {{.*}} <4 x i32> @hlsl::RWBuffer<unsigned int vector[4]>::Load(unsigned int)(ptr {{.*}} @RWBuf, i32 noundef 2)
|
||||
// CHECK: add
|
||||
// CHECK: ret float
|
||||
|
||||
// CHECK: define {{.*}} float @hlsl::Buffer<float>::Load(unsigned int)(ptr {{.*}} %this, i32 noundef %Index)
|
||||
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::Buffer", ptr %{{.*}}, i32 0, i32 0
|
||||
// DXIL-NEXT: %[[HANDLE:.*]] = load target("dx.TypedBuffer", float, 0, 0, 0), ptr %__handle
|
||||
// CHECK-NEXT: %[[INDEX:.*]] = load i32, ptr %Index.addr
|
||||
// DXIL-NEXT: %[[PTR:.*]] = call ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_f32_0_0_0t(target("dx.TypedBuffer", float, 0, 0, 0) %[[HANDLE]], i32 %[[INDEX]])
|
||||
// CHECK-NEXT: %[[VAL:.*]] = load float, ptr %[[PTR]]
|
||||
// CHECK-NEXT: ret float %[[VAL]]
|
||||
|
||||
// CHECK: define {{.*}} <4 x i32> @hlsl::RWBuffer<unsigned int vector[4]>::Load(unsigned int)(ptr {{.*}} %this, i32 noundef %Index)
|
||||
// CHECK: %__handle = getelementptr inbounds nuw %"class.hlsl::RWBuffer", ptr %{{.*}}, i32 0, i32 0
|
||||
// DXIL-NEXT: %[[HANDLE:.*]] = load target("dx.TypedBuffer", <4 x i32>, 1, 0, 0), ptr %__handle
|
||||
// CHECK-NEXT: %[[INDEX:.*]] = load i32, ptr %Index.addr
|
||||
// DXIL-NEXT: %[[PTR:.*]] = call ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_v4i32_1_0_0t(target("dx.TypedBuffer", <4 x i32>, 1, 0, 0) %[[HANDLE]], i32 %[[INDEX]])
|
||||
// CHECK-NEXT: %[[VEC:.*]] = load <4 x i32>, ptr %[[PTR]]
|
||||
// CHECK-NEXT: ret <4 x i32> %[[VEC]]
|
||||
|
||||
// DXIL: declare ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_f32_0_0_0t(target("dx.TypedBuffer", float, 0, 0, 0), i32)
|
||||
// DXIL: declare ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_v4i32_1_0_0t(target("dx.TypedBuffer", <4 x i32>, 1, 0, 0), i32)
|
||||
26
clang/test/CodeGenHLSL/resources/TypedBuffers-subscript.hlsl
Normal file
26
clang/test/CodeGenHLSL/resources/TypedBuffers-subscript.hlsl
Normal file
@@ -0,0 +1,26 @@
|
||||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -o - -O0 %s | FileCheck %s --check-prefixes=DXIL,CHECK
|
||||
// RUN: %clang_cc1 -triple spirv1.6-pc-vulkan1.3-compute -fspv-use-unknown-image-format -emit-llvm -o - -O0 %s | FileCheck %s --check-prefixes=SPIRV,CHECK
|
||||
|
||||
Buffer<int> In;
|
||||
RWBuffer<int> Out;
|
||||
|
||||
[numthreads(1,1,1)]
|
||||
void main(unsigned GI : SV_GroupIndex) {
|
||||
// CHECK: define void @main()
|
||||
|
||||
// DXIL: %[[INPTR:.*]] = call {{.*}} ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_i32_0_0_1t(target("dx.TypedBuffer", i32, 0, 0, 1) %{{.*}}, i32 %{{.*}})
|
||||
// SPIRV: %[[INPTR:.*]] = call {{.*}} ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.SignedImage_i32_5_2_0_0_1_0t(target("spirv.SignedImage", i32, 5, 2, 0, 0, 1, 0) %{{.*}}, i32 %{{.*}})
|
||||
// CHECK: %[[LOAD:.*]] = load i32, ptr {{.*}}%[[INPTR]]
|
||||
// DXIL: %[[OUTPTR:.*]] = call {{.*}} ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_i32_1_0_1t(target("dx.TypedBuffer", i32, 1, 0, 1) %{{.*}}, i32 %{{.*}})
|
||||
// SPIRV: %[[OUTPTR:.*]] = call {{.*}} ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.SignedImage_i32_5_2_0_0_2_0t(target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 0) %{{.*}}, i32 %{{.*}})
|
||||
// CHECK: store i32 %[[LOAD]], ptr {{.*}}%[[OUTPTR]]
|
||||
Out[GI] = In[GI];
|
||||
|
||||
// DXIL: %[[INPTR:.*]] = call {{.*}} ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_i32_1_0_1t(target("dx.TypedBuffer", i32, 1, 0, 1) %{{.*}}, i32 %{{.*}})
|
||||
// SPIRV: %[[INPTR:.*]] = call {{.*}} ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.SignedImage_i32_5_2_0_0_2_0t(target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 0) %{{.*}}, i32 %{{.*}})
|
||||
// CHECK: %[[LOAD:.*]] = load i32, ptr {{.*}}%[[INPTR]]
|
||||
// DXIL: %[[OUTPTR:.*]] = call {{.*}} ptr @llvm.dx.resource.getpointer.p0.tdx.TypedBuffer_i32_1_0_1t(target("dx.TypedBuffer", i32, 1, 0, 1) %{{.*}}, i32 %{{.*}})
|
||||
// SPIRV: %[[OUTPTR:.*]] = call {{.*}} ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.SignedImage_i32_5_2_0_0_2_0t(target("spirv.SignedImage", i32, 5, 2, 0, 0, 2, 0) %{{.*}}, i32 %{{.*}})
|
||||
// CHECK: store i32 %[[LOAD]], ptr {{.*}}%[[OUTPTR]]
|
||||
Out[GI + 1] = Out[GI];
|
||||
}
|
||||
Reference in New Issue
Block a user