NumberOfComputeThreads

NumberOfComputeThreads

#Overview

name: NumberOfComputeThreads

The value of this variable can be defined or overridden in .ini config files. 2 .ini config files referencing this setting variable.

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of NumberOfComputeThreads is to specify the number of compute threads supported by a specific shader platform in Unreal Engine 5. This setting is crucial for the rendering system, particularly for compute shader operations.

This setting variable is primarily used within the RHI (Rendering Hardware Interface) module of Unreal Engine 5. It is part of the FGenericDataDrivenShaderPlatformInfo class, which provides information about various shader platforms.

The value of this variable is set during the parsing of data-driven shader information. This occurs in the ParseDataDrivenShaderInfo function within the DataDrivenShaderPlatformInfo.cpp file.

NumberOfComputeThreads interacts with other shader platform-specific variables such as bSupportsVariableRateShading, bIsSPIRV, and others within the FGenericDataDrivenShaderPlatformInfo class. These variables collectively define the capabilities and characteristics of a specific shader platform.

Developers must be aware that this variable is platform-specific and its value may vary depending on the target hardware. It’s stored as a 10-bit unsigned integer, limiting its maximum value to 1023.

Best practices when using this variable include:

  1. Always check if the shader platform is valid before accessing this value.
  2. Use the provided static function GetNumberOfComputeThreads() to retrieve the value, rather than accessing the member variable directly.
  3. Consider the NumberOfComputeThreads when designing compute shaders to optimize performance for different platforms.
  4. Be aware of the maximum possible value (1023) due to the bit-field implementation.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/VulkanPC/DataDrivenPlatformInfo.ini:117, section: [ShaderPlatform VULKAN_SM5]

Location: <Workspace>/Engine/Config/VulkanPC/DataDrivenPlatformInfo.ini:235, section: [ShaderPlatform VULKAN_SM6]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/DataDrivenShaderPlatformInfo.cpp:265

Scope (from outer to inner):

file
function     void FGenericDataDrivenShaderPlatformInfo::ParseDataDrivenShaderInfo

Source code excerpt:

	GET_SECTION_BOOL_HELPER(bSupportsVariableRateShading);
	GET_SECTION_BOOL_HELPER(bIsSPIRV);
	GET_SECTION_INT_HELPER(NumberOfComputeThreads);

	GET_SECTION_BOOL_HELPER(bWaterUsesSimpleForwardShading);
	GET_SECTION_BOOL_HELPER(bSupportsHairStrandGeometry);
	GET_SECTION_BOOL_HELPER(bSupportsDOFHybridScattering);
	GET_SECTION_BOOL_HELPER(bNeedsExtraMobileFrames);
	GET_SECTION_BOOL_HELPER(bSupportsHZBOcclusion);

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/DataDrivenShaderPlatformInfo.h:89

Scope (from outer to inner):

file
class        class FGenericDataDrivenShaderPlatformInfo

Source code excerpt:

	uint32 bIsSPIRV : 1;
	uint32 bSupportsVariableRateShading : 1;
	uint32 NumberOfComputeThreads : 10;
	uint32 bWaterUsesSimpleForwardShading : 1;
	uint32 bSupportsHairStrandGeometry : 1;
	uint32 bSupportsDOFHybridScattering : 1;
	uint32 bNeedsExtraMobileFrames : 1;
	uint32 bSupportsHZBOcclusion : 1;
	uint32 bSupportsWaterIndirectDraw : 1;

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/DataDrivenShaderPlatformInfo.h:617

Scope (from outer to inner):

file
class        class FGenericDataDrivenShaderPlatformInfo
function     static const uint32 GetNumberOfComputeThreads

Source code excerpt:

	{
		check(IsValid(Platform));
		return Infos[Platform].NumberOfComputeThreads;
	}

	static FORCEINLINE_DEBUGGABLE const bool GetWaterUsesSimpleForwardShading(const FStaticShaderPlatform Platform)
	{
		check(IsValid(Platform));
		return Infos[Platform].bWaterUsesSimpleForwardShading;