Files
UnrealEngineUWP/Engine/Source/Developer/ShaderCompilerCommon/Private/DXCWrapper.cpp
Marcus Wassmer 3b81cf8201 Merging using //UE5/Main_to_//UE5/Release-Engine-Staging @14384769
autoresolved files
#rb none

[CL 14384911 by Marcus Wassmer in ue5-main branch]
2020-09-24 00:43:27 -04:00

66 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "DXCWrapper.h"
#include "HAL/PlatformProcess.h"
#include "Templates/RefCounting.h"
#include "Misc/Paths.h"
static TRefCountPtr<FDllHandle> GDxcHandle;
static TRefCountPtr<FDllHandle> GShaderConductorHandle;
FDllHandle::FDllHandle(const TCHAR* InFilename)
{
#if PLATFORM_WINDOWS
check(InFilename && *InFilename);
FString ShaderConductorDir = FPaths::EngineDir() / TEXT("Binaries/ThirdParty/ShaderConductor/Win64");
FString ModulePath = ShaderConductorDir / InFilename;
Handle = FPlatformProcess::GetDllHandle(*ModulePath);
checkf(Handle, TEXT("Failed to load module: %s"), *ModulePath);
#endif
}
FDllHandle::~FDllHandle()
{
if (Handle)
{
FPlatformProcess::FreeDllHandle(Handle);
Handle = nullptr;
}
}
FDxcModuleWrapper::FDxcModuleWrapper()
{
if (GDxcHandle.GetRefCount() == 0)
{
GDxcHandle = new FDllHandle(TEXT("dxcompiler.dll"));
}
else
{
GDxcHandle->AddRef();
}
}
FDxcModuleWrapper::~FDxcModuleWrapper()
{
GDxcHandle->Release();
}
FShaderConductorModuleWrapper::FShaderConductorModuleWrapper()
{
if (GShaderConductorHandle.GetRefCount() == 0)
{
GShaderConductorHandle = new FDllHandle(TEXT("ShaderConductor.dll"));
}
else
{
GShaderConductorHandle->AddRef();
}
}
FShaderConductorModuleWrapper::~FShaderConductorModuleWrapper()
{
GShaderConductorHandle->Release();
}