Custom Copy Depth pass not working on macOS

Hi,

I’ve encountered a problem with a simple custom ScriptableRenderPass that copies depth buffer to the custom texture. The reason for this pass is that I need 2 separate depth textures: one made just after rendering opaques - which is made by a standard Unity CopyDepth pass generating _CameraDepthTexture. And the second one must be generated after rendering transparent objects (some of which also write to depth buffer). And this is why I added a separate pass to generate this second texture.

This custom pass is using a built-in Unity CopyDepth shader, just like normal CopyDepth pass (code was also inspired by it).

Everything works fine on Windows PC, but it seems that on macOS texture is not being generated at all (or is being generated, but stays completely black). As a source I tried using both activeDepthTexture and cameraDepth taken from UniversalResourceData, but with no effect.
What is interesting, texture appears to be generated when I enter Frame Debugger (!) - only for that single captured frame. After exiting debugger texture stays the same and is not being refreshed (see screenshots below)

Is it a known issue on macOS? Is there anything I could try to make it work?
I cannot tell if the pass is being executed or not, as entering frame debugger “fixes” this issue temporarily. Entire pass code seems to execute fine (according to some Debug.Logs I put there).
Is Frame Debugger doing something special that could force this pass to execute on macOS - something I could do from code?

This is the pass code:

  private Material _blitMaterial;
  private RenderTexture _target;
  private bool _isInitialized;

  public void Initialize() {
    renderPassEvent = RenderPassEvent.AfterRenderingTransparents;
    if (GraphicsSettings.TryGetRenderPipelineSettings<UniversalRendererResources>(out var shaders)) {
      _blitMaterial = CoreUtils.CreateEngineMaterial(shaders.copyDepthPS);
      _isInitialized = true;
    }
  }

  public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) {
    if (_isInitialized) {
      var cameraData = frameData.Get<UniversalCameraData>();
      var targetDescriptor = cameraData.cameraTargetDescriptor;
      targetDescriptor.graphicsFormat = GraphicsFormat.R32_SFloat;
      targetDescriptor.depthStencilFormat = GraphicsFormat.None;
      targetDescriptor.msaaSamples = 1;
      targetDescriptor.bindMS = false;

      var resourceData = frameData.Get<UniversalResourceData>();
      var source = resourceData.activeDepthTexture;
      var target = UniversalRenderer.CreateRenderGraphTexture(renderGraph, targetDescriptor,
                                                              "CustomDepthTexture", true);
      if (!cameraData.isSceneViewCamera && source.IsValid() && target.IsValid()) {
        using var builder = renderGraph.AddRasterRenderPass<PassData>("Pass", out var passData);
        passData.Source = source;
        passData.BlitMaterial = _blitMaterial;
        builder.UseTexture(source);
        builder.SetRenderAttachment(target, 0);
        builder.SetGlobalTextureAfterPass(target, Shader.PropertyToID("_DepthAfterTransparency"));
        builder.AllowPassCulling(false);
        builder.SetRenderFunc((PassData data, RasterGraphContext context) => {
          ExecutePass(context.cmd, data);
        });
      }
    }
  }

  private static void ExecutePass(RasterCommandBuffer commandBuffer, PassData passData) {
    var blitMaterial = passData.BlitMaterial;
    blitMaterial.SetTexture("_CameraDepthAttachment", passData.Source);
    Blitter.BlitTexture(commandBuffer, passData.Source, new(1, 1, 0, 0), blitMaterial, 0);
  }

  private class PassData {

    internal TextureHandle Source;
    internal Material BlitMaterial;

  }

Here are some screenshots that illustrate the problem:

expected
actual
frame_debugger

I also tried replacing CopyDepth shader with an ultra-simple one, that just writes red color to the texture - and it still doesn’t work on macOS (works on Windows though).

Just like the pass would have been culled somehow (but the culling is disabled) or something is skipped on Mac.