2019-12-26 14:45:42 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# pragma once
2018-11-21 20:22:47 -05:00
# include "RenderGraph.h"
2021-01-29 11:05:31 -04:00
# include "Misc/WildcardString.h"
2014-08-21 06:03:00 -04:00
2020-09-24 00:43:27 -04:00
class FOutputDevice ;
2021-04-29 19:32:06 -04:00
# define SUPPORTS_VISUALIZE_TEXTURE (WITH_ENGINE && (!(UE_BUILD_SHIPPING || UE_BUILD_TEST) || WITH_EDITOR))
Merging //UE4/Dev-Rendering-Graph@4492585 to Dev-Rendering (//UE4/Dev-Rendering)
This implements the framework to write the high level rendering code into passes organized in direct acyclic graph. It is also unifying the uniform buffer, shader parameters, and pass parameters to same single API: structures with run time meta data. This allow high level user code be extremely seamless, user code debugging, and render graph ease of implementation and debugging.
Issue of collaborative work of Arne Schnober, Brian Karis, Daniel Wright, Marcus Wassmer and Guillaume Abadie.
Names of the graph managed resources are not final.
#rb Arne.Schnober, Brian.Karis, Daniel.Wright, Marcus.Wassmer
[CL 4492694 by Guillaume Abadie in Dev-Rendering branch]
2018-10-19 17:36:35 -04:00
2018-11-21 20:22:47 -05:00
class RENDERCORE_API FVisualizeTexture : public FRenderResource
2014-03-14 14:13:41 -04:00
{
public :
2020-09-24 00:43:27 -04:00
FVisualizeTexture ( ) = default ;
2014-03-14 14:13:41 -04:00
2020-09-24 00:43:27 -04:00
void ParseCommands ( const TCHAR * Cmd , FOutputDevice & Ar ) ;
2019-09-14 09:45:25 -04:00
2020-09-24 00:43:27 -04:00
void DebugLogOnCrash ( ) ;
2018-12-11 22:25:04 -05:00
2020-09-24 00:43:27 -04:00
void GetTextureInfos_GameThread ( TArray < FString > & Infos ) const ;
/** Creates a new checkpoint (e.g. "SceneDepth@N") for the pooled render target. A null parameter is a no-op. */
2018-12-18 21:41:17 -05:00
# if SUPPORTS_VISUALIZE_TEXTURE
2021-03-04 00:38:01 -04:00
void SetCheckPoint ( FRDGBuilder & GraphBuilder , IPooledRenderTarget * PooledRenderTarget ) ;
2020-09-24 00:43:27 -04:00
void SetCheckPoint ( FRHICommandListImmediate & RHICmdList , IPooledRenderTarget * PooledRenderTarget ) ;
2018-11-21 20:22:47 -05:00
# else
2021-03-04 00:38:01 -04:00
inline void SetCheckPoint ( FRDGBuilder & GraphBuilder , IPooledRenderTarget * PooledRenderTarget ) { }
2020-09-24 00:43:27 -04:00
inline void SetCheckPoint ( FRHICommandListImmediate & RHICmdList , IPooledRenderTarget * PooledRenderTarget ) { }
2018-11-21 20:22:47 -05:00
# endif
2014-03-14 14:13:41 -04:00
private :
2020-09-24 00:43:27 -04:00
enum class EFlags
{
None = 0 ,
SaveBitmap = 1 < < 0 ,
SaveBitmapAsStencil = 1 < < 1 , // stencil normally displays in the alpha channel of depth buffer visualization. This option is just for BMP writeout to get a stencil only BMP.
} ;
FRIEND_ENUM_CLASS_FLAGS ( EFlags ) ;
2018-11-21 20:22:47 -05:00
2021-01-29 06:51:36 -04:00
enum class ECommand
2020-09-24 00:43:27 -04:00
{
2021-01-29 06:51:36 -04:00
Unknown ,
DisableVisualization ,
VisualizeResource ,
DisplayHelp ,
DisplayPoolResourceList ,
DisplayResourceList ,
2020-09-24 00:43:27 -04:00
} ;
2018-11-21 20:22:47 -05:00
2020-09-24 00:43:27 -04:00
enum class EInputUVMapping
{
LeftTop ,
Whole ,
PixelPerfectCenter ,
PictureInPicture
} ;
2014-05-08 09:05:50 -04:00
2020-09-24 00:43:27 -04:00
enum class EInputValueMapping
{
Color ,
Depth ,
Shadow
} ;
2014-08-19 10:41:34 -04:00
2021-01-29 06:51:36 -04:00
enum class EDisplayMode
{
MultiColomn ,
Detailed ,
} ;
2020-09-24 00:43:27 -04:00
enum class ESortBy
{
Index ,
Name ,
Size
} ;
enum class EShaderOp
{
Frac ,
Saturate
} ;
# if SUPPORTS_VISUALIZE_TEXTURE
2021-01-29 06:51:36 -04:00
static void DisplayHelp ( FOutputDevice & Ar ) ;
void DisplayPoolResourceListToLog ( ESortBy SortBy ) ;
void DisplayResourceListToLog ( const TOptional < FWildcardString > & Wildcard ) ;
2020-09-24 00:43:27 -04:00
/** Determine whether a texture should be captured for debugging purposes and return the capture id if needed. */
TOptional < uint32 > ShouldCapture ( const TCHAR * DebugName , uint32 MipIndex ) ;
2014-03-14 14:13:41 -04:00
2018-11-21 20:22:47 -05:00
/** Create a pass capturing a texture. */
2020-09-24 00:43:27 -04:00
void CreateContentCapturePass ( FRDGBuilder & GraphBuilder , FRDGTextureRef Texture , uint32 CaptureId ) ;
void ReleaseDynamicRHI ( ) override ;
void Visualize ( const FString & InName , TOptional < uint32 > InVersion = { } ) ;
uint32 GetVersionCount ( const TCHAR * InName ) const ;
struct FConfig
{
float RGBMul = 1.0f ;
float AMul = 0.0f ;
// -1=off, 0=R, 1=G, 2=B, 3=A
int32 SingleChannel = - 1 ;
float SingleChannelMul = 0.0f ;
EFlags Flags = EFlags : : None ;
EInputUVMapping InputUVMapping = EInputUVMapping : : PictureInPicture ;
EShaderOp ShaderOp = EShaderOp : : Frac ;
uint32 MipIndex = 0 ;
uint32 ArrayIndex = 0 ;
} Config ;
struct FRequested
{
FString Name ;
TOptional < uint32 > Version ;
} Requested ;
struct FCaptured
{
FCaptured ( )
{
Desc . DebugName = TEXT ( " VisualizeTexture " ) ;
}
TRefCountPtr < IPooledRenderTarget > PooledRenderTarget ;
FRDGTextureRef Texture = nullptr ;
FPooledRenderTargetDesc Desc ;
EInputValueMapping InputValueMapping = EInputValueMapping : : Color ;
} Captured ;
ERHIFeatureLevel : : Type FeatureLevel = ERHIFeatureLevel : : SM5 ;
// Maps a texture name to its checkpoint version.
2021-02-18 18:13:28 -04:00
TMap < FString , uint32 > VersionCountMap ;
2018-11-21 20:22:47 -05:00
# endif
2014-03-14 14:13:41 -04:00
2018-11-21 20:22:47 -05:00
friend class FRDGBuilder ;
friend class FVisualizeTexturePresent ;
2014-03-14 14:13:41 -04:00
} ;
2020-09-24 00:43:27 -04:00
ENUM_CLASS_FLAGS ( FVisualizeTexture : : EFlags ) ;
2014-03-14 14:13:41 -04:00
Merging //UE4/Dev-Rendering-Graph@4492585 to Dev-Rendering (//UE4/Dev-Rendering)
This implements the framework to write the high level rendering code into passes organized in direct acyclic graph. It is also unifying the uniform buffer, shader parameters, and pass parameters to same single API: structures with run time meta data. This allow high level user code be extremely seamless, user code debugging, and render graph ease of implementation and debugging.
Issue of collaborative work of Arne Schnober, Brian Karis, Daniel Wright, Marcus Wassmer and Guillaume Abadie.
Names of the graph managed resources are not final.
#rb Arne.Schnober, Brian.Karis, Daniel.Wright, Marcus.Wassmer
[CL 4492694 by Guillaume Abadie in Dev-Rendering branch]
2018-10-19 17:36:35 -04:00
/** The global render targets for easy shading. */
2021-01-29 11:05:31 -04:00
extern RENDERCORE_API TGlobalResource < FVisualizeTexture > GVisualizeTexture ;