@@ -10,9 +10,25 @@ public sealed class WaveformMonitor : Monitor
1010
1111 ComputeBuffer m_Data ;
1212
13- private int threadGroupSize ;
14- private int threadGroupSizeX ;
15- private int threadGroupSizeY ;
13+ int m_ThreadGroupSize ;
14+ int m_ThreadGroupSizeX ;
15+ int m_ThreadGroupSizeY ;
16+
17+ internal override void OnEnable ( )
18+ {
19+ m_ThreadGroupSizeX = 16 ;
20+
21+ if ( RuntimeUtilities . isAndroidOpenGL )
22+ {
23+ m_ThreadGroupSize = 128 ;
24+ m_ThreadGroupSizeY = 8 ;
25+ }
26+ else
27+ {
28+ m_ThreadGroupSize = 256 ;
29+ m_ThreadGroupSizeY = 16 ;
30+ }
31+ }
1632
1733 internal override void OnDisable ( )
1834 {
@@ -24,17 +40,6 @@ internal override void OnDisable()
2440 m_Data = null ;
2541 }
2642
27- internal override void OnEnable ( )
28- {
29- base . OnEnable ( ) ;
30-
31- bool isAndroidOpenGL = Application . platform == RuntimePlatform . Android && SystemInfo . graphicsDeviceType != GraphicsDeviceType . Vulkan ;
32-
33- threadGroupSize = isAndroidOpenGL ? 128 : 256 ;
34- threadGroupSizeX = isAndroidOpenGL ? 16 : 16 ;
35- threadGroupSizeY = isAndroidOpenGL ? 8 : 16 ;
36- }
37-
3843 internal override bool NeedsHalfRes ( )
3944 {
4045 return true ;
@@ -75,7 +80,7 @@ internal override void Render(PostProcessRenderContext context)
7580 int kernel = compute . FindKernel ( "KWaveformClear" ) ;
7681 cmd . SetComputeBufferParam ( compute , kernel , "_WaveformBuffer" , m_Data ) ;
7782 cmd . SetComputeVectorParam ( compute , "_Params" , parameters ) ;
78- cmd . DispatchCompute ( compute , kernel , Mathf . CeilToInt ( width / ( float ) threadGroupSizeX ) , Mathf . CeilToInt ( height / ( float ) threadGroupSizeY ) , 1 ) ;
83+ cmd . DispatchCompute ( compute , kernel , Mathf . CeilToInt ( width / ( float ) m_ThreadGroupSizeX ) , Mathf . CeilToInt ( height / ( float ) m_ThreadGroupSizeY ) , 1 ) ;
7984
8085 // For performance reasons, especially on consoles, we'll just downscale the source
8186 // again to reduce VMEM stalls. Eventually the whole algorithm needs to be rewritten as
@@ -88,7 +93,7 @@ internal override void Render(PostProcessRenderContext context)
8893 cmd . SetComputeBufferParam ( compute , kernel , "_WaveformBuffer" , m_Data ) ;
8994 cmd . SetComputeTextureParam ( compute , kernel , "_Source" , ShaderIDs . WaveformSource ) ;
9095 cmd . SetComputeVectorParam ( compute , "_Params" , parameters ) ;
91- cmd . DispatchCompute ( compute , kernel , width , Mathf . CeilToInt ( height / ( float ) threadGroupSize ) , 1 ) ;
96+ cmd . DispatchCompute ( compute , kernel , width , Mathf . CeilToInt ( height / ( float ) m_ThreadGroupSize ) , 1 ) ;
9297 cmd . ReleaseTemporaryRT ( ShaderIDs . WaveformSource ) ;
9398
9499 // Generate the waveform texture
0 commit comments