com.unity.webrtc icon indicating copy to clipboard operation
com.unity.webrtc copied to clipboard

[BUG]: Custom rendering is adversely by the order and presence of the graphics APIs in Windows, even when forcing the graphics device

Open doctorpangloss opened this issue 2 years ago • 5 comments

Package version

2.4.0-exp.8

Environment

* OS: Windows 11
* Unity version: 2021.3.6f1

Steps To Reproduce

  1. Application.targetFrameRate = 999.
  2. Render the streamed texture using Camera.render.
  3. Set the editor to DirectX 12.
  4. Observe the following frame rates under different configurations:
PlayerSettings.SetGraphicsAPIs(BuildTarget.StandaloneWindows64,
 new[] {GraphicsDeviceType.Direct3D12, GraphicsDeviceType.Direct3D11, GraphicsDeviceType.Vulkan});

Flags                                    FPS
-force-gfx-jobs native --force-d3d12     65
-force-gfx-jobs native --force-d3d11      68
PlayerSettings.SetGraphicsAPIs(BuildTarget.StandaloneWindows64,
 new[] {GraphicsDeviceType.Direct3D11, GraphicsDeviceType.Direct3D12});

Flags                                    FPS
-force-gfx-jobs native --force-d3d12     38
-force-gfx-jobs native --force-d3d11      20

Current Behavior

Unusually poor performance affected by the order and presence of graphics APIs for Windows.

Expected Behavior

Performance should not be affected.

Anything else?

Nothing unusual changes in the profiler. The HDRP scripting and rendering thread work is both longer, the GPU work appears to stay the same.

doctorpangloss avatar Jul 05 '22 17:07 doctorpangloss

@doctorpangloss Can I ask you how you measure the FPS?

When Application.targetFramerate is -1, the framerate depends on the platrofm. And the encoding framerate is 60 by default. But I am not sure these framerate relates on the issue.

karasusan avatar Jul 06 '22 00:07 karasusan

@doctorpangloss Can I ask you how you measure the FPS?

an ancient script I didn't author, which renders the measured FPS to a canvas text

void Update()
        {
            m_Timeleft -= Time.deltaTime;
            m_DeltaFps += Time.timeScale / Time.deltaTime;
            ++m_Frames;

            // Interval ended - update GUI text and start new interval
            if (m_Timeleft <= 0f)
            {
                // display two fractional digits (f2 format)
                text.text = "" + (m_DeltaFps / m_Frames).ToString("f2") + " FPS";
                if ((m_DeltaFps / m_Frames) < 1)
                {
                    text.text = "";
                }
                m_Timeleft = updateInterval;
                m_DeltaFps = 0f;
                m_Frames = 0;
            }
        }

this is consistent with what the profiler reported. I still need to profile on my test Windows machines

doctorpangloss avatar Jul 06 '22 04:07 doctorpangloss

I have explored the issue more and believe there might be something severely glitched with the editor or plugin interacting with the graphics APIs order.

doctorpangloss avatar Jul 11 '22 21:07 doctorpangloss

@doctorpangloss I am curious that this issue occurs only when using the WebRTC package.

karasusan avatar Jul 12 '22 01:07 karasusan

It's a huge puzzle! This order shouldn't impact anything. I can reproduce it 100% though. I can share the repo and binaries if you need.

doctorpangloss avatar Jul 12 '22 03:07 doctorpangloss

@doctorpangloss Hi, can I close this issue?

karasusan avatar Sep 06 '22 02:09 karasusan

yes i will update it and reopen if I have some insights into why this occurs.

doctorpangloss avatar Sep 06 '22 02:09 doctorpangloss