Search Unity

Question Changing name of custom pass in frame debugger?

Discussion in 'Universal Render Pipeline' started by alexanderameye, Sep 4, 2020.

  1. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    I am using the following code for a custom pass in URP.

    Code (CSharp):
    1. CommandBuffer cmd = CommandBufferPool.Get("My Custom Pass");
    2.  
    3. var sortFlags = renderingData.cameraData.defaultOpaqueSortFlags;
    4. var drawingSettings = CreateDrawingSettings(shaderTags, ref renderingData, sortFlags);
    5. drawingSettings.overrideMaterial = stencilMaterial;
    6. drawingSettings.overrideMaterialPassIndex = 0;
    7.  
    8. context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);
    9.        
    The issue is that in the frame debugger, I just see 'RenderLoop.Draw'.

    upload_2020-9-4_13-1-9.png

    How can I make it so that it will show 'My Custom Pass' instead? Or how can I make it so that maybe RenderLoop.Draw is nested under a parent entry called 'My Custom Pass'?

    What I want is like the render opaques pass.

    upload_2020-9-4_13-2-7.png

    Where RenderLoop.Draw is nested under a nice 'Render Opaques' name which is much more descriptive.
     
    Last edited: Sep 4, 2020
  2. epifun

    epifun

    Joined:
    Oct 27, 2020
    Posts:
    6
    @alexanderameye
    Have the same issue? Did you find a solution for this?
     
  3. pensionerov

    pensionerov

    Joined:
    Mar 13, 2018
    Posts:
    12
    I tried to do it in the same way like Unity does it for RenderObjectsPass with ProfilerScope. It sort of works, but mangles the frame debugger hierarchy. Have no idea what I did wrong.
     
  4. pensionerov

    pensionerov

    Joined:
    Mar 13, 2018
    Posts:
    12
    Figured something out, but still no real solution. So in RenderObjectsPass they do something like this:
    Code (CSharp):
    1. CommandBuffer cmd = CommandBufferPool.Get();
    2. using (new ProfilingScope(cmd, new ProfilingSampler("NameInTheDebugger")))
    3. {
    4.     // render things
    5. }
    6. context.ExecuteCommandBuffer(cmd);
    7. CommandBufferPool.Release(cmd);
    It works for me if I use only blits inside the using scope. But context.DrawRenderers breaks the debugger hierarchy. Obviously, in RenderObjectsPass they do use context.DrawRenderers. Why does it work fine there and not in my case I do not know. They have this ominous note above the ProfilingScope, but I haven't used any named command buffers.
    Code (CSharp):
    1. // NOTE: Do NOT mix ProfilingScope with named CommandBuffers i.e. CommandBufferPool.Get("name").
    2. // Currently there's an issue which results in mismatched markers.
     
    alexanderameye likes this.
  5. alexanderameye

    alexanderameye

    Joined:
    Nov 27, 2013
    Posts:
    1,383
    Just doing it like you (profiling scope + unnamed command buffer), it works for me, even with DrawRenderers (see TEST name), this is on URP 12 I believe.

     
  6. pensionerov

    pensionerov

    Joined:
    Mar 13, 2018
    Posts:
    12
    Found out what I was doing wrong. You need to execute the command buffer inside the using scope, clear it there and execute it again after the using scope. ProfilingScope probably adds a "start" command to the buffer on creation and "end" on disposal. It worked for blits becaues I was simply using one command buffer to do everything. DrawRenderers is scheduled separately without a command buffer. So, for me the following worked:

    Code (CSharp):
    1. CommandBuffer cmd = CommandBufferPool.Get();
    2. using (new ProfilingScope(cmd, new ProfilingSampler("NameInTheDebugger")))
    3. {
    4.     context.ExecuteCommandBuffer(cmd);
    5.     cmd.Clear();
    6.     // render things
    7. }
    8. context.ExecuteCommandBuffer(cmd);
    9. CommandBufferPool.Release(cmd);
     
  7. wechat_os_Qy0wtRVljlcvwICm8lBEZh9lY

    wechat_os_Qy0wtRVljlcvwICm8lBEZh9lY

    Joined:
    Oct 30, 2021
    Posts:
    1
    thank you ~~~
     
  8. Propagant

    Propagant

    Joined:
    Nov 18, 2013
    Posts:
    38
    Thanks!