No Description

headless.comp 526B

1234567891011121314151617181920212223242526272829303132
  1. #version 450
  2. layout(binding = 0) buffer Pos {
  3. uint values[ ];
  4. };
  5. layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
  6. layout (constant_id = 0) const uint BUFFER_ELEMENTS = 32;
  7. uint fibonacci(uint n) {
  8. if(n <= 1){
  9. return n;
  10. }
  11. uint curr = 1;
  12. uint prev = 1;
  13. for(uint i = 2; i < n; ++i) {
  14. uint temp = curr;
  15. curr += prev;
  16. prev = temp;
  17. }
  18. return curr;
  19. }
  20. void main()
  21. {
  22. uint index = gl_GlobalInvocationID.x;
  23. if (index >= BUFFER_ELEMENTS)
  24. return;
  25. values[index] = fibonacci(values[index]);
  26. }