2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
Merging //UE4/Dev-Rendering-Graph@4492585 to Dev-Rendering (//UE4/Dev-Rendering)
This implements the framework to write the high level rendering code into passes organized in direct acyclic graph. It is also unifying the uniform buffer, shader parameters, and pass parameters to same single API: structures with run time meta data. This allow high level user code be extremely seamless, user code debugging, and render graph ease of implementation and debugging.
Issue of collaborative work of Arne Schnober, Brian Karis, Daniel Wright, Marcus Wassmer and Guillaume Abadie.
Names of the graph managed resources are not final.
#rb Arne.Schnober, Brian.Karis, Daniel.Wright, Marcus.Wassmer
[CL 4492694 by Guillaume Abadie in Dev-Rendering branch]
2018-10-19 17:36:35 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "RenderGraphResources.h"
|
2018-11-21 18:09:58 -05:00
|
|
|
#include "RenderGraphBuilder.h"
|
Merging //UE4/Dev-Rendering-Graph@4492585 to Dev-Rendering (//UE4/Dev-Rendering)
This implements the framework to write the high level rendering code into passes organized in direct acyclic graph. It is also unifying the uniform buffer, shader parameters, and pass parameters to same single API: structures with run time meta data. This allow high level user code be extremely seamless, user code debugging, and render graph ease of implementation and debugging.
Issue of collaborative work of Arne Schnober, Brian Karis, Daniel Wright, Marcus Wassmer and Guillaume Abadie.
Names of the graph managed resources are not final.
#rb Arne.Schnober, Brian.Karis, Daniel.Wright, Marcus.Wassmer
[CL 4492694 by Guillaume Abadie in Dev-Rendering branch]
2018-10-19 17:36:35 -04:00
|
|
|
#include "Shader.h"
|
2018-11-21 18:09:58 -05:00
|
|
|
#include "ShaderParameterStruct.h"
|
|
|
|
|
#include "ShaderParameterMacros.h"
|
Merging //UE4/Dev-Rendering-Graph@4492585 to Dev-Rendering (//UE4/Dev-Rendering)
This implements the framework to write the high level rendering code into passes organized in direct acyclic graph. It is also unifying the uniform buffer, shader parameters, and pass parameters to same single API: structures with run time meta data. This allow high level user code be extremely seamless, user code debugging, and render graph ease of implementation and debugging.
Issue of collaborative work of Arne Schnober, Brian Karis, Daniel Wright, Marcus Wassmer and Guillaume Abadie.
Names of the graph managed resources are not final.
#rb Arne.Schnober, Brian.Karis, Daniel.Wright, Marcus.Wassmer
[CL 4492694 by Guillaume Abadie in Dev-Rendering branch]
2018-10-19 17:36:35 -04:00
|
|
|
|
2020-02-06 13:13:41 -05:00
|
|
|
class FGlobalShaderMap;
|
|
|
|
|
|
2018-12-18 21:41:17 -05:00
|
|
|
/** An empty shader parameter structure ready to be used anywhere. */
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FEmptyShaderParameters, RENDERCORE_API)
|
|
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
Merging //UE4/Dev-Rendering-Graph@4492585 to Dev-Rendering (//UE4/Dev-Rendering)
This implements the framework to write the high level rendering code into passes organized in direct acyclic graph. It is also unifying the uniform buffer, shader parameters, and pass parameters to same single API: structures with run time meta data. This allow high level user code be extremely seamless, user code debugging, and render graph ease of implementation and debugging.
Issue of collaborative work of Arne Schnober, Brian Karis, Daniel Wright, Marcus Wassmer and Guillaume Abadie.
Names of the graph managed resources are not final.
#rb Arne.Schnober, Brian.Karis, Daniel.Wright, Marcus.Wassmer
[CL 4492694 by Guillaume Abadie in Dev-Rendering branch]
2018-10-19 17:36:35 -04:00
|
|
|
/** Useful parameter struct that only have render targets.
|
|
|
|
|
*
|
|
|
|
|
* FRenderTargetParameters PassParameters;
|
|
|
|
|
* PassParameters.RenderTargets.DepthStencil = ... ;
|
|
|
|
|
* PassParameters.RenderTargets[0] = ... ;
|
|
|
|
|
*/
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FRenderTargetParameters, RENDERCORE_API)
|
|
|
|
|
RENDER_TARGET_BINDING_SLOTS()
|
|
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
2019-01-18 19:20:21 -05:00
|
|
|
/**
|
|
|
|
|
* Clears all render graph tracked resources that are not bound by a shader.
|
|
|
|
|
* Excludes any resources on the ExcludeList from being cleared regardless of whether the
|
|
|
|
|
* shader binds them or not. This is needed for resources that are used outside of shader
|
|
|
|
|
* bindings such as indirect arguments buffers.
|
|
|
|
|
*/
|
|
|
|
|
extern RENDERCORE_API void ClearUnusedGraphResourcesImpl(
|
|
|
|
|
const FShaderParameterBindings& ShaderBindings,
|
|
|
|
|
const FShaderParametersMetadata* ParametersMetadata,
|
|
|
|
|
void* InoutParameters,
|
2020-01-24 18:07:01 -05:00
|
|
|
std::initializer_list<FRDGResourceRef> ExcludeList);
|
Merging //UE4/Dev-Rendering-Graph@4492585 to Dev-Rendering (//UE4/Dev-Rendering)
This implements the framework to write the high level rendering code into passes organized in direct acyclic graph. It is also unifying the uniform buffer, shader parameters, and pass parameters to same single API: structures with run time meta data. This allow high level user code be extremely seamless, user code debugging, and render graph ease of implementation and debugging.
Issue of collaborative work of Arne Schnober, Brian Karis, Daniel Wright, Marcus Wassmer and Guillaume Abadie.
Names of the graph managed resources are not final.
#rb Arne.Schnober, Brian.Karis, Daniel.Wright, Marcus.Wassmer
[CL 4492694 by Guillaume Abadie in Dev-Rendering branch]
2018-10-19 17:36:35 -04:00
|
|
|
|
2020-01-24 18:07:01 -05:00
|
|
|
/** Similar to the function above, but takes a list of shader bindings and only clears if none of the shaders contain the resource. */
|
|
|
|
|
extern RENDERCORE_API void ClearUnusedGraphResourcesImpl(
|
|
|
|
|
TArrayView<const FShaderParameterBindings*> ShaderBindingsList,
|
|
|
|
|
const FShaderParametersMetadata* ParametersMetadata,
|
|
|
|
|
void* InoutParameters,
|
|
|
|
|
std::initializer_list<FRDGResourceRef> ExcludeList);
|
|
|
|
|
|
|
|
|
|
template <typename TShaderClass>
|
2019-09-14 09:45:25 -04:00
|
|
|
void ClearUnusedGraphResources(
|
2020-02-06 13:13:41 -05:00
|
|
|
const TShaderRef<TShaderClass>& Shader,
|
2019-01-18 19:20:21 -05:00
|
|
|
typename TShaderClass::FParameters* InoutParameters,
|
2020-01-24 18:07:01 -05:00
|
|
|
std::initializer_list<FRDGResourceRef> ExcludeList = {})
|
Merging //UE4/Dev-Rendering-Graph@4492585 to Dev-Rendering (//UE4/Dev-Rendering)
This implements the framework to write the high level rendering code into passes organized in direct acyclic graph. It is also unifying the uniform buffer, shader parameters, and pass parameters to same single API: structures with run time meta data. This allow high level user code be extremely seamless, user code debugging, and render graph ease of implementation and debugging.
Issue of collaborative work of Arne Schnober, Brian Karis, Daniel Wright, Marcus Wassmer and Guillaume Abadie.
Names of the graph managed resources are not final.
#rb Arne.Schnober, Brian.Karis, Daniel.Wright, Marcus.Wassmer
[CL 4492694 by Guillaume Abadie in Dev-Rendering branch]
2018-10-19 17:36:35 -04:00
|
|
|
{
|
2018-11-21 20:49:28 -05:00
|
|
|
const FShaderParametersMetadata* ParametersMetadata = TShaderClass::FParameters::FTypeInfo::GetStructMetadata();
|
|
|
|
|
|
|
|
|
|
// Verify the shader have all the parameters it needs. This is done before the
|
2020-01-24 18:07:01 -05:00
|
|
|
// ClearUnusedGraphResourcesImpl() to not mislead user on why some resource are missing
|
2018-11-21 20:49:28 -05:00
|
|
|
// when debugging a validation failure.
|
|
|
|
|
ValidateShaderParameters(Shader, ParametersMetadata, InoutParameters);
|
|
|
|
|
|
|
|
|
|
// Clear the resources the shader won't need.
|
2019-01-18 19:20:21 -05:00
|
|
|
return ClearUnusedGraphResourcesImpl(Shader->Bindings, ParametersMetadata, InoutParameters, ExcludeList);
|
Merging //UE4/Dev-Rendering-Graph@4492585 to Dev-Rendering (//UE4/Dev-Rendering)
This implements the framework to write the high level rendering code into passes organized in direct acyclic graph. It is also unifying the uniform buffer, shader parameters, and pass parameters to same single API: structures with run time meta data. This allow high level user code be extremely seamless, user code debugging, and render graph ease of implementation and debugging.
Issue of collaborative work of Arne Schnober, Brian Karis, Daniel Wright, Marcus Wassmer and Guillaume Abadie.
Names of the graph managed resources are not final.
#rb Arne.Schnober, Brian.Karis, Daniel.Wright, Marcus.Wassmer
[CL 4492694 by Guillaume Abadie in Dev-Rendering branch]
2018-10-19 17:36:35 -04:00
|
|
|
}
|
2018-11-21 18:09:58 -05:00
|
|
|
|
2020-01-24 18:07:01 -05:00
|
|
|
template <typename TShaderClassA, typename TShaderClassB, typename TPassParameterStruct>
|
|
|
|
|
void ClearUnusedGraphResources(
|
2020-02-06 13:13:41 -05:00
|
|
|
const TShaderRef<TShaderClassA>& ShaderA,
|
|
|
|
|
const TShaderRef<TShaderClassB>& ShaderB,
|
2020-01-24 18:07:01 -05:00
|
|
|
TPassParameterStruct* InoutParameters,
|
|
|
|
|
std::initializer_list<FRDGResourceRef> ExcludeList = {})
|
|
|
|
|
{
|
|
|
|
|
static_assert(TIsSame<typename TShaderClassA::FParameters, TPassParameterStruct>::Value, "First shader FParameter type must match pass parameters.");
|
|
|
|
|
static_assert(TIsSame<typename TShaderClassB::FParameters, TPassParameterStruct>::Value, "Second shader FParameter type must match pass parameters.");
|
|
|
|
|
const FShaderParametersMetadata* ParametersMetadata = TPassParameterStruct::FTypeInfo::GetStructMetadata();
|
|
|
|
|
|
|
|
|
|
// Verify the shader have all the parameters it needs. This is done before the
|
|
|
|
|
// ClearUnusedGraphResourcesImpl() to not mislead user on why some resource are missing
|
|
|
|
|
// when debugging a validation failure.
|
|
|
|
|
ValidateShaderParameters(ShaderA, ParametersMetadata, InoutParameters);
|
|
|
|
|
ValidateShaderParameters(ShaderB, ParametersMetadata, InoutParameters);
|
|
|
|
|
|
|
|
|
|
// Clear the resources the shader won't need.
|
|
|
|
|
const FShaderParameterBindings* ShaderBindings[] = { &ShaderA->Bindings, &ShaderB->Bindings };
|
|
|
|
|
return ClearUnusedGraphResourcesImpl(ShaderBindings, ParametersMetadata, InoutParameters, ExcludeList);
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-11 18:27:07 -04:00
|
|
|
/**
|
|
|
|
|
* Register external texture with fallback if the resource is invalid.
|
|
|
|
|
*
|
|
|
|
|
* CAUTION: use this function very wisely. It may actually remove shader parameter validation
|
|
|
|
|
* failure when a pass is actually trying to access a resource not yet or no longer available.
|
|
|
|
|
*/
|
2018-12-18 21:41:17 -05:00
|
|
|
RENDERCORE_API FRDGTextureRef RegisterExternalTextureWithFallback(
|
|
|
|
|
FRDGBuilder& GraphBuilder,
|
|
|
|
|
const TRefCountPtr<IPooledRenderTarget>& ExternalPooledTexture,
|
|
|
|
|
const TRefCountPtr<IPooledRenderTarget>& FallbackPooledTexture,
|
|
|
|
|
const TCHAR* ExternalPooledTextureName = TEXT("External"));
|
|
|
|
|
|
2018-11-21 18:09:58 -05:00
|
|
|
/** All utils for compute shaders.
|
|
|
|
|
*/
|
|
|
|
|
struct RENDERCORE_API FComputeShaderUtils
|
|
|
|
|
{
|
|
|
|
|
/** Ideal size of group size 8x8 to occupy at least an entire wave on GCN, two warp on Nvidia. */
|
|
|
|
|
static constexpr int32 kGolden2DGroupSize = 8;
|
|
|
|
|
|
|
|
|
|
/** Compute the number of group to dispatch. */
|
2019-01-18 19:20:21 -05:00
|
|
|
static FIntVector GetGroupCount(const int32 ThreadCount, const int32 GroupSize)
|
|
|
|
|
{
|
|
|
|
|
return FIntVector(
|
|
|
|
|
FMath::DivideAndRoundUp(ThreadCount, GroupSize),
|
|
|
|
|
1,
|
|
|
|
|
1);
|
|
|
|
|
}
|
2018-11-21 18:09:58 -05:00
|
|
|
static FIntVector GetGroupCount(const FIntPoint& ThreadCount, const FIntPoint& GroupSize)
|
|
|
|
|
{
|
|
|
|
|
return FIntVector(
|
|
|
|
|
FMath::DivideAndRoundUp(ThreadCount.X, GroupSize.X),
|
|
|
|
|
FMath::DivideAndRoundUp(ThreadCount.Y, GroupSize.Y),
|
|
|
|
|
1);
|
|
|
|
|
}
|
|
|
|
|
static FIntVector GetGroupCount(const FIntPoint& ThreadCount, const int32 GroupSize)
|
|
|
|
|
{
|
|
|
|
|
return FIntVector(
|
|
|
|
|
FMath::DivideAndRoundUp(ThreadCount.X, GroupSize),
|
|
|
|
|
FMath::DivideAndRoundUp(ThreadCount.Y, GroupSize),
|
|
|
|
|
1);
|
|
|
|
|
}
|
2019-01-18 19:20:21 -05:00
|
|
|
static FIntVector GetGroupCount(const FIntVector& ThreadCount, const FIntVector& GroupSize)
|
|
|
|
|
{
|
|
|
|
|
return FIntVector(
|
|
|
|
|
FMath::DivideAndRoundUp(ThreadCount.X, GroupSize.X),
|
|
|
|
|
FMath::DivideAndRoundUp(ThreadCount.Y, GroupSize.Y),
|
|
|
|
|
FMath::DivideAndRoundUp(ThreadCount.Z, GroupSize.Z));
|
|
|
|
|
}
|
2018-11-21 18:09:58 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Dispatch a compute shader to rhi command list with its parameters. */
|
|
|
|
|
template<typename TShaderClass>
|
2020-02-06 13:13:41 -05:00
|
|
|
static void Dispatch(FRHICommandList& RHICmdList, const TShaderRef<TShaderClass>& ComputeShader, const typename TShaderClass::FParameters& Parameters, FIntVector GroupCount)
|
2018-11-21 18:09:58 -05:00
|
|
|
{
|
2020-02-06 13:13:41 -05:00
|
|
|
FRHIComputeShader* ShaderRHI = ComputeShader.GetComputeShader();
|
2018-11-21 18:09:58 -05:00
|
|
|
RHICmdList.SetComputeShader(ShaderRHI);
|
|
|
|
|
SetShaderParameters(RHICmdList, ComputeShader, ShaderRHI, Parameters);
|
|
|
|
|
RHICmdList.DispatchComputeShader(GroupCount.X, GroupCount.Y, GroupCount.Z);
|
|
|
|
|
UnsetShaderUAVs(RHICmdList, ComputeShader, ShaderRHI);
|
|
|
|
|
}
|
2019-06-11 18:27:07 -04:00
|
|
|
|
|
|
|
|
/** Indirect dispatch a compute shader to rhi command list with its parameters. */
|
|
|
|
|
template<typename TShaderClass>
|
2019-09-14 09:45:25 -04:00
|
|
|
static void DispatchIndirect(
|
2019-06-11 18:27:07 -04:00
|
|
|
FRHICommandList& RHICmdList,
|
2020-02-06 13:13:41 -05:00
|
|
|
const TShaderRef<TShaderClass>& ComputeShader,
|
2019-06-11 18:27:07 -04:00
|
|
|
const typename TShaderClass::FParameters& Parameters,
|
2019-06-17 13:39:07 -04:00
|
|
|
FRHIVertexBuffer* IndirectArgsBuffer,
|
2019-06-11 18:27:07 -04:00
|
|
|
uint32 IndirectArgOffset)
|
|
|
|
|
{
|
2020-02-06 13:13:41 -05:00
|
|
|
FRHIComputeShader* ShaderRHI = ComputeShader.GetComputeShader();
|
2019-06-11 18:27:07 -04:00
|
|
|
RHICmdList.SetComputeShader(ShaderRHI);
|
|
|
|
|
SetShaderParameters(RHICmdList, ComputeShader, ShaderRHI, Parameters);
|
|
|
|
|
RHICmdList.DispatchIndirectComputeShader(IndirectArgsBuffer, IndirectArgOffset);
|
|
|
|
|
UnsetShaderUAVs(RHICmdList, ComputeShader, ShaderRHI);
|
|
|
|
|
}
|
2018-11-21 18:09:58 -05:00
|
|
|
|
2020-01-24 18:07:01 -05:00
|
|
|
/** Dispatch a compute shader to rhi command list with its parameters and indirect args. */
|
|
|
|
|
template<typename TShaderClass>
|
|
|
|
|
static FORCEINLINE_DEBUGGABLE void DispatchIndirect(
|
|
|
|
|
FRHICommandList& RHICmdList,
|
|
|
|
|
const TShaderClass* ComputeShader,
|
|
|
|
|
const typename TShaderClass::FParameters& Parameters,
|
|
|
|
|
FRDGBufferRef IndirectArgsBuffer,
|
|
|
|
|
uint32 IndirectArgOffset)
|
|
|
|
|
{
|
|
|
|
|
FRHIComputeShader* ShaderRHI = ComputeShader->GetComputeShader();
|
|
|
|
|
RHICmdList.SetComputeShader(ShaderRHI);
|
|
|
|
|
SetShaderParameters(RHICmdList, ComputeShader, ShaderRHI, Parameters);
|
|
|
|
|
RHICmdList.DispatchIndirectComputeShader(IndirectArgsBuffer->GetIndirectRHICallBuffer(), IndirectArgOffset);
|
|
|
|
|
UnsetShaderUAVs(RHICmdList, ComputeShader, ShaderRHI);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-21 18:09:58 -05:00
|
|
|
/** Dispatch a compute shader to render graph builder with its parameters. */
|
|
|
|
|
template<typename TShaderClass>
|
2019-09-14 09:45:25 -04:00
|
|
|
static void AddPass(
|
2018-11-21 18:09:58 -05:00
|
|
|
FRDGBuilder& GraphBuilder,
|
2018-11-21 20:33:41 -05:00
|
|
|
FRDGEventName&& PassName,
|
2020-02-06 13:13:41 -05:00
|
|
|
const TShaderRef<TShaderClass>& ComputeShader,
|
2018-11-21 18:09:58 -05:00
|
|
|
typename TShaderClass::FParameters* Parameters,
|
|
|
|
|
FIntVector GroupCount)
|
|
|
|
|
{
|
|
|
|
|
ClearUnusedGraphResources(ComputeShader, Parameters);
|
|
|
|
|
|
|
|
|
|
GraphBuilder.AddPass(
|
2018-11-21 20:33:41 -05:00
|
|
|
Forward<FRDGEventName>(PassName),
|
2018-11-21 18:09:58 -05:00
|
|
|
Parameters,
|
2019-07-19 14:19:12 -04:00
|
|
|
ERDGPassFlags::Compute,
|
2018-11-21 18:09:58 -05:00
|
|
|
[Parameters, ComputeShader, GroupCount](FRHICommandList& RHICmdList)
|
|
|
|
|
{
|
|
|
|
|
FComputeShaderUtils::Dispatch(RHICmdList, ComputeShader, *Parameters, GroupCount);
|
|
|
|
|
});
|
|
|
|
|
}
|
2019-01-18 19:20:21 -05:00
|
|
|
|
|
|
|
|
/** Dispatch a compute shader to render graph builder with its parameters. */
|
|
|
|
|
template<typename TShaderClass>
|
2019-09-14 09:45:25 -04:00
|
|
|
static void AddPass(
|
2019-01-18 19:20:21 -05:00
|
|
|
FRDGBuilder& GraphBuilder,
|
|
|
|
|
FRDGEventName&& PassName,
|
2020-02-06 13:13:41 -05:00
|
|
|
const TShaderRef<TShaderClass>& ComputeShader,
|
2019-01-18 19:20:21 -05:00
|
|
|
typename TShaderClass::FParameters* Parameters,
|
|
|
|
|
FRDGBufferRef IndirectArgsBuffer,
|
|
|
|
|
uint32 IndirectArgOffset)
|
|
|
|
|
{
|
2019-06-11 18:27:07 -04:00
|
|
|
checkf(IndirectArgsBuffer->Desc.Usage & BUF_DrawIndirect, TEXT("The buffer %s was not flagged for indirect draw parameters"), IndirectArgsBuffer->Name);
|
|
|
|
|
|
2019-01-18 19:20:21 -05:00
|
|
|
ClearUnusedGraphResources(ComputeShader, Parameters, { IndirectArgsBuffer });
|
|
|
|
|
|
|
|
|
|
GraphBuilder.AddPass(
|
|
|
|
|
Forward<FRDGEventName>(PassName),
|
|
|
|
|
Parameters,
|
2019-07-19 14:19:12 -04:00
|
|
|
ERDGPassFlags::Compute,
|
2019-01-18 19:20:21 -05:00
|
|
|
[Parameters, ComputeShader, IndirectArgsBuffer, IndirectArgOffset](FRHICommandList& RHICmdList)
|
2019-06-11 18:27:07 -04:00
|
|
|
{
|
|
|
|
|
// Marks the indirect draw parameter as used by the pass manually, given it can't be bound directly by any of the shader,
|
|
|
|
|
// meaning SetShaderParameters() won't be able to do it.
|
|
|
|
|
IndirectArgsBuffer->MarkResourceAsUsed();
|
|
|
|
|
|
|
|
|
|
FComputeShaderUtils::DispatchIndirect(RHICmdList, ComputeShader, *Parameters, IndirectArgsBuffer->GetIndirectRHICallBuffer(), IndirectArgOffset);
|
2019-01-18 19:20:21 -05:00
|
|
|
});
|
|
|
|
|
}
|
2020-01-24 18:07:01 -05:00
|
|
|
|
2020-02-06 13:13:41 -05:00
|
|
|
static void ClearUAV(FRDGBuilder& GraphBuilder, FGlobalShaderMap* ShaderMap, FRDGBufferUAVRef UAV, uint32 ClearValue);
|
|
|
|
|
static void ClearUAV(FRDGBuilder& GraphBuilder, FGlobalShaderMap* ShaderMap, FRDGBufferUAVRef UAV, FVector4 ClearValue);
|
2019-09-14 09:45:25 -04:00
|
|
|
};
|
|
|
|
|
/** Adds a render graph pass to copy a region from one texture to another. Uses RHICopyTexture under the hood.
|
|
|
|
|
* Formats of the two textures must match. The output and output texture regions be within the respective extents.
|
|
|
|
|
*/
|
|
|
|
|
RENDERCORE_API void AddCopyTexturePass(
|
|
|
|
|
FRDGBuilder& GraphBuilder,
|
|
|
|
|
FRDGTextureRef InputTexture,
|
|
|
|
|
FRDGTextureRef OutputTexture,
|
|
|
|
|
const FRHICopyTextureInfo& CopyInfo);
|
|
|
|
|
|
|
|
|
|
/** Simpler variant of the above function for 2D textures.
|
|
|
|
|
* @param InputPosition The pixel position within the input texture of the top-left corner of the box.
|
|
|
|
|
* @param OutputPosition The pixel position within the output texture of the top-left corner of the box.
|
|
|
|
|
* @param Size The size in pixels of the region to copy from input to output. If zero, the full extent of
|
|
|
|
|
* the input texture is copied.
|
|
|
|
|
*/
|
|
|
|
|
inline void AddCopyTexturePass(
|
|
|
|
|
FRDGBuilder& GraphBuilder,
|
|
|
|
|
FRDGTextureRef InputTexture,
|
|
|
|
|
FRDGTextureRef OutputTexture,
|
|
|
|
|
FIntPoint InputPosition = FIntPoint::ZeroValue,
|
|
|
|
|
FIntPoint OutputPosition = FIntPoint::ZeroValue,
|
|
|
|
|
FIntPoint Size = FIntPoint::ZeroValue)
|
|
|
|
|
{
|
|
|
|
|
FRHICopyTextureInfo CopyInfo;
|
|
|
|
|
CopyInfo.SourcePosition.X = InputPosition.X;
|
|
|
|
|
CopyInfo.SourcePosition.Y = InputPosition.Y;
|
|
|
|
|
CopyInfo.DestPosition.X = OutputPosition.X;
|
|
|
|
|
CopyInfo.DestPosition.Y = OutputPosition.Y;
|
|
|
|
|
if (Size != FIntPoint::ZeroValue)
|
|
|
|
|
{
|
|
|
|
|
CopyInfo.Size = FIntVector(Size.X, Size.Y, 1);
|
|
|
|
|
}
|
|
|
|
|
AddCopyTexturePass(GraphBuilder, InputTexture, OutputTexture, CopyInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-17 04:24:15 -04:00
|
|
|
/** Adds a render graph pass to resolve from one texture to another. Uses RHICopyToResolveTarget under the hood.
|
|
|
|
|
* The formats of the two textures don't need to match.
|
|
|
|
|
*/
|
|
|
|
|
RENDERCORE_API void AddCopyToResolveTargetPass(
|
|
|
|
|
FRDGBuilder& GraphBuilder,
|
|
|
|
|
FRDGTextureRef InputTexture,
|
|
|
|
|
FRDGTextureRef OutputTexture,
|
|
|
|
|
const FResolveParams& ResolveParams);
|
|
|
|
|
|
2019-09-14 09:45:25 -04:00
|
|
|
/** Adds a render graph pass to clear a texture or buffer UAV with a single typed value. */
|
|
|
|
|
RENDERCORE_API void AddClearUAVPass(FRDGBuilder& GraphBuilder, FRDGBufferUAVRef BufferUAV, uint32 Value);
|
|
|
|
|
|
|
|
|
|
RENDERCORE_API void AddClearUAVPass(FRDGBuilder& GraphBuilder, FRDGTextureUAVRef TextureUAV, const float(&ClearValues)[4]);
|
|
|
|
|
|
|
|
|
|
RENDERCORE_API void AddClearUAVPass(FRDGBuilder& GraphBuilder, FRDGTextureUAVRef TextureUAV, const uint32(&ClearValues)[4]);
|
|
|
|
|
|
|
|
|
|
RENDERCORE_API void AddClearUAVPass(FRDGBuilder& GraphBuilder, FRDGTextureUAVRef TextureUAV, const FLinearColor& ClearColor);
|
|
|
|
|
|
2020-01-24 18:07:01 -05:00
|
|
|
/** Clears parts of UAV specified by an array of screen rects. If no rects are specific, then it falls back to a standard UAV clear. */
|
|
|
|
|
RENDERCORE_API void AddClearUAVPass(FRDGBuilder& GraphBuilder, FRDGTextureUAVRef TextureUAV, const uint32(&ClearValues)[4], FRDGBufferSRVRef RectMinMaxBufferSRV, uint32 NumRects);
|
|
|
|
|
|
2019-09-14 09:45:25 -04:00
|
|
|
/** Adds a render graph pass to clear a render target. Prefer to use clear actions if possible. */
|
|
|
|
|
RENDERCORE_API void AddClearRenderTargetPass(FRDGBuilder& GraphBuilder, FRDGTextureRef Texture, const FLinearColor& ClearColor);
|
|
|
|
|
|
|
|
|
|
/** Adds a render graph pass to clear a depth stencil target. Prefer to use clear actions if possible. */
|
|
|
|
|
RENDERCORE_API void AddClearDepthStencilPass(
|
|
|
|
|
FRDGBuilder& GraphBuilder,
|
|
|
|
|
FRDGTextureRef Texture,
|
|
|
|
|
bool bClearDepth,
|
|
|
|
|
float Depth,
|
|
|
|
|
bool bClearStencil,
|
2020-01-24 18:07:01 -05:00
|
|
|
uint8 Stencil);
|
|
|
|
|
|
|
|
|
|
enum class ERDGInitialDataFlags : uint8
|
|
|
|
|
{
|
|
|
|
|
/** Specifies the default behavior, which is to make a copy of the initial data for replay when
|
|
|
|
|
* the graph is executed. The user does not need to preserve lifetime of the data pointer.
|
|
|
|
|
*/
|
|
|
|
|
None = 0,
|
|
|
|
|
|
|
|
|
|
/** Specifies that the user will maintain ownership of the data until the graph is executed. The
|
|
|
|
|
* upload pass will only use a reference to store the data. Use caution with this flag since graph
|
|
|
|
|
* execution is deferred! Useful to avoid the copy if the initial data lifetime is guaranteed to
|
|
|
|
|
* outlive the graph.
|
|
|
|
|
*/
|
|
|
|
|
NoCopy = 0x1
|
|
|
|
|
};
|
|
|
|
|
ENUM_CLASS_FLAGS(ERDGInitialDataFlags)
|
|
|
|
|
|
|
|
|
|
/** Creates a structured buffer with initial data by creating an upload pass. */
|
|
|
|
|
RENDERCORE_API FRDGBufferRef CreateStructuredBuffer(
|
|
|
|
|
FRDGBuilder& GraphBuilder,
|
|
|
|
|
const TCHAR* Name,
|
|
|
|
|
uint32 BytesPerElement,
|
|
|
|
|
uint32 NumElements,
|
|
|
|
|
const void* InitialData,
|
|
|
|
|
uint64 InitialDataSize,
|
|
|
|
|
ERDGInitialDataFlags InitialDataFlags = ERDGInitialDataFlags::None);
|
|
|
|
|
|
|
|
|
|
/** Creates a vertex buffer with initial data by creating an upload pass. */
|
|
|
|
|
RENDERCORE_API FRDGBufferRef CreateVertexBuffer(
|
|
|
|
|
FRDGBuilder& GraphBuilder,
|
|
|
|
|
const TCHAR* Name,
|
|
|
|
|
const FRDGBufferDesc& Desc,
|
|
|
|
|
const void* InitialData,
|
|
|
|
|
uint64 InitialDataSize,
|
|
|
|
|
ERDGInitialDataFlags InitialDataFlags = ERDGInitialDataFlags::None);
|