Here is a screenshot of the CustomPassVolume and the injection point is After Post Process.
Unfortunately, I’m pretty much only familiar with Builtin and URP so the workflow is pretty different than what I’m used to.
The ImGuiHDRPRenderPass is pretty simple because all I need it to do is execute a command buffer. Here is a link to the gist: ImGuiHDRPRenderPass.cs · GitHub
There is some setup done to the Command Buffer initially and the general idea is that
Setup the ViewProjectionMatrix to be orthographic (effectively full screen)
Setup the draw command to draw a mesh
The ImGuiHDRPRenderPass executes the command buffer at the injection point.
While this works well with URP and Builtin - I’m struggling to get this working nicely in HDRP 14.0.5 and Unity 2022.2.4
In your code, I can see that you’re caching the first command buffer received in the Setup() function. in HDRP it’s not guaranteed that you’ll have the same command buffer for each frame, that’s why it’s best to use the command buffer in CustomPassContext (in the Execute function).
Also since HDRP also uses the command buffer execution, the custom pass evaluation happens before the graphics commands are pushed to the GPU. This means that when you do renderContext.ExecuteCommandBuffer (which is instant) your command buffer actually ends up before the HDRP one. To make sure your commands are included at the correct place in HDRP you have two choices:
Append all your commands to the command buffer in the CustomPassContext.
call the ExecuteCommandBuffer on the HDRP command buffer to flush commands on the device.
I can also see that you’re caching the ScriptableRenderContext, I’m not sure what are the implications of this but I’d say it’s safer to use the one in CustomPassContext