r.VT.ParallelTileCompression

r.VT.ParallelTileCompression

#Overview

name: r.VT.ParallelTileCompression

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.VT.ParallelTileCompression is to control the parallel compression of macro tiles in Unreal Engine’s Virtual Texturing system. This setting variable is designed to optimize the performance of texture compression in the rendering pipeline.

This setting variable is primarily used in the Virtual Texturing (VT) subsystem of Unreal Engine’s rendering module. Based on the callsites, it’s specifically utilized in the VirtualTextureDataBuilder component.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, which means parallel tile compression is enabled by default.

The associated variable CVarVTParallelTileCompression interacts directly with r.VT.ParallelTileCompression. They share the same value and purpose.

Developers must be aware that this variable affects the performance of texture compression. Enabling parallel compression (value 1) can potentially speed up the process, especially on systems with multiple cores. However, it might also increase memory usage during compression.

Best practices when using this variable include:

  1. Leave it enabled (value 1) for most scenarios, as it’s the default and likely optimized for general use.
  2. If experiencing memory issues during texture compression, consider disabling it (set to 0) to trade off speed for lower memory usage.
  3. Profile your specific use case to determine if parallel compression provides a significant benefit for your project.

Regarding the associated variable CVarVTParallelTileCompression:

The purpose of CVarVTParallelTileCompression is to provide a programmatic way to access and modify the r.VT.ParallelTileCompression setting within the C++ code.

This variable is used in the Engine module, specifically in the VirtualTextureDataBuilder component. It’s accessed in the Build function of FVirtualTextureDataBuilder to determine whether async compression should be allowed.

The value of CVarVTParallelTileCompression is set using the TAutoConsoleVariable template, which ties it to the r.VT.ParallelTileCompression console variable.

CVarVTParallelTileCompression directly interacts with the bAllowAsync flag in the Build function, potentially overriding its value based on the console variable setting.

Developers should be aware that changing CVarVTParallelTileCompression at runtime will affect the behavior of the VirtualTextureDataBuilder. It’s important to consider the implications on performance and memory usage when modifying this value.

Best practices for using CVarVTParallelTileCompression include:

  1. Use GetValueOnAnyThread() when accessing the value, as shown in the code example, to ensure thread-safe access.
  2. Consider the context in which you’re using this variable. In performance-critical sections, you might want to cache the value rather than querying it repeatedly.
  3. If you need to change this value programmatically, ensure you understand the implications on the Virtual Texturing system’s performance and memory usage.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/VirtualTextureDataBuilder.cpp:24

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarVTParallelTileCompression(
	TEXT("r.VT.ParallelTileCompression"),
	1,
	TEXT("Enables parallel compression of macro tiles")
);

/*
 * Just a simple helper struct wrapping a pointer to an image in some source format.

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/VirtualTextureDataBuilder.cpp:23

Scope: file

Source code excerpt:

#endif

static TAutoConsoleVariable<int32> CVarVTParallelTileCompression(
	TEXT("r.VT.ParallelTileCompression"),
	1,
	TEXT("Enables parallel compression of macro tiles")
);

/*

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/VT/VirtualTextureDataBuilder.cpp:371

Scope (from outer to inner):

file
function     bool FVirtualTextureDataBuilder::Build

Source code excerpt:


	// override async compression if requested
	bAllowAsync = bAllowAsync && CVarVTParallelTileCompression.GetValueOnAnyThread();

	LayerPayload.SetNum(NumLayers);

	{
		FScopedSlowTask BuildTask(NumLayers * NumBlocks);