@@ -7,20 +7,15 @@ internal sealed class LogHistogram
77
88 // Don't forget to update 'ExposureHistogram.hlsl' if you change these values !
99 const int k_Bins = 128 ;
10- int m_ThreadX ;
11- int m_ThreadY ;
1210
1311 public ComputeBuffer data { get ; private set ; }
1412
1513 public void Generate ( PostProcessRenderContext context )
1614 {
1715 if ( data == null )
18- {
19- m_ThreadX = 16 ;
20- m_ThreadY = RuntimeUtilities . isAndroidOpenGL ? 8 : 16 ;
2116 data = new ComputeBuffer ( k_Bins , sizeof ( uint ) ) ;
22- }
23-
17+
18+ uint threadX , threadY , threadZ ;
2419 var scaleOffsetRes = GetHistogramScaleOffsetRes ( context ) ;
2520 var compute = context . resources . computeShaders . exposureHistogram ;
2621 var cmd = context . command ;
@@ -29,16 +24,19 @@ public void Generate(PostProcessRenderContext context)
2924 // Clear the buffer on every frame as we use it to accumulate luminance values on each frame
3025 int kernel = compute . FindKernel ( "KEyeHistogramClear" ) ;
3126 cmd . SetComputeBufferParam ( compute , kernel , "_HistogramBuffer" , data ) ;
32- cmd . DispatchCompute ( compute , kernel , Mathf . CeilToInt ( k_Bins / ( float ) m_ThreadX ) , 1 , 1 ) ;
27+ compute . GetKernelThreadGroupSizes ( kernel , out threadX , out threadY , out threadZ ) ;
28+ cmd . DispatchCompute ( compute , kernel , Mathf . CeilToInt ( k_Bins / ( float ) threadX ) , 1 , 1 ) ;
3329
3430 // Get a log histogram
3531 kernel = compute . FindKernel ( "KEyeHistogram" ) ;
3632 cmd . SetComputeBufferParam ( compute , kernel , "_HistogramBuffer" , data ) ;
3733 cmd . SetComputeTextureParam ( compute , kernel , "_Source" , context . source ) ;
3834 cmd . SetComputeVectorParam ( compute , "_ScaleOffsetRes" , scaleOffsetRes ) ;
35+
36+ compute . GetKernelThreadGroupSizes ( kernel , out threadX , out threadY , out threadZ ) ;
3937 cmd . DispatchCompute ( compute , kernel ,
40- Mathf . CeilToInt ( scaleOffsetRes . z / 2f / m_ThreadX ) ,
41- Mathf . CeilToInt ( scaleOffsetRes . w / 2f / m_ThreadY ) ,
38+ Mathf . CeilToInt ( scaleOffsetRes . z / 2f / threadX ) ,
39+ Mathf . CeilToInt ( scaleOffsetRes . w / 2f / threadY ) ,
4240 1
4341 ) ;
4442
0 commit comments