ShowFlag.ShaderPrint

ShowFlag.ShaderPrint

#Overview

name: ShowFlag.ShaderPrint

This variable is created as a Console Variable (cvar).

It is referenced in 55 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.ShaderPrint is to enable ShaderPrint functionality in Unreal Engine 5, which is used for debug printing from shaders. This setting variable is primarily used for the rendering system, specifically for debugging and visualization purposes.

Key points about ShowFlag.ShaderPrint:

  1. Unreal Engine subsystems that rely on this setting variable:

    • The rendering system, particularly for debugging shaders
    • Various plugins and modules that use ShaderPrint for debugging, such as HairStrands, Nanite, and Lumen
  2. Value setting:

    • The value is typically set through engine show flags or can be forced on programmatically using ShaderPrint::SetEnabled(true)
  3. Interaction with other variables:

    • It interacts closely with the associated variable ShaderPrint, which is used to control ShaderPrint functionality in various parts of the engine
  4. Special considerations for developers:

    • This flag should be enabled when debugging shaders or when needing to visualize debug information directly in the rendering output
    • It may impact performance when enabled, so it should be used judiciously in production environments
  5. Best practices:

    • Use this flag in development and debugging scenarios, not in shipping builds
    • Combine with other debug visualization tools for comprehensive shader and rendering debugging
    • Be aware of potential performance implications when enabled

Regarding the associated variable ShaderPrint:

The purpose of ShaderPrint is to provide a system for debug printing from shaders in Unreal Engine 5. It is closely related to ShowFlag.ShaderPrint and is used throughout the engine for various debugging and visualization tasks.

Key points about ShaderPrint:

  1. It is used across multiple engine subsystems and plugins for debugging purposes, including HairStrands, Nanite, Lumen, and others

  2. The ShaderPrint system can be enabled or disabled using ShaderPrint::SetEnabled(true/false)

  3. It provides methods for requesting space for characters, lines, and other debug elements

  4. Developers should be aware of performance implications when using ShaderPrint extensively

  5. Best practices include using ShaderPrint judiciously, checking if it’s enabled before performing debug operations, and cleaning up any debug data when no longer needed

Both ShowFlag.ShaderPrint and ShaderPrint are powerful tools for debugging and visualizing shader-related issues in Unreal Engine 5, but should be used carefully and primarily in development environments.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:452

Scope: file

Source code excerpt:


/** Enables ShaderPrint functionality that is used for debug printing from shaders (e.g. 'Nanitestats' command). Disable this for certain editor rendering (e.g. thumbnail rendering) */
SHOWFLAG_ALWAYS_ACCESSIBLE(ShaderPrint, SFG_Developer, NSLOCTEXT("UnrealEd", "ShaderPrint", "Shader Print"))

#undef SHOWFLAG_ALWAYS_ACCESSIBLE
#undef SHOWFLAG_FIXED_IN_SHIPPING

#Associated Variable and Callsites

This variable is associated with another variable named ShaderPrint. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Plugins/Animation/DeformerGraph/Source/OptimusCore/Private/DataInterfaces/OptimusDataInterfaceDebugDraw.cpp:141

Scope (from outer to inner):

file
function     FOptimusDebugDrawDataProviderProxy::FOptimusDebugDrawDataProviderProxy

Source code excerpt:

	ShaderPrint::GetParameters(Setup, ConfigParameters);

	// Force ShaderPrint system enable if requested.
	if (InDebugDrawParameters.bForceEnable)
	{
		ShaderPrint::SetEnabled(true);
	}
}

#Loc: <Workspace>/Engine/Plugins/Animation/DeformerGraph/Source/OptimusCore/Private/DataInterfaces/OptimusDataInterfaceDebugDraw.cpp:169

Scope (from outer to inner):

file
function     void FOptimusDebugDrawDataProviderProxy::AllocateResources

Source code excerpt:

void FOptimusDebugDrawDataProviderProxy::AllocateResources(FRDGBuilder& GraphBuilder)
{
	// Allocate ShaderPrint output buffers.
	FShaderPrintData ShaderPrintData = ShaderPrint::CreateShaderPrintData(GraphBuilder, Setup);
	
	// Cache parameters for later GatherDispatchData(). 
	// We only want the buffers that are created here. 
	// We don't use the ShaderPrint uniform buffer because we'll use the loose ConfigParameters instead.
	// That's so we can bind multiple instances of this data interface if we want.
	ShaderPrint::SetParameters(GraphBuilder, ShaderPrintData, CachedParameters);

	if (ShaderPrint::IsEnabled(ShaderPrintData))
	{
		// Enqueue for display at next view render.

#Loc: <Workspace>/Engine/Plugins/Runtime/HairStrands/Source/HairStrandsCore/Private/GroomDebug.cpp:155

Scope (from outer to inner):

file
function     static void AddDebugProjectionHairPass

Source code excerpt:

	}

	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);

	if (!RestRootResources->IsValid(MeshLODIndex) || !DeformedRootResources->IsValid(MeshLODIndex))
	{
		return;
	}

