G
G
Gleb Igumnov2016-11-24 17:15:29
OpenGL
Gleb Igumnov, 2016-11-24 17:15:29

How to correctly form group sizes for OpenGL shaders?

Good afternoon, help me figure it out, otherwise I'm somehow completely confused. I solve the problem of ray tracing, to speed up I try to implement it on computational shaders. There are input arrays of rays and triangles of the scene, size ray_count and face_count, there is an output array size ray_count*face_count. Obviously, the problem is well parallelized, because the search for the intersection of each ray with each triangle does not depend on the others (the choice of the nearest triangle is done later).
I run it as dispatchCompute(ray_count, face_count, 1), in the shader itself I write layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
Everything works very slowly, I don't know how to check it, but I think I misunderstood the idea of ​​shader groups.
Are global groups run sequentially or will their execution be parallelized as well?
Do I understand correctly that local groups inside the global one run in parallel?
Do I understand correctly that the number of calls will be equal to the number of global groups * the number of local groups, and to create local groups I need to somehow calculate the ratio of both?
Is it possible to make local group sizes dynamically calculated?
Or are there no problems here and we need to look for brakes in the algorithm?
And at the same time, the question is, what tool can generally debug / measure the performance of a shader? (I call from C++\OpenFrameworks if that).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question