11// RUN: %dxc -E MainPass -T cs_6_10 %s | FileCheck %s
22
3- #define NUM_BYTES_OF_SHARED_MEM (32 * 1024 )
3+ #define NUM_BYTES_OF_SHARED_MEM (32 * 1024 )
44#define NUM_DWORDS_SHARED_MEM (NUM_BYTES_OF_SHARED_MEM / 4 )
55#define THREAD_GROUP_SIZE_X 1024
66
77groupshared uint g_testBufferPASS[NUM_DWORDS_SHARED_MEM];
88
9- RWStructuredBuffer <uint > g_output : register (u0);
9+ RWStructuredBuffer <uint > g_output : register (u0);
1010
1111// CHECK: @MainPass
1212
1313[GroupSharedLimit (NUM_BYTES_OF_SHARED_MEM)]
14- [numthreads (THREAD_GROUP_SIZE_X, 1 , 1 )]
15- void MainPass ( uint3 DTid : SV_DispatchThreadID )
16- {
17- uint iterations = NUM_DWORDS_SHARED_MEM / THREAD_GROUP_SIZE_X;
18-
19- for (uint i = 0 ; i < iterations; i++)
20- {
14+ [numthreads (THREAD_GROUP_SIZE_X, 1 , 1 )] void
15+ MainPass (uint3 DTid : SV_DispatchThreadID ) {
16+ uint iterations = NUM_DWORDS_SHARED_MEM / THREAD_GROUP_SIZE_X;
17+
18+ for (uint i = 0 ; i < iterations; i++) {
2119 uint index = DTid.x + i * THREAD_GROUP_SIZE_X;
2220 g_testBufferPASS[index] = index;
23- }
24-
25- // synchronize all threads in the group
26- GroupMemoryBarrierWithGroupSync ();
21+ }
2722
28- // write the shared data to the output buffer
29- for (uint i = 0 ; i < iterations; i++)
30- {
23+ // synchronize all threads in the group
24+ GroupMemoryBarrierWithGroupSync ();
25+
26+ // write the shared data to the output buffer
27+ for (uint i = 0 ; i < iterations; i++) {
3128 uint index = DTid.x + i * THREAD_GROUP_SIZE_X;
3229 g_output[index] = g_testBufferPASS[index];
30+ }
3331 }
34- }
3532
3633// RUN: not %dxc -E MainFail -T cs_6_10 %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
3734// CHECK-ERROR: Total Thread Group Shared Memory storage is 32772, exceeded 32768.
3835
3936groupshared uint g_testBufferFAIL[NUM_DWORDS_SHARED_MEM + 1 ];
4037
4138[GroupSharedLimit (NUM_BYTES_OF_SHARED_MEM)]
42- [numthreads (THREAD_GROUP_SIZE_X, 1 , 1 )]
43- void MainFail ( uint3 DTid : SV_DispatchThreadID )
44- {
45- uint iterations = NUM_DWORDS_SHARED_MEM / THREAD_GROUP_SIZE_X;
46-
47- for (uint i = 0 ; i < iterations; i++)
48- {
49- uint index = DTid.x + i * THREAD_GROUP_SIZE_X;
50- g_testBufferFAIL[index] = index;
51- }
52-
53- // synchronize all threads in the group
54- GroupMemoryBarrierWithGroupSync ();
39+ [numthreads (THREAD_GROUP_SIZE_X, 1 , 1 )] void
40+ MainFail (uint3 DTid : SV_DispatchThreadID ) {
41+ uint iterations = NUM_DWORDS_SHARED_MEM / THREAD_GROUP_SIZE_X;
5542
56- // write the shared data to the output buffer
57- for (uint i = 0 ; i < iterations; i++)
58- {
59- uint index = DTid.x + i * THREAD_GROUP_SIZE_X;
60- g_output[index] = g_testBufferFAIL[index];
61- }
62- }
63-
64- // RUN: not %dxc -E MainFail2 -T cs_6_10 %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
65- [numthreads (THREAD_GROUP_SIZE_X, 1 , 1 )]
66- void MainFail2 ( uint3 DTid : SV_DispatchThreadID )
67- {
68- uint iterations = NUM_DWORDS_SHARED_MEM / THREAD_GROUP_SIZE_X;
69-
70- for (uint i = 0 ; i < iterations; i++)
71- {
43+ for (uint i = 0 ; i < iterations; i++) {
7244 uint index = DTid.x + i * THREAD_GROUP_SIZE_X;
7345 g_testBufferFAIL[index] = index;
74- }
75-
76- // synchronize all threads in the group
77- GroupMemoryBarrierWithGroupSync ();
46+ }
7847
79- // write the shared data to the output buffer
80- for (uint i = 0 ; i < iterations; i++)
81- {
48+ // synchronize all threads in the group
49+ GroupMemoryBarrierWithGroupSync ();
50+
51+ // write the shared data to the output buffer
52+ for (uint i = 0 ; i < iterations; i++) {
8253 uint index = DTid.x + i * THREAD_GROUP_SIZE_X;
8354 g_output[index] = g_testBufferFAIL[index];
55+ }
8456 }
85- }
57+
58+ // RUN: not %dxc -E MainFail2 -T cs_6_10 %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
59+ [numthreads (THREAD_GROUP_SIZE_X, 1 , 1 )] void MainFail2 (uint3 DTid : SV_DispatchThreadID ) {
60+ uint iterations = NUM_DWORDS_SHARED_MEM / THREAD_GROUP_SIZE_X;
61+
62+ for (uint i = 0 ; i < iterations; i++) {
63+ uint index = DTid.x + i * THREAD_GROUP_SIZE_X;
64+ g_testBufferFAIL[index] = index;
65+ }
66+
67+ // synchronize all threads in the group
68+ GroupMemoryBarrierWithGroupSync ();
69+
70+ // write the shared data to the output buffer
71+ for (uint i = 0 ; i < iterations; i++) {
72+ uint index = DTid.x + i * THREAD_GROUP_SIZE_X;
73+ g_output[index] = g_testBufferFAIL[index];
74+ }
75+ }
0 commit comments