Advice on a simple parallel task pattern(Beginner question)


#1

Hi ,

I am trying to achieve a perfect looking translucency effect in openGL for an AR headset.
For that matter I need to sort the triangle faces every time the view point changes, since this is a live headset
it means that I need to do it every frame I am rendering, moreover I want to render in at-least 60 fps.

So beyond a certain amount of triangles it is not feasible, and I would like to defer that task to a parallel task.

My data is V,N,F,Pos (Vertices,Normals,Faces,Position)

The naive non-parallel render loop looks like this:

while true
    F_Sorted = sortfaces(V,F,Pos)
    drawtriangles_indexed(V,N,F_sorted,Pos)
end

I am sure there is a super simple way of running the sortfaces function in a parallel task, I am struggling
a little bit with the documentation trying to discern whether I need a task @async or @spawn or channel.

Any comment is appreciated


#2

O.k I’ll answer myself.

It is indeed super simple:

F1= @spawn sortfaces(V,F,Pos)
if isready(F1)
    F_sorted = fetch(F1)
end

Need to make sure that there are enough processes running.