vello/tests/shader/clear.comp
Raph Levien fbfd4ee81b Add workaround for buffer clearing
Add a clear stage and associated tests, and also use it on non-Vulkan
backends to clear the state buffer.

While that's a workaround and will go away when we implement the actual
clear command, it's also a nice demo of how the new "stage" structure
composes.
2021-11-10 17:36:54 -08:00

27 lines
517 B
GLSL

// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
// Clear a buffer.
#version 450
layout(local_size_x = 256) in;
// This should probably be uniform rather than readonly,
// but we haven't done the binding work yet.
layout(binding = 0) readonly buffer ConfigBuf {
// size is in uint (4 byte) units
uint size;
uint value;
};
layout(binding = 1) buffer TargetBuf {
uint[] data;
};
void main() {
uint ix = gl_GlobalInvocationID.x;
if (ix < size) {
data[ix] = value;
}
}