forked from Unity-Technologies/Graphics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Bring back the callback to notify when a shader variant has been processed. - Fixing this[ yamato job](https://yamato-artifactviewer.prd.cds.internal.unity3d.com/bfd11010-3cc0-495c-aa6b-1d019a56c210%2FTest_Report_1%2FUtrTestReport1/TestReport.html )
- Loading branch information
1 parent
3148eb7
commit deecca5
Showing
5 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
Packages/com.unity.render-pipelines.core/Editor/ShaderStripping/ShaderStrippingWatcher.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace UnityEditor.Rendering | ||
{ | ||
/// <summary> | ||
/// Notifies when shader variants have been stripped | ||
/// </summary> | ||
public static class ShaderStrippingWatcher | ||
{ | ||
/// <summary> | ||
/// Callback when a shader has been stripped | ||
/// </summary> | ||
/// <param name="shader">The shader</param> | ||
/// <param name="shaderVariant">The variant</param> | ||
/// <param name="variantsOut">The output variants after the stripping process</param> | ||
/// <param name="stripTimeMs">The total amount of time to strip the variants</param> | ||
/// <typeparam name="TShader">The shader</typeparam> | ||
/// <typeparam name="TShaderVariant">The variant</typeparam> | ||
public delegate void OnShaderStrippedCallbackHandler<TShader, TShaderVariant>(TShader shader, TShaderVariant shaderVariant, uint variantsOut, double stripTimeMs) | ||
where TShader : UnityEngine.Object; | ||
|
||
/// <summary> | ||
/// Callback for <see cref="Shader"/> | ||
/// </summary> | ||
public static event OnShaderStrippedCallbackHandler<Shader, ShaderSnippetData> shaderProcessed; | ||
|
||
/// <summary> | ||
/// Callback for <see cref="ComputeShader"/> | ||
/// </summary> | ||
public static event OnShaderStrippedCallbackHandler<ComputeShader, string> computeShaderProcessed; | ||
|
||
internal static void OnShaderProcessed<TShader, TShaderVariant>(TShader shader, TShaderVariant shaderVariant, uint variantsOut, double stripTimeMs) | ||
where TShader : UnityEngine.Object | ||
{ | ||
if (typeof(TShader) == typeof(Shader)) | ||
{ | ||
shaderProcessed?.Invoke((Shader)Convert.ChangeType(shader, typeof(Shader)), (ShaderSnippetData)Convert.ChangeType(shaderVariant, typeof(ShaderSnippetData)), variantsOut, stripTimeMs); | ||
} | ||
else if (typeof(TShader) == typeof(ComputeShader)) | ||
{ | ||
computeShaderProcessed?.Invoke((ComputeShader)Convert.ChangeType(shader, typeof(ComputeShader)), shaderVariant.ToString(), variantsOut, stripTimeMs); | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ges/com.unity.render-pipelines.core/Editor/ShaderStripping/ShaderStrippingWatcher.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters