OnPostRender changes

OnPostRender no longer works in the new render pipelines though it does not mention that in the documents (https://docs.unity3d.com/2020.1/Documentation/ScriptReference/MonoBehaviour.OnPostRender.html) which would be helpful but anyway...

The example in the above page does not work and my previous code using GL functions doesn't work either, if adjusted to use RenderPipelineManager.endCameraRendering, which is a bit of an issue.
Should the GL functions still work within the new 'post render'?

I was using the post render to render into a render texture with a dummy camera using GL calls

The docs largely ignore SRPs.

I think you're supposed to use custom passes now : https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@8.2/manual/Custom-Pass.html

Yes it is awkward with the docs - SRPs are like a hack-on.
Anyway the thing is I am not wanting post effects I was previously using GL calls to fast copy textures into a render texture to generate a new image at runtime but it is unclear how to do that now, previously you could do something like this:

//cam is a dummy camera only used for offscreen stuff
cam.targetTexture = renderTex;
cam.Render();//calls OnPostRender with GL. calls or Graphics.DrawTexture
cam.targetTexture = null;

//copy to Texture2D
RenderTexture.active = renderTex;
target.ReadPixels(new Rect(0, 0, 1024, 1024), 0, 0);
RenderTexture.active = null;

Demo of gl commands writing to render texture in built-in
How on earth in HDRP/SRP is a bit of a mystery, I can "RenderPipelineManager.endCameraRendering += OnHDPostRender" to do similar but then I get a ScriptableRenderContext and Camera which do not work without some additional context calls?!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PostRenderTest : MonoBehaviour
    public RawImage rawImage;//target UI texture for test

    Camera cam;
    RenderTexture renderTex;

    bool textureDraw = false;

    void Awake()
        cam = GetComponent<Camera>();
        if (cam == null)
            cam = gameObject.AddComponent<Camera>();
            cam.clearFlags = CameraClearFlags.Color;
            cam.backgroundColor = new Color32( 0, 0, 255, 255 );
            cam.cullingMask = 0;
        cam.enabled = false;

    private void Start()

    void OnPostRender()
        if (textureDraw)
            var shader = Shader.Find( "Hidden/Internal-Colored" );
            Material mat = new Material( shader );
            mat.SetInt( "_Cull", (int)UnityEngine.Rendering.CullMode.Off );
            mat.SetInt( "_ZWrite", 0 );
            mat.SetInt( "_ZTest", (int)UnityEngine.Rendering.CompareFunction.Always );

            GL.LoadPixelMatrix( 0, 1024, 0, 1024 );

            mat.SetPass( 0 );

            GL.Begin( GL.TRIANGLES );
            GL.Color( Color.red );


            textureDraw = false;

    void Test()
        if (renderTex == null) renderTex = new RenderTexture( 1024, 1024, 0 );

        cam.targetTexture = renderTex;
        textureDraw = true;
        textureDraw = false;
        cam.targetTexture = null;

        rawImage.texture = renderTex;

CustomRenderTextures it seems might be better...
or Graphics.Blit for simple stuff actually