Files
UnrealEngineUWP/Engine/Source/Runtime/RenderCore/Public/ShaderStableKeyDebugInfoReader.h
arciel rekman 6880bfff22 Added facility to convert shader hashes back to their human-readable stable keys.
- A cooked game can be given an argument -shkfile=/path/to/file.shk (a "stable shader keys" file produced during the cook) and use it to provide information on compiled PSOs (and singular shaders if needed).

[FYI] Kenzo.TerElst
#preflight 63866f6c8b12eb83a7b5c1a1

[CL 23323655 by arciel rekman in ue5-main branch]
2022-11-29 22:39:31 -05:00

44 lines
1.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
/**
* Code for reading .shk files and using that information to map shader hashes back to human-readable identifies.
*/
#pragma once
#include "ShaderCodeLibrary.h"
namespace UE
{
namespace ShaderUtils
{
/** Class that uses build metadata (*.shk files storing mapping of stable shader keys to their hashes) to provide high level info on shaders and PSOs. */
class FShaderStableKeyDebugInfoReader
{
/** Maps shader hashes to their sources. */
TMap<FSHAHash, TSet<FStableShaderKeyAndValue>> ShaderHashesToSource;
public:
/** Whether the info reader is usable */
bool IsInitialized() const { return !ShaderHashesToSource.IsEmpty(); }
/** Initializes the class with a pointer to directory holding SHK files */
bool Initialize(const FString& ShaderStableKeyFile);
/** Returns a string describing a shader. Because of shader deduplication there can be several multiple (thousands) possible options */
FString GetShaderStableNameOptions(const FSHAHash& ShaderHash, int32 MaxOptionsToInclude = 16);
/** Returns a string describing a PSO (shaders only). Because of shader deduplication there can be several multiple (thousands) possible options. */
FString GetPSOStableNameOptions(const FGraphicsPipelineStateInitializer& Initializer, int32 MaxOptionsToInclude = 16);
/** Prints a pipeline info to log if configured to do so. */
void DumpPSOToLogIfConfigured(const FGraphicsPipelineStateInitializer& Initializer);
};
}
}