// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "SceneUpdateCommandQueue.h" #include "PrimitiveSceneInfo.h" #include "GPUSceneWriter.h" struct FViewSceneChangeSet; /** * Definitions of primitive scene update commands. */ enum class EPrimitiveUpdateDirtyFlags : uint32 { None = 0u, /** The Transform is modified by this command. */ Transform = 1u << 0, /** The (any) instance data is modified by this command. */ InstanceData = 1u << 1, /** * The culling bounds are modified by this command. * This means the bounds (instance, primitive or both) as used in the culling and should not be updated for any other case. * Thus, needs to be set for transform updates of all kinds. */ CullingBounds = 1u << 2, /** * Culling distances or similar, affecting culling logic, but NOT the bounds. */ CullingLogic = 1u << 3, /** Any state that either makes its way into GPU-Scene or the per primitive UB */ GPUState = 1u << 4, /** All culling-affecting changes */ AllCulling = CullingBounds | CullingLogic, All = GPUState | Transform | InstanceData | CullingBounds | CullingLogic, }; ENUM_CLASS_FLAGS(EPrimitiveUpdateDirtyFlags); enum class EPrimitiveUpdateId : uint32 { UpdateTransform, UpdateInstance, UpdateAttachmentRoot, CustomPrimitiveData, OcclusionBoundsSlacks, InstanceCullDistance, DrawDistance, DistanceFieldScene, OverridePreviousTransform, UpdateInstanceFromCompute, MAX }; using FScenePrimitiveUpdates = TSceneUpdateCommandQueue; using FPrimitiveUpdateCommand = FScenePrimitiveUpdates::FUpdateCommand; template using TPrimitiveUpdatePayloadBase = FScenePrimitiveUpdates::TPayloadBase; struct FUpdateTransformCommand : public TPrimitiveUpdatePayloadBase { FBoxSphereBounds WorldBounds; FBoxSphereBounds LocalBounds; FMatrix LocalToWorld; FVector AttachmentRootPosition; }; struct FUpdateInstanceCommand : public TPrimitiveUpdatePayloadBase { FPrimitiveSceneProxy* PrimitiveSceneProxy{ nullptr }; FBoxSphereBounds WorldBounds; FBoxSphereBounds LocalBounds; }; struct FUpdateInstanceFromComputeCommand : public TPrimitiveUpdatePayloadBase { FPrimitiveSceneProxy* PrimitiveSceneProxy{ nullptr }; FGPUSceneWriteDelegate GPUSceneWriter; }; /** * Helper for the update payloads that contain a single payload value. */ template struct TSingleValuePrimitiveUpdatePayload : public TPrimitiveUpdatePayloadBase { TSingleValuePrimitiveUpdatePayload(const InPayloadDataType &InValue) : Value(InValue) {} InPayloadDataType Value; }; using FUpdateAttachmentRootData = TSingleValuePrimitiveUpdatePayload; // No GPU side effect (?). using FUpdateCustomPrimitiveData = TSingleValuePrimitiveUpdatePayload; // Needs upload using FUpdateOcclusionBoundsSlacksData = TSingleValuePrimitiveUpdatePayload; // Only affects primitive occlusion. using FUpdateInstanceCullDistanceData = TSingleValuePrimitiveUpdatePayload; // Affects GPU culling? using FUpdateDrawDistanceData = TSingleValuePrimitiveUpdatePayload; // Only affects CPU culling. using FUpdateDistanceFieldSceneData = TPrimitiveUpdatePayloadBase; // Only affects DF scene rep - candidate for using abstract type. using FUpdateOverridePreviousTransformData = TSingleValuePrimitiveUpdatePayload;// Overrides the previous transform, which needs to be propagated to the GPU, but otherwise does not change anything on its own. /** * Change set that is valid before removes are processed and the scene data modified. * The referenced arrays have RDG life-time and can be safely used in RDG tasks. * However, the referenced data (primitive/proxy) and meaning of the persistent ID is not generally valid past the call in which this is passed. * Thus, care need to be excercised. */ class FScenePreUpdateChangeSet { public: TConstArrayView RemovedPrimitiveIds; TConstArrayView RemovedPrimitiveSceneInfos; const FScenePrimitiveUpdates &PrimitiveUpdates; const FViewSceneChangeSet* ViewUpdateChangeSet = nullptr; }; /** * Change set that is valid before after adds are processed and the scene data is modified. * The referenced arrays have RDG life-time and can be safely used in RDG tasks. */ class FScenePostUpdateChangeSet { public: TConstArrayView AddedPrimitiveIds; TConstArrayView AddedPrimitiveSceneInfos; const FScenePrimitiveUpdates &PrimitiveUpdates; const FViewSceneChangeSet* ViewUpdateChangeSet = nullptr; };