You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
* Track namespaces for symbols * Re-emit namespace scopes * Conservatively include symbols from all namespaces in minified code (as if they were all global) * Additional parsing work will be required to more accurately track used symbols based on active namespaces (i.e. handle `using` keyword, etc.) * Added RemoveDeadCode() overload that takes an explicit list of required symbols instead of just an entry point name #rb dan.elksnitis #preflight 6398be5e35203bc7aa7f9b47 [CL 23494729 by Yuriy ODonnell in ue5-main branch]
62 lines
1.6 KiB
C++
62 lines
1.6 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
#include "Containers/UnrealString.h"
|
|
#include "Misc/EnumClassFlags.h"
|
|
|
|
namespace UE::ShaderMinifier
|
|
{
|
|
|
|
enum EMinifyShaderFlags
|
|
{
|
|
None = 0,
|
|
|
|
/** Add `// REASON: foo` comments next to emitted code blocks to identify which other block uses it or other reason why it was included */
|
|
OutputReasons = 1 << 1,
|
|
|
|
/** Add a comment describing how many functions, structs, etc. were emitted */
|
|
OutputStats = 1 << 2,
|
|
|
|
/** Add `#line <line> <filename>` directives for each emitted code block */
|
|
OutputLines = 1 << 3,
|
|
|
|
/** Keep original global scope comment lines, such as `// #define FOO 123` that were added by UE shader preprocessor */
|
|
OutputCommentLines = 1 << 4,
|
|
};
|
|
ENUM_CLASS_FLAGS(EMinifyShaderFlags)
|
|
|
|
struct FDiagnosticMessage
|
|
{
|
|
FString Message;
|
|
FString File;
|
|
int32 Offset = INDEX_NONE;
|
|
int32 Line = INDEX_NONE;
|
|
int32 Column = INDEX_NONE;
|
|
};
|
|
|
|
struct FDiagnostics
|
|
{
|
|
TArray<FDiagnosticMessage> Errors;
|
|
TArray<FDiagnosticMessage> Warnings;
|
|
};
|
|
|
|
struct FMinifiedShader
|
|
{
|
|
FString Code;
|
|
FDiagnostics Diagnostics;
|
|
|
|
bool Success() const
|
|
{
|
|
return Diagnostics.Errors.IsEmpty() && !Code.IsEmpty();
|
|
}
|
|
};
|
|
|
|
extern SHADERCOMPILERCOMMON_API FMinifiedShader Minify(const FStringView PreprocessedShader, const FStringView EntryPoint, EMinifyShaderFlags Flags = EMinifyShaderFlags::None);
|
|
extern SHADERCOMPILERCOMMON_API FMinifiedShader Minify(const FStringView PreprocessedShader, TConstArrayView<FStringView> RequiredSymbols, EMinifyShaderFlags Flags = EMinifyShaderFlags::None);
|
|
|
|
} // UE::ShaderMinifier
|
|
|