MediaIO.EnableGPUDirectInput

MediaIO.EnableGPUDirectInput

#Overview

name: MediaIO.EnableGPUDirectInput

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 MediaIO.EnableGPUDirectInput is to enable GPU direct for faster video frame copies in the MediaIO framework. This setting is experimental and is designed to improve performance in media input operations.

This setting variable is primarily used in the MediaIO framework, which is part of Unreal Engine’s media subsystem. Specifically, it is utilized in the MediaIOCore module, which is responsible for handling media input and output operations.

The value of this variable is set through a console variable (CVar) named CVarEnableGPUDirectInput. It is initialized with a default value of 0, meaning it is disabled by default. Users can change this value at runtime using console commands or through configuration files.

The associated variable CVarEnableGPUDirectInput directly interacts with MediaIO.EnableGPUDirectInput. They share the same value and purpose. This variable is used in the CanUseGPUTextureTransfer() function of the FMediaIOCorePlayerBase class to determine if GPU texture transfer should be used.

Developers must be aware of several things when using this variable:

  1. It is experimental, so it may not be stable or fully optimized.
  2. Enabling this feature might affect performance in unexpected ways, so thorough testing is recommended.
  3. It is render thread safe, meaning it can be safely accessed from the render thread.

Best practices when using this variable include:

  1. Only enable it if you need faster video frame copies and have tested its impact on your specific use case.
  2. Monitor performance carefully when enabling this feature to ensure it provides the desired benefits.
  3. Be prepared to disable it if you encounter any issues or unexpected behavior.

Regarding the associated variable CVarEnableGPUDirectInput:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Media/MediaIOFramework/Source/MediaIOCore/Private/Player/MediaIOCorePlayerBase.cpp:75

Scope (from outer to inner):

file
namespace    MediaIOCorePlayerDetail

Source code excerpt:


	static TAutoConsoleVariable<int32> CVarEnableGPUDirectInput(
		TEXT("MediaIO.EnableGPUDirectInput"), 0,
		TEXT("Whether to enable GPU direct for faster video frame copies. (Experimental)"),
		ECVF_RenderThreadSafe);
}

DECLARE_GPU_STAT_NAMED(STAT_MediaIOPlayer_JITR_TransferTexture, TEXT("JITR_TransferTexture"));

#Associated Variable and Callsites

This variable is associated with another variable named CVarEnableGPUDirectInput. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Plugins/Media/MediaIOFramework/Source/MediaIOCore/Private/Player/MediaIOCorePlayerBase.cpp:74

Scope (from outer to inner):

file
namespace    MediaIOCorePlayerDetail

Source code excerpt:

		ECVF_Cheat);

	static TAutoConsoleVariable<int32> CVarEnableGPUDirectInput(
		TEXT("MediaIO.EnableGPUDirectInput"), 0,
		TEXT("Whether to enable GPU direct for faster video frame copies. (Experimental)"),
		ECVF_RenderThreadSafe);
}

DECLARE_GPU_STAT_NAMED(STAT_MediaIOPlayer_JITR_TransferTexture, TEXT("JITR_TransferTexture"));

#Loc: <Workspace>/Engine/Plugins/Media/MediaIOFramework/Source/MediaIOCore/Private/Player/MediaIOCorePlayerBase.cpp:605

Scope (from outer to inner):

file
function     bool FMediaIOCorePlayerBase::CanUseGPUTextureTransfer

Source code excerpt:

bool FMediaIOCorePlayerBase::CanUseGPUTextureTransfer() const
{
	return GPUTextureTransfer && MediaIOCorePlayerDetail::CVarEnableGPUDirectInput.GetValueOnAnyThread();
}

bool FMediaIOCorePlayerBase::HasTextureAvailableForGPUTransfer() const
{
	FScopeLock ScopeLock(&TexturesCriticalSection);
	return !Textures.IsEmpty();