r.ResetRenderTargetsExtent

r.ResetRenderTargetsExtent

#Overview

name: r.ResetRenderTargetsExtent

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.ResetRenderTargetsExtent is to reset the internal render target extents in Unreal Engine 5. This setting variable is primarily used in the rendering system to control the allocation and sizing of render targets.

Based on the callsites provided, this variable is primarily relied upon by the following Unreal Engine subsystems and modules:

  1. MovieRenderPipeline: Used in the movie rendering pipeline for adjusting render target sizes after rendering is complete.
  2. FunctionalTesting: Utilized in screenshot functional tests to prepare the rendering system for capturing screenshots.
  3. LevelEditor: Employed in the high-resolution screenshot functionality to reset the frame buffer.
  4. Renderer: Directly referenced in the rendering system for resetting scene texture extents.

The value of this variable is not set directly in the provided code snippets. Instead, it is used as a console command, typically executed through UKismetSystemLibrary::ExecuteConsoleCommand(). This suggests that it’s a command rather than a traditional variable, and its execution triggers the reset of render target extents.

While there are no direct interactions with other variables shown in the provided code, it’s closely related to rendering state and may indirectly affect or be affected by other rendering-related variables and systems.

Developers should be aware of the following when using this variable:

  1. It’s primarily used for resetting render target sizes, which can be crucial for ensuring correct rendering in various scenarios, such as after changing resolutions or when capturing screenshots.
  2. It’s often used in conjunction with other rendering-related operations, such as flushing rendering commands or preparing for screenshot captures.
  3. The variable is registered as a cheat command (ECVF_Cheat), indicating it’s not intended for regular use in shipping builds.

Best practices when using this variable include:

  1. Use it sparingly and only when necessary, such as after significant changes to rendering resolution or when preparing for specific rendering tasks like high-resolution screenshots or movie rendering.
  2. Always consider the potential performance impact of resetting render target extents, as it may cause reallocation of rendering resources.
  3. Be cautious when using it in shipping builds, as it’s registered as a cheat command and may not be available or could have unintended consequences.
  4. When used in custom rendering pipelines or testing scenarios, ensure proper synchronization with other rendering operations to avoid potential conflicts or race conditions.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineCore/Private/Graph/MovieGraphPipeline.cpp:1452

Scope (from outer to inner):

file
function     void UMovieGraphPipeline::TransitionToState

Source code excerpt:

			// and cause it to re-allocate at the currrent size on the next render request, which is likely to be the size
			// of the PIE window (720p) or the Viewport itself.
			//UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), TEXT("r.ResetRenderTargetsExtent"), nullptr);
			//CustomTimeStep->RestoreCachedWorldSettings();

			//GAreScreenMessagesEnabled = bPrevGScreenMessagesEnabled;

			//UE_LOG(LogMovieRenderPipeline, Log, TEXT("Movie Pipeline completed. Duration: %s"), *(FDateTime::UtcNow() - InitializationTime).ToString());

#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineCore/Private/MoviePipeline.cpp:578

Scope (from outer to inner):

file
function     void UMoviePipeline::TransitionToState

Source code excerpt:

			// and cause it to re-allocate at the currrent size on the next render request, which is likely to be the size
			// of the PIE window (720p) or the Viewport itself.
			UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), TEXT("r.ResetRenderTargetsExtent"), nullptr);
			CustomTimeStep->RestoreCachedWorldSettings();

			GAreScreenMessagesEnabled = bPrevGScreenMessagesEnabled;

			UE_LOG(LogMovieRenderPipeline, Log, TEXT("Movie Pipeline completed. Duration: %s"), *(FDateTime::UtcNow() - InitializationTime).ToString());

#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Private/ScreenshotFunctionalTestBase.cpp:152

Scope (from outer to inner):

file
function     void AScreenshotFunctionalTestBase::PrepareForScreenshot

Source code excerpt:

	{
		FlushRenderingCommands();
		UKismetSystemLibrary::ExecuteConsoleCommand(GameViewportClient->GetWorld(), TEXT("r.ResetRenderTargetsExtent"), nullptr);
	}
#endif
#endif
}

void AScreenshotFunctionalTestBase::OnScreenShotCaptured(int32 InSizeX, int32 InSizeY, const TArray<FColor>& InImageData)

#Loc: <Workspace>/Engine/Source/Editor/LevelEditor/Private/HighResScreenshotUI.cpp:298

Scope (from outer to inner):

file
function     void SHighResScreenshotDialog::ResetFrameBuffer

Source code excerpt:

		if (Client)
		{
			UKismetSystemLibrary::ExecuteConsoleCommand(Client->GetWorld(), TEXT("r.ResetRenderTargetsExtent"), nullptr);
		}
	}
#endif
}

TWeakPtr<class SWindow> SHighResScreenshotDialog::OpenDialog(const TSharedPtr<FSceneViewport>& InViewport, TSharedPtr<SCaptureRegionWidget> InCaptureRegionWidget)

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3360

Scope (from outer to inner):

file
function     void CreateConsoleVariables

Source code excerpt:

	IConsoleManager::Get().RegisterConsoleCommand(TEXT("r.ResetViewState"), TEXT("Reset some state (e.g. TemporalAA index) to make rendering more deterministic (for automated screenshot verification)"), ECVF_Cheat);
	IConsoleManager::Get().RegisterConsoleCommand(TEXT("r.RHI.Name"),		TEXT("Show current RHI's name"), ECVF_Cheat);
	IConsoleManager::Get().RegisterConsoleCommand(TEXT("r.ResetRenderTargetsExtent"), TEXT("To reset internal render target extents"), ECVF_Cheat);
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)

#if WITH_DUMPGPU
	IConsoleManager::Get().RegisterConsoleCommand(TEXT("DumpGPU"), TEXT("Dump one frame of rendering intermediary resources to disk."), ECVF_Cheat);
#endif

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Renderer.cpp:644

Scope (from outer to inner):

file
function     static bool RendererExec

Source code excerpt:

		return true;
	}
	else if (FParse::Command(&Cmd, TEXT("r.ResetRenderTargetsExtent")))
	{
		ResetSceneTextureExtentHistory();
		Ar.Logf(TEXT("Scene texture extent history reset. Next scene render will reallocate textures at the requested size."));
		return true;
	}
#endif