Don't include commented out defines in the preprocessed code by default.

- Defines will still be there if we're dumping the shader code for debug.
- This makes the code less unique in general case and also avoids unnecessary works that no one sees.

#rb Lukas.Hermanns
[FYI] Lukas.Hermanns, Rolando.Caloca

#ROBOMERGE-OWNER: ryan.gerleve
#ROBOMERGE-AUTHOR: arciel.rekman
#ROBOMERGE-SOURCE: CL 11311362 via CL 11311438 via CL 11311455
#ROBOMERGE-BOT: NETWORKING (Main -> Dev-Networking) (v654-11333218)

[CL 11522590 by arciel rekman in Dev-Networking branch]
This commit is contained in:
arciel rekman
2020-02-18 17:00:18 -05:00
parent c7912c90aa
commit 8758235d95
3 changed files with 17 additions and 4 deletions

View File

@@ -79,7 +79,7 @@ bool CompileShader_VectorVM(const FShaderCompilerInput& Input, FShaderCompilerOu
SCOPE_CYCLE_COUNTER(STAT_VectorVM_Compiler_CompileShader_VectorVMPreprocessShader);
// Don't include shader definitions since it creates shader compilation errors.
if (!PreprocessShader(PreprocessedShader, Output, Input, AdditionalDefines, false))
if (!PreprocessShader(PreprocessedShader, Output, Input, AdditionalDefines, EDumpShaderDefines::DontIncludeDefines))
{
// The preprocessing stage will add any relevant errors.
if (Output.Errors.Num() != 0)

View File

@@ -219,7 +219,7 @@ bool PreprocessShader(
FShaderCompilerOutput& ShaderOutput,
const FShaderCompilerInput& ShaderInput,
const FShaderCompilerDefinitions& AdditionalDefines,
bool bShaderDumpDefinesAsCommentedCode
EDumpShaderDefines DefinesPolicy
)
{
// Skip the cache system and directly load the file path (used for debugging)
@@ -312,7 +312,7 @@ bool PreprocessShader(
}
// List the defines used for compilation in the preprocessed shaders, especially to know witch permutation vector this shader is.
if (bShaderDumpDefinesAsCommentedCode)
if (DefinesPolicy == EDumpShaderDefines::AlwaysIncludeDefines || (DefinesPolicy == EDumpShaderDefines::DontCare && ShaderInput.DumpDebugInfoPath.Len() > 0))
{
DumpShaderDefinesAsCommentedCode(ShaderInput, &OutPreprocessedShader);
}

View File

@@ -5,6 +5,19 @@
#include "CoreMinimal.h"
#include "ShaderCore.h"
/** 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.
@@ -19,4 +32,4 @@ extern SHADERPREPROCESSOR_API bool PreprocessShader(
FShaderCompilerOutput& ShaderOutput,
const FShaderCompilerInput& ShaderInput,
const FShaderCompilerDefinitions& AdditionalDefines,
bool bShaderDumpDefinesAsCommentedCode = true);
EDumpShaderDefines DefinesPolicy = EDumpShaderDefines::DontCare);