Files
UnrealEngineUWP/Engine/Source/Runtime/RenderCore/Private/RenderCaptureInterface.cpp
Marc Audy 0cbbc781ca Merge UE5/Release-Engine-Staging @ 15740152 to UE5/Main
This represents UE4/Main @ 15709114

[CL 15740605 by Marc Audy in ue5-main branch]
2021-03-18 15:20:03 -04:00

82 lines
2.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "RenderCaptureInterface.h"
#include "IRenderCaptureProvider.h"
#include "RenderingThread.h"
#include "RHI.h"
namespace RenderCaptureInterface
{
FScopedCapture::FScopedCapture(bool bEnable, TCHAR const* InEventName, TCHAR const* InFileName)
: bCapture(bEnable && IRenderCaptureProvider::IsAvailable())
, bEvent(false)
, RHICommandList(nullptr)
{
check(!GIsThreadedRendering || !IsInRenderingThread());
if (bCapture)
{
ENQUEUE_RENDER_COMMAND(BeginCaptureCommand)([this, EventName = FString(InEventName), FileName = FString(InFileName)](FRHICommandListImmediate& RHICommandListLocal)
{
IRenderCaptureProvider::Get().BeginCapture(&RHICommandListLocal, IRenderCaptureProvider::ECaptureFlags_Launch, FileName);
if (!EventName.IsEmpty())
{
RHICommandListLocal.PushEvent(*EventName, FColor::White);
bEvent = true;
}
});
}
}
FScopedCapture::FScopedCapture(bool bEnable, FRHICommandListImmediate* InRHICommandList, TCHAR const* InEventName, TCHAR const* InFileName)
: bCapture(bEnable && IRenderCaptureProvider::IsAvailable())
, RHICommandList(InRHICommandList)
{
check(!GIsThreadedRendering || IsInRenderingThread());
if (bCapture)
{
IRenderCaptureProvider::Get().BeginCapture(RHICommandList, IRenderCaptureProvider::ECaptureFlags_Launch, FString(InFileName));
if (InEventName != nullptr)
{
RHICommandList->PushEvent(InEventName, FColor::White);
bEvent = true;
}
}
}
FScopedCapture::~FScopedCapture()
{
if (bCapture)
{
if (RHICommandList != nullptr)
{
check(!GIsThreadedRendering || IsInRenderingThread());
if (bEvent)
{
RHICommandList->PopEvent();
}
IRenderCaptureProvider::Get().EndCapture(RHICommandList);
}
else
{
check(!GIsThreadedRendering || !IsInRenderingThread());
ENQUEUE_RENDER_COMMAND(EndCaptureCommand)([bPopEvent = bEvent](FRHICommandListImmediate& RHICommandListLocal)
{
if (bPopEvent)
{
RHICommandListLocal.PopEvent();
}
IRenderCaptureProvider::Get().EndCapture(&RHICommandListLocal);
});
}
}
}
}