Files
UnrealEngineUWP/Engine/Source/Runtime/AVEncoder/Private/Encoders/NVENC/NVENC_Common.h
aurel cordonnier e0ad4e25df Merge from Release-Engine-Test @ 16624776 to UE5/Main
This represents UE4/Main @ 16579691 and Dev-PerfTest @ 16579576

[CL 16625248 by aurel cordonnier in ue5-main branch]
2021-06-10 13:13:24 -04:00

72 lines
1.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include <CoreMinimal.h>
#include <HAL/Thread.h>
#if PLATFORM_DESKTOP && !PLATFORM_APPLE
THIRD_PARTY_INCLUDES_START
#if PLATFORM_WINDOWS
#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/PreWindowsApi.h"
#endif
#include <nvEncodeAPI.h>
#if PLATFORM_WINDOWS
#include "Windows/PostWindowsApi.h"
#include "Windows/HideWindowsPlatformTypes.h"
#endif
THIRD_PARTY_INCLUDES_END
// helper macro to define and clear NVENC structures
// also sets the struct version number
#define NVENCStruct(OfType, VarName) \
OfType VarName; \
FMemory::Memzero(VarName); \
VarName.version = OfType ## _VER
namespace AVEncoder
{
class FNVENCCommon : public NV_ENCODE_API_FUNCTION_LIST
{
public:
// attempt to load NVENC
static FNVENCCommon& Setup();
// shutdown - release loaded dll
static void Shutdown();
bool GetIsAvailable() const { return bIsAvailable; }
FString GetErrorString(void* Encoder, NVENCSTATUS ForStatus)
{
const char* LastError = nvEncGetLastErrorString(Encoder);
if (LastError)
{
return FString::Format(TEXT("error {0} ('{1}')"), { ForStatus, UTF8_TO_TCHAR(LastError) });
}
return FString("Error getting error string! Is NVENC configured correctly?");
}
private:
FNVENCCommon() = default;
void SetupNVENCFunctions();
static FCriticalSection ProtectSingleton;
static FNVENCCommon Singleton;
void* DllHandle = nullptr;
bool bIsAvailable = false;
bool bWasSetUp = false;
};
} /* namespace AVEncoder */
#endif // PLATFORM_DESKTOP && !PLATFORM_APPLE