-
Notifications
You must be signed in to change notification settings - Fork 855
[ShaderGraph][2021.2] Throttling animated preview framerate #5164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi! This comment will help you figure out which jobs to run before merging your PR. The suggestions are dynamic based on what files you have changed. Shader Graph Depending on the scope of your PR, you may need to run more jobs than what has been suggested. Please speak to your lead or a Graphics SDET (#devs-graphics-automation) if you are unsure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, clean improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this for a pretty long period of time, as well as on mac - seems to work great!
Cherry pick from 1985929 # Conflicts: # com.unity.shadergraph/CHANGELOG.md # com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs
Cherry picked from 1985929 # Conflicts: # com.unity.shadergraph/CHANGELOG.md # com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs
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
Before with two animated graphs of 8 nodes: ~35% GPU usage

Same independent of which window focused, or if Unity app is focused.
After:

Similar / slightly reduced cost, but much more stable behavior (less oscillation):
Note: user who reported the 50% GPU usage noted that in his project this PR dropped it to around ~5% usage. I think with my settings the project is already getting throttled approximately to the desired framerate through the update calls.
When a non-ShaderGraph unity window selected: ~20% (10 fps)

When another app selected: ~7% (2 fps)

Yamato:
ShaderGraph PR job: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Fthrottle-preview/.yamato%252Fall-shadergraph.yml%2523PR_ShaderGraph_2021.2/7747012/job/pipeline
Comments to reviewers
Notes for the reviewers you have assigned.