#Loc: <Workspace>/Engine/Plugins/Runtime/HairStrands/Source/HairStrandsCore/Private/GroomDebug.cpp:559

Scope (from outer to inner):

file
function     static void AddDrawDebugCardsGuidesPass

Source code excerpt:

	}

	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);

	if (ShaderPrintData == nullptr || !ShaderPrint::IsEnabled(*ShaderPrintData))
	{
		return;
	}

#Loc: <Workspace>/Engine/Plugins/Runtime/HairStrands/Source/HairStrandsCore/Private/GroomDebug.cpp:767

Scope (from outer to inner):

file
function     static void AddHairDebugPrintInstancePass

Source code excerpt:

	}

	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);
	// Request more drawing primitives & characters for printing if needed	
	ShaderPrint::RequestSpaceForLines(InstanceCount * 64u);
	ShaderPrint::RequestSpaceForCharacters(InstanceCount * 256 + 512);

	if (!ShaderPrintData || InstanceCount == 0) { return; }

#Loc: <Workspace>/Engine/Plugins/Runtime/HairStrands/Source/HairStrandsCore/Private/GroomDebug.cpp:1170

Scope (from outer to inner):

file
function     static void AddHairDebugPrintMemoryPass

Source code excerpt:

	if (BindingBuffer.IsEmpty())	{ BindingBuffer.AddDefaulted(); }

	// Force ShaderPrint on.
	ShaderPrint::RequestSpaceForCharacters((ComponentCount + GroomCount + BindingCount) * 256 + 512);

	FHairDebugPrintMemoryCS::FParameters* Parameters = GraphBuilder.AllocParameters<FHairDebugPrintMemoryCS::FParameters>();
	Parameters->ComponentCount  = ComponentCount;
	Parameters->ComponentNames  = ComponentNames.GetParameters(GraphBuilder);
	Parameters->ComponentBuffer = GraphBuilder.CreateSRV(CreateVertexBuffer(GraphBuilder, TEXT("Hair.Debug.Component"), FRDGBufferDesc::CreateBufferDesc(4, InfoInUints * ComponentBuffer.Num()), ComponentBuffer.GetData(), InfoInBytes * ComponentBuffer.Num()), PF_R32_UINT);

#Loc: <Workspace>/Engine/Plugins/Runtime/HairStrands/Source/HairStrandsCore/Private/GroomManager.cpp:428

Scope (from outer to inner):

file
function     static void AddHairSkinCacheDebugPass

Source code excerpt:

	const uint32 UniqueMeshCount = HairGeometryCache.DebugDatas.Num();

	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);
	// Request more drawing primitives & characters for printing if needed	
	ShaderPrint::RequestSpaceForLines(UniqueMeshCount * 64u);
	ShaderPrint::RequestSpaceForCharacters(UniqueMeshCount * 256 + 512);

	ShaderPrint::FStrings UniqueMeshNames(UniqueMeshCount);

#Loc: <Workspace>/Engine/Plugins/Runtime/HairStrands/Source/HairStrandsCore/Private/GroomTextureBuilder.cpp:12

Scope: file

Source code excerpt:

#include "ShaderParameterStruct.h"
#include "GlobalShader.h"
//#include "ShaderPrint.h"
#include "CommonRenderResources.h"
#include "HairStrandsMeshProjection.h"
#include "Engine/StaticMesh.h"
#include "TextureResource.h"
#include "UObject/Package.h"
#include "HairStrandsDefinitions.h"

#Loc: <Workspace>/Engine/Plugins/Runtime/HairStrands/Source/HairStrandsCore/Private/HairStrandsInterpolation.cpp:1249

Scope: file

Source code excerpt:

	if (ShaderPrintData)
	{
		ShaderPrint::SetParameters(GraphBuilder, *ShaderPrintData, Parameters->ShaderPrintUniformBuffer);
	}
	Parameters->OutputIndexBuffer = OutIndexBuffer;
	Parameters->RaytracingProceduralSplits = ProceduralSplits;

	const bool bCullingEnable = CullingData.bCullingResultAvailable;
	Parameters->HairStrandsVF_bCullingEnable = bCullingEnable ? 1 : 0;

#Loc: <Workspace>/Engine/Source/Developer/ShaderPreprocessor/Private/ShaderPreprocessor.cpp:718

Scope (from outer to inner):

