Add a chapter on Compute Shaders#366
Conversation
SaschaWillems
left a comment
There was a problem hiding this comment.
Having a chapter explaining basic compute terms is a great addition 👍🏻
| ---- | ||
| shared uint my_var; | ||
| void main() { | ||
| // All the invocations in the workgroup are going to try to write to the same memory. |
There was a problem hiding this comment.
I think it's confusing to lead with this example, and would be better to start with examples of cross-thread communication and using barrier() first.
There was a problem hiding this comment.
can you provide some GLSL snippets here (in the comment), I know you are more of an expert in this area and probably better at providing some better examples to provide
There was a problem hiding this comment.
You could use a reduction as a simple example of cross-thread communication:
shared float temp[BLOCK_SIZE];
temp[tid] = x;
[[unroll]] for (uint s = BLOCK_SIZE / 2; s > 0; s >>= 1) {
barrier();
float other = temp[tid ^ s];
barrier();
temp[tid] += other;
}
shared float my_var[BLOCK_SIZE];
void reduction(float x) {
uint tid = gl_GlobalInvocationID;
my_var[tid] = x;
for (uint s = BLOCK_SIZE / 2; s > 0; s >>= 1) {
barrier();
float other = my_var[tid ^ s];
barrier();
my_var[tid] += other;
}
}
There was a problem hiding this comment.
sorry, we can add this in a follow up, this example makes is confusing... was is suppose to be an example of having a race condition?
gpx1000
left a comment
There was a problem hiding this comment.
The chapter is a solid addition and fills a clear gap in the guide!
charles-lunarg
left a comment
There was a problem hiding this comment.
Lots of grammar nits & suggestions of things that can be improved.
Co-authored-by: Charles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Co-authored-by: Charles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Co-authored-by: Charles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Co-authored-by: Charles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Co-authored-by: Charles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Co-authored-by: Charles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Co-authored-by: Charles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Co-authored-by: Charles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Co-authored-by: Charles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Rendered view
Kind review @jeffbolznv - mainly around the shared memory races and any other stuff you think would be useful