Skip to content

Conversation

cdxntchou
Copy link

@cdxntchou cdxntchou commented Sep 8, 2021

Purpose of this PR

Addressing: https://fogbugz.unity3d.com/f/cases/1351801/

Backports:
2021.2: #5164
2021.1: #5574
2020.3: #5575

Fixing an issue where animated preview rendering can take huge amounts of GPU time.

Animated preview rendering is only throttled by the rate at which update is called, and this can be 300 fps or more, depending on your machine and setup, which can result in excessive GPU usage. Some users were seeing very hefty GPUs burning 50% of their time rendering the animated previews at thousands of FPS.

This PR adds a throttle, limiting animated previews to render at your monitor refresh rate.
When the ShaderGraph window is not focused, it further reduces that to 10 fps max.
And when Unity is not active (i.e. another app has focus), it drops it down to 2 fps.


Testing status

Describe what manual/automated tests were performed for this PR

  • Tested on Windows with debug logging enabled, to see that preview rendering is called at most 60 times/second.
  • Tested on Windows, with another Unity window focused, to see that preview rendering is called at most 10 times/second.
  • Tested on Windows, with another program active, to see that preview rendering is called at most 2 times/second.
  • Tested with two ShaderGraph editor windows open -- the focused one gets updated at 60 fps, the other at 10 fps.

Before with two animated graphs of 8 nodes: ~21-22% GPU usage
Same independent of which window focused, or if Unity app is focused.
image

After: ~10%
image

When a non-ShaderGraph unity window selected: ~3-4%
image

When another app selected: ~2-3%
image

Yamato:

ShaderGraph PR job: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/10.x.x%252Fsg%252Fthrottle-preview/.yamato%252Fall-shadergraph.yml%2523PR_ShaderGraph_2020.3/8613998/job/pipeline


Comments to reviewers

Notes for the reviewers you have assigned.

Cherry picked from 1985929

# Conflicts:
#	com.unity.shadergraph/CHANGELOG.md
#	com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs
Copy link
Contributor

@jessebarker jessebarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@GrantLamb-Unity GrantLamb-Unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the test artifacts. Approving 👍

@cdxntchou cdxntchou merged commit 9ae4748 into 10.x.x/release Sep 10, 2021
@cdxntchou cdxntchou deleted the 10.x.x/sg/throttle-preview branch September 10, 2021 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants