1------------------------------------------------------------------------- 2drawElements Quality Program Test Specification 3----------------------------------------------- 4 5Copyright 2014 The Android Open Source Project 6 7Licensed under the Apache License, Version 2.0 (the "License"); 8you may not use this file except in compliance with the License. 9You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13Unless required by applicable law or agreed to in writing, software 14distributed under the License is distributed on an "AS IS" BASIS, 15WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16See the License for the specific language governing permissions and 17limitations under the License. 18------------------------------------------------------------------------- 19 Shader atomic counter tests 20 21Tests: 22 + dEQP-GLES31.functional.shaders.atomic_counter.* 23 24Includes: 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 36Excludes: 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 44Description: 45 46Test cases perform atomic counter calls and saves results to a SSBO. The SSBO 47and the atomic counter buffer are read back from the device after executing 48the shader. Atomic counter values are verified by comparing against the 49initial value subtracted by total number of calls to atomicCounterDecrement() 50and incremented by total number of calls to atomicCounterIncrement() performed 51by the shader. SSBO value verification depends on the set of functions used in 52the shader. Values returned by call to atomicCounterDecrement() are 53incremented by one so that all values in the SSBO are values of counter before 54peforming operation. Atomic counter values returned by different atomic 55counters are verified separately. 56 57Test cases using only atomicCounter() call are verified by checking that all 58calls returned the same value as set initially to the atomic counter. 59 60Test case using either atomicCounterIncrement() or atomicCounterDecrement() 61call check that each value returned is unique and all values are in continuous 62range from initial value to the expected result value. 63 64Test cases using either atomicCounterIncrement() or atomicCounterDecrement() 65and atomicCounter() call perform call to atomicCounter() before and after each 66call to atomicCounterIncrement()/atomicCounterDecrement(). Test cases check 67that value returned by atomicCounterIncrement()/atomicCounterDecrement() is 68between values returned by previous and following call to atomicCounter(). 69 70Test cases with calls to both atomicCounterIncrement() and 71atomicCounterDecrement() are verified by counting how many times each value 72was returned by each function. Using these counts we check that there is 73possible order in which operations could have been performed. Following pseudo 74code checks that there is possible order in which increments and decrements 75could have happened. 76 77// Minimum value returned by atomicCounterDecrement() or atomicCounterIncrement() 78minValue 79// Maximum value returned by atomicCounterDecrement() or atomicCounterIncrement() 80maxValue 81// incrementCounts[value] is how many times value was returned by atomicCounterIncrement() 82incrementCounts[] 83// decrementCounts[value] is how many times value-1 was returned by atomicCounterDecrement() 84decrementCounts[] 85// Value of counter before any operation has been performed 86initialValue 87// Value of counter after executing shader 88resultValue 89 90pos = initialValue 91 92while 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 112Test set includes negative shader compilation cases as well. In such cases the 113compilation is simply expected to fail. 114