Reputation: 53027
For computing automatas on Open/WebGL, my naive approach would be to encode the state of the automata as a texture, treating each pixel as an automata cell; then I'd call a fragment shader that texture, computing the next state and rendering it back. I'd then repeat the process indefinitely.
My issue is: wouldn't that cause the memory to be transferred between CPU/GPU at each invocation of the fragment shader? Ideally, I want to call the fragment shader several (thousands) of times without any communication between CPU/GPU; possibly, making good use of processing units local memories.
Is that possible?
Upvotes: 2
Views: 402
Reputation: 96689
Why would you need to transfer a texture data through CPU when calculating next state?
You will need two textures. Put your cells' current state into one of them and use a shader to draw next state into the second texture. Then do the opposite: Draw next state into the first texture while using second one as a current state. Repeat this as many times as needed.
Upvotes: 2