Cmd.Blit into depth texture

I’ve been trying to blur a depth buffer based on the Universal RP DoF renderpass.
The depth texture has been successfully blurred but now I’m trying to blit result back to the depth buffer.

The problem is that cmd.blit binds the destination depth buffer as a depth/stencil buffer rather than as the color RT. Is this intended behavior ?

I tried working around the problem by rendering a fullscreen quad by hand but I’m again having trouble binding the depth buffer as a color RT.

  void Render(CommandBuffer cmd, ref RenderingData renderingData)
        {
            ref var cameraData = ref renderingData.cameraData;

            int wh = m_Descriptor.width;// / 2;
            int hh = m_Descriptor.height;// / 2;

            // Assumes a radius of 1 is 1 at 1080p
            // Past a certain radius our gaussian kernel will look very bad so we'll clamp it for
            // very high resolutions (4K+).
            float maxRadius = BlurRadius * (wh / 1080f);
            maxRadius = Mathf.Min(maxRadius, 5f);

            m_Materials.m_ExpandDepthMaterial.SetFloat(ShaderConstants._MaxRadius, maxRadius);

            // Temporary textures
            cmd.GetTemporaryRT(ShaderConstants._PingTexture, GetStereoCompatibleDescriptor(wh, hh, m_DefaultDepthFormat), FilterMode.Bilinear);
            cmd.GetTemporaryRT(ShaderConstants._PongTexture, GetStereoCompatibleDescriptor(wh, hh, m_DefaultDepthFormat), FilterMode.Bilinear);
           

            // Blur
            cmd.SetGlobalTexture(ShaderConstants._SourceTexture, source.id);
            cmd.Blit(source.id, ShaderConstants._PingTexture, m_Materials.m_ExpandDepthMaterial, 0);
            cmd.Blit(ShaderConstants._PingTexture, ShaderConstants._PongTexture, m_Materials.m_ExpandDepthMaterial, 1);

            // Levels
            cmd.Blit(ShaderConstants._PongTexture, ShaderConstants._PingTexture, m_Materials.m_ExpandDepthMaterial, 2);

            // source.id gets bound to the Depth/Stencil slot rather than as RT0
            //cmd.Blit(ShaderConstants._PongTexture, source.id, m_Materials.m_ExpandDepthMaterial, 2);

            // Error: Graphics.CopyTexture called with null source texture
            // cmd.ConvertTexture(ShaderConstants._PingTexture, source.id);

            // Both _MainTex and RT0 remain unbound
            cmd.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.identity);
            cmd.SetViewport(cameraData.camera.pixelRect);
            cmd.SetGlobalTexture(ShaderConstants._SourceTexture, ShaderConstants._PingTexture);
            // Force pongtexture as the DS to avoid source.id being used.
            cmd.SetRenderTarget(source.id, (RenderTargetIdentifier)ShaderConstants._PongTexture);
            cmd.DrawMesh(RenderingUtils.fullscreenMesh, Matrix4x4.identity, m_Materials.m_ExpandDepthMaterial, 0, 3);

            // Cleanup
            cmd.ReleaseTemporaryRT(ShaderConstants._PingTexture);
            cmd.ReleaseTemporaryRT(ShaderConstants._PongTexture);
        }

Some further experimenting:
Creating a second texture and passing it as a Blit() destination causes there to be no drawcall at all.

            m_CutoutDepthTexture.Init("_CameraCutoutDepthTexture");
            m_BlurredCutoutDepthTexture.Init("_BlurredCutoutDepthTexture");
 cmd.Blit(ShaderConstants._PongTexture, destination.id, m_Materials.m_ExpandDepthMaterial, 2);

I’m new to SRP and have no idea what’s going on, any help ?

I have the same problem, I made Height Fog and render it before transparent, the result is all the transparent object pass Ztest
I use cmd(Blit, texture, texture ,material) replace cmd.Blit to solve the problem

What is assigned to source.id? A depth buffer of a render texture?
Isn’t writing to Depth/stencil what you wanted to do in the first place? You have blurred the source, and copying the blurred texture back to source as is.
You could also try blitting back to the render texture itself (with color buffer), but writing only SV_Depth and ZWrite on