r.ExrReadAndProcessOnGPU
r.ExrReadAndProcessOnGPU
#Overview
name: r.ExrReadAndProcessOnGPU
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allows reading of Large Uncompressed EXR files directly into Structured Buffer.\nand be processed on GPU\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ExrReadAndProcessOnGPU is to enable reading and processing of large uncompressed EXR (OpenEXR) files directly on the GPU using a structured buffer. This setting is primarily related to the image media handling system within Unreal Engine 5.
This setting variable is utilized by the ImgMedia plugin, specifically within the ExrImgMediaReader module. The plugin is responsible for handling various image media formats, with this particular setting focusing on EXR file processing.
The value of this variable is set through a console variable (CVarEnableUncompressedExrGpuReader) and is initialized to true by default. This means that GPU-based reading and processing of uncompressed EXR files is enabled out of the box.
The associated variable CVarEnableUncompressedExrGpuReader directly interacts with r.ExrReadAndProcessOnGPU, as they share the same value and purpose. This console variable is used to control the behavior at runtime.
Developers must be aware that this feature is specifically designed for large uncompressed EXR files and is only applicable when using a D3D12 RHI (Runtime Hardware Interface). The code checks for these conditions before applying the GPU-based reading and processing.
Best practices when using this variable include:
- Ensure that the target hardware supports D3D12 for this feature to be effective.
- Monitor performance when working with large EXR files to determine if GPU processing provides a significant benefit in your specific use case.
- Be prepared to toggle this setting off (set to false) if you encounter any issues or if CPU-based processing is preferred for certain scenarios.
Regarding the associated variable CVarEnableUncompressedExrGpuReader:
This console variable is directly linked to r.ExrReadAndProcessOnGPU and serves as the programmatic interface for controlling the feature. It is defined using TAutoConsoleVariable, which allows for runtime modification of the setting.
The variable is used in the FExrImgMediaReader::GetReader function to determine whether to use the GPU-based reader (FExrImgMediaReaderGpu) or not. This decision is made based on several factors, including the RHI type, compression status of the EXR file, and whether the file is optimized for GPU processing.
Developers should be aware that changing the value of CVarEnableUncompressedExrGpuReader at runtime will affect the behavior of EXR file reading and processing in the ImgMedia plugin. It’s important to consider the performance implications and potential visual differences when toggling this setting, especially in production environments.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Media/ImgMedia/Source/ImgMedia/Private/Readers/ExrImgMediaReader.cpp:19
Scope: file
Source code excerpt:
static TAutoConsoleVariable<bool> CVarEnableUncompressedExrGpuReader(
TEXT("r.ExrReadAndProcessOnGPU"),
true,
TEXT("Allows reading of Large Uncompressed EXR files directly into Structured Buffer.\n")
TEXT("and be processed on GPU\n"));
/* FExrImgMediaReader structors
#Associated Variable and Callsites
This variable is associated with another variable named CVarEnableUncompressedExrGpuReader
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Media/ImgMedia/Source/ImgMedia/Private/Readers/ExrImgMediaReader.cpp:18
Scope: file
Source code excerpt:
DECLARE_MEMORY_STAT(TEXT("EXR Reader Pool Memory."), STAT_ExrMediaReaderPoolMem, STATGROUP_ImgMediaPlugin);
static TAutoConsoleVariable<bool> CVarEnableUncompressedExrGpuReader(
TEXT("r.ExrReadAndProcessOnGPU"),
true,
TEXT("Allows reading of Large Uncompressed EXR files directly into Structured Buffer.\n")
TEXT("and be processed on GPU\n"));
#Loc: <Workspace>/Engine/Plugins/Media/ImgMedia/Source/ImgMedia/Private/Readers/ExrImgMediaReader.cpp:370
Scope (from outer to inner):
file
function TSharedPtr<IImgMediaReader, ESPMode::ThreadSafe> FExrImgMediaReader::GetReader
Source code excerpt:
if (GDynamicRHI && GDynamicRHI->GetInterfaceType() == ERHIInterfaceType::D3D12
&& Info.CompressionName == "Uncompressed"
&& CVarEnableUncompressedExrGpuReader.GetValueOnAnyThread()
&& bIsOptimizedForGpu
)
{
TSharedRef<FExrImgMediaReaderGpu, ESPMode::ThreadSafe> GpuReader =
MakeShared<FExrImgMediaReaderGpu, ESPMode::ThreadSafe>(InLoader);
GpuReader->SetCustomFormatInfo(bIsCustomFormat, TileSize);