Slate.ShowOverdraw

Slate.ShowOverdraw

#Overview

name: Slate.ShowOverdraw

This variable is created as a Console Variable (cvar).

It is referenced in 8 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Slate.ShowOverdraw is to enable or disable the visualization of overdraw in Slate, Unreal Engine’s UI framework. Overdraw occurs when multiple UI elements are drawn on top of each other, potentially impacting performance.

This setting variable is primarily used by the Slate RHI (Rendering Hardware Interface) Renderer subsystem, which is responsible for rendering Slate UI elements. It’s part of the SlateRHIRenderer module.

The value of this variable is set through a console command, as indicated by the TAutoConsoleVariable declaration. It can be toggled between 0 (don’t show overdraw) and 1 (show overdraw).

The associated variable CVarShowSlateOverdraw directly interacts with Slate.ShowOverdraw. They share the same value and are used interchangeably in the code.

Developers should be aware that enabling this variable will impact rendering performance, as it changes the blending state and pixel shader used for rendering Slate elements. It’s primarily intended for debugging and optimization purposes.

Best practices for using this variable include:

  1. Use it during development and testing phases to identify areas of high overdraw.
  2. Disable it in production builds to avoid unnecessary performance overhead.
  3. Use in conjunction with other Slate debugging tools for comprehensive UI optimization.

Regarding the associated variable CVarShowSlateOverdraw:

The purpose of CVarShowSlateOverdraw is identical to Slate.ShowOverdraw – it controls the visualization of Slate UI overdraw.

It’s used in the same SlateRHIRenderer subsystem and is typically checked in render-thread operations.

The value is set through the console variable system, allowing for runtime toggling.

CVarShowSlateOverdraw directly interacts with Slate.ShowOverdraw, and they are used interchangeably in the codebase.

Developers should be aware that this variable is only available when WITH_SLATE_VISUALIZERS is defined, typically in debug or development builds.

Best practices for CVarShowSlateOverdraw are the same as for Slate.ShowOverdraw, focusing on its use as a development and optimization tool rather than a production feature.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:112

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarShowSlateOverdraw(
	TEXT("Slate.ShowOverdraw"),
	0,
	TEXT("0: Don't show overdraw, 1: Show Overdraw"),
	ECVF_Default
);

TAutoConsoleVariable<int32> CVarShowSlateBatching(

#Loc: <Workspace>/Engine/Source/Developer/SlateReflector/Private/Widgets/SSlateOptions.cpp:87

Scope (from outer to inner):

file
function     void SSlateOptions::Construct
function     static TSharedRef<SWidget> FillToolbar

Source code excerpt:

#endif // WITH_SLATE_DEBUGGING
			AddMenuEntry(MenuBuilder, Icon, LOCTEXT("ShowBatching", "Show Batching"), TEXT("Slate.ShowBatching"));
			AddMenuEntry(MenuBuilder, Icon, LOCTEXT("ShowOverdraw", "Show Overdraw"), TEXT("Slate.ShowOverdraw"));
			
			return MenuBuilder.MakeWidget();
		}
	};

	struct ValidationLocal : Local

#Associated Variable and Callsites

This variable is associated with another variable named CVarShowSlateOverdraw. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:111

Scope: file

Source code excerpt:

#if WITH_SLATE_VISUALIZERS

TAutoConsoleVariable<int32> CVarShowSlateOverdraw(
	TEXT("Slate.ShowOverdraw"),
	0,
	TEXT("0: Don't show overdraw, 1: Show Overdraw"),
	ECVF_Default
);

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:991

Scope (from outer to inner):

file
function     void RenderSlateBatch

Source code excerpt:


#if WITH_SLATE_VISUALIZERS
	if (CVarShowSlateBatching.GetValueOnRenderThread() != 0 || CVarShowSlateOverdraw.GetValueOnRenderThread() != 0)
	{
		RPInfo.ColorRenderTargets[0].Action = ERenderTargetActions::Clear_Store;
		if (ViewportInfo.bRequiresStencilTest)
		{
			// Reset the backbuffer as our color render target and also set a depth stencil buffer
			ERenderTargetActions StencilAction = IsMemorylessTexture(ViewportInfo.DepthStencil) ? ERenderTargetActions::Clear_DontStore : ERenderTargetActions::Clear_Store;

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.h:36

Scope: file

Source code excerpt:


#if WITH_SLATE_VISUALIZERS
extern TAutoConsoleVariable<int32> CVarShowSlateOverdraw;
extern TAutoConsoleVariable<int32> CVarShowSlateBatching;
#endif

class FSlateBackBuffer : public FRenderTarget
{
public:

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderingPolicy.cpp:955

Scope: file

Source code excerpt:

					GraphicsPSOInit.BlendState = TStaticBlendState<CW_RGBA, BO_Add, BF_SourceAlpha, BF_InverseSourceAlpha, BO_Add, BF_One, BF_InverseSourceAlpha>::GetRHI();
				}
				else if (CVarShowSlateOverdraw.GetValueOnRenderThread() != 0)
				{
					GraphicsPSOInit.BlendState = TStaticBlendState<CW_RGB, BO_Add, BF_One, BF_One, BO_Add, BF_Zero, BF_InverseSourceAlpha>::GetRHI();
				}
				else
#endif
				{

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderingPolicy.cpp:1162

Scope: file

Source code excerpt:

							BatchingPixelShader->SetBatchColor(BatchedParameters, BatchColor);
						}
						else if (CVarShowSlateOverdraw.GetValueOnRenderThread() != 0)
						{
							TShaderMapRef<FSlateDebugOverdrawPS> OverdrawPixelShader(ShaderMap);

							GraphicsPSOInit.BoundShaderState.VertexDeclarationRHI = bUseInstancing ? GSlateInstancedVertexDeclaration.VertexDeclarationRHI : GSlateVertexDeclaration.VertexDeclarationRHI;
							GraphicsPSOInit.BoundShaderState.VertexShaderRHI = GlobalVertexShader.GetVertexShader();
							GraphicsPSOInit.BoundShaderState.PixelShaderRHI = OverdrawPixelShader.GetPixelShader();

#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderingPolicy.cpp:1413

Scope (from outer to inner):

file
function     TShaderRef<FSlateElementPS> FSlateRHIRenderingPolicy::GetTexturePixelShader

Source code excerpt:


#if WITH_SLATE_VISUALIZERS
	if ( CVarShowSlateOverdraw.GetValueOnRenderThread() != 0 )
	{
		PixelShader = TShaderMapRef<FSlateDebugOverdrawPS>(ShaderMap);
	}
	else
#endif
	{