Search Unity

How to Avoid RenderTexture.ResolveAA when Intercepting Image with CommandBuffer?

Discussion in 'Shaders' started by AhSai, Aug 17, 2019.

  1. AhSai

    AhSai

    Joined:
    Jun 25, 2017
    Posts:
    129
    Hi, I am using the way shown in this manual https://docs.unity3d.com/Manual/GraphicsCommandBuffers.html to intercept the current image with CommandBuffer to replace GrabPass. However, if I turn on MSAA, everytime I do a
    Code (CSharp):
    1. commandBuffer.Blit(BuiltinRenderTextureType.CurrentActive, screenCopyID);
    it will result in a RenderTexture.ResolveAA. Since this "grab screen" is only used for refraction effect, and another RenderTexture.ResolveAA will be called later in the image effect shader, the RenderTexture.ResolveAA in the "grab screen" stage seems unnecessary. So is there any work around to this problem?
     
  2. DavidSWu

    DavidSWu

    Joined:
    Jun 20, 2016
    Posts:
    183
    On tiled rendering architectures, the CurrentActive Render Target exists only temporarily and cannot be read from (other than via frame buffer fetch) so in order to copy from it, it needs to be resolved to physical memory.
    Also when you blit, it sets the target texture as the active render target in tiled memory, so you have to resolve out the current active render before the blit if you do not want to overwrite it.
    In theory you copy copy out the full MSAA render target (it might actually have to do it to save/restore it) but then reading from it is slow as you have to resolve within your shader.
     
    JSmithIR likes this.
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,442