r.TexturesComputeChannelMinMaxDuringSave

r.TexturesComputeChannelMinMaxDuringSave

#Overview

name: r.TexturesComputeChannelMinMaxDuringSave

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.TexturesComputeChannelMinMaxDuringSave is to control whether textures determine per-channel minimum and maximum values during the saving process for early format computation. This setting variable is primarily used in the texture processing and saving system of Unreal Engine.

This setting variable is utilized in the Engine module, specifically within the texture handling subsystem. Based on the callsites, it’s clear that this variable is used in the texture saving process.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, meaning the feature is disabled by default. Developers can change this value through console commands or configuration files.

The associated variable CVarTexturesComputeChannelMinMaxDuringSave directly interacts with r.TexturesComputeChannelMinMaxDuringSave. They share the same value and purpose.

Developers must be aware that enabling this variable (setting it to a non-zero value) will cause the engine to compute per-channel minimum and maximum values for textures during the saving process. This can have performance implications, as it requires additional processing time when saving textures.

Best practices when using this variable include:

  1. Only enable it when necessary, as it can increase texture save times.
  2. Consider the performance impact on larger projects with many textures.
  3. Use it in conjunction with other texture optimization techniques for best results.

Regarding the associated variable CVarTexturesComputeChannelMinMaxDuringSave:

The purpose of CVarTexturesComputeChannelMinMaxDuringSave is identical to r.TexturesComputeChannelMinMaxDuringSave. It’s the actual console variable that controls the behavior.

This variable is used in the Engine module, specifically in the texture saving process. It’s referenced in the UTexture::PreSave function, which is called before a texture is saved.

The value is set through the console variable system, initialized with a default value of 0.

CVarTexturesComputeChannelMinMaxDuringSave directly controls the behavior of updating channel linear min/max values during texture saving.

Developers should be aware that this variable is marked as ECVF_ReadOnly, meaning its value should not be changed at runtime. It’s intended to be set before the engine starts or through configuration files.

Best practices for using CVarTexturesComputeChannelMinMaxDuringSave include:

  1. Set it in project configuration files if you want to enable this feature project-wide.
  2. Be cautious about enabling it in large projects, as it can significantly increase texture save times.
  3. Use it in combination with other texture optimization settings for optimal results.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Texture.cpp:80

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarTexturesComputeChannelMinMaxDuringSave(
	TEXT("r.TexturesComputeChannelMinMaxDuringSave"),
	0,
	TEXT("Whether textures determine per channel min/max on save for early format computation."),
	ECVF_ReadOnly);

// GSkipInvalidDXTDimensions prevents crash with non-4x4 aligned DXT
// if the Texture code is working correctly, this should not be necessary

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Texture.cpp:79

Scope: file

Source code excerpt:

	ECVF_Default);

static TAutoConsoleVariable<int32> CVarTexturesComputeChannelMinMaxDuringSave(
	TEXT("r.TexturesComputeChannelMinMaxDuringSave"),
	0,
	TEXT("Whether textures determine per channel min/max on save for early format computation."),
	ECVF_ReadOnly);

// GSkipInvalidDXTDimensions prevents crash with non-4x4 aligned DXT

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Texture.cpp:1341

Scope (from outer to inner):

file
function     void UTexture::PreSave

Source code excerpt:

	{
		if (Source.LayerColorInfo.Num() == 0 &&
			CVarTexturesComputeChannelMinMaxDuringSave.GetValueOnGameThread())
		{
			// Decompresses and scans the texture.
			Source.UpdateChannelLinearMinMax();
		}

		GWarn->StatusUpdate(0, 0, FText::Format(NSLOCTEXT("UnrealEd", "SavingPackage_CompressingSourceArt", "Compressing source art for texture:  {0}"), FText::FromString(GetName())));