1
- // RUN: %dxc -T cs_6_6 %s | FileCheck %s
1
+ // RUN: %dxc -DTYPE=float4 -DIX=SIx -T vs_6_6 %s | FileCheck %s
2
+ // RUN: %dxc -DTYPE=Float4 -DIX=SIx -T vs_6_6 %s | FileCheck %s
3
+ // RUN: %dxc -DARRAYS -DIX=SIx -T vs_6_6 %s | FileCheck %s
4
+ // RUN: %dxc -DTYPE=float4 -DIX=VIx -T vs_6_6 %s | FileCheck %s --check-prefixes=CHECK,VIX
5
+ // RUN: %dxc -DTYPE=Float4 -DIX=VIx -T vs_6_6 %s | FileCheck %s --check-prefixes=CHECK,VIX
6
+ // RUN: %dxc -DARRAYS -DIX=VIx -T vs_6_6 %s | FileCheck %s --check-prefixes=CHECK,VIX
2
7
3
8
// Test codegen for various load and store operations for different buffer types and indexes
4
9
5
- struct Float4 { float4 f; };
6
-
7
- #ifdef STRUCTS
8
- #define TYPE Float4
10
+ #ifdef ARRAYS
11
+ #define TYPE float [ 4 ]
12
+ #define TBTYPE float4
13
+ #define DECL (x) float x[ 4 ]
9
14
#else
10
- #define TYPE float4
15
+ #define TBTYPE TYPE
16
+ #define DECL (x) TYPE x
11
17
#endif
12
- // TODO: Add testing for arrays
13
18
19
+ struct Float4 { float4 f; };
14
20
15
- // Start at 1 to avoid the weird zeroinitilizer createHandle case below
16
21
ByteAddressBuffer RoByBuf : register (t1);
17
22
RWByteAddressBuffer RwByBuf : register (u1);
18
23
19
24
StructuredBuffer< TYPE > RoStBuf : register (t2);
20
25
RWStructuredBuffer < TYPE > RwStBuf : register (u2);
21
26
22
- Buffer < TYPE > RoTyBuf : register (t3);
23
- RWBuffer < TYPE > RwTyBuf : register (u3);
27
+ Buffer < TBTYPE > RoTyBuf : register (t3);
28
+ RWBuffer < TBTYPE > RwTyBuf : register (u3);
24
29
25
30
ConsumeStructuredBuffer <TYPE> CnStBuf : register (u4);
26
31
AppendStructuredBuffer <TYPE> ApStBuf : register (u5);
27
32
28
- uint1 VecIx;
29
-
30
- [numthreads (8 ,1 ,1 )]
31
- void main (uint SclIx : SV_GroupIndex ) {
33
+ float4 Add (float4 f1, float4 f2) { return f1 + f2; }
34
+ Float4 Add (Float4 f1, Float4 f2) {
35
+ Float4 ret;
36
+ ret.f = f1.f + f2.f;
37
+ return ret;
38
+ }
39
+ float Add (float f1[4 ], float f2[4 ])[4 ] {
40
+ float ret[4 ];
41
+ ret[0 ] = f1[0 ] + f2[0 ];
42
+ ret[1 ] = f1[1 ] + f2[1 ];
43
+ ret[2 ] = f1[2 ] + f2[2 ];
44
+ ret[3 ] = f1[3 ] + f2[3 ];
45
+ return ret;
46
+ }
47
+
48
+ float4 Add (float4 f1, float4 f2, float4 f3, float4 f4) { return f1 + f2 + f3 + f4; }
49
+ Float4 Add (Float4 f1, Float4 f2, Float4 f3, Float4 f4) {
50
+ Float4 ret;
51
+ ret.f = f1.f + f2.f + f3.f + f4.f;
52
+ return ret;
53
+ }
54
+ float Add (float f1[4 ], float f2[4 ], float f3[4 ], float f4[4 ])[4 ] {
55
+ float ret[4 ];
56
+ ret[0 ] = f1[0 ] + f2[0 ] + f3[0 ] + f4[0 ];
57
+ ret[1 ] = f1[1 ] + f2[1 ] + f3[1 ] + f4[1 ];
58
+ ret[2 ] = f1[2 ] + f2[2 ] + f3[2 ] + f4[2 ];
59
+ ret[3 ] = f1[3 ] + f2[3 ] + f3[3 ] + f4[3 ];
60
+ return ret;
61
+ }
62
+
63
+ void main (uint SIx[2 ] : SIX, uint1 VIx[2 ] : VIX) {
32
64
// ByteAddressBuffer Tests
33
65
34
66
// CHECK-DAG: [[HDLROBY:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 1, i32 1, i32 0, i8 0 }, i32 1, i1 false)
@@ -37,53 +69,65 @@ void main(uint SclIx : SV_GroupIndex) {
37
69
// CHECK-DAG: [[HDLROST:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 2, i32 2, i32 0, i8 0 }, i32 2, i1 false)
38
70
// CHECK-DAG: [[HDLRWST:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 2, i32 2, i32 0, i8 1 }, i32 2, i1 false)
39
71
40
- // CHUCK -DAG: [[HDLROTY:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 3, i32 3, i32 0, i8 0 }, i32 3, i1 false)
41
- // CHUCK -DAG: [[HDLRWTY:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 3, i32 3, i32 0, i8 1 }, i32 3, i1 false)
72
+ // CHECK -DAG: [[HDLROTY:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 3, i32 3, i32 0, i8 0 }, i32 3, i1 false)
73
+ // CHECK -DAG: [[HDLRWTY:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 3, i32 3, i32 0, i8 1 }, i32 3, i1 false)
42
74
43
75
// CHECK-DAG: [[HDLCON:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 4, i32 4, i32 0, i8 1 }, i32 4, i1 false)
44
76
// CHECK-DAG: [[HDLAPP:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, %dx.types.ResBind { i32 5, i32 5, i32 0, i8 1 }, i32 5, i1 false)
45
77
46
- // CHECK: [[IDX:%.*]] = call i32 @dx.op.flattenedThreadIdInGroup.i32(i32 96)
78
+ // CHECK: [[IX0:%.*]] = call i32 @dx.op.loadInput.i32(i32 4,
79
+
47
80
// CHECK: [[ANHDLRWBY:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[HDLRWBY]]
48
- // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLRWBY]], i32 [[IDX ]]
81
+ // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLRWBY]], i32 [[IX0 ]]
49
82
50
83
// CHECK: [[ANHDLROBY:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[HDLROBY]]
51
- // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLROBY]], i32 [[IDX]]
52
- TYPE babElt1 = RwByBuf.Load< TYPE >(SclIx);
53
- TYPE babElt2 = RoByBuf.Load< TYPE >(SclIx);
54
- // CHECK: [[IDX2:%.*]] = add i32 [[IDX]], 16
55
- SclIx = SclIx + 16 ;
56
-
57
- // CHECK: all void @dx.op.rawBufferStore.f32(i32 140, %dx.types.Handle [[ANHDLRWBY]], i32 [[IDX2]]
58
- RwByBuf.Store< TYPE >(SclIx, babElt1 + babElt2);
84
+ // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLROBY]], i32 [[IX0]]
85
+ DECL (babElt1) = RwByBuf.Load< TYPE >(IX[0 ]);
86
+ DECL (babElt2) = RoByBuf.Load< TYPE >(IX[0 ]);
87
+
88
+ // CHECK: all void @dx.op.rawBufferStore.f32(i32 140, %dx.types.Handle [[ANHDLRWBY]], i32 [[IX0]]
89
+ RwByBuf.Store< TYPE >(IX[0 ], Add (babElt1, babElt2));
59
90
60
91
// StructuredBuffer Tests
61
- // Load 'em up!
62
92
// CHECK: [[ANHDLRWST:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[HDLRWST]]
63
- // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLRWST]], i32 [[IDX2]]
64
- TYPE stbElt1 = RwStBuf.Load (SclIx);
93
+ // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLRWST]], i32 [[IX0]]
94
+ DECL (stbElt1) = RwStBuf.Load (IX[0 ]);
95
+ // CHECK: [[IX1:%.*]] = call i32 @dx.op.loadInput.i32(i32 4,
96
+ // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLRWST]], i32 [[IX1]]
97
+ DECL (stbElt2) = RwStBuf[IX[1 ]];
98
+
65
99
// CHECK: [[ANHDLROST:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[HDLROST]]
66
- // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLROST]], i32 [[IDX2]]
67
- TYPE stbElt2 = RoStBuf.Load (SclIx);
68
- // CHECK: [[IDX3:%.*]] = add i32 [[IDX]], 17
69
- SclIx = SclIx + 1 ;
70
- // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLRWST]], i32 [[IDX3]]
71
- TYPE stbElt3 = RwStBuf[SclIx];
72
- // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLROST]], i32 [[IDX3]]
73
- TYPE stbElt4 = RoStBuf[SclIx];
100
+ // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLROST]], i32 [[IX0]]
101
+ DECL (stbElt3) = RoStBuf.Load (IX[0 ]);
102
+ // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLROST]], i32 [[IX1]]
103
+ DECL (stbElt4) = RoStBuf[IX[1 ]];
104
+
105
+ // CHECK: all void @dx.op.rawBufferStore.f32(i32 140, %dx.types.Handle [[ANHDLRWST]], i32 [[IX0]]
106
+ RwStBuf[IX[0 ]] = Add (stbElt1, stbElt2, stbElt3, stbElt4);
107
+
108
+ // {Append/Consume}StructuredBuffer Tests
74
109
// CHECK: [[ANHDLCON:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[HDLCON]]
75
- // CHECK: [[CONIDX :%.*]] = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle [[ANHDLCON]], i8 -1)
76
- // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLCON]], i32 [[CONIDX ]]
77
- TYPE cnElt = CnStBuf.Consume ();
110
+ // CHECK: [[CONIX :%.*]] = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle [[ANHDLCON]], i8 -1)
111
+ // CHECK: call %dx.types.ResRet.f32 @dx.op.rawBufferLoad.f32(i32 139, %dx.types.Handle [[ANHDLCON]], i32 [[CONIX ]]
112
+ DECL ( cnElt) = CnStBuf.Consume ();
78
113
79
- // Ship 'em out!
80
-
81
- // CHECK: [[ANHDLRWST:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[HDLRWST]]
82
- // CHECK: all void @dx.op.rawBufferStore.f32(i32 140, %dx.types.Handle [[ANHDLRWST]], i32 [[IDX3]]
83
- RwStBuf[SclIx] = cnElt;
84
-
85
114
// CHECK: [[ANHDLAPP:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[HDLAPP]]
86
- // CHECK: [[APPIDX:%.*]] = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle [[ANHDLAPP]], i8 1)
87
- // CHECK: all void @dx.op.rawBufferStore.f32(i32 140, %dx.types.Handle [[ANHDLAPP]], i32 [[APPIDX]]
88
- ApStBuf.Append (stbElt1 + stbElt2 + stbElt3 + stbElt4);
115
+ // CHECK: [[APPIX:%.*]] = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle [[ANHDLAPP]], i8 1)
116
+ // CHECK: all void @dx.op.rawBufferStore.f32(i32 140, %dx.types.Handle [[ANHDLAPP]], i32 [[APPIX]]
117
+ ApStBuf.Append (cnElt);
118
+
119
+ // TypedBuffer Tests
120
+ // CHECK: [[ANHDLRWTY:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[HDLRWTY]]
121
+ // CHECK: call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle [[ANHDLRWTY]], i32 [[IX0]]
122
+ TBTYPE typElt1 = RwTyBuf.Load (IX[0 ]);
123
+ // CHECK: call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle [[ANHDLRWTY]], i32 [[IX1]]
124
+ TBTYPE typElt2 = RwTyBuf[IX[1 ]];
125
+ // CHECK: [[ANHDLROTY:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[HDLROTY]]
126
+ // CHECK: call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle [[ANHDLROTY]], i32 [[IX0]]
127
+ TBTYPE typElt3 = RoTyBuf.Load (IX[0 ]);
128
+ // CHECK: call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle [[ANHDLROTY]], i32 [[IX1]]
129
+ TBTYPE typElt4 = RoTyBuf[IX[1 ]];
130
+
131
+ // CHECK: all void @dx.op.bufferStore.f32(i32 69, %dx.types.Handle [[ANHDLRWTY]], i32 [[IX0]]
132
+ RwTyBuf[IX[0 ]] = Add (typElt1, typElt2, typElt3, typElt4);
89
133
}
0 commit comments