Modify a texture for use in next render pass?

Hi there! I’ve learned a ton from this book. I’m trying to write a physarum simulation with a compute pipeline for the particle simulation that’s then rendered into a 2D texture. Basically for this simulation to work, it needs to read from (and render) a texture that’s modified and preserved on each render. I used the chapter 16 samples as a starting point, but I’m stuck on being able to use the output of the render as the input (without clearing) for the next step of the simulation. Put another way, I want to modify a texture as the output of a render pass and use that texture as input for the next compute pass.

I used code from the water tutorial to figure out how to render to a texture rather than the display (then I render that texture to the display) so I at least have – I think – a persistent texture that I could use as input. The problem is that this texture gets cleared every time my render pass writes to it. I tried removing the .clear property from the texture’s .loadAction but that seems to create a new uninitialized texture every time, rather than maintaining the data from the previous render.

The code for the render pipeline is here:

And the code to set up the texture is here:

Any ideas would be super appreciated, thank you!

I figured it out – it’s using LoadAction.load for the descriptor! Thank you, Ray Wenderlich forums, for being my rubber ducky :smiley:

Well done - any time :hatched_chick:!