Skip to content

Commit ea4ff29

Browse files
author
Greg Roth
authored
[lit][SPIRV] convert runFileTest shaders to lit FileCheck test (microsoft#5911)
Convert from bottom of CodeGenSpirvTest.cpp. Skipped FileTest::CompatibilityWithVk1p1 as barrier for runCodeTest.
2 parents f6bf30a + 121344a commit ea4ff29

File tree

47 files changed

+283
-448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+283
-448
lines changed

tools/clang/test/CodeGenSPIRV/spirv.legal.cbuffer.hlsl

Lines changed: 0 additions & 76 deletions
This file was deleted.

tools/clang/test/CodeGenSPIRV/spirv.legal.tbuffer.hlsl

Lines changed: 0 additions & 81 deletions
This file was deleted.

tools/clang/test/CodeGenSPIRV/vk.cloption.invert-w.ps.hlsl

Lines changed: 0 additions & 12 deletions
This file was deleted.

tools/clang/test/CodeGenSPIRV/vk.cloption.invert-y.vs.hlsl

Lines changed: 0 additions & 11 deletions
This file was deleted.

tools/clang/test/CodeGenSPIRV/spirv.interpolation.ps.hlsl renamed to tools/clang/test/CodeGenSPIRV_Lit/spirv.interpolation.ps.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %dxc -T ps_6_0 -E main
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
22

33
// Required by the sample interpolation mode
44
// CHECK: OpCapability SampleRateShading

tools/clang/test/CodeGenSPIRV/spirv.interpolation.vs.hlsl renamed to tools/clang/test/CodeGenSPIRV_Lit/spirv.interpolation.vs.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %dxc -T vs_6_0 -E main
1+
// RUN: %dxc -T vs_6_0 -E main -fcgl %s -spirv | FileCheck %s
22

33
// Required by the sample interpolation mode
44
// CHECK: OpCapability SampleRateShading
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// %type_ConstantBuffer_S is the type for myCBuffer. With layout decoration.
4+
// %S is the type for myASBuffer elements. With layout decoration.
5+
// %S_0 is the type for function local variables. Without layout decoration.
6+
7+
// CHECK: OpMemberDecorate %type_ConstantBuffer_S 0 Offset 0
8+
// CHECK: OpMemberDecorate %S 0 Offset 0
9+
// CHECK-NOT: OpMemberDecorate %S_0 0 Offset 0
10+
11+
// CHECK: %type_ConstantBuffer_S = OpTypeStruct %v4float
12+
// CHECK: %S = OpTypeStruct %v4float
13+
// CHECK: %S_0 = OpTypeStruct %v4float
14+
struct S {
15+
float4 f;
16+
};
17+
18+
// CHECK: %myCBuffer = OpVariable %_ptr_Uniform_type_ConstantBuffer_S Uniform
19+
ConstantBuffer<S> myCBuffer;
20+
AppendStructuredBuffer<S> myASBuffer;
21+
22+
S retStuff();
23+
24+
float4 doStuff(S buffer) {
25+
return buffer.f;
26+
}
27+
28+
float4 main(in float4 pos : SV_Position) : SV_Target
29+
{
30+
// Initializing a T with a ConstantBuffer<T> is a copy
31+
// CHECK: [[val:%[0-9]+]] = OpLoad %type_ConstantBuffer_S %myCBuffer
32+
// CHECK-NEXT: [[vec:%[0-9]+]] = OpCompositeExtract %v4float [[val]] 0
33+
// CHECK-NEXT: [[tmp:%[0-9]+]] = OpCompositeConstruct %S_0 [[vec]]
34+
// CHECK-NEXT: OpStore %buffer1 [[tmp]]
35+
S buffer1 = myCBuffer;
36+
37+
// Assigning a ConstantBuffer<T> to a T is a copy
38+
// CHECK: [[val_0:%[0-9]+]] = OpLoad %type_ConstantBuffer_S %myCBuffer
39+
// CHECK-NEXT: [[vec_0:%[0-9]+]] = OpCompositeExtract %v4float [[val_0]] 0
40+
// CHECK-NEXT: [[tmp_0:%[0-9]+]] = OpCompositeConstruct %S_0 [[vec_0]]
41+
// CHECK-NEXT: OpStore %buffer2 [[tmp_0]]
42+
S buffer2;
43+
buffer2 = myCBuffer;
44+
45+
// We have the same struct type here
46+
// CHECK: [[val_1:%[0-9]+]] = OpFunctionCall %S_0 %retStuff
47+
// CHECK-NEXT: OpStore %buffer3 [[val_1]]
48+
S buffer3;
49+
buffer3 = retStuff();
50+
51+
// Write out each component recursively
52+
// CHECK: [[ptr:%[0-9]+]] = OpAccessChain %_ptr_Uniform_S %myASBuffer %uint_0 {{%[0-9]+}}
53+
// CHECK-NEXT: [[val_2:%[0-9]+]] = OpLoad %type_ConstantBuffer_S %myCBuffer
54+
// CHECK-NEXT: [[vec_1:%[0-9]+]] = OpCompositeExtract %v4float [[val_2]] 0
55+
// CHECK-NEXT: [[tmp_1:%[0-9]+]] = OpCompositeConstruct %S_0 [[vec_1]]
56+
// CHECK-NEXT: [[vec_2:%[0-9]+]] = OpCompositeExtract %v4float [[tmp_1]] 0
57+
// CHECK-NEXT: [[tmp_2:%[0-9]+]] = OpCompositeConstruct %S [[vec_2]]
58+
// CHECK-NEXT: OpStore [[ptr]] [[tmp_2]]
59+
myASBuffer.Append(myCBuffer);
60+
61+
// Passing a ConstantBuffer<T> to a T parameter is a copy
62+
// CHECK: [[val_3:%[0-9]+]] = OpLoad %type_ConstantBuffer_S %myCBuffer
63+
// CHECK-NEXT: [[vec_3:%[0-9]+]] = OpCompositeExtract %v4float [[val_3]] 0
64+
// CHECK-NEXT: [[tmp_3:%[0-9]+]] = OpCompositeConstruct %S_0 [[vec_3]]
65+
// CHECK-NEXT: OpStore %param_var_buffer [[tmp_3]]
66+
return doStuff(myCBuffer);
67+
}
68+
69+
S retStuff() {
70+
// Returning a ConstantBuffer<T> as a T is a copy
71+
// CHECK: [[val_4:%[0-9]+]] = OpLoad %type_ConstantBuffer_S %myCBuffer
72+
// CHECK-NEXT: [[vec_4:%[0-9]+]] = OpCompositeExtract %v4float [[val_4]] 0
73+
// CHECK-NEXT: [[ret:%[0-9]+]] = OpCompositeConstruct %S_0 [[vec_4]]
74+
// CHECK-NEXT: OpReturnValue [[ret]]
75+
return myCBuffer;
76+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
2+
3+
// Note: The following is invalid SPIR-V code.
4+
//
5+
// * The assignment ignores storage class (and thus layout) difference.
6+
7+
// %type_TextureBuffer_S is the type for myTBuffer. With layout decoration.
8+
// %S is the type for myASBuffer elements. With layout decoration.
9+
// %S_0 is the type for function local variables. Without layout decoration.
10+
11+
// CHECK: OpMemberDecorate %type_TextureBuffer_S 0 Offset 0
12+
// CHECK: OpMemberDecorate %S 0 Offset 0
13+
// CHECK-NOT: OpMemberDecorate %S_0 0 Offset 0
14+
15+
// CHECK: %type_TextureBuffer_S = OpTypeStruct %v4float
16+
// CHECK: %S = OpTypeStruct %v4float
17+
// CHECK: %S_0 = OpTypeStruct %v4float
18+
struct S {
19+
float4 f;
20+
};
21+
22+
// CHECK: %myTBuffer = OpVariable %_ptr_Uniform_type_TextureBuffer_S Uniform
23+
TextureBuffer<S> myTBuffer;
24+
AppendStructuredBuffer<S> myASBuffer;
25+
26+
S retStuff();
27+
28+
float4 doStuff(S buffer) {
29+
return buffer.f;
30+
}
31+
32+
float4 main(in float4 pos : SV_Position) : SV_Target
33+
{
34+
// Initializing a T with a TextureBuffer<T> is a copy
35+
// CHECK: [[val:%[0-9]+]] = OpLoad %type_TextureBuffer_S %myTBuffer
36+
// CHECK-NEXT: [[vec:%[0-9]+]] = OpCompositeExtract %v4float [[val]] 0
37+
// CHECK-NEXT: [[tmp:%[0-9]+]] = OpCompositeConstruct %S_0 [[vec]]
38+
// CHECK-NEXT: OpStore %buffer1 [[tmp]]
39+
S buffer1 = myTBuffer;
40+
41+
// Assigning a TextureBuffer<T> to a T is a copy
42+
// CHECK: [[val_0:%[0-9]+]] = OpLoad %type_TextureBuffer_S %myTBuffer
43+
// CHECK-NEXT: [[vec_0:%[0-9]+]] = OpCompositeExtract %v4float [[val_0]] 0
44+
// CHECK-NEXT: [[tmp_0:%[0-9]+]] = OpCompositeConstruct %S_0 [[vec_0]]
45+
// CHECK-NEXT: OpStore %buffer2 [[tmp_0]]
46+
S buffer2;
47+
buffer2 = myTBuffer;
48+
49+
// We have the same struct type here
50+
// CHECK: [[val_1:%[0-9]+]] = OpFunctionCall %S_0 %retStuff
51+
// CHECK-NEXT: OpStore %buffer3 [[val_1]]
52+
S buffer3;
53+
buffer3 = retStuff();
54+
55+
// TODO: The underlying struct type has the same layout but %type_TextureBuffer_S
56+
// has an additional BufferBlock decoration. So this causes an validation error.
57+
// CHECK: [[ptr:%[0-9]+]] = OpAccessChain %_ptr_Uniform_S %myASBuffer %uint_0 {{%[0-9]+}}
58+
// CHECK-NEXT: [[tb:%[0-9]+]] = OpLoad %type_TextureBuffer_S %myTBuffer
59+
// CHECK-NEXT: [[vec_1:%[0-9]+]] = OpCompositeExtract %v4float [[tb]] 0
60+
// CHECK-NEXT: [[loc:%[0-9]+]] = OpCompositeConstruct %S_0 [[vec_1]]
61+
// CHECK-NEXT: [[vec_2:%[0-9]+]] = OpCompositeExtract %v4float [[loc]] 0
62+
// CHECK-NEXT: [[val_2:%[0-9]+]] = OpCompositeConstruct %S [[vec_2]]
63+
// CHECK-NEXT: OpStore [[ptr]] [[val_2]]
64+
myASBuffer.Append(myTBuffer);
65+
66+
// Passing a TextureBuffer<T> to a T parameter is a copy
67+
// CHECK: [[val_3:%[0-9]+]] = OpLoad %type_TextureBuffer_S %myTBuffer
68+
// CHECK-NEXT: [[vec_3:%[0-9]+]] = OpCompositeExtract %v4float [[val_3]] 0
69+
// CHECK-NEXT: [[tmp_1:%[0-9]+]] = OpCompositeConstruct %S_0 [[vec_3]]
70+
// CHECK-NEXT: OpStore %param_var_buffer [[tmp_1]]
71+
return doStuff(myTBuffer);
72+
}
73+
74+
S retStuff() {
75+
// Returning a TextureBuffer<T> as a T is a copy
76+
// CHECK: [[val_4:%[0-9]+]] = OpLoad %type_TextureBuffer_S %myTBuffer
77+
// CHECK-NEXT: [[vec_4:%[0-9]+]] = OpCompositeExtract %v4float [[val_4]] 0
78+
// CHECK-NEXT: [[ret:%[0-9]+]] = OpCompositeConstruct %S_0 [[vec_4]]
79+
// CHECK-NEXT: OpReturnValue [[ret]]
80+
return myTBuffer;
81+
}

tools/clang/test/CodeGenSPIRV/spirv.stage-io.16bit.hlsl renamed to tools/clang/test/CodeGenSPIRV_Lit/spirv.stage-io.16bit.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %dxc -T vs_6_2 -E main -enable-16bit-types
1+
// RUN: %dxc -T vs_6_2 -E main -enable-16bit-types -fcgl %s -spirv | FileCheck %s
22

33
// CHECK: OpCapability StorageInputOutput16
44

tools/clang/test/CodeGenSPIRV/spirv.stage-io.relaxed-precision.hlsl renamed to tools/clang/test/CodeGenSPIRV_Lit/spirv.stage-io.relaxed-precision.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %dxc -T vs_6_2 -E main
1+
// RUN: %dxc -T vs_6_2 -E main -fcgl %s -spirv | FileCheck %s
22

33
// CHECK: OpDecorate %in_var_A Location 0
44
// CHECK: OpDecorate %in_var_B Location 4

0 commit comments

Comments
 (0)