dymokomi/luce-gpu
Source of release 0.5.5
0.5.5 / tests / gpu / shaders / special.comp
#version 450
// Specialization constants of every kind a kernel takes. With the defaults,
// value i is 2i - 1; MODE 1 negates it, FLIP multiplies it by ten, and a
// specialized SCALE and OFFSET change the line. The last value records the
// constants themselves.
layout(local_size_x = 64) in;
layout(constant_id = 0) const uint MODE = 0u;
layout(constant_id = 1) const int OFFSET = -1;
layout(constant_id = 2) const float SCALE = 2.0;
layout(constant_id = 5) const bool FLIP = false;
layout(set = 0, binding = 0, std430) writeonly buffer Values { float values[]; };
layout(push_constant) uniform Params { uint n; } params;
void main() {
uint i = gl_GlobalInvocationID.x;
if (i >= params.n)
return;
float x = float(i) * SCALE + float(OFFSET);
if (MODE == 1u)
x = -x;
if (FLIP)
x = x * 10.0;
values[i] = x;
}