r.Test.ViewRectOffset
r.Test.ViewRectOffset
#Overview
name: r.Test.ViewRectOffset
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Moves the view rect within the renderer\'s internal render target.\n 0: disabled (default);
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Test.ViewRectOffset is to move the view rectangle within the renderer’s internal render target for testing purposes. This setting variable is primarily used in the rendering system of Unreal Engine 5.
Based on the provided callsites, this variable is utilized in the Renderer module of Unreal Engine, specifically within the SceneRendering.cpp file.
The value of this variable is set through a console variable (CVarTestInternalViewRectOffset) with a default value of 0, which means the feature is disabled by default.
This variable interacts with the internal buffer size calculation and view rectangle preparation in the rendering process. It’s associated with CVarTestInternalViewRectOffset, which shares the same value.
Developers must be aware that:
- This variable is only active in non-shipping builds (#if !UE_BUILD_SHIPPING).
- When enabled (value > 0), it doubles the size of the desired internal buffer.
- It affects the preparation of view rectangles for rendering, potentially moving the view rect within the renderer’s internal render target.
Best practices when using this variable include:
- Only use it for testing purposes, not in production builds.
- Be cautious of potential performance impacts when enabling this feature, as it increases the internal buffer size.
- Ensure to disable it (set to 0) when not actively testing to avoid unintended effects on rendering.
Regarding the associated variable CVarTestInternalViewRectOffset:
The purpose of CVarTestInternalViewRectOffset is to provide a console-accessible way to control the r.Test.ViewRectOffset setting.
This variable is defined and used within the Renderer module, specifically in SceneRendering.cpp.
The value of this variable is set through the console, with a default value of 0 (disabled).
It directly interacts with r.Test.ViewRectOffset, as they share the same value and purpose.
Developers should be aware that:
- This is a console variable, allowing for runtime adjustment of the view rect offset for testing.
- It’s only available in non-shipping builds.
Best practices for using CVarTestInternalViewRectOffset include:
- Use it for debugging and testing render target issues.
- Remember to reset it to 0 after testing to avoid unintended effects on rendering.
- Be aware of its impact on internal buffer size and rendering performance when enabled.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:384
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarTestInternalViewRectOffset(
TEXT("r.Test.ViewRectOffset"),
0,
TEXT("Moves the view rect within the renderer's internal render target.\n")
TEXT(" 0: disabled (default);"));
static TAutoConsoleVariable<int32> CVarTestCameraCut(
TEXT("r.Test.CameraCut"),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:3011
Scope (from outer to inner):
file
function FIntPoint FSceneRenderer::GetDesiredInternalBufferSize
Source code excerpt:
{
// Increase the size of desired buffer size by 2 when testing for view rectangle offset.
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Test.ViewRectOffset"));
if (CVar->GetValueOnAnyThread() > 0)
{
DesiredBufferSize *= 2;
}
}
#endif
#Associated Variable and Callsites
This variable is associated with another variable named CVarTestInternalViewRectOffset
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:383
Scope: file
Source code excerpt:
#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<int32> CVarTestInternalViewRectOffset(
TEXT("r.Test.ViewRectOffset"),
0,
TEXT("Moves the view rect within the renderer's internal render target.\n")
TEXT(" 0: disabled (default);"));
static TAutoConsoleVariable<int32> CVarTestCameraCut(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:3187
Scope (from outer to inner):
file
function void FSceneRenderer::PrepareViewRectsForRendering
Source code excerpt:
#if !UE_BUILD_SHIPPING
{
int32 ViewRectOffset = CVarTestInternalViewRectOffset.GetValueOnRenderThread();
if (Views.Num() == 1 && ViewRectOffset > 0)
{
FViewInfo& View = Views[0];
FIntPoint DesiredBufferSize = GetDesiredInternalBufferSize(ViewFamily);