r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws

r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws

#Overview

name: r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws is to enable capturing of the water info texture for a specified number of draws. This setting variable is primarily used for debugging and profiling the water rendering system in Unreal Engine 5.

This setting variable is primarily utilized by the Water plugin and the Renderer module of Unreal Engine 5. The main subsystems that rely on this variable are the water rendering system and the render capture system.

The value of this variable is set through the console or programmatically using the console variable system. It can be modified at runtime, allowing developers to capture water info texture draws on demand.

The associated variable CVarRenderCaptureNextWaterInfoDraws interacts directly with r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws. They share the same value and are used interchangeably in the code.

Developers must be aware that enabling this variable will impact performance, as it triggers additional render captures. It should be used judiciously, primarily for debugging and profiling purposes.

Best practices when using this variable include:

  1. Only enable it when necessary for debugging or profiling water rendering.
  2. Set the value to the minimum number of draws required for analysis to minimize performance impact.
  3. Remember to disable it (set to 0) after capturing the required information.
  4. Use in conjunction with other water rendering debug tools for comprehensive analysis.

Regarding the associated variable CVarRenderCaptureNextWaterInfoDraws:

This is the actual console variable object that corresponds to r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws. It’s used to access and modify the value of the setting throughout the code.

The purpose of CVarRenderCaptureNextWaterInfoDraws is to provide a programmatic interface to the r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws setting. It allows the engine to read and write the value of the setting in C++ code.

This variable is used in both the Water plugin and the Renderer module, specifically in the water info rendering functions.

The value of CVarRenderCaptureNextWaterInfoDraws is typically set through the console variable system, either via console commands or programmatically in C++ code.

When using CVarRenderCaptureNextWaterInfoDraws, developers should be aware that changes to this variable will immediately affect the behavior of the water info texture capture system. It’s important to handle this variable thread-safely, as it’s accessed from both the game and render threads.

Best practices for using CVarRenderCaptureNextWaterInfoDraws include:

  1. Use the appropriate thread-safe accessor methods when reading or writing the value.
  2. Consider the performance implications of frequent changes to this variable.
  3. Reset the value to 0 after capturing the required number of draws to avoid unnecessary overhead.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRenderCaptureNextWaterInfoDraws(
	TEXT("r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws"),
	0,
	TEXT("Enable capturing of the water info texture for the next N draws"),
	ECVF_RenderThreadSafe);

BEGIN_SHADER_PARAMETER_STRUCT(FWaterInfoTexturePassParameters, )
	SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FViewUniformShaderParameters, View)

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterInfoRendering.cpp:716

Scope (from outer to inner):

file
namespace    UE::WaterInfo
function     void UpdateWaterInfoRendering

