I recently started testing my project in URP and would like to try and use async compute to calculate some effects while shadows are rendering. I use RenderPipelineManager.beginFrameRendering to set up a command buffer, finishing it with CreateAsyncGraphicsFence and calling ExecuteCommandBufferAsync on the ScriptableRenderContext. However, I cannot find where to tell the renderer to wait for my graphics fence. Is this possible, or do I need a completely custom SRP to do this?
You can inject a render pass after shadows and call [WaitOnGPUFence](https://docs.unity3d.com/2018.3/Documentation/ScriptReference/Rendering.CommandBuffer.WaitOnGPUFence.html).
On top of my head something like this:
Create a Renderer Feature. There’s a template available in Asset → Create → Render Pipeline → Universal Render Pipelien → Renderer Feature
Change the render pass event to RenderPassEvent.AfterRenderingShadows
In the Execute method of your render pass:
3.1) Call ScriptableRenderContext.Submit(). This will submit the work for all render passes before this one to GPU.
3.2) Call WaitOnGPUFence, execute your work. Possibly call Submit again if you want this work to be schedule right away in GPU.
The render pipeline currently only calls context.Submit at the end of each camera. We are looking at calling this by default after shadows to get better work schedule but we need to test some corner cases in VR still.
Thank you for the info! Render passes seem like a great feature. I’m having some trouble getting it to run on my machine though. From my understanding async compute requires DX12. My GPU should support this but I cannot get the editor to run with it enabled. Am I correct in assuming async compute is a feature not widely supported on desktop platforms yet?
I have my script setup to do this, but SystemInfo.supportsAsyncCompute returns false so I figured it isn’t even possible (hence my question regarding DX12).
Running the code anyway gives me an exception saying the command buffer is not properly configured.