ComputeShader: read and write into the same RenderTexture.

I compute PerlinNoise into RenderTexture via ComputeShader and then I need to apply a filter(also CompueShader) on this RenderTexture.
But if I read from my texture and write to the same, shader is reading only zero values.

I use this way:
public void Dispatch(RenderTexture texture) {
var tmpSource = RenderTexture.GetTemporary( texture.width, texture.height, 0, texture.format );
Graphics.Blit( texture, tmpSource );
shader.SetTexture( 0, “_Texture”, tmpSource );
shader.SetTexture( 0, “_Result”, texture );
shader.Dispatch(0, texture.width/32, texture.height/32, 1);
RenderTexture.ReleaseTemporary( tmpSource );
}
But if I call this method in EventType.MouseDrag and EventType.ScrollWheel events (two times for frame), I get problem that FilterShader is also getting empty RenderTexture. I think it is due to the combination Graphics.Blit and Dispatch. Maybe Dispatch is invoked before Graphics.Blit was completed.
How I can do it correctly?

Your dispatch function looks correct. The method of coping the render texture is the right why to do it.

You do however need to enable random writes on the texture before the compute shader dispatch call.

public void Dispatch(RenderTexture texture)
{
var tmpSource = RenderTexture.GetTemporary( texture.width, texture.height, 0, texture.format );
Graphics.Blit( texture, tmpSource );

texture.enableRandomWrite = true;

shader.SetTexture( 0, "_Texture", tmpSource );
shader.SetTexture( 0, "_Result", texture );
shader.Dispatch(0, texture.width/32, texture.height/32, 1);
RenderTexture.ReleaseTemporary( tmpSource );

}

Of course I enable enableRandomWrite that compute PerlinNoise. Only it should be done before texture.Create.
You can see video with my problem

And I attached this project. See CurveFilter class.

1902509–122704–DX11 PerlinNoise2D.unitypackage (22 KB)