You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
This represents UE4/Main up to CL# 14958402 [CL 15028197 by Marc Audy in ue5-main branch]
107 lines
2.3 KiB
C++
107 lines
2.3 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "RenderCaptureInterface.h"
|
|
#include "RenderingThread.h"
|
|
|
|
namespace RenderCaptureInterface
|
|
{
|
|
static FOnFrameCaptureDelegate GFrameCaptureDelegates;
|
|
static FOnBeginCaptureDelegate GBeginDelegates;
|
|
static FOnEndCaptureDelegate GEndDelegates;
|
|
|
|
void RegisterCallbacks(FOnFrameCaptureDelegate InFrameCaptureDelegate)
|
|
{
|
|
check(!GFrameCaptureDelegates.IsBound());
|
|
GFrameCaptureDelegates = InFrameCaptureDelegate;
|
|
}
|
|
|
|
void RegisterCallbacks(FOnBeginCaptureDelegate InBeginDelegate, FOnEndCaptureDelegate InEndDelegate)
|
|
{
|
|
check(!GBeginDelegates.IsBound());
|
|
GBeginDelegates = InBeginDelegate;
|
|
check(!GEndDelegates.IsBound());
|
|
GEndDelegates = InEndDelegate;
|
|
}
|
|
|
|
void UnregisterCallbacks()
|
|
{
|
|
GFrameCaptureDelegates.Unbind();
|
|
GBeginDelegates.Unbind();
|
|
GEndDelegates.Unbind();
|
|
}
|
|
|
|
|
|
void FrameCapture()
|
|
{
|
|
if (GFrameCaptureDelegates.IsBound())
|
|
{
|
|
GFrameCaptureDelegates.Execute();
|
|
}
|
|
}
|
|
|
|
void BeginCapture(FRHICommandListImmediate* RHICommandList, TCHAR const* Name)
|
|
{
|
|
if (GBeginDelegates.IsBound())
|
|
{
|
|
GBeginDelegates.Execute(RHICommandList, Name);
|
|
}
|
|
}
|
|
|
|
void EndCapture(FRHICommandListImmediate* RHICommandList)
|
|
{
|
|
if (GEndDelegates.IsBound())
|
|
{
|
|
GEndDelegates.Execute(RHICommandList);
|
|
}
|
|
}
|
|
|
|
FScopedCapture::FScopedCapture(bool bEnable, TCHAR const* Name)
|
|
: bCapture(bEnable)
|
|
, RHICmdList(nullptr)
|
|
{
|
|
check(!GUseThreadedRendering || !IsInRenderingThread());
|
|
|
|
if (bCapture)
|
|
{
|
|
ENQUEUE_RENDER_COMMAND(CaptureCommand)([Name](FRHICommandListImmediate& RHICommandListLocal)
|
|
{
|
|
BeginCapture(&RHICommandListLocal, Name);
|
|
});
|
|
}
|
|
}
|
|
|
|
FScopedCapture::FScopedCapture(bool bEnable, FRHICommandListImmediate* RHICommandList, TCHAR const* Name)
|
|
: bCapture(bEnable)
|
|
, RHICmdList(RHICommandList)
|
|
{
|
|
check(!GUseThreadedRendering || IsInRenderingThread());
|
|
|
|
if (bCapture)
|
|
{
|
|
BeginCapture(RHICmdList, Name);
|
|
}
|
|
}
|
|
|
|
FScopedCapture::~FScopedCapture()
|
|
{
|
|
if (bCapture)
|
|
{
|
|
if (RHICmdList != nullptr)
|
|
{
|
|
check(!GUseThreadedRendering || IsInRenderingThread());
|
|
|
|
EndCapture(RHICmdList);
|
|
}
|
|
else
|
|
{
|
|
check(!GUseThreadedRendering || !IsInRenderingThread());
|
|
|
|
ENQUEUE_RENDER_COMMAND(CaptureCommand)([](FRHICommandListImmediate& RHICommandListLocal)
|
|
{
|
|
EndCapture(&RHICommandListLocal);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|