Files
UnrealEngineUWP/Engine/Source/Developer/ShaderPreprocessor/Public/ShaderPreprocessor.h
dan elksnitis cc7c2c54f4 [shaders] shader format preprocessing cleanup & refactoring
- move uniform buffer cleanup and dead stripping into ShaderPreprocessor module's PreprocessShader function
- add "required symbols" to compiler input struct to specify additional symbols to keep during minification aside from those specified by the entrypoint; modify API such that both an entry point string and additional symbols can be specified (to avoid each backend needing to manually parse the compound RT entry point string)
- make use of ModifyShaderCompilerInput in all backends to set additional defines and required symbols on input struct up front; only use the AdditionalDefines map in cases where it's actually necessary
- remove the various per-platform defines for enabling minifier, no longer required now that this has been rolled out for all backends
- fix SCW directcompile mode; this had rotted due to pieces of the FShaderCompilerEnvironment having been added that weren't explicitly serialized to either cmdline or in the shader source. this now serializes as a base64 string written inside the USF containing all portions of the environment required for compilation (using the same serialization function as is used to write/read the SCW input file)
- use a debug flag for indicating we're in "direct compile" mode and should load the debug USF off disk, rather than the poorly named "bSkipPreprocessedCache" (this name is both inaccurate and also confusing due to the addition of the preprocessed job cache)
- modify platform "force wave32" mechanism to use a pragma directive to set a compiler define, instead of doing string replacement in the preprocessed source
- add a view version of the RT entrypoint parsing to use in preprocessing, note that other paths still need to construct fstrings due to further manipulation so keeping the FString path around too
- clean up backends manually checking the "directcompile" cmdline arg

#rb christopher.waters, Yuriy.ODonnell
#rb Chris.Waters
#rb Laura.Hermanns

[CL 30023082 by dan elksnitis in ue5-main branch]
2023-11-30 15:56:34 -05:00

66 lines
2.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "HAL/Platform.h"
#include "ShaderCore.h"
class FShaderCompilerDefinitions;
class FShaderPreprocessOutput;
class FString;
struct FShaderCompilerInput;
struct FShaderCompilerOutput;
/** Governs the behavior for adding shader defines to the preprocessed source. Can be helpful for the debugging, but makes the source unique
which can prevent efficient caching.
*/
enum class EDumpShaderDefines : uint8
{
/** Will not be dumped unless Input.DumpDebugInfoPath is set */
DontCare,
/** No defines */
DontIncludeDefines,
/** Defines will be added in the comments */
AlwaysIncludeDefines
};
/**
* Preprocess a shader.
* @param OutPreprocessedShader - Upon return contains the preprocessed source code.
* @param ShaderOutput - ShaderOutput to which errors can be added.
* @param ShaderInput - The shader compiler input.
* @param AdditionalDefines - Additional defines with which to preprocess the shader.
* @param bShaderDumpDefinesAsCommentedCode - Whether to add shader definitions as comments.
* @returns true if the shader is preprocessed without error.
*/
UE_DEPRECATED(5.4, "Please use overload of PreprocessShader accepting a FShaderPreprocessOutput struct.")
extern SHADERPREPROCESSOR_API bool PreprocessShader(
FString& OutPreprocessedShader,
FShaderCompilerOutput& ShaderOutput,
const FShaderCompilerInput& ShaderInput,
PRAGMA_DISABLE_DEPRECATION_WARNINGS // FShaderCompilerDefinitions will be made internal in the future, marked deprecated until then
const FShaderCompilerDefinitions& AdditionalDefines,
PRAGMA_ENABLE_DEPRECATION_WARNINGS
EDumpShaderDefines DefinesPolicy = EDumpShaderDefines::DontCare);
/**
* Preprocess a shader.
* @param Output - Preprocess output struct. Source, directives and possibly errors will be populated.
* @param Input - The shader compiler input.
* @param MergedEnvironment - The result of merging the Environment and SharedEnvironment from the FShaderCompilerInput
* (it is assumed this overload is called outside of the worker process which merges this in-place, so this merge step must be
* performed by the caller)
* @param AdditionalDefines - Additional defines with which to preprocess the shader.
* @param bShaderDumpDefinesAsCommentedCode - Whether to add shader definitions as comments.
* @returns true if the shader is preprocessed without error.
*/
extern SHADERPREPROCESSOR_API bool PreprocessShader(
FShaderPreprocessOutput& Output,
const FShaderCompilerInput& Input,
const FShaderCompilerEnvironment& MergedEnvironment,
PRAGMA_DISABLE_DEPRECATION_WARNINGS // FShaderCompilerDefinitions will be made internal in the future, marked deprecated until then
const FShaderCompilerDefinitions& AdditionalDefines = FShaderCompilerDefinitions(),
PRAGMA_ENABLE_DEPRECATION_WARNINGS
EDumpShaderDefines DefinesPolicy = EDumpShaderDefines::DontCare);