bSupportsClipDistance

bSupportsClipDistance

#Overview

name: bSupportsClipDistance

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bSupportsClipDistance is to indicate whether a specific shader platform supports clip distance functionality in rendering. This variable is part of the shader compilation and rendering system in Unreal Engine 5.

Based on the callsites, this setting variable is primarily used in the Engine’s shader compiler subsystem and the RHI (Rendering Hardware Interface) module. It’s particularly relevant for platform-specific shader compilation and rendering capabilities.

The value of this variable is set in two main places:

  1. In FGenericDataDrivenShaderPlatformInfo::SetDefaultValues(), where it’s initially set to true.
  2. In FGenericDataDrivenShaderPlatformInfo::ParseDataDrivenShaderInfo(), where it can be overridden based on configuration data.

This variable interacts with other platform-specific capability flags, such as bSupportsManualVertexFetch, bSupportsVolumeTextureAtomics, and bSupportsShaderPipelines. It’s used in conjunction with these flags to determine the overall capabilities of a shader platform.

Developers must be aware that this variable affects shader compilation. When bSupportsClipDistance is true, the PLATFORM_SUPPORTS_CLIP_DISTANCE macro is defined in the shader code, which can lead to different shader code paths being compiled.

Best practices when using this variable include:

  1. Ensuring that the value is correctly set for each supported platform.
  2. Using the FDataDrivenShaderPlatformInfo::GetSupportsClipDistance() method to check the value, rather than accessing the variable directly.
  3. Being mindful of how this capability affects shader code and adjusting rendering techniques accordingly when clip distance is not supported.
  4. Considering the performance implications of using clip distance on platforms where it’s supported, as it may have varying costs on different hardware.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/Android/DataDrivenPlatformInfo.ini:66, section: [ShaderPlatform OPENGL_ES3_1_ANDROID]

Location: <Workspace>/Engine/Config/Android/DataDrivenPlatformInfo.ini:86, section: [ShaderPlatform VULKAN_ES3_1_ANDROID]

Location: <Workspace>/Engine/Config/Windows/DataDrivenPlatformInfo.ini:179, section: [ShaderPlatform OPENGL_PCES3_1]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:8364

Scope (from outer to inner):

file
function     void GlobalBeginCompileShader

Source code excerpt:


	{
		const bool bSupportsClipDistance = FDataDrivenShaderPlatformInfo::GetSupportsClipDistance((EShaderPlatform)Target.Platform);
		SET_SHADER_DEFINE(Input.Environment, PLATFORM_SUPPORTS_CLIP_DISTANCE, bSupportsClipDistance ? 1u : 0u);
	}

	{
		const bool bSupportsVertexShaderSRVs = FDataDrivenShaderPlatformInfo::GetSupportsVertexShaderSRVs((EShaderPlatform)Target.Platform);
		SET_SHADER_DEFINE(Input.Environment, PLATFORM_SUPPORTS_VERTEX_SHADER_SRVS, bSupportsVertexShaderSRVs ? 1u : 0u);
	}

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

Scope (from outer to inner):

file
function     void FGenericDataDrivenShaderPlatformInfo::SetDefaultValues

Source code excerpt:

	bSupportsManualVertexFetch = true;
	bSupportsVolumeTextureAtomics = true;
	bSupportsClipDistance = true;
	bSupportsShaderPipelines = true;
	MaxSamplers = 16;
}

void FGenericDataDrivenShaderPlatformInfo::ParseDataDrivenShaderInfo(const FConfigSection& Section, uint32 Index)
{

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

Scope (from outer to inner):

file
function     void FGenericDataDrivenShaderPlatformInfo::ParseDataDrivenShaderInfo

Source code excerpt:

	GET_SECTION_BOOL_HELPER(bSupportsSceneDataCompressedTransforms);
	GET_SECTION_BOOL_HELPER(bSupportsSwapchainUAVs);
	GET_SECTION_BOOL_HELPER(bSupportsClipDistance);
	GET_SECTION_BOOL_HELPER(bSupportsNNEShaders);
	GET_SECTION_BOOL_HELPER(bSupportsShaderPipelines);
	GET_SECTION_BOOL_HELPER(bSupportsUniformBufferObjects);
	GET_SECTION_BOOL_HELPER(bRequiresBindfulUtilityShaders);
	GET_SECTION_INT_HELPER(MaxSamplers);
	GET_SECTION_BOOL_HELPER(SupportsBarycentricsIntrinsics);

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

Scope (from outer to inner):

file
class        class FGenericDataDrivenShaderPlatformInfo

Source code excerpt:

	uint32 bIsPreviewPlatform : 1;
	uint32 bSupportsSwapchainUAVs : 1;
	uint32 bSupportsClipDistance : 1;
	uint32 bSupportsNNEShaders: 1;
	uint32 bSupportsShaderPipelines : 1;
	uint32 bSupportsUniformBufferObjects : 1;
	uint32 bRequiresBindfulUtilityShaders : 1;
	uint32 MaxSamplers : 8;
	uint32 SupportsBarycentricsIntrinsics : 1;

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

Scope (from outer to inner):

file
class        class FGenericDataDrivenShaderPlatformInfo
function     static const bool GetSupportsClipDistance

Source code excerpt:

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

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