@@ -18,8 +18,20 @@ public enum Channel
1818 public Channel channel = Channel . Master ;
1919
2020 ComputeBuffer m_Data ;
21- const int k_Bins = 256 ;
22- const int k_ThreadGroupSize = 16 ;
21+ private int numBins ;
22+ private int threadGroupSizeX ;
23+ private int threadGroupSizeY ;
24+
25+ internal override void OnEnable ( )
26+ {
27+ base . OnEnable ( ) ;
28+
29+ bool isAndroidOpenGL = Application . platform == RuntimePlatform . Android && SystemInfo . graphicsDeviceType != GraphicsDeviceType . Vulkan ;
30+
31+ numBins = isAndroidOpenGL ? 128 : 256 ;
32+ threadGroupSizeX = isAndroidOpenGL ? 16 : 16 ;
33+ threadGroupSizeY = isAndroidOpenGL ? 8 : 16 ;
34+ }
2335
2436 internal override void OnDisable ( )
2537 {
@@ -41,7 +53,7 @@ internal override void Render(PostProcessRenderContext context)
4153 CheckOutput ( width , height ) ;
4254
4355 if ( m_Data == null )
44- m_Data = new ComputeBuffer ( k_Bins , sizeof ( uint ) ) ;
56+ m_Data = new ComputeBuffer ( numBins , sizeof ( uint ) ) ;
4557
4658 var compute = context . resources . computeShaders . gammaHistogram ;
4759 var cmd = context . command ;
@@ -50,7 +62,7 @@ internal override void Render(PostProcessRenderContext context)
5062 // Clear the buffer on every frame as we use it to accumulate values on every frame
5163 int kernel = compute . FindKernel ( "KHistogramClear" ) ;
5264 cmd . SetComputeBufferParam ( compute , kernel , "_HistogramBuffer" , m_Data ) ;
53- cmd . DispatchCompute ( compute , kernel , Mathf . CeilToInt ( k_Bins / ( float ) k_ThreadGroupSize ) , 1 , 1 ) ;
65+ cmd . DispatchCompute ( compute , kernel , Mathf . CeilToInt ( numBins / ( float ) threadGroupSizeX ) , 1 , 1 ) ;
5466
5567 // Gather all pixels and fill in our histogram
5668 kernel = compute . FindKernel ( "KHistogramGather" ) ;
@@ -65,8 +77,8 @@ internal override void Render(PostProcessRenderContext context)
6577 cmd . SetComputeTextureParam ( compute , kernel , "_Source" , ShaderIDs . HalfResFinalCopy ) ;
6678 cmd . SetComputeBufferParam ( compute , kernel , "_HistogramBuffer" , m_Data ) ;
6779 cmd . DispatchCompute ( compute , kernel ,
68- Mathf . CeilToInt ( parameters . x / k_ThreadGroupSize ) ,
69- Mathf . CeilToInt ( parameters . y / k_ThreadGroupSize ) ,
80+ Mathf . CeilToInt ( parameters . x / threadGroupSizeX ) ,
81+ Mathf . CeilToInt ( parameters . y / threadGroupSizeY ) ,
7082 1
7183 ) ;
7284
0 commit comments