Files
UnrealEngineUWP/Engine/Source/Developer/ShaderFormatOpenGL/Public/ShaderFormatOpenGL.h
allan bentham bfb449ada1 Force GLSL intrinsic return types to (full) float when HLSLCC_UseFullPrecisionInPS is requested.
#rb jack.porter
[FYI] Dmitriy.Dyomin
#rnx
[FYI] carl.lloyd


#ROBOMERGE-OWNER: allan.bentham
#ROBOMERGE-AUTHOR: allan.bentham
#ROBOMERGE-SOURCE: CL 12162757 via CL 12162758 via CL 12163188
#ROBOMERGE-BOT: (v661-12148976)

[CL 12163190 by allan bentham in Main branch]
2020-03-13 11:36:26 -04:00

106 lines
4.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "RHIDefinitions.h"
#include "hlslcc.h"
#if PLATFORM_WINDOWS
#include "Windows/WindowsHWrapper.h"
#endif
struct FShaderCompilerInput;
struct FShaderCompilerOutput;
enum GLSLVersion
{
GLSL_150_REMOVED,
GLSL_430,
GLSL_ES2_REMOVED,
GLSL_ES2_WEBGL_REMOVED,
GLSL_150_ES2_DEPRECATED, // ES2 Emulation
GLSL_150_ES2_NOUB_DEPRECATED, // ES2 Emulation with NoUBs
GLSL_150_ES3_1, // ES3.1 Emulation
GLSL_ES2_IOS_REMOVED,
GLSL_310_ES_EXT,
GLSL_ES3_1_ANDROID,
GLSL_SWITCH,
GLSL_SWITCH_FORWARD,
GLSL_MAX
};
class SHADERFORMATOPENGL_API FOpenGLFrontend
{
public:
virtual ~FOpenGLFrontend()
{
}
void CompileShader(const struct FShaderCompilerInput& Input, struct FShaderCompilerOutput& Output, const class FString& WorkingDirectory, GLSLVersion Version);
protected:
// does the given version support SSO? Allows subclasses to device based on it's own format
virtual bool SupportsSeparateShaderObjects(GLSLVersion Version);
// if true, the shader output map will contain true names (i.e. ColorModifier) instead of helper names for runtime binding (i.e. pb_5)
virtual bool OutputTrueParameterNames()
{
return false;
}
virtual bool IsSM5(GLSLVersion Version)
{
return Version == GLSL_430 || Version == GLSL_310_ES_EXT;
}
// what is the max number of samplers the shader platform can use?
virtual uint32 GetMaxSamplers(GLSLVersion Version);
virtual uint32 CalculateCrossCompilerFlags(GLSLVersion Version, const TArray<uint32>& CompilerFlags);
// set up compilation information like defines and HlslCompileTarget
virtual void SetupPerVersionCompilationEnvironment(GLSLVersion Version, class FShaderCompilerDefinitions& AdditionalDefines, EHlslCompileTarget& HlslCompilerTarget);
virtual void ConvertOpenGLVersionFromGLSLVersion(GLSLVersion InVersion, int& OutMajorVersion, int& OutMinorVersion);
// create the compiling backend
virtual struct FGlslCodeBackend* CreateBackend(GLSLVersion Version, uint32 CCFlags, EHlslCompileTarget HlslCompilerTarget);
// create the language spec
virtual class FGlslLanguageSpec* CreateLanguageSpec(GLSLVersion Version, bool bDefaultPrecisionIsHalf);
// Allow a subclass to perform additional work on the cross compiled source code
virtual bool PostProcessShaderSource(GLSLVersion Version, EShaderFrequency Frequency, const ANSICHAR* ShaderSource,
uint32 SourceLen, class FShaderParameterMap& ParameterMap, TMap<FString, FString>& BindingNameMap, TArray<struct FShaderCompilerError>& Errors,
const FShaderCompilerInput& ShaderInput)
{
return true;
}
// allow subclass to write out different output, returning true if it did write everything it needed
virtual bool OptionalSerializeOutputAndReturnIfSerialized(FArchive& Ar)
{
return false;
}
void BuildShaderOutput(FShaderCompilerOutput& ShaderOutput, const FShaderCompilerInput& ShaderInput, const ANSICHAR* InShaderSource, int32 SourceLen, GLSLVersion Version);
void PrecompileShader(FShaderCompilerOutput& ShaderOutput, const FShaderCompilerInput& ShaderInput, const ANSICHAR* ShaderSource, GLSLVersion Version, EHlslShaderFrequency Frequency);
bool PlatformSupportsOfflineCompilation(const GLSLVersion ShaderVersion) const;
// fills device capabilities in 'offline', mostly hardcoded values
void FillDeviceCapsOfflineCompilation(struct FDeviceCapabilities &Caps, const GLSLVersion ShaderVersion) const;
// final source code processing, based on device capabilities, before actual (offline) compilation; it mostly mirrors the behaviour of OpenGLShaders.cpp/GLSLToDeviceCompatibleGLSL()
TSharedPtr<ANSICHAR> PrepareCodeForOfflineCompilation(GLSLVersion ShaderVersion, EShaderFrequency Frequency, const ANSICHAR* InShaderSource) const;
void CompileOffline(const FShaderCompilerInput& ShaderInput, FShaderCompilerOutput &Output, const GLSLVersion ShaderVersion, const ANSICHAR *InShaderSource);
// based on ShaderVersion decides what platform specific compiler to use
void PlatformCompileOffline(const FShaderCompilerInput &Input, FShaderCompilerOutput& ShaderOutput, const ANSICHAR* ShaderSource, const GLSLVersion ShaderVersion);
};