#version 450 #pragma shader_stage(compute) layout (std430, binding = 0) buffer coherent BufferIn { uint[] data_in; }; layout (constant_id = 0) const uint CHANGE_COUNT = 1; layout (local_size_x = 1) in; void main() { int n_changes = 0; for(int i = 0; i < data_in.length(); i++){ if(data_in[i - 1] > data_in[i]){ uint tmp = data_in[i]; data_in[i] = data_in[i-1]; data_in[i-1] = tmp; if(n_changes++ > CHANGE_COUNT) return; } } }