file
function     PRAGMA_ENABLE_DEPRECATION_WARNINGS /** * Preprocess a shader. * @param OutPreprocessedShader - Upon return contains the preprocessed source code. * @param ShaderOutput - ShaderOutput to which erro

Source code excerpt:

	// the preprocessor first.  By contrast, for shader asserts, we must NOT run the preprocessor on the arguments first, because
	// the assert macro sets a state flag which modifies behavior of TEXT macros inside the assert.  Asserts store their TEXT tokens
	// outside the shader for printing in code when an assert is triggered, while ShaderPrint stores TEXT in the shader itself.
	arrput(StbDefines, pp_define_custom_macro(&MacroArena, ShaderPrintTextIdentifier, 1));
	arrput(StbDefines, pp_define_custom_macro(&MacroArena, ShaderPrintAssertIdentifier, 0));

	PRAGMA_ENABLE_DEPRECATION_WARNINGS

	FStbPreprocessContext Context{ Input, Environment };

#Loc: <Workspace>/Engine/Source/Developer/ShaderPreprocessor/Private/ShaderPreprocessor.cpp:831

Scope (from outer to inner):

file
function     PRAGMA_ENABLE_DEPRECATION_WARNINGS /** * Preprocess a shader. * @param OutPreprocessedShader - Upon return contains the preprocessed source code. * @param ShaderOutput - ShaderOutput to which erro

Source code excerpt:

	if (!HasError)
	{
		// Append ShaderPrint generated code at the end of the shader if necessary
		Context.ShaderPrintGenerate(OutPreprocessedAnsi, &Output.EditDiagnosticDatas());

		// "preprocessor_file_size" includes null terminator, so subtract one when initializing the FShaderSource (which automatically null terminates)
		Output.EditSource().Set({ OutPreprocessedAnsi, preprocessor_file_size(OutPreprocessedAnsi) - 1 });
	}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:451

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeGPUSkinCache, SFG_Hidden, NSLOCTEXT("UnrealEd", "VisualizeGPUSkinCache", "Visualize GPU Skin Cache"))

/** Enables ShaderPrint functionality that is used for debug printing from shaders (e.g. 'Nanitestats' command). Disable this for certain editor rendering (e.g. thumbnail rendering) */
SHOWFLAG_ALWAYS_ACCESSIBLE(ShaderPrint, SFG_Developer, NSLOCTEXT("UnrealEd", "ShaderPrint", "Shader Print"))

#undef SHOWFLAG_ALWAYS_ACCESSIBLE
#undef SHOWFLAG_FIXED_IN_SHIPPING

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/GPUScene.cpp:1921

Scope (from outer to inner):

file
function     void FGPUScene::DebugRender

