Skip to content

Commit d65c200

Browse files
Merge branch 'KhronosGroup:master' into master
2 parents 6204713 + 9e70729 commit d65c200

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed

Test/atomicAdd.comp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#version 320 es
2+
layout(local_size_x = 1) in;
3+
4+
struct structType{
5+
int y[3];
6+
};
7+
8+
layout(std430) buffer t2 {
9+
structType f;
10+
} t;
11+
12+
buffer coherent Buffer { int x; };
13+
int z;
14+
15+
void main() {
16+
atomicAdd(x, 1);
17+
atomicAdd(t.f.y[1], 1);
18+
atomicAdd(z, 1);
19+
}

Test/baseResults/atomicAdd.comp.out

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
atomicAdd.comp
2+
ERROR: 0:18: 'atomicAdd' : Atomic memory function can only be used for shader storage block member or shared variable.
3+
ERROR: 1 compilation errors. No code generated.
4+
5+
6+
Shader version: 320
7+
local_size = (1, 1, 1)
8+
ERROR: node is still EOpNull!
9+
0:15 Function Definition: main( ( global void)
10+
0:15 Function Parameters:
11+
0:16 Sequence
12+
0:16 AtomicAdd ( global highp int)
13+
0:16 x: direct index for structure (layout( column_major shared) coherent buffer highp int)
14+
0:16 'anon@0' (layout( column_major shared) coherent buffer block{layout( column_major shared) coherent buffer highp int x})
15+
0:16 Constant:
16+
0:16 0 (const uint)
17+
0:16 Constant:
18+
0:16 1 (const int)
19+
0:17 AtomicAdd ( global highp int)
20+
0:17 direct index (layout( std430) temp highp int)
21+
0:17 y: direct index for structure (layout( std430) global 3-element array of highp int)
22+
0:17 f: direct index for structure (layout( column_major std430 offset=0) buffer structure{layout( std430) global 3-element array of highp int y})
23+
0:17 't' (layout( column_major std430) buffer block{layout( column_major std430 offset=0) buffer structure{layout( std430) global 3-element array of highp int y} f})
24+
0:17 Constant:
25+
0:17 0 (const int)
26+
0:17 Constant:
27+
0:17 0 (const int)
28+
0:17 Constant:
29+
0:17 1 (const int)
30+
0:17 Constant:
31+
0:17 1 (const int)
32+
0:18 AtomicAdd ( global highp int)
33+
0:18 'z' ( global highp int)
34+
0:18 Constant:
35+
0:18 1 (const int)
36+
0:? Linker Objects
37+
0:? 'gl_WorkGroupSize' ( const highp 3-component vector of uint WorkGroupSize)
38+
0:? 1 (const uint)
39+
0:? 1 (const uint)
40+
0:? 1 (const uint)
41+
0:? 't' (layout( column_major std430) buffer block{layout( column_major std430 offset=0) buffer structure{layout( std430) global 3-element array of highp int y} f})
42+
0:? 'anon@0' (layout( column_major shared) coherent buffer block{layout( column_major shared) coherent buffer highp int x})
43+
0:? 'z' ( global highp int)
44+
45+
46+
Linked compute stage:
47+
48+
49+
Shader version: 320
50+
local_size = (1, 1, 1)
51+
ERROR: node is still EOpNull!
52+
0:15 Function Definition: main( ( global void)
53+
0:15 Function Parameters:
54+
0:16 Sequence
55+
0:16 AtomicAdd ( global highp int)
56+
0:16 x: direct index for structure (layout( column_major shared) coherent buffer highp int)
57+
0:16 'anon@0' (layout( column_major shared) coherent buffer block{layout( column_major shared) coherent buffer highp int x})
58+
0:16 Constant:
59+
0:16 0 (const uint)
60+
0:16 Constant:
61+
0:16 1 (const int)
62+
0:17 AtomicAdd ( global highp int)
63+
0:17 direct index (layout( std430) temp highp int)
64+
0:17 y: direct index for structure (layout( std430) global 3-element array of highp int)
65+
0:17 f: direct index for structure (layout( column_major std430 offset=0) buffer structure{layout( std430) global 3-element array of highp int y})
66+
0:17 't' (layout( column_major std430) buffer block{layout( column_major std430 offset=0) buffer structure{layout( std430) global 3-element array of highp int y} f})
67+
0:17 Constant:
68+
0:17 0 (const int)
69+
0:17 Constant:
70+
0:17 0 (const int)
71+
0:17 Constant:
72+
0:17 1 (const int)
73+
0:17 Constant:
74+
0:17 1 (const int)
75+
0:18 AtomicAdd ( global highp int)
76+
0:18 'z' ( global highp int)
77+
0:18 Constant:
78+
0:18 1 (const int)
79+
0:? Linker Objects
80+
0:? 'gl_WorkGroupSize' ( const highp 3-component vector of uint WorkGroupSize)
81+
0:? 1 (const uint)
82+
0:? 1 (const uint)
83+
0:? 1 (const uint)
84+
0:? 't' (layout( column_major std430) buffer block{layout( column_major std430 offset=0) buffer structure{layout( std430) global 3-element array of highp int y} f})
85+
0:? 'anon@0' (layout( column_major shared) coherent buffer block{layout( column_major shared) coherent buffer highp int x})
86+
0:? 'z' ( global highp int)
87+

glslang/MachineIndependent/Initialize.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7283,6 +7283,9 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
72837283

72847284
snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors);
72857285
s.append(builtInConstant);
7286+
7287+
snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingVectors = %d;", resources.maxVaryingVectors);
7288+
s.append(builtInConstant);
72867289
}
72877290

72887291
snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs);

glslang/MachineIndependent/ParseHelper.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,6 +2409,12 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
24092409
arg0->getType().isFloatingDomain()) {
24102410
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float2, fnCandidate.getName().c_str());
24112411
}
2412+
2413+
const TIntermTyped* base = TIntermediate::findLValueBase(arg0, true);
2414+
const TQualifier& qualifier = base->getType().getQualifier();
2415+
if (qualifier.storage != EvqShared && qualifier.storage != EvqBuffer)
2416+
error(loc,"Atomic memory function can only be used for shader storage block member or shared variable.", fnCandidate.getName().c_str(), "");
2417+
24122418
break;
24132419
}
24142420

gtests/AST.FromFile.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ INSTANTIATE_TEST_SUITE_P(
282282
"terminate.vert",
283283
"negativeWorkGroupSize.comp",
284284
"textureoffset_sampler2darrayshadow.vert",
285+
"atomicAdd.comp",
285286
})),
286287
FileNameAsCustomTestSuffix
287288
);

0 commit comments

Comments
 (0)