r.Shaders.SkipCompression

r.Shaders.SkipCompression

#Overview

name: r.Shaders.SkipCompression

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.Shaders.SkipCompression is to control shader compression after compilation. It is primarily used in the rendering system of Unreal Engine 5, specifically in the shader compilation and management process.

This setting variable is relied upon by the RenderCore module, which is a core component of Unreal Engine’s rendering system. It’s used in shader resource management and compilation processes.

The value of this variable is set through a console variable (CVar) system, allowing it to be modified at runtime. It’s defined as a TAutoConsoleVariable with an initial value of 0, meaning shader compression is enabled by default.

This variable interacts with the Oodle compression system used for shaders. When r.Shaders.SkipCompression is enabled, it doesn’t actually skip compression entirely but instead configures Oodle to use no compression (Selkie compressor with compression level None).

Developers must be aware that:

  1. This variable is only valid in non-shipping and non-test builds, as indicated by the ECVF_Cheat flag.
  2. It’s marked as read-only (ECVF_ReadOnly), suggesting it should not be modified during gameplay.
  3. Skipping shader compression can significantly reduce shader compilation time, especially when using debug shaders.

Best practices when using this variable include:

  1. Use it only during development and debugging, never in shipping builds.
  2. Be cautious about performance implications when enabling it, as uncompressed shaders may consume more memory.
  3. Consider enabling it temporarily when iterating on shader development to speed up the compilation process.
  4. Remember to disable it before final builds or performance testing, as it may not represent real-world performance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:91

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSkipShaderCompression(
	TEXT("r.Shaders.SkipCompression"),
	0,
	TEXT("Skips shader compression after compiling. Shader compression time can be quite significant when using debug shaders. This CVar is only valid in non-shipping/test builds."),
	ECVF_ReadOnly | ECVF_Cheat
	);

static TAutoConsoleVariable<int32> CVarAllowCompilingThroughWorkers(

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderResource.cpp:50

Scope (from outer to inner):

file
function     void GetShaderCompressionOodleSettings

Source code excerpt:

#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	// Since we always use Oodle, we make SkipCompression tell Oodle to not compress.
	static const IConsoleVariable* CVarSkipCompression = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Shaders.SkipCompression"));
	static bool bSkipCompression = (CVarSkipCompression && CVarSkipCompression->GetInt() != 0);
	if (UNLIKELY(bSkipCompression))
	{
		OutCompressor = FOodleDataCompression::ECompressor::Selkie;
		OutLevel = FOodleDataCompression::ECompressionLevel::None;
		return;

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Public/ShaderCore.h:143

Scope: file

Source code excerpt:

extern RENDERCORE_API bool AllowDebugViewmodes(EShaderPlatform Platform);

/** Returns the shader compression format. Oodle is used exclusively now. r.Shaders.SkipCompression configures Oodle to be uncompressed instead of returning NAME_None.*/
extern RENDERCORE_API FName GetShaderCompressionFormat();

/** Returns Oodle-specific shader compression format settings (passing ShaderFormat for future proofing, but as of now the setting is global for all formats). */
extern RENDERCORE_API void GetShaderCompressionOodleSettings(FOodleDataCompression::ECompressor& OutCompressor, FOodleDataCompression::ECompressionLevel& OutLevel, const FName& ShaderFormat = NAME_None);

struct FShaderTarget