You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb Lukas.Hermanns [FYI] Dmitriy.Dyomin #ROBOMERGE-OWNER: carl.lloyd #ROBOMERGE-AUTHOR: carl.lloyd #ROBOMERGE-SOURCE: CL 18309759 via CL 18309767 via CL 18310351 via CL 18310386 via CL 18310920 via CL 18310950 via CL 18312599 via CL 18312697 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469) [CL 18312969 by carl lloyd in ue5-release-engine-test branch]
132 lines
3.4 KiB
C++
132 lines
3.4 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "VulkanShaderFormat.h"
|
|
#include "VulkanCommon.h"
|
|
#include "Modules/ModuleInterface.h"
|
|
#include "Modules/ModuleManager.h"
|
|
#include "Interfaces/IShaderFormat.h"
|
|
#include "Interfaces/IShaderFormatModule.h"
|
|
#include "hlslcc.h"
|
|
#include "ShaderCore.h"
|
|
#include "ShaderCompilerCore.h"
|
|
#include "DXCWrapper.h"
|
|
#include "ShaderConductorContext.h"
|
|
|
|
static FName NAME_VULKAN_ES3_1_ANDROID(TEXT("SF_VULKAN_ES31_ANDROID"));
|
|
static FName NAME_VULKAN_ES3_1(TEXT("SF_VULKAN_ES31"));
|
|
static FName NAME_VULKAN_SM5(TEXT("SF_VULKAN_SM5"));
|
|
static FName NAME_VULKAN_SM5_ANDROID(TEXT("SF_VULKAN_SM5_ANDROID"));
|
|
|
|
class FShaderFormatVulkan : public IShaderFormat
|
|
{
|
|
enum
|
|
{
|
|
UE_SHADER_VULKAN_ES3_1_VER = 34,
|
|
UE_SHADER_VULKAN_SM5_VER = 34,
|
|
};
|
|
|
|
int32 InternalGetVersion(FName Format) const
|
|
{
|
|
if (Format == NAME_VULKAN_SM5 || Format == NAME_VULKAN_SM5_ANDROID)
|
|
{
|
|
return UE_SHADER_VULKAN_SM5_VER;
|
|
}
|
|
else if (Format == NAME_VULKAN_ES3_1_ANDROID || Format == NAME_VULKAN_ES3_1)
|
|
{
|
|
return UE_SHADER_VULKAN_ES3_1_VER;
|
|
}
|
|
|
|
check(0);
|
|
return -1;
|
|
}
|
|
|
|
uint32 ShaderConductorVersionHash;
|
|
|
|
public:
|
|
|
|
FShaderFormatVulkan(uint32 InShaderConductorVersionHash)
|
|
: ShaderConductorVersionHash(InShaderConductorVersionHash)
|
|
{
|
|
}
|
|
|
|
virtual uint32 GetVersion(FName Format) const override
|
|
{
|
|
uint32 Version = HashCombine(GetTypeHash(HLSLCC_VersionMajor), GetTypeHash(HLSLCC_VersionMinor));
|
|
Version = HashCombine(Version, GetTypeHash(InternalGetVersion(Format)));
|
|
Version = HashCombine(Version, GetTypeHash(ShaderConductorVersionHash));
|
|
|
|
#if VULKAN_ENABLE_BINDING_DEBUG_NAMES
|
|
Version = HashCombine(Version, 0xFC0848E2);
|
|
#endif
|
|
|
|
return Version;
|
|
}
|
|
virtual void GetSupportedFormats(TArray<FName>& OutFormats) const
|
|
{
|
|
OutFormats.Add(NAME_VULKAN_SM5);
|
|
OutFormats.Add(NAME_VULKAN_ES3_1_ANDROID);
|
|
OutFormats.Add(NAME_VULKAN_ES3_1);
|
|
OutFormats.Add(NAME_VULKAN_SM5_ANDROID);
|
|
}
|
|
|
|
virtual void CompileShader(FName Format, const struct FShaderCompilerInput& Input, struct FShaderCompilerOutput& Output,const FString& WorkingDirectory) const
|
|
{
|
|
check(InternalGetVersion(Format) >= 0);
|
|
if (Format == NAME_VULKAN_ES3_1)
|
|
{
|
|
DoCompileVulkanShader(Input, Output, WorkingDirectory, EVulkanShaderVersion::ES3_1);
|
|
}
|
|
else if (Format == NAME_VULKAN_ES3_1_ANDROID)
|
|
{
|
|
DoCompileVulkanShader(Input, Output, WorkingDirectory, EVulkanShaderVersion::ES3_1_ANDROID);
|
|
}
|
|
else if (Format == NAME_VULKAN_SM5 || Format == NAME_VULKAN_SM5_ANDROID)
|
|
{
|
|
DoCompileVulkanShader(Input, Output, WorkingDirectory, EVulkanShaderVersion::SM5);
|
|
}
|
|
}
|
|
|
|
virtual const TCHAR* GetPlatformIncludeDirectory() const
|
|
{
|
|
return TEXT("Vulkan");
|
|
}
|
|
|
|
virtual bool UsesHLSLcc(const struct FShaderCompilerInput& Input) const override
|
|
{
|
|
return !Input.Environment.CompilerFlags.Contains(CFLAG_ForceDXC);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Module for Vulkan shaders
|
|
*/
|
|
|
|
static IShaderFormat* Singleton = nullptr;
|
|
|
|
class FVulkanShaderFormatModule : public IShaderFormatModule, public FShaderConductorModuleWrapper
|
|
{
|
|
public:
|
|
virtual ~FVulkanShaderFormatModule()
|
|
{
|
|
delete Singleton;
|
|
Singleton = nullptr;
|
|
}
|
|
|
|
virtual IShaderFormat* GetShaderFormat()
|
|
{
|
|
if (!Singleton)
|
|
{
|
|
Singleton = new FShaderFormatVulkan(FShaderConductorModuleWrapper::GetModuleVersionHash());
|
|
}
|
|
|
|
return Singleton;
|
|
}
|
|
|
|
virtual void ShutdownModule() override
|
|
{
|
|
CrossCompiler::FShaderConductorContext::Shutdown();
|
|
}
|
|
};
|
|
|
|
IMPLEMENT_MODULE( FVulkanShaderFormatModule, VulkanShaderFormat);
|