You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#ttp 306334 - ROCKET: TASK: PUNTABLE: Stats: FN: Make diagnostic stats discoverable and available in the UI (don't require console to toggle) #branch UE4 #change DECLARE_STATS_GROUP û Added additional param GroupCategory, for subfolder use in the UI. Fixedup all Stats Group usage so the category is now propagated through where it needs to be. Currently all Group stats have the Category æAdvancedÆ, and all engine stats have the Category æSimpleÆ û this is just to differentiate them for now, better categories will come along in future. Modified FindOrAddMetaData as it now broadcasts a delegate (via a TaskGraph) whenever a new stat meta data is added û this was needed as not all the stat groups are æregisteredÆ when the level viewports are created (they are drip loaded), so the viewports need to listen for any additions thereafter... GroupDescription is displayed as a tooltip in the UI for the stat entry and we may want to localize these. RenderStats & RenderGroupedWithHierarchy: Modified so that it now takes the viewport that it should render to as a param (which is also used to determine if each stat should be visible). Removed StatsEnabled delegate in favour of StatCheckEnabled, StatEnabled, StatDisabled, StatDisableAll for more finite usage and feedback when toggling them. Modified FHUDGroupManager HandleCommand It now uses the new delegates to work out whether it needs to enable or disable for the current viewport, so itÆs more involved than a simple toggle, itÆs more ôis the stat enabled for the current viewport, and is it enabled for any viewportö delegate querying so it can react accordingly. Added struct FSimpleStatFuncs: Which contains info on each æSimple StatÆ such as; name, category, description, renderfunc, togglefunc and the side of the viewport it should be rendered to ExecSimpleStat û Calls Exec for a registered Simple Stat, ensuring the correct viewport is set IsSimpleStat û Checks to see if a stat is a registered Simple Stat or not SetSimpleStat û Sets the state of a specified Simple Stats SetSimpleStats - Sets the state of the specified Simple Stats RenderSimpleStats û Renders the Simple Stats if they are enabled, and have Render functions assigned. Each Exec function had the code it executes which itÆs toggled and rendered into functions Added FStatUnitData & FStatHitchesData: Moved all the globals/static variables used when enabling Stat Unit/Hitches into a struct as itÆs now used by multiple viewports and they needed their own copies. Also moved their draw functions here too. FSceneViewport: SwapStatCommands û Exchanges the enabled stats between two viewports, this is so when PIEing the stats which were enabled on the Level Viewport (if playing in active viewport only) get transposed to the Game Viewport, and then restored when PIE ends. SEditorViewport: ToggleStatCommand û Called when a stat is enabled/disabled from the UI IsStatCommandVisible û Checks to see if a stat command should appear as visible in the UI SEditorViewportViewMenu: GenerateViewMenuContent û Made protected and virtual so it could be called externally. FLevelViewportCommands: Added the code needed to generate commands for each of the Stat menu entries, however because not all stats are registered when this happens, it also creates some delegates to listen out for others that are registered later Destructor û Needed to reset delegates HandleNewGroupStat û Creates the new group stat commands HandleNewStat û Creates the new stat command FindStatIndex û Looks for where a stat should be inserted in the menu in order to maintain alphabetical order SLevelViewport: Modified the code so that the states of all the SimpleStats are saved so they can be restored next time the editor is ran (previously just handled FPS). OnFloatingButtonClicked û Called whenever any of the level viewports floating buttons are clicked in order to correctly set the ælastÆ viewport global OnToggleAllStatCommands û Called when the user selects æHide AllÆ from the viewport. ToggleStatCommand û Called when the user selects any other stat option from the viewport. BindStatCommand û Used to bind the menu action to the command name (used by delegate) Added SLevelEditorViewportViewMenu (extends SEditorViewportViewMenu), and overrode GenerateViewMenuContent so that OnFloatingButtonClicked can be called whenever the menu is clicked on. This is also called during GenerateOptionsMenu, GenerateCameraMenu, GenerateShowMenu & OnToggleMaximize Added global ptr GStatProcessingViewportClient (sim to Current, Last) used to keep track of which viewport the stat should be applied too (only valid within the scope of the Exec call). FViewportClient: Moved global ESoundShowFlags enum list into this class. FCommonViewportClient: Destructor û Needed to reset GStatProcessingViewportClient FLevelEditorViewportClient SetCurrentViewport û moved code responsible for setting the global æcurrentÆ viewport ptr into a func SetLastKeyViewport û moved the code responsible for settings the global ælastÆ viewport ptr into a func UGameViewportClient: Destructor û Needed to cleanup delegate usage. FViewportClient & FLevelEditorViewportClient & UGameViewportClient* GetStatUnitData û The viewports copy of the variables needed when running the Stat Unit Exec GetStatHitchesData û The viewports copy of the variables needed when running the Stat Hitches Exec GetEnabledStats û Gets a list of all the stats which are enabled for the viewport SetEnabledStats û Sets a list of all the stats which should be enabled for the viewport IsStatEnabled û Checks to see if a specific stat is enabled for the viewport SetStatEnabled û Sets a specifics stats state to enabled or disabled GetSoundShowFlags û Gets which flags are enabled for the Stat Sounds Exec SetSoundShowFlags û Sets which flags are enabled for the Stat Sounds Exec HandleViewportStatCheckEnabled (delegate) û checks to see if a specific stat is enabled on this viewport HandleViewportStatEnabled (delegate) û enables a specific stat for the viewport HandleViewportStatDisabled (delegate) û disables a specific stat for the viewport HandleViewportStatDisableAll (delegate) û disables all stats for the viewport *FViewportClient has dummy virtual funcs and LevelEditor/Game both have the same implementations, the only differences is the GameViewports member variables are static so that the stat info persists between runs. FLevelEditorViewportInstanceSettings deprecated bShowFPS in favour of an EnabledStats array (so we can track the state of all stats, not just FPS). Added new config var bSaveSimpleStats: if enabled, restores previously enabled level viewport simple stats the next time the editor runs (defaults to false). Modified FillShowFlagMenu so that thereÆs just one func and you specify where (if any) youÆd like a separator to occur. Added FillShowStatsSubMenus so that menus can be generated which have submenus Added the Stats sub menu to the View menu Modified Execs so that the GStatProcessingViewportClient is set to the correct default viewport (if it wasnÆt specified), and clears again after itÆs been processed HandleStatCommand now takes World and ViewportClient as params too û needed when Execs enabled other Execs so the world/viewport persists. SetAverageUnitTimes û Added as a Setter func for GetAverageUnitTimes (moved code out of Stat Unit renderer and modified so that it only updates once per frame). Stripped out all unneeded globals [CL 2058522 by Andrew Brown in Main branch]
460 lines
20 KiB
C++
460 lines
20 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
RenderingThread.h: Rendering thread definitions.
|
|
=============================================================================*/
|
|
|
|
#ifndef __RenderingThread_H__
|
|
#define __RenderingThread_H__
|
|
|
|
#include "RenderCore.h"
|
|
#include "TaskGraphInterfaces.h"
|
|
|
|
////////////////////////////////////
|
|
// Render thread API
|
|
////////////////////////////////////
|
|
|
|
/** @return True if called from the rendering thread, or if called from ANY thread during single threaded rendering */
|
|
extern RENDERCORE_API bool IsInRenderingThread();
|
|
|
|
/** @return True if called from the rendering thread. */
|
|
// Unlike IsInRenderingThread, this will always return false if we are running single threaded. It only returns true if this is actually a separate rendering thread. Mostly useful for checks
|
|
extern RENDERCORE_API bool IsInActualRenderingThread();
|
|
|
|
/** Thread used for rendering */
|
|
extern RENDERCORE_API FRunnableThread* GRenderingThread;
|
|
|
|
/**
|
|
* Whether the renderer is currently running in a separate thread.
|
|
* If this is false, then all rendering commands will be executed immediately instead of being enqueued in the rendering command buffer.
|
|
*/
|
|
extern RENDERCORE_API bool GIsThreadedRendering;
|
|
|
|
/**
|
|
* Whether the rendering thread should be created or not.
|
|
* Currently set by command line parameter and by the ToggleRenderingThread console command.
|
|
*/
|
|
extern RENDERCORE_API bool GUseThreadedRendering;
|
|
|
|
#if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
static FORCEINLINE void CheckNotBlockedOnRenderThread() {}
|
|
#else // #if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
/** Whether the main thread is currently blocked on the rendering thread, e.g. a call to FlushRenderingCommands. */
|
|
extern RENDERCORE_API bool GMainThreadBlockedOnRenderThread;
|
|
|
|
/** Asserts if called from the main thread when the main thread is blocked on the rendering thread. */
|
|
static FORCEINLINE void CheckNotBlockedOnRenderThread() { ensure(!GMainThreadBlockedOnRenderThread || !IsInGameThread()); }
|
|
#endif // #if (UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
|
|
|
|
/** Starts the rendering thread. */
|
|
extern RENDERCORE_API void StartRenderingThread();
|
|
|
|
/** Stops the rendering thread. */
|
|
extern RENDERCORE_API void StopRenderingThread();
|
|
|
|
/**
|
|
* Checks if the rendering thread is healthy and running.
|
|
* If it has crashed, UE_LOG is called with the exception information.
|
|
*/
|
|
extern RENDERCORE_API void CheckRenderingThreadHealth();
|
|
|
|
/** Checks if the rendering thread is healthy and running, without crashing */
|
|
extern RENDERCORE_API bool IsRenderingThreadHealthy();
|
|
|
|
/** Advances stats for the rendering thread. */
|
|
extern RENDERCORE_API void RenderingThreadTick(int64 StatsFrame, int32 MasterDisableChangeTagStartFrame);
|
|
|
|
/**
|
|
* Adds a task that must be completed either before the next scene draw or a flush rendering commands
|
|
* This can be called from any thread though it probably doesn't make sense to call it from the render thread.
|
|
* @param TaskToAdd, task to add as a pending render thread task
|
|
*/
|
|
extern RENDERCORE_API void AddFrameRenderPrerequisite(const FGraphEventRef& TaskToAdd);
|
|
|
|
/**
|
|
* Gather the frame render prerequisites and make sure all render commands are at least queued
|
|
*/
|
|
extern RENDERCORE_API void AdvanceFrameRenderPrerequisite();
|
|
|
|
/**
|
|
* Waits for the rendering thread to finish executing all pending rendering commands. Should only be used from the game thread.
|
|
*/
|
|
extern RENDERCORE_API void FlushRenderingCommands();
|
|
|
|
|
|
////////////////////////////////////
|
|
// Render thread suspension
|
|
////////////////////////////////////
|
|
|
|
/**
|
|
* Encapsulates stopping and starting the renderthread so that other threads can manipulate graphics resources.
|
|
*/
|
|
class RENDERCORE_API FSuspendRenderingThread
|
|
{
|
|
public:
|
|
/**
|
|
* Constructor that flushes and suspends the renderthread
|
|
* @param bRecreateThread - Whether the rendering thread should be completely destroyed and recreated, or just suspended.
|
|
*/
|
|
FSuspendRenderingThread( bool bRecreateThread );
|
|
|
|
/** Destructor that starts the renderthread again */
|
|
~FSuspendRenderingThread();
|
|
|
|
private:
|
|
/** Whether we should use a rendering thread or not */
|
|
bool bUseRenderingThread;
|
|
|
|
/** Whether the rendering thread was currently running or not */
|
|
bool bWasRenderingThreadRunning;
|
|
|
|
/** Whether the rendering thread should be completely destroyed and recreated, or just suspended */
|
|
bool bRecreateThread;
|
|
};
|
|
|
|
/** Helper macro for safely flushing and suspending the rendering thread while manipulating graphics resources */
|
|
#define SCOPED_SUSPEND_RENDERING_THREAD(bRecreateThread) FSuspendRenderingThread SuspendRenderingThread(bRecreateThread)
|
|
|
|
////////////////////////////////////
|
|
// Render commands
|
|
////////////////////////////////////
|
|
|
|
#if UE_SERVER
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND(TypeName,Code)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND(TypeName,Code)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER(TypeName,ParamType1,ParamName1,ParamValue1,Code)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER_CREATE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamValue1)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER_DECLARE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamName1,ParamValue1,Code)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,Code)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER_CREATE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamValue1,ParamType2,ParamValue2)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER_DECLARE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,Code)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,Code)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER_CREATE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamValue1,ParamType2,ParamValue2,ParamType3,ParamValue3)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER_DECLARE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,Code)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,ParamType4,ParamName4,ParamValue4,Code)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER_CREATE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamValue1,ParamType2,ParamValue2,ParamType3,ParamValue3,ParamType4,ParamValue4)
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER_DECLARE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,ParamType4,ParamName4,ParamValue4,Code)
|
|
#else
|
|
|
|
/** The parent class of commands stored in the rendering command queue. */
|
|
class RENDERCORE_API FRenderCommand
|
|
{
|
|
public:
|
|
// All render commands run on the render thread
|
|
static ENamedThreads::Type GetDesiredThread()
|
|
{
|
|
return ENamedThreads::RenderThread;
|
|
}
|
|
|
|
static ESubsequentsMode::Type GetSubsequentsMode()
|
|
{
|
|
// Don't support tasks having dependencies on us, reduces task graph overhead tracking and dealing with subsequents
|
|
return ESubsequentsMode::FireAndForget;
|
|
}
|
|
};
|
|
|
|
//
|
|
// Macros for using render commands.
|
|
//
|
|
|
|
DECLARE_STATS_GROUP(TEXT("Render Thread Commands"), STATGROUP_RenderThreadCommands, STATCAT_Advanced);
|
|
|
|
#define TASK_FUNCTION(Code) \
|
|
void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent) \
|
|
{ \
|
|
Code; \
|
|
}
|
|
|
|
#define TASKNAME_FUNCTION(TypeName) \
|
|
FORCEINLINE TStatId GetStatId() const \
|
|
{ \
|
|
RETURN_QUICK_DECLARE_CYCLE_STAT(TypeName, STATGROUP_RenderThreadCommands); \
|
|
}
|
|
|
|
/**
|
|
* Declares a rendering command type with 0 parameters.
|
|
*/
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND(TypeName,Code) \
|
|
class EURCMacro_##TypeName : public FRenderCommand \
|
|
{ \
|
|
public: \
|
|
TASKNAME_FUNCTION(TypeName) \
|
|
TASK_FUNCTION(Code) \
|
|
}; \
|
|
{ \
|
|
if(GIsThreadedRendering || !IsInGameThread()) \
|
|
{ \
|
|
CheckNotBlockedOnRenderThread(); \
|
|
TGraphTask<EURCMacro_##TypeName>::CreateTask().ConstructAndDispatchWhenReady(); \
|
|
} \
|
|
else \
|
|
{ \
|
|
EURCMacro_##TypeName TempCommand; \
|
|
FScopeCycleCounter EURCMacro_Scope(TempCommand.GetStatId()); \
|
|
TempCommand.DoTask(ENamedThreads::GameThread, FGraphEventRef() ); \
|
|
} \
|
|
}
|
|
|
|
/**
|
|
* Declares a rendering command type with 1 parameters.
|
|
*/
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,Code) \
|
|
class EURCMacro_##TypeName : public FRenderCommand \
|
|
{ \
|
|
public: \
|
|
typedef ParamType1 _ParamType1; \
|
|
EURCMacro_##TypeName(const _ParamType1& In##ParamName1): \
|
|
ParamName1(In##ParamName1) \
|
|
{} \
|
|
TASK_FUNCTION(Code) \
|
|
TASKNAME_FUNCTION(TypeName) \
|
|
private: \
|
|
ParamType1 ParamName1; \
|
|
};
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER_CREATE(TypeName,ParamType1,ParamValue1) \
|
|
{ \
|
|
if(GIsThreadedRendering || !IsInGameThread()) \
|
|
{ \
|
|
CheckNotBlockedOnRenderThread(); \
|
|
TGraphTask<EURCMacro_##TypeName>::CreateTask().template ConstructAndDispatchWhenReady<ParamType1>(ParamValue1); \
|
|
} \
|
|
else \
|
|
{ \
|
|
EURCMacro_##TypeName TempCommand(ParamValue1); \
|
|
FScopeCycleCounter EURCMacro_Scope(TempCommand.GetStatId()); \
|
|
TempCommand.DoTask(ENamedThreads::GameThread, FGraphEventRef() ); \
|
|
} \
|
|
}
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER(TypeName,ParamType1,ParamName1,ParamValue1,Code) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,Code) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER_CREATE(TypeName,ParamType1,ParamValue1)
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER_DECLARE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamName1,ParamValue1,Code) \
|
|
template <typename TemplateParamName> \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,Code)
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER_CREATE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamValue1) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER_CREATE(TypeName<TemplateParamName>,ParamType1,ParamValue1)
|
|
|
|
/**
|
|
* Declares a rendering command type with 2 parameters.
|
|
*/
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,Code) \
|
|
class EURCMacro_##TypeName : public FRenderCommand \
|
|
{ \
|
|
public: \
|
|
typedef ParamType1 _ParamType1; \
|
|
typedef ParamType2 _ParamType2; \
|
|
EURCMacro_##TypeName(const _ParamType1& In##ParamName1,const _ParamType2& In##ParamName2): \
|
|
ParamName1(In##ParamName1), \
|
|
ParamName2(In##ParamName2) \
|
|
{} \
|
|
TASK_FUNCTION(Code) \
|
|
TASKNAME_FUNCTION(TypeName) \
|
|
private: \
|
|
ParamType1 ParamName1; \
|
|
ParamType2 ParamName2; \
|
|
};
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER_CREATE(TypeName,ParamType1,ParamValue1,ParamType2,ParamValue2) \
|
|
{ \
|
|
if(GIsThreadedRendering || !IsInGameThread()) \
|
|
{ \
|
|
CheckNotBlockedOnRenderThread(); \
|
|
TGraphTask<EURCMacro_##TypeName>::CreateTask().template ConstructAndDispatchWhenReady<ParamType1,ParamType2>(ParamValue1,ParamValue2); \
|
|
} \
|
|
else \
|
|
{ \
|
|
EURCMacro_##TypeName TempCommand(ParamValue1,ParamValue2); \
|
|
FScopeCycleCounter EURCMacro_Scope(TempCommand.GetStatId()); \
|
|
TempCommand.DoTask(ENamedThreads::GameThread, FGraphEventRef() ); \
|
|
} \
|
|
}
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,Code) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,Code) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER_CREATE(TypeName,ParamType1,ParamValue1,ParamType2,ParamValue2)
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER_DECLARE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,Code) \
|
|
template <typename TemplateParamName> \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,Code)
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER_CREATE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamValue1,ParamType2,ParamValue2) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER_CREATE(TypeName<TemplateParamName>,ParamType1,ParamValue1,ParamType2,ParamValue2)
|
|
|
|
/**
|
|
* Declares a rendering command type with 3 parameters.
|
|
*/
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,Code) \
|
|
class EURCMacro_##TypeName : public FRenderCommand \
|
|
{ \
|
|
public: \
|
|
typedef ParamType1 _ParamType1; \
|
|
typedef ParamType2 _ParamType2; \
|
|
typedef ParamType3 _ParamType3; \
|
|
EURCMacro_##TypeName(const _ParamType1& In##ParamName1,const _ParamType2& In##ParamName2,const _ParamType3& In##ParamName3): \
|
|
ParamName1(In##ParamName1), \
|
|
ParamName2(In##ParamName2), \
|
|
ParamName3(In##ParamName3) \
|
|
{} \
|
|
TASK_FUNCTION(Code) \
|
|
TASKNAME_FUNCTION(TypeName) \
|
|
private: \
|
|
ParamType1 ParamName1; \
|
|
ParamType2 ParamName2; \
|
|
ParamType3 ParamName3; \
|
|
};
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER_CREATE(TypeName,ParamType1,ParamValue1,ParamType2,ParamValue2,ParamType3,ParamValue3) \
|
|
{ \
|
|
if(GIsThreadedRendering || !IsInGameThread()) \
|
|
{ \
|
|
CheckNotBlockedOnRenderThread(); \
|
|
TGraphTask<EURCMacro_##TypeName>::CreateTask().template ConstructAndDispatchWhenReady<ParamType1,ParamType2,ParamType3>(ParamValue1,ParamValue2,ParamValue3); \
|
|
} \
|
|
else \
|
|
{ \
|
|
EURCMacro_##TypeName TempCommand(ParamValue1,ParamValue2,ParamValue3); \
|
|
FScopeCycleCounter EURCMacro_Scope(TempCommand.GetStatId()); \
|
|
TempCommand.DoTask(ENamedThreads::GameThread, FGraphEventRef() ); \
|
|
} \
|
|
}
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,Code) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,Code) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER_CREATE(TypeName,ParamType1,ParamValue1,ParamType2,ParamValue2,ParamType3,ParamValue3)
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER_DECLARE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,Code) \
|
|
template <typename TemplateParamName> \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,Code)
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER_CREATE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamValue1,ParamType2,ParamValue2,ParamType3,ParamValue3) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER_CREATE(TypeName<TemplateParamName>,ParamType1,ParamValue1,ParamType2,ParamValue2,ParamType3,ParamValue3)
|
|
|
|
/**
|
|
* Declares a rendering command type with 4 parameters.
|
|
*/
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,ParamType4,ParamName4,ParamValue4,Code) \
|
|
class EURCMacro_##TypeName : public FRenderCommand \
|
|
{ \
|
|
public: \
|
|
typedef ParamType1 _ParamType1; \
|
|
typedef ParamType2 _ParamType2; \
|
|
typedef ParamType3 _ParamType3; \
|
|
typedef ParamType4 _ParamType4; \
|
|
EURCMacro_##TypeName(const _ParamType1& In##ParamName1,const _ParamType2& In##ParamName2,const _ParamType3& In##ParamName3,const _ParamType4& In##ParamName4): \
|
|
ParamName1(In##ParamName1), \
|
|
ParamName2(In##ParamName2), \
|
|
ParamName3(In##ParamName3), \
|
|
ParamName4(In##ParamName4) \
|
|
{} \
|
|
TASK_FUNCTION(Code) \
|
|
TASKNAME_FUNCTION(TypeName) \
|
|
private: \
|
|
ParamType1 ParamName1; \
|
|
ParamType2 ParamName2; \
|
|
ParamType3 ParamName3; \
|
|
ParamType4 ParamName4; \
|
|
};
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER_CREATE(TypeName,ParamType1,ParamValue1,ParamType2,ParamValue2,ParamType3,ParamValue3,ParamType4,ParamValue4) \
|
|
{ \
|
|
if(GIsThreadedRendering || !IsInGameThread()) \
|
|
{ \
|
|
CheckNotBlockedOnRenderThread(); \
|
|
TGraphTask<EURCMacro_##TypeName>::CreateTask().template ConstructAndDispatchWhenReady<ParamType1,ParamType2,ParamType3,ParamType4>(ParamValue1,ParamValue2,ParamValue3,ParamValue4); \
|
|
} \
|
|
else \
|
|
{ \
|
|
EURCMacro_##TypeName TempCommand(ParamValue1,ParamValue2,ParamValue3,ParamValue4); \
|
|
FScopeCycleCounter EURCMacro_Scope(TempCommand.GetStatId()); \
|
|
TempCommand.DoTask(ENamedThreads::GameThread, FGraphEventRef() ); \
|
|
} \
|
|
}
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,ParamType4,ParamName4,ParamValue4,Code) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,ParamType4,ParamName4,ParamValue4,Code) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER_CREATE(TypeName,ParamType1,ParamValue1,ParamType2,ParamValue2,ParamType3,ParamValue3,ParamType4,ParamValue4)
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER_DECLARE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,ParamType4,ParamName4,ParamValue4,Code) \
|
|
template <typename TemplateParamName> \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER_DECLARE(TypeName,ParamType1,ParamName1,ParamValue1,ParamType2,ParamName2,ParamValue2,ParamType3,ParamName3,ParamValue3,ParamType4,ParamName4,ParamValue4,Code)
|
|
|
|
#define ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER_CREATE_TEMPLATE(TypeName,TemplateParamName,ParamType1,ParamValue1,ParamType2,ParamValue2,ParamType3,ParamValue3,ParamType4,ParamValue4) \
|
|
ENQUEUE_UNIQUE_RENDER_COMMAND_FOURPARAMETER_CREATE(TypeName<TemplateParamName>,ParamType1,ParamValue1,ParamType2,ParamValue2,ParamType3,ParamValue3,ParamType4,ParamValue4)
|
|
|
|
#endif //UE_SERVER
|
|
|
|
////////////////////////////////////
|
|
// Render fences
|
|
////////////////////////////////////
|
|
|
|
/**
|
|
* Used to track pending rendering commands from the game thread.
|
|
*/
|
|
class RENDERCORE_API FRenderCommandFence
|
|
{
|
|
public:
|
|
|
|
/**
|
|
* Adds a fence command to the rendering command queue.
|
|
* Conceptually, the pending fence count is incremented to reflect the pending fence command.
|
|
* Once the rendering thread has executed the fence command, it decrements the pending fence count.
|
|
*/
|
|
void BeginFence();
|
|
|
|
/**
|
|
* Waits for pending fence commands to retire.
|
|
* @param bProcessGameThreadTasks, if true we are on a short callstack where it is safe to process arbitrary game thread tasks while we wait
|
|
*/
|
|
void Wait(bool bProcessGameThreadTasks = false) const;
|
|
|
|
// return true if the fence is complete
|
|
bool IsFenceComplete() const;
|
|
|
|
private:
|
|
/** Graph event that represents completion of this fence **/
|
|
mutable FGraphEventRef CompletionEvent;
|
|
};
|
|
|
|
////////////////////////////////////
|
|
// Deferred cleanup
|
|
////////////////////////////////////
|
|
|
|
/**
|
|
* The base class of objects that need to defer deletion until the render command queue has been flushed.
|
|
*/
|
|
class RENDERCORE_API FDeferredCleanupInterface
|
|
{
|
|
public:
|
|
virtual void FinishCleanup() = 0;
|
|
virtual ~FDeferredCleanupInterface() {}
|
|
};
|
|
|
|
/**
|
|
* A set of cleanup objects which are pending deletion.
|
|
*/
|
|
class FPendingCleanupObjects
|
|
{
|
|
TArray<FDeferredCleanupInterface*> CleanupArray;
|
|
public:
|
|
FPendingCleanupObjects();
|
|
RENDERCORE_API ~FPendingCleanupObjects();
|
|
};
|
|
|
|
/**
|
|
* Adds the specified deferred cleanup object to the current set of pending cleanup objects.
|
|
*/
|
|
extern RENDERCORE_API void BeginCleanup(FDeferredCleanupInterface* CleanupObject);
|
|
|
|
/**
|
|
* Transfers ownership of the current set of pending cleanup objects to the caller. A new set is created for subsequent BeginCleanup calls.
|
|
* @return A pointer to the set of pending cleanup objects. The called is responsible for deletion.
|
|
*/
|
|
extern RENDERCORE_API FPendingCleanupObjects* GetPendingCleanupObjects();
|
|
|
|
#endif
|