Source code excerpt:

	TRACE_CPUPROFILER_EVENT_SCOPE(WaterInfo::UpdateWaterInfoRendering);

	static auto* CVarRenderCaptureNextWaterInfoDraws = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws"));
	int32 RenderCaptureNextWaterInfoDraws = CVarRenderCaptureNextWaterInfoDraws ? CVarRenderCaptureNextWaterInfoDraws->AsVariableInt()->GetValueOnGameThread() : 0;
	RenderCaptureInterface::FScopedCapture RenderCapture((RenderCaptureNextWaterInfoDraws != 0), TEXT("RenderWaterInfo"));
	if (RenderCaptureNextWaterInfoDraws != 0)
	{
		RenderCaptureNextWaterInfoDraws = FMath::Max(0, RenderCaptureNextWaterInfoDraws - 1);
		CVarRenderCaptureNextWaterInfoDraws->Set(RenderCaptureNextWaterInfoDraws);

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterInfoRendering.cpp:1060

Scope (from outer to inner):

file
namespace    UE::WaterInfo
function     void UpdateWaterInfoRendering_CustomRenderPass

Source code excerpt:

	}

	static auto* CVarRenderCaptureNextWaterInfoDraws = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws"));
	int32 RenderCaptureNextWaterInfoDraws = CVarRenderCaptureNextWaterInfoDraws ? CVarRenderCaptureNextWaterInfoDraws->AsVariableInt()->GetValueOnGameThread() : 0;
	bool bPerformRenderCapture = false;
	if (RenderCaptureNextWaterInfoDraws != 0)
	{
		RenderCaptureNextWaterInfoDraws = FMath::Max(0, RenderCaptureNextWaterInfoDraws - 1);
		CVarRenderCaptureNextWaterInfoDraws->Set(RenderCaptureNextWaterInfoDraws);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterInfoRendering.cpp:716

Scope (from outer to inner):

file
namespace    UE::WaterInfo
function     void UpdateWaterInfoRendering

Source code excerpt:

	TRACE_CPUPROFILER_EVENT_SCOPE(WaterInfo::UpdateWaterInfoRendering);

	static auto* CVarRenderCaptureNextWaterInfoDraws = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws"));
	int32 RenderCaptureNextWaterInfoDraws = CVarRenderCaptureNextWaterInfoDraws ? CVarRenderCaptureNextWaterInfoDraws->AsVariableInt()->GetValueOnGameThread() : 0;
	RenderCaptureInterface::FScopedCapture RenderCapture((RenderCaptureNextWaterInfoDraws != 0), TEXT("RenderWaterInfo"));
	if (RenderCaptureNextWaterInfoDraws != 0)
	{
		RenderCaptureNextWaterInfoDraws = FMath::Max(0, RenderCaptureNextWaterInfoDraws - 1);
		CVarRenderCaptureNextWaterInfoDraws->Set(RenderCaptureNextWaterInfoDraws);
	}

	if (!IsValid(Context.TextureRenderTarget) || Scene == nullptr)
	{
		return;
	}

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterInfoRendering.cpp:1060

Scope (from outer to inner):

file
namespace    UE::WaterInfo
function     void UpdateWaterInfoRendering_CustomRenderPass

Source code excerpt:

	}

	static auto* CVarRenderCaptureNextWaterInfoDraws = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws"));
	int32 RenderCaptureNextWaterInfoDraws = CVarRenderCaptureNextWaterInfoDraws ? CVarRenderCaptureNextWaterInfoDraws->AsVariableInt()->GetValueOnGameThread() : 0;
	bool bPerformRenderCapture = false;
	if (RenderCaptureNextWaterInfoDraws != 0)
	{
		RenderCaptureNextWaterInfoDraws = FMath::Max(0, RenderCaptureNextWaterInfoDraws - 1);
		CVarRenderCaptureNextWaterInfoDraws->Set(RenderCaptureNextWaterInfoDraws);
		bPerformRenderCapture = true;
	}

	const FVector ZoneExtent = Context.ZoneToRender->GetDynamicWaterInfoExtent();

	FVector ViewLocation = Context.ZoneToRender->GetDynamicWaterInfoCenter();

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRenderCaptureNextWaterInfoDraws(
	TEXT("r.Water.WaterInfo.RenderCaptureNextWaterInfoDraws"),
	0,
	TEXT("Enable capturing of the water info texture for the next N draws"),
	ECVF_RenderThreadSafe);

BEGIN_SHADER_PARAMETER_STRUCT(FWaterInfoTexturePassParameters, )

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

Scope (from outer to inner):

file
function     void RenderWaterInfoTexture

Source code excerpt:

	}

	int32 RenderCaptureNextWaterInfoDraws = CVarRenderCaptureNextWaterInfoDraws.GetValueOnRenderThread();
	RenderCaptureInterface::FScopedCapture RenderCapture((RenderCaptureNextWaterInfoDraws != 0), GraphBuilder, TEXT("RenderWaterInfo"));
	if (RenderCaptureNextWaterInfoDraws != 0)
	{
		RenderCaptureNextWaterInfoDraws = FMath::Max(0, RenderCaptureNextWaterInfoDraws - 1);
		CVarRenderCaptureNextWaterInfoDraws->Set(RenderCaptureNextWaterInfoDraws);
	}
	

	TRACE_CPUPROFILER_EVENT_SCOPE(WaterInfo::RenderWaterInfoTexture);
	RDG_EVENT_SCOPE(GraphBuilder, "WaterInfoTexture");
	RDG_GPU_STAT_SCOPE(GraphBuilder, WaterInfoTexture);