UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ShaderPrintParameters.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3// The ShaderPrint system uses a RWBuffer to capture any debug print from a shader.
4// This means that the buffer needs to be bound for the shader you wish to debug.
5// 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).
6// But for now you need to manually add binding information to your FShader class.
7// To do this use SHADER_PARAMETER_STRUCT_INCLUDE(ShaderPrint::FShaderParameters) in your FShader::FParameters declaration.
8// Then call a variant of SetParameters().
9
10#pragma once
11
12#include "CoreMinimal.h"
16#include "ShaderParameters.h"
17
18class FRDGBuilder;
19class FSceneView;
20class FViewInfo;
24struct FShaderPrintData;
25
26namespace ShaderPrint
27{
28 // ShaderPrint uniform buffer layout
30 SHADER_PARAMETER(FIntPoint, Resolution)
31 SHADER_PARAMETER(FIntPoint, CursorCoord)
34 SHADER_PARAMETER(FVector2f, FontSpacing)
35 SHADER_PARAMETER(uint32, MaxCharacterCount)
37 SHADER_PARAMETER(uint32, MaxStateCount)
38 SHADER_PARAMETER(uint32, MaxLineCount)
39 SHADER_PARAMETER(uint32, MaxTriangleCount)
40 SHADER_PARAMETER(uint32, IsDrawLocked)
42
43 // ShaderPrint parameter struct declaration
49
50 // Does the platform support the ShaderPrint system?
51 // Use this to create debug shader permutations only for supported platforms.
53
54 // Set any flags or defines needed when using ShaderPrint
57
58 // Have we enabled the ShaderPrint system?
59 // Note that even when the ShaderPrint system is enabled, it may be disabled on any view due to platform support or view flags.
61
62 // Force enable/disable the ShaderPrint system.
64
65 // Returns true if the shader print data is valid for binding.
66 // This should be checked before using with any ShaderPrint shader permutation.
68
69 // Returns true if the shader print data is enabled.
70 // 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.
71 // This can be checked to early out on any work that is only generating ShaderPrint data.
73
74 // Returns true if the default view exists and has valid shader print data.
75 // This should be checked before using with any ShaderPrint shader permutation.
77
78 // Returns true if the default view exists and shader print data that is enabled.
79 // 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.
80 // This can be checked to early out on any work that is only generating ShaderPrint data.
82
89 RENDERER_API void RequestSpaceForCharacters(uint32 MaxElementCount);
90
97 RENDERER_API void RequestSpaceForLines(uint32 MaxElementCount);
98
105 RENDERER_API void RequestSpaceForTriangles(uint32 MaxElementCount);
106
109 {
111 FShaderPrintSetup() = default;
116
118 bool bEnabled = false;
120 FIntRect ViewRect = FIntRect(0, 0, 1, 1);
122 FIntPoint CursorCoord = FIntPoint(-1, -1);
124 FVector PreViewTranslation = FVector::ZeroVector;
126 float DPIScale = 1.f;
128 FIntPoint FontSize = 1;
130 FIntPoint FontSpacing = 1;
132 uint32 MaxCharacterCount = 0;
134 uint32 MaxStateCount = 0;
136 uint32 MaxLineCount = 0;
138 uint32 MaxTriangleCount = 0;
139 // Whether current draw is locked or not. Useful to stop rendering new stuff on top of the history. */
140 bool bIsDrawLocked = false;
141 };
142
145
148
153
156
157 UE_DEPRECATED(5.2, "Use the version of this function that takes a FSceneInterface")
159
164
165 UE_DEPRECATED(5.1, "Use one of the other implementations of SetParameters()")
166 void SetParameters(FRDGBuilder& GraphBuilder, const FViewInfo& View, FShaderParameters& OutParameters);
167
168 // Experimental GPU string
169 //
170 // In Cpp:
171 // SHADER_PARAMETER_STRUCT(ShaderPrint::FStrings::FShaderPararameters, MyVariable)
172 // ShaderPrint::FStrings MyVariable;
173 // MyVariable.Add(FString(...), StringId);
174 //
175 // In shader:
176 // FSTRINGS(MyVariable)
177 // void foo()
178 // {
179 // InitShaderPrintContext Ctx = InitShaderPrintContext(...);
180 // PrintMyVariable(Ctx, StringId, FontWhite);
181 // }
207}
208
225
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::Math::TIntRect< int32 > FIntRect
Definition MathFwd.h:133
FInt32Point FIntPoint
Definition MathFwd.h:124
EShaderPlatform
Definition RHIShaderPlatform.h:11
#define SHADER_PARAMETER_RDG_BUFFER_SRV(ShaderType, MemberName)
Definition ShaderParameterMacros.h:1800
#define END_GLOBAL_SHADER_PARAMETER_STRUCT
Definition ShaderParameterMacros.h:1669
#define SHADER_PARAMETER_RDG_BUFFER_UAV(ShaderType, MemberName)
Definition ShaderParameterMacros.h:1812
#define BEGIN_SHADER_PARAMETER_STRUCT(StructTypeName, DllStorage)
Definition ShaderParameterMacros.h:1482
#define SHADER_PARAMETER_STRUCT_REF(StructType, MemberName)
Definition ShaderParameterMacros.h:1909
#define BEGIN_GLOBAL_SHADER_PARAMETER_STRUCT
Definition ShaderParameterMacros.h:1663
#define END_SHADER_PARAMETER_STRUCT()
Definition ShaderParameterMacros.h:1485
#define SHADER_PARAMETER(MemberType, MemberName)
Definition ShaderParameterMacros.h:1684
uint32 Offset
Definition VulkanMemory.cpp:4033
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition RenderGraphResources.h:1321
Definition RenderGraphBuilder.h:49
Definition SceneInterface.h:106
Definition SceneView.h:1425
Definition SceneRendering.h:1132
Definition Array.h:670
Definition RefCounting.h:454
Definition ShaderParameterMacros.h:136
Definition ShaderPrint.cpp:22
FFrozenShaderPrintData FreezeShaderPrintData(FRDGBuilder &GraphBuilder, FShaderPrintData &ShaderPrintData)
Definition ShaderPrint.cpp:853
bool IsDefaultViewValid()
Definition ShaderPrint.cpp:333
FShaderPrintData UnFreezeShaderPrintData(FRDGBuilder &GraphBuilder, FFrozenShaderPrintData &FrozenShaderPrintData)
Definition ShaderPrint.cpp:865
bool IsDefaultViewEnabled()
Definition ShaderPrint.cpp:338
void SetEnabled(bool bInEnabled)
Definition ShaderPrint.cpp:317
bool IsSupported(EShaderPlatform InShaderPlatform)
Definition ShaderPrint.cpp:285
void SetParameters(FRDGBuilder &GraphBuilder, const FShaderPrintData &InData, FShaderParameters &OutParameters)
Definition ShaderPrint.cpp:265
bool IsEnabled()
Definition ShaderPrint.cpp:312
void RequestSpaceForLines(uint32 InCount)
Definition ShaderPrint.cpp:348
void ModifyCompilationEnvironment(const EShaderPlatform Platform, FShaderCompilerEnvironment &OutEnvironment)
Definition ShaderPrint.cpp:296
void RequestSpaceForTriangles(uint32 InCount)
Definition ShaderPrint.cpp:353
void SubmitShaderPrintData(FFrozenShaderPrintData &InData, FSceneInterface const *InScene)
Definition ShaderPrint.cpp:358
void GetParameters(FShaderPrintSetup const &InSetup, FShaderPrintCommonParameters &OutParameters)
Definition ShaderPrint.cpp:231
void RequestSpaceForCharacters(uint32 InCount)
Definition ShaderPrint.cpp:343
FShaderPrintData CreateShaderPrintData(FRDGBuilder &GraphBuilder, FShaderPrintSetup const &InSetup, FSceneViewState *InViewState)
Definition ShaderPrint.cpp:763
Definition ShaderPrintParameters.h:233
TRefCountPtr< FRDGPooledBuffer > ShaderPrintEntryBuffer
Definition ShaderPrintParameters.h:236
ShaderPrint::FShaderPrintSetup Setup
Definition ShaderPrintParameters.h:234
TRefCountPtr< FRDGPooledBuffer > ShaderPrintStateBuffer
Definition ShaderPrintParameters.h:237
Definition GlobalShader.h:73
Definition ShaderCore.h:544
Definition ShaderPrintParameters.h:218
FRDGBufferRef ShaderPrintStateBuffer
Definition ShaderPrintParameters.h:223
FRDGBufferRef ShaderPrintEntryBuffer
Definition ShaderPrintParameters.h:222
ShaderPrint::FShaderPrintSetup Setup
Definition ShaderPrintParameters.h:219
TUniformBufferRef< ShaderPrint::FShaderPrintCommonParameters > UniformBuffer
Definition ShaderPrintParameters.h:220
Definition ShaderPrintParameters.h:109
Definition ShaderPrintParameters.h:183
Definition IntPoint.h:25
static CORE_API const TVector< double > ZeroVector
Definition Vector.h:79