Source code excerpt:

	if (DebugMode > 0)
	{
		// Force ShaderPrint on.
		ShaderPrint::SetEnabled(true); 

		int32 NumInstances = InstanceSceneDataAllocator.GetMaxSize();
		if (ShaderPrint::IsEnabled(View.ShaderPrintData) && NumInstances > 0)
		{
			// This lags by one frame, so may miss some in one frame, also overallocates since we will cull a lot.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HairStrands/HairStrandsDebug.cpp:55

Scope (from outer to inner):

file
function     static bool TryEnableShaderDrawAndShaderPrint

Source code excerpt:

static bool TryEnableShaderDrawAndShaderPrint(const FViewInfo& View, uint32 ResquestedShaderDrawElements, uint32 RequestedShaderPrintElements)
{
	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);

	ShaderPrint::RequestSpaceForCharacters(RequestedShaderPrintElements);
	ShaderPrint::RequestSpaceForLines(ResquestedShaderDrawElements);

	return ShaderPrint::IsEnabled(View.ShaderPrintData);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HairStrands/HairStrandsDebug.cpp:143

Scope (from outer to inner):

file
function     static void AddPrintLODInfoPass

Source code excerpt:

	}

	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);
	ShaderPrint::RequestSpaceForCharacters(2000);

	if (!ShaderPrint::IsEnabled(View.ShaderPrintData))
	{
		return;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HairStrands/HairStrandsDebug.cpp:893

Scope (from outer to inner):

file
function     static void AddDebugHairTangentPass

Source code excerpt:

	Parameters->SceneTextures			= SceneTextures.UniformBuffer;
	Parameters->BilinearTextureSampler	= TStaticSamplerState<SF_Bilinear>::GetRHI();
	ShaderPrint::SetParameters(GraphBuilder, View.ShaderPrintData, Parameters->ShaderPrint);

	const FIntVector DispatchCount = DispatchCount.DivideAndRoundUp(FIntVector(OutputTexture->Desc.Extent.X, OutputTexture->Desc.Extent.Y, 1), FIntVector(8, 8, 1));
	ShaderPrint::RequestSpaceForLines(DispatchCount.X * DispatchCount.Y);

	TShaderMapRef<FDebugHairTangentCS> ComputeShader(View.ShaderMap);
	FComputeShaderUtils::AddPass(GraphBuilder, RDG_EVENT_NAME("HairStrands::DebugTangentCS"), ComputeShader, Parameters, DispatchCount);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HairStrands/HairStrandsDebug.cpp:1290

Scope (from outer to inner):

file
function     static void InternalRenderHairStrandsDebugInfo

Source code excerpt:

	if (HairData.DebugData.IsPPLLDataValid()) // Check if PPLL rendering is used and its debug view is enabled.
	{
		// Force ShaderPrint on.
		ShaderPrint::SetEnabled(true);
		ShaderPrint::RequestSpaceForCharacters(256);

		const FIntPoint PPLLResolution = HairData.DebugData.PPLLData.NodeIndexTexture->Desc.Extent;
		FHairVisibilityDebugPPLLCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FHairVisibilityDebugPPLLCS::FParameters>();
		PassParameters->PPLLMeanListElementCountPerPixel = GetHairStrandsMeanSamplePerPixel(View.GetShaderPlatform());

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/HairStrands/HairStrandsVisibility.cpp:1173

Scope: file

Source code excerpt:

static void AddAttributeDebugPass(FRDGBuilder& GraphBuilder, const FViewInfo& View, const FHairStrandsMacroGroupDatas& MacroGroupDatas, const FRDGTextureRef& NodeIndexTexture, const FRDGBufferSRVRef& NodeVisBuffer)
{
	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);
	ShaderPrint::RequestSpaceForCharacters(2048);
	ShaderPrint::RequestSpaceForLines(256);
	if (!ShaderPrint::IsEnabled(View.ShaderPrintData))
	{
		return;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/IESTextureManager.cpp:139

Scope (from outer to inner):

file
namespace    IESAtlas
function     static FRDGTextureRef AddIESDebugPass

Source code excerpt:

	const FRDGTextureDesc& OutputDesc)
{
	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);

	FRDGTextureRef OutputTexture = GraphBuilder.CreateTexture(FRDGTextureDesc::Create2D(OutputDesc.Extent, OutputDesc.Format, FClearValueBinding::Black, TexCreate_UAV | TexCreate_ShaderResource), TEXT("IESAtlas.DebugTexture"));
	FRDGTextureRef AtlasTexture = GIESTextureManager.AtlasTexture ? GraphBuilder.RegisterExternalTexture(GIESTextureManager.AtlasTexture) : GSystemTextures.GetBlackDummy(GraphBuilder);

	const FIntPoint OutputResolution(OutputTexture->Desc.Extent);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightGridInjection.cpp:1134

Scope (from outer to inner):

file
function     FScreenPassTexture AddVisualizeLightGridPass

Source code excerpt:

		RDG_EVENT_SCOPE(GraphBuilder, "VisualizeLightGrid");

		// Force ShaderPrint on.
		ShaderPrint::SetEnabled(true);

		ShaderPrint::RequestSpaceForLines(128);
		ShaderPrint::RequestSpaceForCharacters(128);

		FDebugLightGridPS::FPermutationDomain PermutationVector;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenScreenProbeGather.cpp:1031

Scope (from outer to inner):

file
function     void AddLumenScreenProbeDebugPass

Source code excerpt:

	FRDGBufferRef IntegrateIndirectArgs)
{
	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);

	ShaderPrint::RequestSpaceForCharacters(1024);
	ShaderPrint::RequestSpaceForLines(1024);
	ShaderPrint::RequestSpaceForTriangles(ViewportIntegrateTileDimensionsWithOverflow.X * ViewportIntegrateTileDimensionsWithOverflow.Y * 2);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenScreenProbeGather.cpp:1045

Scope (from outer to inner):

file
function     void AddLumenScreenProbeDebugPass

Source code excerpt:

	PassParameters->IntegrateTileData = GraphBuilder.CreateSRV(IntegrateTileData);
	PassParameters->IntegrateIndirectArgs = GraphBuilder.CreateSRV(IntegrateIndirectArgs, PF_R32_UINT);
	ShaderPrint::SetParameters(GraphBuilder, View.ShaderPrintData, PassParameters->ShaderPrint);

	FLumenScreenProbeSubstrateDebugPass::FPermutationDomain PermutationVector;
	auto ComputeShader = View.ShaderMap->GetShader<FLumenScreenProbeSubstrateDebugPass>(PermutationVector);
	FComputeShaderUtils::AddPass(
		GraphBuilder,
		RDG_EVENT_NAME("ScreenProbeDebug"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenVisualize.cpp:483

Scope: file

Source code excerpt:


/**
 * Render gathered traces using ShaderPrint line rendering.
 */
void RenderVisualizeTraces(
	FRDGBuilder& GraphBuilder,
	const FViewInfo& View,
	FRDGTextureRef ColorGradingTexture,
	FRDGBufferRef EyeAdaptationBuffer)
{
	if (CVarVisualizeUseShaderPrintForTraces.GetValueOnRenderThread() == 0)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteStreamOut.cpp:118

Scope: file

Source code excerpt:

			SHADER_PARAMETER(float, StreamOutCutError)

			SHADER_PARAMETER_STRUCT_INCLUDE(ShaderPrint::FShaderParameters, ShaderPrint)
		END_SHADER_PARAMETER_STRUCT()

		class FCountVerticesAndTrianglesDim : SHADER_PERMUTATION_BOOL("NANITE_STREAM_OUT_COUNT_VERTICES_AND_TRIANGLES");
		class FCacheClustersDim : SHADER_PERMUTATION_BOOL("NANITE_STREAM_OUT_CACHE_CLUSTERS");
		using FPermutationDomain = TShaderPermutationDomain<FCountVerticesAndTrianglesDim, FCacheClustersDim>;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteStreamOut.cpp:156

Scope: file

Source code excerpt:

			SHADER_PARAMETER_RDG_BUFFER_UAV(RWBuffer<uint>, StreamOutDispatchIndirectArgsRW)

			SHADER_PARAMETER_STRUCT_INCLUDE(ShaderPrint::FShaderParameters, ShaderPrint)
		END_SHADER_PARAMETER_STRUCT()
	};
	IMPLEMENT_GLOBAL_SHADER(FAllocateRangesCS, "/Engine/Private/Nanite/NaniteStreamOut.usf", "AllocateRangesCS", SF_Compute);

	struct FNaniteStreamOutCS : public FNaniteGlobalShader
	{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteStreamOut.cpp:184

Scope: file

Source code excerpt:

			SHADER_PARAMETER_RDG_BUFFER_SRV(StructuredBuffer, SegmentMappingBuffer)

			SHADER_PARAMETER_STRUCT_INCLUDE(ShaderPrint::FShaderParameters, ShaderPrint)

			RDG_BUFFER_ACCESS(IndirectArgs, ERHIAccess::IndirectArgs)
		END_SHADER_PARAMETER_STRUCT()

		static inline void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
		{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteStreamOut.cpp:396

Scope: file

Source code excerpt:

			PassParameters->StreamOutCutError = CutError;

			ShaderPrint::SetParameters(GraphBuilder, PassParameters->ShaderPrint);

			FNaniteStreamOutTraversalCS::FPermutationDomain PermutationVector;
			PermutationVector.Set<FNaniteStreamOutTraversalCS::FCountVerticesAndTrianglesDim>(true);
			PermutationVector.Set<FNaniteStreamOutTraversalCS::FCacheClustersDim>(GNaniteStreamOutCacheTraversalData);

			auto ComputeShader = ShaderMap->GetShader<FNaniteStreamOutTraversalCS>(PermutationVector);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteStreamOut.cpp:449

Scope: file

Source code excerpt:

			PassParameters->StreamOutCutError = CutError;

			ShaderPrint::SetParameters(GraphBuilder, PassParameters->ShaderPrint);

			FNaniteStreamOutTraversalCS::FPermutationDomain PermutationVector;
			PermutationVector.Set<FNaniteStreamOutTraversalCS::FCountVerticesAndTrianglesDim>(false);
			PermutationVector.Set<FNaniteStreamOutTraversalCS::FCacheClustersDim>(false);

			auto ComputeShader = ShaderMap->GetShader<FNaniteStreamOutTraversalCS>(PermutationVector);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteStreamOut.cpp:482

Scope: file

Source code excerpt:

				PassParameters->StreamOutDispatchIndirectArgsRW = GraphBuilder.CreateUAV(StreamOutDispatchIndirectArgsBuffer);

				ShaderPrint::SetParameters(GraphBuilder, PassParameters->ShaderPrint);

				auto ComputeShader = ShaderMap->GetShader<FAllocateRangesCS>();

				FComputeShaderUtils::AddPass(GraphBuilder, RDG_EVENT_NAME("NaniteStreamOut::AllocateRanges"), ComputeShader, PassParameters, FComputeShaderUtils::GetGroupCountWrapped(NumRequests, 64));
			}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Nanite/NaniteStreamOut.cpp:513

Scope (from outer to inner):

file
namespace    Nanite

Source code excerpt:

				PassParameters->IndirectArgs = StreamOutDispatchIndirectArgsBuffer;

				ShaderPrint::SetParameters(GraphBuilder, PassParameters->ShaderPrint);

				auto ComputeShader = ShaderMap->GetShader<FNaniteStreamOutCS>();

				FComputeShaderUtils::AddPass(GraphBuilder, RDG_EVENT_NAME("NaniteStreamOut::StreamOut"), ComputeShader, PassParameters, StreamOutDispatchIndirectArgsBuffer, 0);
			}
		}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:137

Scope (from outer to inner):

file
function     static void AddOITPixelDebugPass

Source code excerpt:

		return;

	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);
	ShaderPrint::RequestSpaceForCharacters(512);

	FOITPixelDebugCS::FParameters* Parameters = GraphBuilder.AllocParameters<FOITPixelDebugCS::FParameters>();
	Parameters->PassType = OITData.PassType;
	Parameters->SupportedPass = OITData.SupportedPass;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/OIT/OIT.cpp:785

Scope (from outer to inner):

file
class        class FOITSortTriangleIndex_WriteOutCS : public FGlobalShader
function     BEGIN_SHADER_PARAMETER_STRUCT

Source code excerpt:

	}

	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);
	ShaderPrint::RequestSpaceForCharacters(DebugData.VisibleInstances * 256 + 512);
	ShaderPrint::RequestSpaceForLines(DebugData.VisiblePrimitives * 8 + DebugData.VisibleInstances * 32);

	FOITSortTriangleIndex_Debug::FParameters* Parameters = GraphBuilder.AllocParameters<FOITSortTriangleIndex_Debug::FParameters>();
	Parameters->VisibleInstances = DebugData.VisibleInstances;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp:3091

