r.TextureProfiler.EnableRenderTargetCSV

r.TextureProfiler.EnableRenderTargetCSV

#Overview

name: r.TextureProfiler.EnableRenderTargetCSV

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.TextureProfiler.EnableRenderTargetCSV is to enable CSV profiler output for all Render Targets in Unreal Engine 5. This setting variable is primarily used for profiling and debugging the rendering system, specifically for tracking the memory usage and allocation of render targets.

This setting variable is relied upon by the RHI (Rendering Hardware Interface) module of Unreal Engine 5, as evidenced by its implementation in the TextureProfiler.cpp file within the RHI source code.

The value of this variable is set through a console variable (CVarTextureProfilerEnableRenderTargetCSV) using the TAutoConsoleVariable template. It is initialized with a default value of true, meaning the CSV profiler output for render targets is enabled by default.

This variable interacts closely with another variable named CVarTextureProfilerEnableTextureCSV, which serves a similar purpose but for textures instead of render targets. They are often used together to provide a comprehensive view of texture and render target usage in the engine.

Developers must be aware that enabling this variable will impact performance due to the additional overhead of collecting and outputting profiling data. It should primarily be used for debugging and optimization purposes, not in shipping builds.

Best practices when using this variable include:

  1. Only enable it when actively profiling render target usage.
  2. Use it in conjunction with CVarTextureProfilerEnableTextureCSV for a complete picture of texture memory usage.
  3. Be mindful of the performance impact when enabled.
  4. Analyze the resulting CSV output to identify potential memory optimizations in render target usage.

Regarding the associated variable CVarTextureProfilerEnableRenderTargetCSV:

This is the actual console variable that controls the r.TextureProfiler.EnableRenderTargetCSV setting. It is used internally by the engine to check whether render target profiling should be performed. The variable is checked in the FTextureProfiler::Update function to determine if profiling data should be collected and reported for render targets.

When using this variable, developers should:

  1. Access its value using the GetValueOnAnyThread() method when needed.
  2. Be aware that changing this value at runtime will immediately affect the profiling behavior.
  3. Use it in conjunction with FCsvProfiler to ensure profiling data is captured only when necessary.

In summary, both r.TextureProfiler.EnableRenderTargetCSV and its associated CVarTextureProfilerEnableRenderTargetCSV are crucial tools for profiling and optimizing render target usage in Unreal Engine 5, but should be used judiciously due to their potential performance impact.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/TextureProfiler.cpp:49

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarTextureProfilerEnableRenderTargetCSV(
	TEXT("r.TextureProfiler.EnableRenderTargetCSV"),
	true,
	TEXT("True to enable csv profiler output for all Render Targets."));

static FAutoConsoleCommand CmdTextureProfilerDumpRenderTargets(
	TEXT("r.TextureProfiler.DumpRenderTargets"),
	TEXT("Dumps all render targets allocated by the RHI.\n")

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/TextureProfiler.cpp:48

Scope: file

Source code excerpt:

	TEXT("True to enable csv profiler output for all textures.  Does not include render targets."));

static TAutoConsoleVariable<bool> CVarTextureProfilerEnableRenderTargetCSV(
	TEXT("r.TextureProfiler.EnableRenderTargetCSV"),
	true,
	TEXT("True to enable csv profiler output for all Render Targets."));

static FAutoConsoleCommand CmdTextureProfilerDumpRenderTargets(
	TEXT("r.TextureProfiler.DumpRenderTargets"),

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/TextureProfiler.cpp:314

Scope (from outer to inner):

file
function     void FTextureProfiler::Update

Source code excerpt:

	check(IsInRenderingThread());

	if (FCsvProfiler::Get()->IsCapturing_Renderthread() && !CVarTextureProfilerEnableRenderTargetCSV.GetValueOnAnyThread() && !CVarTextureProfilerEnableTextureCSV.GetValueOnAnyThread())
	{
		return;
	}

	FScopeLock Lock(&TextureMapCS);
	

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/TextureProfiler.cpp:348

Scope (from outer to inner):

file
function     void FTextureProfiler::Update

Source code excerpt:

		}

		ReportTextureStat(CVarTextureProfilerEnableRenderTargetCSV, Pair.Value.GetTextureNameString(), CSV_CATEGORY_INDEX(RenderTargetProfiler), ToMB(Pair.Value.PeakSize), ECsvCustomStatOp::Set);
		ReportTextureStat(CVarTextureProfilerEnableRenderTargetCSV, Pair.Value.GetTextureNameString(), CSV_CATEGORY_INDEX(RenderTargetWasteProfiler), ToMB(Pair.Value.AllocationWaste), ECsvCustomStatOp::Set);

		Pair.Value.ResetPeakSize();
	}

	FTextureDetails OtherTextureSizes;
	for (auto& Pair : CombinedTextureSizes)

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/TextureProfiler.cpp:370

Scope (from outer to inner):

file
function     void FTextureProfiler::Update

Source code excerpt:

	}

	ReportTextureStat(CVarTextureProfilerEnableRenderTargetCSV, "Total", CSV_CATEGORY_INDEX(RenderTargetProfiler), ToMB(TotalRenderTargetSize.PeakSize), ECsvCustomStatOp::Set);
	ReportTextureStat(CVarTextureProfilerEnableRenderTargetCSV, "Total", CSV_CATEGORY_INDEX(RenderTargetWasteProfiler), ToMB(TotalRenderTargetSize.AllocationWaste), ECsvCustomStatOp::Set);
	ReportTextureStat(CVarTextureProfilerEnableRenderTargetCSV, "Other", CSV_CATEGORY_INDEX(RenderTargetProfiler), ToMB(OtherRenderTargetSizes.PeakSize), ECsvCustomStatOp::Set);
	ReportTextureStat(CVarTextureProfilerEnableRenderTargetCSV, "Other", CSV_CATEGORY_INDEX(RenderTargetWasteProfiler), ToMB(OtherRenderTargetSizes.AllocationWaste), ECsvCustomStatOp::Set);

	ReportTextureStat(CVarTextureProfilerEnableTextureCSV, "Total", CSV_CATEGORY_INDEX(TextureProfiler), ToMB(TotalTextureSize.PeakSize), ECsvCustomStatOp::Set);
	ReportTextureStat(CVarTextureProfilerEnableTextureCSV, "Total", CSV_CATEGORY_INDEX(TextureWasteProfiler), ToMB(TotalTextureSize.AllocationWaste), ECsvCustomStatOp::Set);
	ReportTextureStat(CVarTextureProfilerEnableTextureCSV, "Other", CSV_CATEGORY_INDEX(TextureProfiler), ToMB(OtherTextureSizes.PeakSize), ECsvCustomStatOp::Set);
	ReportTextureStat(CVarTextureProfilerEnableTextureCSV, "Other", CSV_CATEGORY_INDEX(TextureWasteProfiler), ToMB(OtherTextureSizes.AllocationWaste), ECsvCustomStatOp::Set);