Files
UnrealEngineUWP/Engine/Source/Developer/ShaderCompilerCommon/Private/DXCWrapper.cpp
Marc Audy 4c1bb11c29 Merge UE5/Release-Engine-Staging to UE5/Main @ 14548662
This represents UE4/Main @ 14525125 + cherrypicked fixes
#skipundocheck

[CL 14551026 by Marc Audy in ue5-main branch]
2020-10-22 19:19:16 -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.SafeRelease();
}
FShaderConductorModuleWrapper::FShaderConductorModuleWrapper()
{
if (GShaderConductorHandle.GetRefCount() == 0)
{
GShaderConductorHandle = new FDllHandle(TEXT("ShaderConductor.dll"));
}
else
{
GShaderConductorHandle->AddRef();
}
}
FShaderConductorModuleWrapper::~FShaderConductorModuleWrapper()
{
GShaderConductorHandle.SafeRelease();
}