Scope (from outer to inner):

file
function     static void AddGBufferPicking

Source code excerpt:

	}

	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);

	FGBufferPickingCS::FParameters* Parameters = GraphBuilder.AllocParameters<FGBufferPickingCS::FParameters>();
	Parameters->ViewUniformBuffer = View.ViewUniformBuffer;
	Parameters->SceneTexturesStruct = SceneTextures;
	ShaderPrint::SetParameters(GraphBuilder, View.ShaderPrintData, Parameters->ShaderPrintParameters);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RayTracing/RayTracingDebug.cpp:954

Scope (from outer to inner):

file
function     static void PrintTopKMostHitMessage

Source code excerpt:

static void PrintTopKMostHitMessage(FRDGBuilder& GraphBuilder, const FScene* Scene, const FViewInfo& View, const TArray<FRayTracingHitStatsEntry>& HitStatsArray)
{
	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);

	int32 NumPrimitives = CVarRayTracingDebugHitCountTopKHits.GetValueOnRenderThread();
	if (ShaderPrint::IsEnabled(View.ShaderPrintData) && NumPrimitives > 0)
	{
		// This lags by one frame, so may miss some in one frame, also overallocates since we will cull a lot.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RectLightTextureManager.cpp:313

Scope (from outer to inner):

file
namespace    RectLightAtlas
function     static FRDGTextureRef AddRectLightDebugInfoPass

Source code excerpt:

	const FRDGTextureDesc& OutputDesc)
{
	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);

	FRDGTextureRef OutputTexture = GraphBuilder.CreateTexture(FRDGTextureDesc::Create2D(OutputDesc.Extent, OutputDesc.Format, FClearValueBinding::Black, TexCreate_UAV | TexCreate_ShaderResource), TEXT("RectLight.DebugTexture"));

	FGlobalShaderMap* ShaderMap = View.ShaderMap;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/RendererScene.cpp:2923

