Slate.ShowBatching
Slate.ShowBatching
#Overview
name: Slate.ShowBatching
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: Don\'t show batching, 1: Show Batching
It is referenced in 9
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Slate.ShowBatching is to enable or disable the visualization of batching in the Slate UI system of Unreal Engine 5. This setting is primarily used for debugging and performance analysis of the Slate rendering process.
This setting variable is mainly utilized by the SlateRHIRenderer module, which is responsible for rendering Slate UI elements using the RHI (Rendering Hardware Interface). It’s part of the Slate UI system and is used in conjunction with other debugging tools.
The value of this variable is set through a console command. It’s defined as a TAutoConsoleVariable, which means it can be changed at runtime through the console or configuration files.
The associated variable CVarShowSlateBatching directly interacts with Slate.ShowBatching. They share the same value and are used interchangeably in the code.
Developers should be aware that this variable is primarily intended for debugging purposes. Enabling it may have performance implications, as it modifies the rendering process to visualize batching.
Best practices when using this variable include:
- Only enable it when debugging UI rendering issues or optimizing UI performance.
- Disable it in production builds to avoid any potential performance overhead.
- Use it in conjunction with other Slate debugging tools for a comprehensive analysis.
Regarding the associated variable CVarShowSlateBatching:
- It’s the C++ representation of the Slate.ShowBatching console variable.
- It’s used directly in the rendering code to check if batching visualization should be enabled.
- The variable is checked on the render thread, indicating its use in real-time rendering decisions.
- When enabled, it modifies the pixel shader and blend state used for rendering Slate elements, allowing for the visualization of batching.
Developers should treat CVarShowSlateBatching as they would Slate.ShowBatching, understanding that changes to one will affect the other. This variable is crucial for low-level debugging of Slate rendering performance and should be used judiciously.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:119
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarShowSlateBatching(
TEXT("Slate.ShowBatching"),
0,
TEXT("0: Don't show batching, 1: Show Batching"),
ECVF_Default
);
#endif
#Loc: <Workspace>/Engine/Source/Developer/SlateReflector/Private/Widgets/SSlateOptions.cpp:86
Scope (from outer to inner):
file
function void SSlateOptions::Construct
function static TSharedRef<SWidget> FillToolbar
Source code excerpt:
AddMenuEntry(MenuBuilder, Icon, LOCTEXT("DesignerRetainedRendering", "Designer Retained Rendering"), TEXT("Slate.EnableDesignerRetainedRendering"));
#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();
}
};
#Associated Variable and Callsites
This variable is associated with another variable named CVarShowSlateBatching
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:118
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarShowSlateBatching(
TEXT("Slate.ShowBatching"),
0,
TEXT("0: Don't show batching, 1: Show Batching"),
ECVF_Default
);
#endif
#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:37
Scope: file
Source code excerpt:
#if WITH_SLATE_VISUALIZERS
extern TAutoConsoleVariable<int32> CVarShowSlateOverdraw;
extern TAutoConsoleVariable<int32> CVarShowSlateBatching;
#endif
class FSlateBackBuffer : public FRenderTarget
{
public:
FSlateBackBuffer(FTexture2DRHIRef InRenderTargetTexture, FIntPoint InSizeXY)
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderingPolicy.cpp:918
Scope: file
Source code excerpt:
#if WITH_SLATE_VISUALIZERS
TShaderRef<FSlateDebugBatchingPS> BatchingPixelShader;
if (CVarShowSlateBatching.GetValueOnRenderThread() != 0)
{
BatchingPixelShader = TShaderMapRef<FSlateDebugBatchingPS>(ShaderMap);
PixelShader = BatchingPixelShader;
}
else
#endif
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderingPolicy.cpp:951
Scope: file
Source code excerpt:
#if WITH_SLATE_VISUALIZERS
if (CVarShowSlateBatching.GetValueOnRenderThread() != 0)
{
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();
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderingPolicy.cpp:995
Scope: file
Source code excerpt:
#if WITH_SLATE_VISUALIZERS
if (CVarShowSlateBatching.GetValueOnRenderThread() != 0)
{
BatchingPixelShader->SetBatchColor(BatchedParameters, BatchColor);
}
#endif
FRHISamplerState* SamplerState = BilinearClamp;
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderingPolicy.cpp:1151
Scope: file
Source code excerpt:
#if WITH_SLATE_VISUALIZERS
if (CVarShowSlateBatching.GetValueOnRenderThread() != 0)
{
TShaderMapRef<FSlateDebugBatchingPS> BatchingPixelShader(ShaderMap);
GraphicsPSOInit.BoundShaderState.VertexDeclarationRHI = bUseInstancing ? GSlateInstancedVertexDeclaration.VertexDeclarationRHI : GSlateVertexDeclaration.VertexDeclarationRHI;
GraphicsPSOInit.BoundShaderState.VertexShaderRHI = GlobalVertexShader.GetVertexShader();
GraphicsPSOInit.BoundShaderState.PixelShaderRHI = BatchingPixelShader.GetPixelShader();