You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
It made sens back in UE4 needing to do GVisualizeTexture.SetCheckPoint(), but now being fully transparent in RDG like DumpGPU it just doesn't make sens to not have it by default in test build like we do with DumpGPU #rb trivial #preflight 642e021cda7f958370105e26 [CL 24956650 by guillaume abadie in ue5-main branch]
191 lines
4.7 KiB
C++
191 lines
4.7 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "Containers/Array.h"
|
|
#include "Containers/Map.h"
|
|
#include "Containers/UnrealString.h"
|
|
#include "HAL/Platform.h"
|
|
#include "HAL/PlatformCrt.h"
|
|
#include "Misc/EnumClassFlags.h"
|
|
#include "Misc/Optional.h"
|
|
#include "Misc/WildcardString.h"
|
|
#include "RenderResource.h"
|
|
#include "RendererInterface.h"
|
|
#include "Templates/RefCounting.h"
|
|
|
|
#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_3
|
|
#include "RHIDefinitions.h"
|
|
#include "RenderGraph.h"
|
|
#include "RenderGraphDefinitions.h"
|
|
#include "RenderGraphResources.h"
|
|
#endif
|
|
|
|
class FOutputDevice;
|
|
class FRDGBuilder;
|
|
class FRHICommandListImmediate;
|
|
class FWildcardString;
|
|
|
|
#define SUPPORTS_VISUALIZE_TEXTURE (WITH_ENGINE && (!UE_BUILD_SHIPPING || WITH_EDITOR))
|
|
|
|
class RENDERCORE_API FVisualizeTexture : public FRenderResource
|
|
{
|
|
public:
|
|
FVisualizeTexture() = default;
|
|
|
|
void ParseCommands(const TCHAR* Cmd, FOutputDevice &Ar);
|
|
|
|
void DebugLogOnCrash();
|
|
|
|
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. */
|
|
#if SUPPORTS_VISUALIZE_TEXTURE
|
|
void SetCheckPoint(FRDGBuilder& GraphBuilder, IPooledRenderTarget* PooledRenderTarget);
|
|
void SetCheckPoint(FRHICommandListImmediate& RHICmdList, IPooledRenderTarget* PooledRenderTarget);
|
|
#else
|
|
inline void SetCheckPoint(FRDGBuilder& GraphBuilder, IPooledRenderTarget* PooledRenderTarget) {}
|
|
inline void SetCheckPoint(FRHICommandListImmediate& RHICmdList, IPooledRenderTarget* PooledRenderTarget) {}
|
|
#endif
|
|
|
|
static FRDGTextureRef AddVisualizeTexturePass(
|
|
FRDGBuilder& GraphBuilder,
|
|
class FGlobalShaderMap* ShaderMap,
|
|
const FRDGTextureRef InputTexture);
|
|
|
|
static FRDGTextureRef AddVisualizeTextureAlphaPass(
|
|
FRDGBuilder& GraphBuilder,
|
|
class FGlobalShaderMap* ShaderMap,
|
|
const FRDGTextureRef InputTexture);
|
|
|
|
private:
|
|
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);
|
|
|
|
enum class ECommand
|
|
{
|
|
Unknown,
|
|
DisableVisualization,
|
|
VisualizeResource,
|
|
DisplayHelp,
|
|
DisplayPoolResourceList,
|
|
DisplayResourceList,
|
|
};
|
|
|
|
enum class EInputUVMapping
|
|
{
|
|
LeftTop,
|
|
Whole,
|
|
PixelPerfectCenter,
|
|
PictureInPicture
|
|
};
|
|
|
|
enum class EInputValueMapping
|
|
{
|
|
Color,
|
|
Depth,
|
|
Shadow
|
|
};
|
|
|
|
enum class EDisplayMode
|
|
{
|
|
MultiColomn,
|
|
Detailed,
|
|
};
|
|
|
|
enum class ESortBy
|
|
{
|
|
Index,
|
|
Name,
|
|
Size
|
|
};
|
|
|
|
enum class EShaderOp
|
|
{
|
|
Frac,
|
|
Saturate
|
|
};
|
|
|
|
#if SUPPORTS_VISUALIZE_TEXTURE
|
|
static void DisplayHelp(FOutputDevice &Ar);
|
|
void DisplayPoolResourceListToLog(ESortBy SortBy);
|
|
void DisplayResourceListToLog(const TOptional<FWildcardString>& Wildcard);
|
|
|
|
/** 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);
|
|
|
|
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;
|
|
};
|
|
|
|
/** Adds a pass to visualize a texture. */
|
|
static FRDGTextureRef AddVisualizeTexturePass(
|
|
FRDGBuilder& GraphBuilder,
|
|
class FGlobalShaderMap* ShaderMap,
|
|
const FRDGTextureRef InputTexture,
|
|
const FConfig& Config,
|
|
EInputValueMapping InputValueMapping,
|
|
uint32 CaptureId);
|
|
|
|
/** Create a pass capturing a texture. */
|
|
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;
|
|
|
|
FConfig 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.
|
|
TMap<FString, uint32> VersionCountMap;
|
|
#endif
|
|
|
|
friend class FRDGBuilder;
|
|
friend class FVisualizeTexturePresent;
|
|
};
|
|
|
|
ENUM_CLASS_FLAGS(FVisualizeTexture::EFlags);
|
|
|
|
/** The global render targets for easy shading. */
|
|
extern RENDERCORE_API TGlobalResource<FVisualizeTexture> GVisualizeTexture;
|