Files
UnrealEngineUWP/Engine/Source/Runtime/Renderer/Private/RendererModule.h
jason hoerner b19bb6be2f UE5_MAIN: Multi-view-family scene renderer refactor, part 1. Major structural change to allow scene renderer to accept multiple view families, with otherwise negligible changes in internal behavior.
* Added "BeginRenderingViewFamilies" render interface call that accepts multiple view families.  Original "BeginRenderingViewFamily" falls through to this.
* FSceneRenderer modified to include an array of view families, plus an active view family and the Views for that family.
* Swap ViewFamily to ActiveViewFamily.
* Swap Views array from TArray<FViewInfo> to TArrayView<FViewInfo>, including where the Views array is passed to functions.
* FSceneRenderer iterates over the view families, rendering each one at a time, as separate render graph executions.
* Some frame setup and cleanup logic outside the render graph runs once.
* Moved stateful FSceneRenderer members to FViewFamilyInfo, to preserve existing one-at-a-time view family rendering behavior.
* Display Cluster (Virtual Production) uses new API.

Next step will push everything into one render graph, which requires handling per-family external resources and cleaning up singletons (like FSceneTextures and FSceneTexturesConfig).  Once that's done, we'll be in a position to further interleave rendering, properly handle once per frame work, and solve artifacts in various systems.

#jira none
#rnx
#rb zach.bethel
#preflight 625df821b21bb49791d377c9

[CL 19813996 by jason hoerner in ue5-main branch]
2022-04-19 14:45:26 -04:00

