OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scan_resolve.cs
Go to the documentation of this file.
1 #version 310 es
2 
3 /* Copyright (c) 2014-2017, ARM Limited and Contributors
4  *
5  * SPDX-License-Identifier: MIT
6  *
7  * Permission is hereby granted, free of charge,
8  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 /*
24  * Take a scan array which has been scanned per-block and sum array (inclusive scan for per-block results)
25  * and resolve the result to get a complete inclusive scan result.
26  * Needed if we need to do scan in multiple stages.
27  */
28 
29 layout(local_size_x = 32) in; // We work on 4 items at once, so this value should be BLOCK_SIZE / 4.
30 layout(binding = 0, std430) readonly buffer Data
31 {
32  uvec4 buf[];
33 };
34 
35 layout(binding = 1, std430) readonly buffer BlockSumData
36 {
37  uvec4 blocksum[];
38 };
39 
40 layout(binding = 2, std430) writeonly buffer OutData
41 {
42  uvec4 outbuf[];
43 };
44 
45 void main()
46 {
47  uint ident = gl_GlobalInvocationID.x;
48  uint wg_ident = gl_WorkGroupID.x;
49  uvec4 miniblock0 = buf[4u * ident + 0u];
50  uvec4 miniblock1 = buf[4u * ident + 1u];
51  uvec4 miniblock2 = buf[4u * ident + 2u];
52  uvec4 miniblock3 = buf[4u * ident + 3u];
53  if (wg_ident != 0u) {
54  uvec4 prev_sum = blocksum[wg_ident - 1u];
55  miniblock0 += prev_sum;
56  miniblock1 += prev_sum;
57  miniblock2 += prev_sum;
58  miniblock3 += prev_sum;
59  }
60  outbuf[4u * ident + 0u] = miniblock0;
61  outbuf[4u * ident + 1u] = miniblock1;
62  outbuf[4u * ident + 2u] = miniblock2;
63  outbuf[4u * ident + 3u] = miniblock3;
64 }
layout(local_size_x=32) in
GLint GLint GLint GLint GLint x
Definition: gl2ext.h:574
GLenum GLuint buffer
Definition: gl2ext.h:628
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: gl2ext.h:134
void main()
Definition: scan_resolve.cs:45