UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
OpenGLShaders.cpp File Reference

Classes

class  FOpenGLBinaryCacheStats
 
class  FOpenGLCompiledShaderValue
 
struct  FOpenGLUniformName
 
class  FOpenGLLinkedProgramBase
 
class  FOpenGLLinkedProgram
 
struct  FOpenGLLinkedProgram::FPackedUniformInfo
 
struct  FOpenGLLinkedProgram::FShaderStage
 
struct  FOpenGLLinkedProgram::FGraphicsProgram
 
struct  FOpenGLLinkedProgram::FComputeProgram
 
class  FOpenGLLinkedProgram::FLRUInfo
 
class  FGLProgramCacheLRU
 
class  FGLProgramCache
 
struct  FOpenGLShaderVaryingMapping
 

Namespaces

namespace  UE
 
namespace  UE::OpenGL
 

Macros

#define VERIFY_GL_SHADER_LINK   1
 
#define VERIFY_GL_SHADER_COMPILE   1
 
#define OGL_BINARYCACHE_STATS   !UE_BUILD_SHIPPING
 
#define OGL_BINARYCACHE_STATS_MARKBEGINCOMPILE(x)   if(FOpenGLBinaryCacheStats::IsEnabled()) { FOpenGLBinaryCacheStats::Get().MarkStartTime(x);}
 
#define OGL_BINARYCACHE_STATS_MARKCOMPILED(x)   if(FOpenGLBinaryCacheStats::IsEnabled()) { FOpenGLBinaryCacheStats::Get().MarkCompileFinishTime(x);}
 
#define OGL_BINARYCACHE_STATS_MARKBINARYCACHEMISS(x, y)   if(FOpenGLBinaryCacheStats::IsEnabled()) { FOpenGLBinaryCacheStats::Get().MarkCacheMissedTime(x,y);}
 
#define OGL_BINARYCACHE_STATS_MARKBINARYCACHEUSE(x)   if(FOpenGLBinaryCacheStats::IsEnabled()) { FOpenGLBinaryCacheStats::Get().MarkCacheUse(x);}
 
#define OGL_BINARYCACHE_STATS_LOG()   if(FOpenGLBinaryCacheStats::IsEnabled()) { FOpenGLBinaryCacheStats::Get().LogStats();}
 
#define LAST_RELEASED_PROGRAMS_CACHE_COUNT   10
 
#define PROGRAM_BINARY_RETRIEVABLE_HINT   0x8257
 

Typedefs

typedef TMap< FOpenGLCompiledShaderKey, FOpenGLCompiledShaderValueFOpenGLCompiledShaderCache
 

Functions

bool IsPrecachingEnabled ()
 
void PE_AppendCString (TArray< ANSICHAR > &Dest, const ANSICHAR *Source)
 
void PE_ReplaceCString (TArray< ANSICHAR > &Dest, const ANSICHAR *Source, const ANSICHAR *Replacement)
 
uint32 GetTypeHash (FAnsiCharArray const &CharArray)
 
void OPENGLDRV_API GetCurrentOpenGLShaderDeviceCapabilities (FOpenGLShaderDeviceCapabilities &Capabilities)
 
void OPENGLDRV_API GLSLToDeviceCompatibleGLSL (FAnsiCharArray &GlslCodeOriginal, const FString &ShaderName, GLenum TypeEnum, const FOpenGLShaderDeviceCapabilities &Capabilities, FAnsiCharArray &GlslCode)
 
bool UE::OpenGL::CreateGLProgramFromBinary (GLuint &ProgramOUT, const TArrayView< const uint8 > &ProgramBinary)
 
void DestroyShadersAndPrograms ()
 
void UE::OpenGL::OnGLProgramLoadedFromBinaryCache (const FOpenGLProgramKey &ProgramKey, TUniqueObj< FOpenGLProgramBinary > &&ProgramBinaryData)
 

Variables

int32 GUntouchedProgramEvictTimeSeconds = 0
 
int32 GProgramLRUResidentCountBeforeEviction = 300
 
const uint32 SizeOfFloat4 = 16
 
const uint32 NumFloatsInFloat4 = 4
 

Macro Definition Documentation

◆ LAST_RELEASED_PROGRAMS_CACHE_COUNT

#define LAST_RELEASED_PROGRAMS_CACHE_COUNT   10

◆ OGL_BINARYCACHE_STATS

#define OGL_BINARYCACHE_STATS   !UE_BUILD_SHIPPING

