title: Metal: Do I need multiple RenderPipelines to have multiple shaders?
body: <p>I am very new to metal so bear with me as I am transitioning from the ugly state machine calls of OpenGL to modern graphics frameworks. I really want to make sure I understand how everything works and works together. </p>
  
  <p>I have read most of Apples documentation but it does a better job describing the function of individual components than how they come together.</p>
  
  <p>I am trying to understand essentially whether I should have multiple renderPipelines and renderEncoders are needed in my situation.</p>
  
  <p>To describe my pipeline at a high level here is what goes on:</p>
  
  <ol>
  <li>Retrieve the previous frame's contents from an offscreen texture that was rendered to and draw some new contents onto it.</li>
  <li>Swith to rendering on the screen. Draw the texture from step 1 to the screen.</li>
  <li>Do some post processing (in native resolution).</li>
  <li>Draw the UI ontop as quads. (essentailly a repeat of 2)</li>
  </ol>
  
  <p>So in essence there will be the following vertex/fragment shader pairs </p>
  
  <ul>
  <li>Draw the entities (step 1)  </li>
  <li>Draw quads on a specefied area (step 2 and 4)  </li>
  <li>Post processing shader 1 (step 3) uses different inputs than D and cant be done in the same shader  </li>
  <li>Post processing shader 2 (step 3) uses different inputs than C and can't be done in the same shader</li>
  </ul>
  
  <p>There will be the following texture groups </p>
  
  <ul>
  <li>Texture for each UI element</li>
  <li>Texture for the offscreen drawing done in step 1</li>
  <li>Potentially more offscreen textures will be used in post processing depening on metals preformance</li>
  </ul>
  
  <p>Ultimately my confusions are this:</p>
  
  <ul>
  <li>Q1. Render Pipelines take only one vertex and one fragment function so does this mean I need have 4 render pipelines even though I only have 3 unique steps to my drawing procedure?</li>
  <li>Q2. How am I supposed to use multiple pipelines in one encoder? Wouldn't each sucessive call on <code>.setRenderPipelineState</code> override the previous one?</li>
  <li>Q3. Would you recommend keeping all of my <code>.setFragmentTexture</code> calls right after creating my encoder or do I need to set those only right before they are needed.</li>
  <li>Q4. Is it valid to keep my depthState constant even as I switch between pipelineStates? How do I ensure that my entities on step 1 are rendered with depth but make sure depth information is lost between frames so entities are all on top of the previous contents? </li>
  <li>Q5. What do I do with render step 3 where I have two post processing steps? Do those have to be seperate pipelines?</li>
  <li>Q6. How can I efficiently build my pipeline knowing that steps 2 and 4 are essentially the same just with different inputs?</li>
  </ul>
  
  <p>I guess it would help me if someone would walk me through what renderPipelineObjects I will need and for what. It would also be useful to understand what some of the renderCommandEncoder commands might look like at a psuedocode level.</p>