diff --git a/Source/Engine/Renderer/MotionBlurPass.cpp b/Source/Engine/Renderer/MotionBlurPass.cpp index 850933f05..168d35e73 100644 --- a/Source/Engine/Renderer/MotionBlurPass.cpp +++ b/Source/Engine/Renderer/MotionBlurPass.cpp @@ -213,7 +213,7 @@ void MotionBlurPass::RenderMotionVectors(RenderContext& renderContext) // Render camera motion vectors (background) if (!data.TemporalAAJitter.IsZero() || data.CurrentVP != data.PreviousVP) { - PROFILE_GPU_CPU("Camera Motion Vectors"); + PROFILE_GPU("Camera Motion Vectors"); context->SetRenderTarget(motionVectors->View()); context->SetState(_psCameraMotionVectors); context->DrawFullscreenTriangle(); @@ -229,7 +229,6 @@ void MotionBlurPass::RenderMotionVectors(RenderContext& renderContext) context->SetRenderTarget(depthBuffer->View(), motionVectors->View()); renderContext.View.Pass = DrawPass::MotionVectors; // TODO: maybe update material PerFrame data because render viewport can be other size than ScreenSize from render buffers - renderContext.List->SortDrawCalls(renderContext, false, DrawCallsListType::MotionVectors); renderContext.List->ExecuteDrawCalls(renderContext, DrawCallsListType::MotionVectors); // Cleanup diff --git a/Source/Engine/Renderer/Renderer.cpp b/Source/Engine/Renderer/Renderer.cpp index ff66ec32a..710312ab6 100644 --- a/Source/Engine/Renderer/Renderer.cpp +++ b/Source/Engine/Renderer/Renderer.cpp @@ -323,11 +323,12 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont // Build batch of render contexts (main view and shadow projections) const bool isGBufferDebug = GBufferPass::IsDebugView(renderContext.View.Mode); + const bool needMotionVectors = Renderer::NeedMotionVectors(renderContext); { PROFILE_CPU_NAMED("Collect Draw Calls"); view.Pass = DrawPass::GBuffer | DrawPass::Forward | DrawPass::Distortion; - if (Renderer::NeedMotionVectors(renderContext)) + if (needMotionVectors) view.Pass |= DrawPass::MotionVectors; renderContextBatch.GetMainContext() = renderContext; // Sync render context in batch with the current value @@ -369,6 +370,8 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont renderContext.List->SortDrawCalls(renderContext, false, DrawCallsListType::GBufferNoDecals); renderContext.List->SortDrawCalls(renderContext, true, DrawCallsListType::Forward); renderContext.List->SortDrawCalls(renderContext, false, DrawCallsListType::Distortion); + if (needMotionVectors) + renderContext.List->SortDrawCalls(renderContext, false, DrawCallsListType::MotionVectors); for (int32 i = 1; i < renderContextBatch.Contexts.Count(); i++) { auto& shadowContext = renderContextBatch.Contexts[i];