Search Issue Tracker

By Design

Votes

0

Found in

2019.4

2020.1

2020.2

2020.2.1f1

2020.3

Issue ID

1307902

Regression

No

GraphicsFormatUtility.GetGraphicsFormat throws error when TextureFormat.RGB24 is used

Texture

-

Reproduction steps:
1. Open the attached project ("GraphicsFormat.zip")
2. Open the "SampleScene" scene
3. Enter Play mode
4. Open the Console window

Expected result: Texture successfully created, no errors in the console
Actual result: Error in the console:

Texture creation failed. 'R8G8B8_UNorm' is not supported for Sample usage on this platform. Use 'SystemInfo.IsFormatSupported' C# API to check format support.
UnityEngine.Texture2D:.ctor (int,int,UnityEngine.Experimental.Rendering.GraphicsFormat,int,UnityEngine.Experimental.Rendering.TextureCreationFlags)

Reproducible with: 2019.4.22f1, 2020.2.7f1, 2020.3.0f1, 2021.1.0b10, 2021.2.0a7
Could not test with: 2018.4.33f1 (NUnit errors)

  1. Resolution Note:

    I'm closing this as this behavior is by design.

    GraphicsFormat is by-design a low-level format that needs to be queries in order to be used (using SystemInfo.IsFormatSupported).
    Unless SystemInfo.IsFormatSupported reports that a specific format can be used for a specific use case (render/sample/…) on your specific setup (OS, GPU, Drivers, …), you cannot do it. The philosophy of GraphicsFormat is that if it is reported that you can use it, it can be used directly on the GPU (without any intervention from Unity).

    This is opposite of TextureFormat. All TextureFormats should be able to use on any platform but without ANY guarantees about what exactly is happening in the background. For example compressed textures might become RAW (with additional decompression on the CPU), the GPU resource might be another type, … The philosophy of TextureFormat is that we (Unity) might jump through hoops in order to make it easy to use (at a protentional memory/performance cost)

    This is exactly what your issue is highlighting. R8G8B8 is a format that (afaik) virtually no GPU actually supports. Some older APIs might emulate it in the driver and that is exactly how we thread it in Unity: We convert it on the fly to R8G8B8A8.
    So when using the GraphicsFormat directly, an error is expected.

    Best Regards,
    Dieter

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.