MerlinVR / USharpVideo

A basic video player made for VRChat using Udon and UdonSharp
MIT License
322 stars 43 forks source link

Global GI Vram fix #33

Closed LokiHellheim closed 2 years ago

LokiHellheim commented 2 years ago

Hi merlin you probably know that unity 2019.4 has a vram leak on Global GI and renders like used on the video.

A simple counter will delay the update and instead of updating the render texture every frame we can do it every second or two depending on the need.

Me and my friends use the video player you created to watch movies and the vram is full after every movie, and shared system ram too (i have 32gb, and sometimes i end up on 28 GB). So i use this simple counter to delay the update of the RenderGIUpdate

Renderer targetRenderer;
        int contador = 0;
        public int SlowRefreshByFPS = 90;
        void Start()
        {
            targetRenderer = GetComponent<Renderer>();
        }

        private void Update()
        {
            if (contador == SlowRefreshByFPS)
            {
                RendererExtensions.UpdateGIMaterials(targetRenderer);
                contador = 0;
            }
            else {
                contador++;
                 }
        }

As a default i use 90 updates, but most of the times people is on 45fps, so the delay can be as low as 45. As you know the refresh rate can be link on the amount of FPS, but i prefer a static number since low FPS means that a lot is happening and you don't want to update the render on that situation.

Loki H.

PD: im great fan of you work.

MerlinVR commented 2 years ago

Thanks, Unity has fixed this issue in Unity 2019.4.30 and VRC is currently testing 2019.4.30 to make sure it's stable. So it should hopefully be fixed properly in the client in the next few weeks and will not need mitigations that can only slow the leak. I'll leave this issue up until then.

LokiHellheim commented 2 years ago

As you said we changed of version of unity to the 2019.4.30f1 the issue has been fixed.

MerlinVR commented 2 years ago

👍