Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Why doesn't URP support using NativeRenderPass on the XR platform?

Discussion in 'Universal Render Pipeline' started by fedly, Feb 27, 2023.

  1. fedly

    fedly

    Joined:
    Aug 26, 2014
    Posts:
    3
    URP Version:12.1.7

    I want to enable URP's NativeRenderPass in Quest development, but it doesn't seem to work. While debugging the code, I found this line of code in ScriptableRenderer.cs:
    Code (CSharp):
    1.             // Use eye texture's width and height as screen params when XR is enabled
    2.             if (cameraData.xr.enabled)
    3.             {
    4.                 scaledCameraWidth = (float)cameraData.cameraTargetDescriptor.width;
    5.                 scaledCameraHeight = (float)cameraData.cameraTargetDescriptor.height;
    6.                 cameraWidth = (float)cameraData.cameraTargetDescriptor.width;
    7.                 cameraHeight = (float)cameraData.cameraTargetDescriptor.height;
    8.  
    9.                 useRenderPassEnabled = false;
    10.             }
    The last line of code indicates that NativeRenderPass cannot be used in XR. Can someone tell me why?
    This has been bothering me for a long time, and I want to figure it out.
     
  2. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    98
    RenderPass support is work in progress and has been enabled only on mobile (non XR) so far. It should be available under the hood on all platforms from 23.2 when RenderGraph is enabled in URP

    Currently (versions before 23) the only benefit of using RenderPass in URP is reduced cost when using the deferred renderer, so unless you are using the deferred renderer in your XR application, there would be no benefit in having RenderPass enabled compared to the non-RP path
     
    fedly and DevDunk like this.
  3. fedly

    fedly

    Joined:
    Aug 26, 2014
    Posts:
    3
    My original intention was to use Subpass in Quest, and in the second subpass, use depth as input to achieve some effects such as soft particles and decals. Now I know that this method may not be feasible in Unity at present.
    Thank you, anyway
     
  4. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    98
    you can do that by using the RenderPass API. What the NativeRenderPass option does, is converting automatically the existing URP internal passes to use that API under the hood. But this wouldn't have effect on any of your custom passes.

    So not having NativeRenderPass enabled shouldn't stop you at all from using the RenderPass API
     
  5. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    98
    in general though, since you mentioned you wanted to use depth as input attachment: we only support color targets framebuffer fetch, because of some platforms not supporting depth fbfetch.

    You can achieve what you need by copying your depth to a color RT and then use that, we do something similar in our deferred renderer lighting passes
     
  6. fedly

    fedly

    Joined:
    Aug 26, 2014
    Posts:
    3
    Alright, I will try to implement how to do that.
     
  7. nosv

    nosv

    Joined:
    Aug 27, 2013
    Posts:
    2
    I am also trying to implement Vulkan subpasses on Quest. I faced some issues with NativeRenderPass and tried using the RenderPass API instead. Eventually, I managed to implement working subpasses on Quest, but only in the Multi-Pass mode. In the Multiview mode, the image is correctly displayed only for the left eye.

    Perhaps the issue is that VkRenderPassCreateInfo is used to create the RenderPass on the native side instead of VkRenderPassMultiviewCreateInfo, so only the first slice of the framebuffer is correctly processed? Setting volumeDepth to 2 inside BeginRenderPass does not solve the issue.

    So, is it currently possible to implement subpasses with Multiview enabled or will this functionality only be available in future releases?

    The issue is present in the latest Unity versions:
    - 2022.2.7f1 URP 14.0.6
    - 2023.1.0a26 URP 15.0.3
     
    Last edited: Mar 1, 2023
  8. linfuqing

    linfuqing

    Joined:
    May 11, 2015
    Posts:
    166
    Can use depth as input attachment instead of _CameraDepthTexture in transparent subpass?
    I don't think write the depth to the color rt(alpha channel?) is a good idea,it need more bandwidth.
     
  9. linfuqing

    linfuqing

    Joined:
    May 11, 2015
    Posts:
    166
  10. linfuqing

    linfuqing

    Joined:
    May 11, 2015
    Posts:
    166
  11. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    98
    when I mean depth as color, we copy the depth to a F32 color texture so precision shouldn't be the issue, however you need the extra depth copy which can be expensive

    regarding binding depth as input attachment, it is not supported on some platforms like Metal, but if you are targeting Vulkan/GLES only and using the depthFetch instruction you could give it a try