summaryrefslogtreecommitdiff
path: root/graphics/asymptote/base/shaders/postsum.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/asymptote/base/shaders/postsum.glsl')
-rw-r--r--graphics/asymptote/base/shaders/postsum.glsl30
1 files changed, 30 insertions, 0 deletions
diff --git a/graphics/asymptote/base/shaders/postsum.glsl b/graphics/asymptote/base/shaders/postsum.glsl
new file mode 100644
index 0000000000..9a2afaf845
--- /dev/null
+++ b/graphics/asymptote/base/shaders/postsum.glsl
@@ -0,0 +1,30 @@
+layout(local_size_x=1) in;
+
+uniform uint elements;
+
+layout(binding=1, std430) buffer offsetBuffer
+{
+ uint offset[];
+};
+
+uint ceilquotient(uint a, uint b)
+{
+ return (a+b-1u)/b;
+}
+
+void main(void)
+{
+ uint id=gl_GlobalInvocationID.x;
+
+ uint m=ceilquotient(elements,gl_NumWorkGroups.x);
+ uint row=m*id;
+ uint col=min(m,elements-row);
+ uint stop=row+col-1u;
+
+ uint curr=offset[row];
+ for(uint i=row; i < stop; ++i) {
+ uint next=offset[i+1u];
+ curr += next;
+ offset[i+1u]=curr;
+ }
+}