Files
charles bloom 83a33c6d95 TextureFormatManager better init safety
do Invalidate in your constructor so you are valid after LoadModule
in case someone tries to Load TextureFormatManager and use it other than TargetPlatform
mutex protect thread access
fixes TBW broken by previous CL on TextureFormatManager

#preflight 6269c22f4510fc7faaf8c8aa
#rb zousar.shaker

#ROBOMERGE-AUTHOR: charles.bloom
#ROBOMERGE-SOURCE: CL 19949335 via CL 19949395 via CL 19949397
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v943-19904690)

[CL 19952589 by charles bloom in ue5-main branch]
2022-04-28 02:05:06 -04:00

34 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreTypes.h"
#include "Interfaces/ITextureFormatManagerModule.h"
#include "Modules/ModuleManager.h"
/** Return the Texture Format Manager interface, if it is available, otherwise return nullptr. **/
inline ITextureFormatManagerModule* GetTextureFormatManager()
{
// GetModule , not Load. Should be loaded by TargetPlatform or Program startup on main thread.
// cannot load modules from threads so must be done before any thread needs this module
ITextureFormatManagerModule* TFMM = FModuleManager::GetModulePtr<ITextureFormatManagerModule>("TextureFormat");
if ( TFMM == nullptr )
{
UE_LOG(LogInit, Error, TEXT("Texture format manager Ptr was requested but not available."));
}
return TFMM;
}
/** Return the Texture Format Manager interface, fatal error if it is not available. **/
inline ITextureFormatManagerModule& GetTextureFormatManagerRef()
{
class ITextureFormatManagerModule* TextureFormatManager = GetTextureFormatManager();
if (!TextureFormatManager)
{
UE_LOG(LogInit, Fatal, TEXT("Texture format manager Ref was requested, but not available."));
CA_ASSUME( TextureFormatManager != NULL ); // Suppress static analysis warning in unreachable code (fatal error)
}
return *TextureFormatManager;
}