@@ -45,8 +45,8 @@ internal override void Render(PostProcessRenderContext context)
4545 cmd . BeginSample ( "Waveform" ) ;
4646
4747 var parameters = new Vector4 (
48- context . width / 2 ,
49- context . height / 2 ,
48+ width ,
49+ height ,
5050 RuntimeUtilities . isLinearColorSpace ? 1 : 0 ,
5151 0f
5252 ) ;
@@ -55,15 +55,21 @@ internal override void Render(PostProcessRenderContext context)
5555 int kernel = compute . FindKernel ( "KWaveformClear" ) ;
5656 cmd . SetComputeBufferParam ( compute , kernel , "_WaveformBuffer" , m_Data ) ;
5757 cmd . SetComputeVectorParam ( compute , "_Params" , parameters ) ;
58- cmd . SetComputeVectorParam ( compute , "_BufferParams" , new Vector4 ( width , height , 0f , 0f ) ) ;
5958 cmd . DispatchCompute ( compute , kernel , Mathf . CeilToInt ( width / 16f ) , Mathf . CeilToInt ( height / 16f ) , 1 ) ;
6059
60+ // For performance reasons, especially on consoles, we'll just downscale the source
61+ // again to reduce VMEM stalls. Eventually the whole algorithm needs to be rewritten as
62+ // it's currently pretty naive.
63+ cmd . GetTemporaryRT ( ShaderIDs . WaveformSource , width , height , 0 , FilterMode . Bilinear , context . sourceFormat ) ;
64+ cmd . BlitFullscreenTriangle ( ShaderIDs . HalfResFinalCopy , ShaderIDs . WaveformSource ) ;
65+
6166 // Gather all pixels and fill in our waveform
6267 kernel = compute . FindKernel ( "KWaveformGather" ) ;
6368 cmd . SetComputeBufferParam ( compute , kernel , "_WaveformBuffer" , m_Data ) ;
64- cmd . SetComputeTextureParam ( compute , kernel , "_Source" , ShaderIDs . HalfResFinalCopy ) ;
69+ cmd . SetComputeTextureParam ( compute , kernel , "_Source" , ShaderIDs . WaveformSource ) ;
6570 cmd . SetComputeVectorParam ( compute , "_Params" , parameters ) ;
66- cmd . DispatchCompute ( compute , kernel , Mathf . CeilToInt ( context . width / 2f ) , Mathf . CeilToInt ( context . width / 2f / 256f ) , 1 ) ;
71+ cmd . DispatchCompute ( compute , kernel , width , Mathf . CeilToInt ( height / 256f ) , 1 ) ;
72+ cmd . ReleaseTemporaryRT ( ShaderIDs . WaveformSource ) ;
6773
6874 // Generate the waveform texture
6975 var sheet = context . propertySheets . Get ( context . resources . shaders . waveform ) ;
0 commit comments