How to check if a device supports rendering to texture?

As my game was crashing on multiple devices, I came to an unexpected realization: some phones don’t support rendering to image for some reason? So I just want a way to check if the device supports it. I understand there’s a function
SystemInfo.SupportsRenderTextureFormat(), but I’m not sure how to use it and I have a limited way of testing this on other devices and the documentation doesn’t make it very clear. Or perhaps I should change the Color Format of the render texture?

Hi, some devices support a RenderTexture format only for specific usage(s). You can find more information here.

For example,

using UnityEngine.Experimental.Rendering;

bool supportRender = SystemInfo.IsFormatSupported(GraphicsFormat.xxx, FormatUsage.Render);

if (!supportRender)
    // we should change the RT to another format.
1 Like

Thank you for your answer! I will look into it.

    public bool SupportsRenderOfPausedMenuGameTexture()
    {
        return SupportsRender(pausedMenuGameTexture.depthStencilFormat, pausedMenuGameTexture.format);
    }

    public static bool SupportsRender()
    {
        return SupportsRender(GraphicsFormat.R8G8B8A8_UNorm, RenderTextureFormat.ARGB32);
    }

    public static bool SupportsRender(GraphicsFormat format, RenderTextureFormat renderTextureFormat)
    {
        return SystemInfo.IsFormatSupported(format, FormatUsage.Render) && SystemInfo.SupportsRenderTextureFormat(renderTextureFormat);
    }

Do you think this is a correct way of handling this? Should I pass RenderTexture.depthStencilFormat to the SystemInfo.IsFormatSupported() function, or something else? Thank you for explaining this and pointing me at a very right direction!

I think you can ignore the depth stencil format and check the color format only. Unity should find a compatible depth format for the RT.

By the way, have you tried using GraphicsFormat.R8G8B8A8_SRGB for rendering? This format is widely supported on old mobiles and it should be fine to store colors (paused menu). “UNorm” is usually used to store non-color data like smoothness.

2 Likes

I will try it, thank you! I used that one only because it was set as default for my RenderTexture and I thought it would be appropriate. Thank you once again, so far my game has more errors per day than users per day xd (solely because of this render texture)

1 Like