Scope (from outer to inner):

file
function     void FScene::ShowPhysicsField

Source code excerpt:

	if (PhysicsField && PhysicsField->FieldResource && PhysicsField->FieldResource->FieldInfos.bShowFields)
	{
		// Force ShaderPrint on.
		ShaderPrint::SetEnabled(true);
		ShaderPrint::RequestSpaceForLines(128000);
	}
}

void FScene::ResetPhysicsField()

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneCulling/SceneCullingRenderer.cpp:115

Scope (from outer to inner):

file
function     void FSceneCullingRenderer::DebugRender

Source code excerpt:

	if (CVarSceneCullingDebugRenderMode.GetValueOnRenderThread() != 0 && MaxCellCount > 0)
	{
		// Force ShaderPrint on.
		ShaderPrint::SetEnabled(true); 

		// This lags by one frame, so may miss some in one frame, also overallocates since we will cull a lot.
		ShaderPrint::RequestSpaceForLines(MaxCellCount * 12 * Views.Num());

		// Note: we have to construct this as the GPU currently does not have a mapping of what cells are valid.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:181

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:

	}

	// Empty buffer for binding when ShaderPrint is disabled
	class FEmptyBuffer : public FBufferWithRDG
	{
	public:
		void InitRHI(FRHICommandListBase&) override
		{
			Buffer = AllocatePooledBuffer(FRDGBufferDesc::CreateStructuredDesc(4, GetCountersUintSize()), TEXT("ShaderPrint.EmptyValueBuffer"));

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:229

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:

	// Uniform buffer
	
	// ShaderPrint uniform buffer
	IMPLEMENT_GLOBAL_SHADER_PARAMETER_STRUCT(FShaderPrintCommonParameters, "ShaderPrintData");
	
	// Fill the uniform buffer parameters
	void GetParameters(FShaderPrintSetup const& InSetup, FShaderPrintCommonParameters& OutParameters)
	{
		const FVector2D ViewSize(FMath::Max(InSetup.ViewRect.Size().X, 1), FMath::Max(InSetup.ViewRect.Size().Y, 1));

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:376

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:

	// Common Shaders

	// Upload ShaderPrint parmeters into diagnostic buffer
	class FShaderPrintUploadCS: public FGlobalShader
	{
	public:
		DECLARE_GLOBAL_SHADER(FShaderPrintUploadCS);
		SHADER_USE_PARAMETER_STRUCT(FShaderPrintUploadCS, FGlobalShader);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:402

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:


	
	// Upload ShaderPrint parmeters into diagnostic buffer
	class FShaderPrintCopyCS: public FGlobalShader
	{
	public:
		DECLARE_GLOBAL_SHADER(FShaderPrintCopyCS);
		SHADER_USE_PARAMETER_STRUCT(FShaderPrintCopyCS, FGlobalShader);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:739

Scope (from outer to inner):

file
namespace    ShaderPrint
function     FShaderPrintSetup::FShaderPrintSetup

Source code excerpt:

	FShaderPrintSetup::FShaderPrintSetup(FSceneView const& View)
	{
		bEnabled = IsEnabled() && IsSupported(View.GetShaderPlatform()) && View.Family->EngineShowFlags.ShaderPrint;

		ViewRect = View.UnconstrainedViewRect;
		CursorCoord = View.CursorPos;
		PreViewTranslation = View.ViewMatrices.GetPreViewTranslation();
		DPIScale = View.Family->DebugDPIScale;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:920

Scope (from outer to inner):

file
namespace    ShaderPrint
function     void BeginView

Source code excerpt:

		if (IsSupported(View.GetShaderPlatform()))
		{
			// Upload/Copy ShaderPrint parameters into UEDiagnostic buffer
			InternalUploadParameters(GraphBuilder, View.ShaderPrintData);
		}
	}

	void BeginViews(FRDGBuilder& GraphBuilder, TArrayView<FViewInfo> Views)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.h:0

Scope: file

Source code excerpt:

// Copyright Epic Games, Inc. All Rights Reserved.

// Use ShaderPrint to debug print from any shader type.
// Call BeginViews() at the start of a view group to init the debug output buffer.
// Call DrawView() to composite the debug data to the final render target.
// Call EndViews() at the end of the view group to tidy up.

// The shader HLSL code should include the ShaderPrintCommon.ush and use the ShaderPrint*() functions.
// The shader C++ code needs to bind the buffers required to capture the debug print. See ShaderPrintParameters.h for this. 

#pragma once

#include "CoreMinimal.h"

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Substrate/SubstrateRoughRefraction.cpp:415

Scope: file

Source code excerpt:

			return;
		}
		check(ShaderPrint::IsEnabled(View.ShaderPrintData));	// One must enable ShaderPrint beforehand using r.ShaderPrint=1

		//////////////////////////////////////////////////////////////////////////
		// Create resources
		
		// Texture to count
		const uint32 SampleCountTextureWidth = 64;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Substrate/SubstrateVisualize.cpp:273

Scope (from outer to inner):

file
namespace    Substrate
function     static void AddVisualizeMaterialPropertiesPasses

Source code excerpt:

	if (!FMaterialPrintInfoCS::IsSupported(Platform)) return;

	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);
	ShaderPrint::RequestSpaceForLines(1024);
	ShaderPrint::RequestSpaceForCharacters(1024);
	FRDGBufferUAVRef PrintOffsetBufferUAV = nullptr;

	FRDGBufferRef PrintOffsetBuffer = GraphBuilder.CreateBuffer(FRDGBufferDesc::CreateBufferDesc(4, 2), TEXT("Substrate.DebugPrintPositionOffset"));

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Substrate/SubstrateVisualize.cpp:335

Scope (from outer to inner):

file
namespace    Substrate
function     static void AddVisualizeSystemInfoPasses

Source code excerpt:

	if (!FSubstrateSystemInfoCS::IsSupported(Platform)) return;

	// Force ShaderPrint on.
	ShaderPrint::SetEnabled(true);
	ShaderPrint::RequestSpaceForLines(1024);
	ShaderPrint::RequestSpaceForCharacters(1024);

	const FRDGTextureDesc MaterialBufferDesc = View.SubstrateViewData.SceneData->MaterialTextureArray->Desc;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:925

Scope (from outer to inner):

file
class        class FRenderVolumetricCloudEmptySpaceSkippingCS : public FMeshMaterialShader

Source code excerpt:

		SHADER_PARAMETER_RDG_UNIFORM_BUFFER(FSceneUniformParameters, Scene)
		SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, OutStartTracingDistanceTexture)
//		SHADER_PARAMETER_STRUCT_INCLUDE(ShaderPrint::FShaderParameters, ShaderPrintParameters)
	END_SHADER_PARAMETER_STRUCT()

	static const int32 ThreadGroupSizeX = 1;
	static const int32 ThreadGroupSizeY = 1;
	static const int32 ThreadGroupSizeZ = 64;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:939

Scope (from outer to inner):

file
class        class FRenderVolumetricCloudEmptySpaceSkippingCS : public FMeshMaterialShader
function     static bool ShouldCompilePermutation

Source code excerpt:

		if (PermutationVector.Get<FCloudEmptySpaceSkippingDebug>())
		{
			return false;	// TODO implement the debug version using ShaderPrint::FShaderParameters
		}

		return bIsCompatible;
	}

	static void ModifyCompilationEnvironment(const FMaterialShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricCloudRendering.cpp:2324

Scope (from outer to inner):

file
function     void FSceneRenderer::RenderVolumetricCloudsInternal

Source code excerpt:

			//if (bCloudEmptySpaceSkippingDebug)
			//{
			//	ShaderPrint::SetEnabled(true);
			//	ShaderPrint::RequestSpaceForLines(65536);
			//	ShaderPrint::SetParameters(GraphBuilder, MainView.ShaderPrintData, PassParameters->ShaderPrintParameters);
			//}
			
			const FMaterialRenderProxy* MaterialRenderProxy = nullptr;
			const FMaterial* MaterialResource = &CloudVolumeMaterialProxy->GetMaterialWithFallback(Scene->GetFeatureLevel(), MaterialRenderProxy);
			MaterialRenderProxy = MaterialRenderProxy ? MaterialRenderProxy : CloudVolumeMaterialProxy;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Public/ShaderPrintParameters.h:0

Scope: file

Source code excerpt:

// Copyright Epic Games, Inc. All Rights Reserved.

// The ShaderPrint system uses a RWBuffer to capture any debug print from a shader.
// This means that the buffer needs to be bound for the shader you wish to debug.
// It would be ideal if that was automatic (maybe by having a fixed bind point for the buffer and binding it for the entire view).
// But for now you need to manually add binding information to your FShader class.
// To do this use SHADER_PARAMETER_STRUCT_INCLUDE(ShaderPrint::FShaderParameters) in your FShader::FParameters declaration.
// Then call a variant of SetParameters().

#pragma once

#include "CoreMinimal.h"
#include "RenderGraphDefinitions.h"

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Public/ShaderPrintParameters.h:25

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:

namespace ShaderPrint
{
	// ShaderPrint uniform buffer layout
	BEGIN_GLOBAL_SHADER_PARAMETER_STRUCT(FShaderPrintCommonParameters, RENDERER_API)
		SHADER_PARAMETER(FIntPoint, Resolution)
		SHADER_PARAMETER(FIntPoint, CursorCoord)
		SHADER_PARAMETER(FVector3f, TranslatedWorldOffset)
		SHADER_PARAMETER(FVector2f, FontSize)
		SHADER_PARAMETER(FVector2f, FontSpacing)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Public/ShaderPrintParameters.h:40

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:

	END_GLOBAL_SHADER_PARAMETER_STRUCT()

	// ShaderPrint parameter struct declaration
	BEGIN_SHADER_PARAMETER_STRUCT(FShaderParameters, )
		SHADER_PARAMETER_STRUCT_REF(FShaderPrintCommonParameters, Common)
		SHADER_PARAMETER_RDG_BUFFER_SRV(Buffer<uint>, ShaderPrint_StateBuffer)
		SHADER_PARAMETER_RDG_BUFFER_UAV(RWBuffer<uint>, ShaderPrint_RWEntryBuffer)
	END_SHADER_PARAMETER_STRUCT()

	// Does the platform support the ShaderPrint system?
	// Use this to create debug shader permutations only for supported platforms.
	RENDERER_API bool IsSupported(EShaderPlatform Platform);

	// Set any flags or defines needed when using ShaderPrint
	RENDERER_API void ModifyCompilationEnvironment(const EShaderPlatform Platform, FShaderCompilerEnvironment& OutEnvironment);
	RENDERER_API void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment);

	// Have we enabled the ShaderPrint system?
	// Note that even when the ShaderPrint system is enabled, it may be disabled on any view due to platform support or view flags.
	RENDERER_API bool IsEnabled();

	// Force enable/disable the ShaderPrint system.
	RENDERER_API void SetEnabled(bool bInEnabled);

	// Returns true if the shader print data is valid for binding.
	// This should be checked before using with any ShaderPrint shader permutation.
	RENDERER_API bool IsValid(FShaderPrintData const& InShaderPrintData);

	// Returns true if the shader print data is enabled.
	// When the shader print data is valid but disabled then it can be used with any ShaderPrint shader permutation, but no data will be captured.
	// This can be checked to early out on any work that is only generating ShaderPrint data.
	RENDERER_API bool IsEnabled(FShaderPrintData const& InShaderPrintData);

	// Returns true if the default view exists and has valid shader print data.
	// This should be checked before using with any ShaderPrint shader permutation.
	RENDERER_API bool IsDefaultViewValid();

	// Returns true if the default view exists and shader print data that is enabled.
	// When the shader print data is valid but disabled then it can be used with any ShaderPrint shader permutation, but no data will be captured.
	// This can be checked to early out on any work that is only generating ShaderPrint data.
	RENDERER_API bool IsDefaultViewEnabled();

	/**
	 * Call to ensure enough space for some number of characters, is added cumulatively each frame, to make 
	 * it possible for several systems to request a certain number independently.
	 * Is used to grow the max element count for subsequent frames (as the allocation happens early in the frame).

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Public/ShaderPrintParameters.h:168

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:

	//
	// In Cpp:
	//   SHADER_PARAMETER_STRUCT(ShaderPrint::FStrings::FShaderPararameters, MyVariable)
	//   ShaderPrint::FStrings MyVariable;
	//	 MyVariable.Add(FString(...), StringId);
	//
	// In shader:
	//   FSTRINGS(MyVariable)
	//   void foo()
	//   {