◆ OGL_BINARYCACHE_STATS_LOG

#define OGL_BINARYCACHE_STATS_LOG ( )    if(FOpenGLBinaryCacheStats::IsEnabled()) { FOpenGLBinaryCacheStats::Get().LogStats();}

◆ OGL_BINARYCACHE_STATS_MARKBEGINCOMPILE

#define OGL_BINARYCACHE_STATS_MARKBEGINCOMPILE (   x)    if(FOpenGLBinaryCacheStats::IsEnabled()) { FOpenGLBinaryCacheStats::Get().MarkStartTime(x);}

◆ OGL_BINARYCACHE_STATS_MARKBINARYCACHEMISS

#define OGL_BINARYCACHE_STATS_MARKBINARYCACHEMISS (   x,
 
)    if(FOpenGLBinaryCacheStats::IsEnabled()) { FOpenGLBinaryCacheStats::Get().MarkCacheMissedTime(x,y);}

◆ OGL_BINARYCACHE_STATS_MARKBINARYCACHEUSE

#define OGL_BINARYCACHE_STATS_MARKBINARYCACHEUSE (   x)    if(FOpenGLBinaryCacheStats::IsEnabled()) { FOpenGLBinaryCacheStats::Get().MarkCacheUse(x);}

◆ OGL_BINARYCACHE_STATS_MARKCOMPILED

#define OGL_BINARYCACHE_STATS_MARKCOMPILED (   x)    if(FOpenGLBinaryCacheStats::IsEnabled()) { FOpenGLBinaryCacheStats::Get().MarkCompileFinishTime(x);}

◆ PROGRAM_BINARY_RETRIEVABLE_HINT

#define PROGRAM_BINARY_RETRIEVABLE_HINT   0x8257

◆ VERIFY_GL_SHADER_COMPILE

#define VERIFY_GL_SHADER_COMPILE   1

◆ VERIFY_GL_SHADER_LINK

#define VERIFY_GL_SHADER_LINK   1

Typedef Documentation

◆ FOpenGLCompiledShaderCache

Function Documentation

◆ DestroyShadersAndPrograms()

void DestroyShadersAndPrograms ( )

◆ GetCurrentOpenGLShaderDeviceCapabilities()

void OPENGLDRV_API GetCurrentOpenGLShaderDeviceCapabilities ( FOpenGLShaderDeviceCapabilities Capabilities)

Gets the GL device capabilities for the current device.

Parameters
Capabilities[out] The current platform's capabilities on device for shader compiling

◆ GetTypeHash()

uint32 GetTypeHash ( FAnsiCharArray const &  CharArray)
inline

◆ GLSLToDeviceCompatibleGLSL()

void OPENGLDRV_API GLSLToDeviceCompatibleGLSL ( FAnsiCharArray GlslCodeOriginal,
const FString &  ShaderName,
GLenum  TypeEnum,
const FOpenGLShaderDeviceCapabilities Capabilities,
FAnsiCharArray GlslCode 
)

Processes the GLSL output of the shader cross compiler to get GLSL that can be compiled on a platform with the specified capabilities. Works around inconsistencies between OpenGL implementations, including lack of support for certain extensions and drivers with non-conformant behavior.

Parameters
GlslCodeOriginal- [in,out] GLSL output from shader cross compiler to be modified. Process is destructive; pass in a copy if still need original!
ShaderName- [in] Shader name
TypeEnum- [in] Type of shader (GL_[VERTEX, FRAGMENT, GEOMETRY, TESS_CONTROL, TESS_EVALUATION]_SHADER)
Capabilities- [in] GL Device capabilities
GlslCode- [out] Compilable GLSL

◆ IsPrecachingEnabled()

bool IsPrecachingEnabled ( )

◆ PE_AppendCString()

void PE_AppendCString ( TArray< ANSICHAR > &  Dest,
const ANSICHAR Source 
)

◆ PE_ReplaceCString()

void PE_ReplaceCString ( TArray< ANSICHAR > &  Dest,
const ANSICHAR Source,
const ANSICHAR Replacement 
)

Variable Documentation

◆ GProgramLRUResidentCountBeforeEviction

int32 GProgramLRUResidentCountBeforeEviction = 300

◆ GUntouchedProgramEvictTimeSeconds

int32 GUntouchedProgramEvictTimeSeconds = 0

◆ NumFloatsInFloat4

const uint32 NumFloatsInFloat4 = 4

◆ SizeOfFloat4

const uint32 SizeOfFloat4 = 16