Hi, guys
I’d like to intercept and copy depth buffer in the middle of prepass. (DepthRendering.cpp)
More precisely, a result of static mesh draw before dynamic mesh draw in prepass.
In Directx12 FDeferredShadingSceneRenderer::RenderPrePassViewParallel() is default path and it generate multiple CommandList and put them in a FPrePassParallelCommandListSet
Putting CopyTexture in the middle of the RenderPrePassViewParallel copies the depth before finishing prepass.
bool FDeferredShadingSceneRenderer::RenderPrePassViewParallel(const FViewInfo& View, FRHICommandListImmediate& ParentCmdList, TFunctionRef AfterTasksAreStarted, bool bDoPrePre)
{
bool bDepthWasCleared = false;
{
FPrePassParallelCommandListSet ParallelCommandListSet(View, this, ParentCmdList,
CVarRHICmdPrePassDeferredContexts.GetValueOnRenderThread() > 0,
CVarRHICmdFlushRenderThreadTasksPrePass.GetValueOnRenderThread() == 0 && CVarRHICmdFlushRenderThreadTasks.GetValueOnRenderThread() == 0);
if (!View.IsInstancedStereoPass())
{
// Draw the static occluder primitives using a depth drawing policy.
// Draw opaque occluders which support a separate position-only
// vertex buffer to minimize vertex fetch bandwidth, which is
// often the bottleneck during the depth only pass.
Scene->PositionOnlyDepthDrawList.DrawVisibleParallel(View.StaticMeshOccluderMap, View.StaticMeshBatchVisibility, ParallelCommandListSet);
// Draw opaque occluders, using double speed z where supported.
Scene->DepthDrawList.DrawVisibleParallel(View.StaticMeshOccluderMap, View.StaticMeshBatchVisibility, ParallelCommandListSet);
// Draw opaque occluders with masked materials
if (EarlyZPassMode >= DDM_AllOccluders)
{
Scene->MaskedDepthDrawList.DrawVisibleParallel(View.StaticMeshOccluderMap, View.StaticMeshBatchVisibility, ParallelCommandListSet);
}
}
else
{
const StereoPair StereoView(Views[0], Views[1], Views[0].StaticMeshOccluderMap, Views[1].StaticMeshOccluderMap, Views[0].StaticMeshBatchVisibility, Views[1].StaticMeshBatchVisibility);
Scene->PositionOnlyDepthDrawList.DrawVisibleParallelInstancedStereo(StereoView, ParallelCommandListSet);
Scene->DepthDrawList.DrawVisibleParallelInstancedStereo(StereoView, ParallelCommandListSet);
if (EarlyZPassMode >= DDM_AllOccluders)
{
Scene->MaskedDepthDrawList.DrawVisibleParallelInstancedStereo(StereoView, ParallelCommandListSet);
}
}
//copy depth buffer after static pre-pass
ParentCmdList.CopyTexture(
SceneContext.GetSceneDepthTexture(),
SceneContext.GetDestinationSceneDepthTexture(),
FResolveParams() );
if (!GStartPrepassParallelTranslatesImmediately)
{
// we do this step here (awkwardly) so that the above tasks can be in flight while we get the particles (which must be dynamic) setup.
if (bDoPrePre)
{
AfterTasksAreStarted();
bDepthWasCleared = PreRenderPrePass(ParentCmdList);
}
// Dynamic
FRHICommandList* CmdList = ParallelCommandListSet.NewParallelCommandList();
FGraphEventRef AnyThreadCompletionEvent = TGraphTask::CreateTask(ParallelCommandListSet.GetPrereqs(), ENamedThreads::GetRenderThread())
.ConstructAndDispatchWhenReady(*this, *CmdList, View, ParallelCommandListSet.DrawRenderState);
ParallelCommandListSet.AddParallelCommandList(CmdList, AnyThreadCompletionEvent);
}
else
{
if (bDoPrePre)
{
bDepthWasCleared = PreRenderPrePass(ParentCmdList);
}
}
}
is there any way to execute the command list (set) explicitly to get the prepass done at certain point?
I tried ParallelCommandListSet.WaitForTasks() but didn’t work
Best