145 lines
7.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
/*=============================================================================
RendererPrivate.h: Renderer interface private definitions.
=============================================================================*/
#pragma once
#include "CoreMinimal.h"
#include "RendererInterface.h"
#include "Shader.h"
class FHitProxyId;
class FLightCacheInterface;
class FMaterial;
class FPrimitiveSceneInfo;
class FSceneInterface;
class FSceneView;
class FSceneViewFamily;
class FSceneViewStateInterface;
class FViewInfo;
struct FMeshBatch;
struct FSynthBenchmarkResults;
struct FSceneTextures;
template<class ResourceType> class TGlobalResource;
DECLARE_LOG_CATEGORY_EXTERN(LogRenderer, Log, All);
/** The renderer module implementation. */
class FRendererModule final : public IRendererModule
{
public:
FRendererModule();
virtual bool SupportsDynamicReloading() override { return true; }
virtual void StartupModule() override;
virtual void ShutdownModule() override;
virtual void BeginRenderingViewFamily(FCanvas* Canvas,FSceneViewFamily* ViewFamily) override;
virtual void CreateAndInitSingleView(FRHICommandListImmediate& RHICmdList, class FSceneViewFamily* ViewFamily, const struct FSceneViewInitOptions* ViewInitOptions) override;
virtual FSceneInterface* AllocateScene(UWorld* World, bool bInRequiresHitProxies, bool bCreateFXSystem, ERHIFeatureLevel::Type InFeatureLevel) override;
virtual void RemoveScene(FSceneInterface* Scene) override;
virtual void UpdateStaticDrawLists() override;
virtual void UpdateStaticDrawListsForMaterials(const TArray<const FMaterial*>& Materials) override;
virtual FSceneViewStateInterface* AllocateViewState(ERHIFeatureLevel::Type FeatureLevel) override;
virtual uint32 GetNumDynamicLightsAffectingPrimitive(const FPrimitiveSceneInfo* PrimitiveSceneInfo,const FLightCacheInterface* LCI) override;
virtual void OnWorldCleanup(UWorld* World, bool bSessionEnded, bool bCleanupResources, bool bWorldChanged) override;
virtual void InitializeSystemTextures(FRHICommandListImmediate& RHICmdList);
virtual void DrawTileMesh(FCanvasRenderContext& RenderContext, FMeshPassProcessorRenderState& DrawRenderState, const FSceneView& View, FMeshBatch& Mesh, bool bIsHitTesting, const FHitProxyId& HitProxyId, bool bUse128bitRT = false) override;
virtual void DebugLogOnCrash() override;
virtual void GPUBenchmark(FSynthBenchmarkResults& InOut, float WorkScale) override;
virtual void ExecVisualizeTextureCmd(const FString& Cmd) override;
virtual void UpdateMapNeedsLightingFullyRebuiltState(UWorld* World) override;
virtual void DrawRectangle(
FRHICommandList& RHICmdList,
float X,
float Y,
float SizeX,
float SizeY,
float U,
float V,
float SizeU,
float SizeV,
FIntPoint TargetSize,
FIntPoint TextureSize,
const TShaderRef<FShader>& VertexShader,
EDrawRectangleFlags Flags = EDRF_Default
) override;
virtual const TSet<FSceneInterface*>& GetAllocatedScenes() override
{
return AllocatedScenes;
}
virtual void RegisterCustomCullingImpl(ICustomCulling* impl) override;
virtual void UnregisterCustomCullingImpl(ICustomCulling* impl) override;
virtual FDelegateHandle RegisterPostOpaqueRenderDelegate(const FPostOpaqueRenderDelegate& InPostOpaqueRenderDelegate) override;
virtual void RemovePostOpaqueRenderDelegate(FDelegateHandle InPostOpaqueRenderDelegate) override;
virtual FDelegateHandle RegisterOverlayRenderDelegate(const FPostOpaqueRenderDelegate& InOverlayRenderDelegate) override;
virtual void RemoveOverlayRenderDelegate(FDelegateHandle InOverlayRenderDelegate) override;
virtual FOnResolvedSceneColor& GetResolvedSceneColorCallbacks() override
{
return PostResolvedSceneColorCallbacks;
}
virtual void PostRenderAllViewports() override;
virtual void PerFrameCleanupIfSkipRenderer() override;
virtual IAllocatedVirtualTexture* AllocateVirtualTexture(const FAllocatedVTDescription& Desc) override;
virtual void DestroyVirtualTexture(IAllocatedVirtualTexture* AllocatedVT) override;
virtual IAdaptiveVirtualTexture* AllocateAdaptiveVirtualTexture(const FAdaptiveVTDescription& AdaptiveVTDesc, const FAllocatedVTDescription& AllocatedVTDesc) override;
virtual void DestroyAdaptiveVirtualTexture(IAdaptiveVirtualTexture* AdaptiveVT) override;
virtual FVirtualTextureProducerHandle RegisterVirtualTextureProducer(const FVTProducerDescription& Desc, IVirtualTexture* Producer) override;
virtual void ReleaseVirtualTextureProducer(const FVirtualTextureProducerHandle& Handle) override;
virtual void AddVirtualTextureProducerDestroyedCallback(const FVirtualTextureProducerHandle& Handle, FVTProducerDestroyedFunction* Function, void* Baton) override;
virtual uint32 RemoveAllVirtualTextureProducerDestroyedCallbacks(const void* Baton) override;
virtual void ReleaseVirtualTexturePendingResources() override;
virtual void RequestVirtualTextureTiles(TArray<uint64>&& InPageRequests) override;
virtual void RequestVirtualTextureTiles(const FVector2D& InScreenSpaceSize, int32 InMipLevel) override;
virtual void RequestVirtualTextureTiles(const FMaterialRenderProxy* InMaterialRenderProxy, const FVector2D& InScreenSpaceSize, ERHIFeatureLevel::Type InFeatureLevel) override;
virtual void RequestVirtualTextureTilesForRegion(IAllocatedVirtualTexture* AllocatedVT, const FVector2D& InScreenSpaceSize, const FVector2D& InViewportPosition, const FVector2D& InViewportSize, const FVector2D& InUV0, const FVector2D& InUV1, int32 InMipLevel) override;
virtual void LoadPendingVirtualTextureTiles(FRHICommandListImmediate& RHICmdList, ERHIFeatureLevel::Type FeatureLevel) override;
virtual void SetVirtualTextureRequestRecordBuffer(uint64 Handle) override;
virtual uint64 GetVirtualTextureRequestRecordBuffer(TSet<uint64>& OutPageRequests) override;
virtual void FlushVirtualTextureCache() override;
virtual void SetNaniteRequestRecordBuffer(uint64 Handle) override;
virtual uint64 GetNaniteRequestRecordBuffer(TArray<uint32>& OutPageRequests) override;
virtual void RequestNanitePages(TArrayView<uint32> InRequestData) override;
virtual void PrefetchNaniteResource(const Nanite::FResources* Resource, uint32 NumFramesUntilRender) override;
virtual void RegisterPersistentViewUniformBufferExtension(IPersistentViewUniformBufferExtension* Extension) override;
void RenderPostOpaqueExtensions(
FRDGBuilder& GraphBuilder,
TArrayView<const FViewInfo> Views,
const FSceneTextures& SceneTextures);
void RenderOverlayExtensions(
FRDGBuilder& GraphBuilder,
TArrayView<const FViewInfo> Views,
const FSceneTextures& SceneTextures);
void RenderPostResolvedSceneColorExtension(FRDGBuilder& GraphBuilder, const FSceneTextures& SceneTextures);
virtual IScenePrimitiveRenderingContext* BeginScenePrimitiveRendering(FRDGBuilder& GraphBuilder, FSceneViewFamily* ViewFamily) override;
virtual void InvalidatePathTracedOutput() override;
virtual void BeginRenderingViewFamilies(FCanvas* Canvas, TArrayView<FSceneViewFamily*> ViewFamilies) override;
private:
TSet<FSceneInterface*> AllocatedScenes;
FOnPostOpaqueRender PostOpaqueRenderDelegate;
FOnPostOpaqueRender OverlayRenderDelegate;
FOnResolvedSceneColor PostResolvedSceneColorCallbacks;
FDelegateHandle StopRenderingThreadDelegate;
};
extern ICustomCulling* GCustomCullingImpl;