Version: 2019.3
Setting the active Render Pipeline Asset
Scriptable Render Pipeline (SRP) Batcher

Scheduling and executing rendering commands in the Scriptable Render Pipeline

In the Scriptable Render Pipeline (SRP), you use C# scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary
to configure and schedule renderingThe process of drawing graphics to the screen (or to a render texture). By default, the main camera in Unity renders its view to the screen. More info
See in Glossary
commands. You then tell Unity’s low-level graphics architecture to execute them, which sends instructions to the graphics API.

The main way of doing this is by using the Scriptable Render Context, but you can also execute Command Buffers immediately.

Using the Scriptable Render Context

The Scriptable Render Context acts as an interface between your C# code and Unity’s low-level graphics code. In SRP, rendering works using delayed execution; you use the Scriptable Render Context to build up a list of rendering commands, and then you tell Unity to execute them. Unity’s low-level graphics architecture then sends instructions to the graphics API.

To schedule rendering commands, pass CommandBuffers to ScriptableRenderContext.ExecuteCommandBuffer(), or make API calls to the Scriptable Render Context. When you want Unity to perform the commands that you have scheduled, call ScriptableRenderContext.Submit(). Note that it does not matter whether you used a Command Buffer or an API call to schedule a command; Unity schedules all rendering commands in the same way, and does not execute any of them until you call Submit().

This example code demonstrates how to schedule and perform a command to clear the current render target.

using UnityEngine;
using UnityEngine.Rendering;

public class ExampleRenderPipelineInstance : RenderPipeline
{
        public ExampleRenderPipelineInstance() {
        }

    protected void Render(ScriptableRenderContext context, Camera[] cameras) {
        // Create and schedule a command to clear the current render target
        var cmd = new CommandBuffer();
        cmd.ClearRenderTarget(true, true, Color.black);
        context.ExecuteCommandBuffer(cmd);
        cmd.Release();

         // Tell the Scriptable Render Context to tell the graphics API to perform the scheduled commands
        context.Submit();
    }
}

Executing Command Buffers immediately

You can execute Command Buffers immediately without using the Scriptable Render Context, by calling Graphics.ExecuteCommandBuffer(). Calls to this API take place outside of the render pipeline.

Additional information

For more information on commands that you can schedule using Command Buffers, see Command Buffers API documentation.

Setting the active Render Pipeline Asset
Scriptable Render Pipeline (SRP) Batcher