Merge "Use de::ArrayBuffer, not raw arrays, in sglrReferenceContext."
[platform/upstream/VK-GL-CTS.git] / doc / testspecs / GLES31 / functional.shaders.atomic_counter.txt
1 -------------------------------------------------------------------------
2 drawElements Quality Program Test Specification
3 -----------------------------------------------
4
5 Copyright 2014 The Android Open Source Project
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11      http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 -------------------------------------------------------------------------
19     Shader atomic counter tests
20
21 Tests:
22  + dEQP-GLES31.functional.shaders.atomic_counter.*
23
24 Includes:
25  + Calls to atomicCounter(), atomicCounterIncrement() and atomicCounterDecrement()
26    - Only in compute shaders
27    - With different number of parallel shaders
28    - With different number of calls per shader
29    - With different combinations of operations
30    - With conditional calls depending on thread and call number
31  + Atomic counters with different offsets
32  + Atomic counters with default layout qualifier and implicit offset and binding
33  + Invalid offsets and bindings in layout qualifier
34  + Invalid offsets and bindings in default layout qualifier
35
36 Excludes:
37  + Multiple binding points and buffers
38    - Only single binding point is required by specification
39  + Use in other than compute shader
40    - Specification requires zero binding points in other shader types
41  + Usage in multiple shaders at same time
42  + Multiple shader innovocations
43
44 Description:
45
46 Test cases perform atomic counter calls and saves results to a SSBO. The SSBO
47 and the atomic counter buffer are read back from the device after executing
48 the shader. Atomic counter values are verified by comparing against the
49 initial value subtracted by total number of calls to atomicCounterDecrement()
50 and incremented by total number of calls to atomicCounterIncrement() performed
51 by the shader. SSBO value verification depends on the set of functions used in
52 the shader. Values returned by call to atomicCounterDecrement() are
53 incremented by one so that all values in the SSBO are values of counter before
54 peforming operation. Atomic counter values returned by different atomic
55 counters are verified separately.
56
57 Test cases using only atomicCounter() call are verified by checking that all
58 calls returned the same value as set initially to the atomic counter.
59
60 Test case using either atomicCounterIncrement() or atomicCounterDecrement()
61 call check that each value returned is unique and all values are in continuous
62 range from initial value to the expected result value.
63
64 Test cases using either atomicCounterIncrement() or atomicCounterDecrement()
65 and atomicCounter() call perform call to atomicCounter() before and after each
66 call to atomicCounterIncrement()/atomicCounterDecrement(). Test cases check
67 that value returned by atomicCounterIncrement()/atomicCounterDecrement() is
68 between values returned by previous and following call to atomicCounter().
69
70 Test cases with calls to both atomicCounterIncrement() and
71 atomicCounterDecrement() are verified by counting how many times each value
72 was returned by each function. Using these counts we check that there is
73 possible order in which operations could have been performed. Following pseudo
74 code checks that there is possible order in which increments and decrements
75 could have happened.
76
77 // Minimum value returned by atomicCounterDecrement() or atomicCounterIncrement()
78 minValue
79 // Maximum value returned by atomicCounterDecrement() or atomicCounterIncrement()
80 maxValue
81 // incrementCounts[value] is how many times value was returned by atomicCounterIncrement()
82 incrementCounts[]
83 // decrementCounts[value] is how many times value-1 was returned by atomicCounterDecrement()
84 decrementCounts[]
85 // Value of counter before any operation has been performed
86 initialValue
87 // Value of counter after executing shader
88 resultValue
89
90 pos = initialValue
91
92 while incrementCounts[pos] + decrementCounts[pos] == 0:
93         // Prefer operations that would move away from the result value.
94         if incrementCounts[pos] > 0 and pos > resultValue:
95                 incrementCounts[pos]--
96                 pos++
97         else if decrementCounts[pos]:
98                 decrementCounts[pos]--
99                 pos--
100         else
101                 incrementCounts[pos]--
102                 pos++
103
104         // Last value might have never been returned by call
105         // to atomicCounterIncrement() or atomicCounterDecrement()
106         // if it's outside of range.
107         if pos < minValue or pos > maxValue:
108                 break
109
110 // Check that incrementCounts and decrementCounts contain only zero values.
111
112 Test set includes negative shader compilation cases as well. In such cases the
113 compilation is simply expected to fail.