Files
UnrealEngineUWP/Engine/Shaders/Shared/VirtualShadowMapDefinitions.h

66 lines
2.4 KiB
C
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
/*================================================================================================
VirtualShadowMapDefinitions.h: used in virtual shadow map shaders and C++ code to define common constants
!!! Changing this file requires recompilation of the engine !!!
=================================================================================================*/
#pragma once
#define VIRTUAL_SHADOW_MAP_VISUALIZE_NONE 0
#define VIRTUAL_SHADOW_MAP_VISUALIZE_SHADOW_FACTOR (1 << 0)
#define VIRTUAL_SHADOW_MAP_VISUALIZE_CLIPMAP_OR_MIP (1 << 1)
#define VIRTUAL_SHADOW_MAP_VISUALIZE_VIRTUAL_PAGE (1 << 2)
#define VIRTUAL_SHADOW_MAP_VISUALIZE_CACHED_PAGE (1 << 3)
#define VIRTUAL_SHADOW_MAP_VISUALIZE_SMRT_RAY_COUNT (1 << 4)
#define VIRTUAL_SHADOW_MAP_VISUALIZE_CLIPMAP_VIRTUAL_SPACE (1 << 5)
#define VIRTUAL_SHADOW_MAP_VISUALIZE_GENERAL_DEBUG (1 << 6)
Dirty page tracking for non-nanite implementation & WPO-invalidations from Nanite - bMaterialMayModifyPosition -> bMaterialUsesWorldPositionOffset for non-nanite, we don't want to invalidate due to PDO - Nanite instance culling records static primitives that invalidate the VSM (so they get cached as dynamic) - Dirty page flags now store the invalidation as well (static & dynamic) so 3x in size - Nanite VSM instance/cluster culling uses PRIMITIVE_SCENE_DATA_FLAG_EVALUATE_WORLD_POSITION_OFFSET to drive bHasMoved and invalidaiton. - Non-nanite instance culling outputs dirty page flags for invalidating instances, with in-group load balancing for large footprints - Store invalidation flags in physical page metadata flags (removed the cumulative dirty flags buffer). - Added bAnyMaterialHasWorldPositionOffset (accessor AnyMaterialHasWorldPositionOffset()) to FPrimitiveSceneProxy. - Driving PRIMITIVE_SCENE_DATA_FLAG_EVALUATE_WORLD_POSITION_OFFSET from bAnyMaterialHasWorldPositionOffset in addition to EvaluateWorldPositionOffset. - Removed near clip permutation for non-nanite VSM culling shader. - Non-nanite vsm raster passes are all batched in a single RDG pass to better allow overlap between draws and lower pass overhead. - Removed old GPU->GPU invalidation logic. - Removed dynamic caster flags and update the physical page metadata directly - Renamed PRIMITIVE_SCENE_DATA_FLAG_SHOULD_CACHE_SHADOW -> PRIMITIVE_SCENE_DATA_FLAG_SHOULD_CACHE_SHADOW #rb andrew.lauritzen,jamie.hayes #jira UE-147061 #preflight 631b0a18a60c539c98cf1308 [CL 21973831 by ola olsson in ue5-main branch]
2022-09-12 18:06:57 -04:00
#define VIRTUAL_SHADOW_MAP_VISUALIZE_DIRTY_PAGE (1 << 7)
#define VIRTUAL_SHADOW_MAP_VISUALIZE_GPU_INVALIDATED_PAGE (1 << 8)
#define VIRTUAL_SHADOW_MAP_VISUALIZE_MERGED_PAGE (1 << 9)
#define VIRTUAL_SHADOW_MAP_VISUALIZE_NANITE_OVERDRAW (1 << 10)
#define VSM_PROJ_FLAG_CURRENT_DISTANT_LIGHT (1U << 0)
Batch of improvements to page management, that help improve passes of page allocation. Implemented single-page page table support for distant lights - store only a single page table entry for distant lights - modify page lookup logic in various places to handle this Implemented override behavior to render everything to dynamic pages for a light that always invalidates using r.Shadow.Virtual.Cache.ForceInvalidateClipmaps (behave as uncached, despite caching being enabled). This brings performance to par with uncached rendering by removing various overheads that are not achieving anything for this case. - Added a new flag to the nanite view to indicate if it is uncached VSM_PROJ_FLAG_UNCACHED, currently driven by the cvar r.Shadow.Virtual.Cache.ForceInvalidateClipmaps - If this flag is set on a view ShouldCacheInstanceAsStatic, which now takes a nanite view, returns false, causing all rendering to go to the dynamic pages. - To preserve HZB functionality, the HZB build is modified to load from the dynamic depth pages (normally it uses the static) - The page initializer (that clears depth) skips static pages for uncached bviews as they will not be used. - Finally the page merge pass that combines static & dynamic depth into the dynamic page also skips pages from uncached views. Optimized page allocation pass by storing the actual pages needing allocation from the cache init pass. Optimized hierarchical page flag generation by dispatching over physical pages instead of virtual. Fixed dynamic primitive cache invalidation logic. #jira UE-122102 #rb andrew.lauritzen #preflight 63087c2592620e5ec3aa3f2f [CL 21590421 by ola olsson in ue5-main branch]
2022-08-26 11:06:04 -04:00
#define VSM_PROJ_FLAG_UNCACHED (1U << 1) // Used to indicate that the light is uncached and should only render to dynamic pages
#define VSM_PROJ_FLAG_UNREFERENCED (1U << 2) // Used to indicate that the light is not referenced/rendered to this render
Batch of improvements to page management, that help improve passes of page allocation. Implemented single-page page table support for distant lights - store only a single page table entry for distant lights - modify page lookup logic in various places to handle this Implemented override behavior to render everything to dynamic pages for a light that always invalidates using r.Shadow.Virtual.Cache.ForceInvalidateClipmaps (behave as uncached, despite caching being enabled). This brings performance to par with uncached rendering by removing various overheads that are not achieving anything for this case. - Added a new flag to the nanite view to indicate if it is uncached VSM_PROJ_FLAG_UNCACHED, currently driven by the cvar r.Shadow.Virtual.Cache.ForceInvalidateClipmaps - If this flag is set on a view ShouldCacheInstanceAsStatic, which now takes a nanite view, returns false, causing all rendering to go to the dynamic pages. - To preserve HZB functionality, the HZB build is modified to load from the dynamic depth pages (normally it uses the static) - The page initializer (that clears depth) skips static pages for uncached bviews as they will not be used. - Finally the page merge pass that combines static & dynamic depth into the dynamic page also skips pages from uncached views. Optimized page allocation pass by storing the actual pages needing allocation from the cache init pass. Optimized hierarchical page flag generation by dispatching over physical pages instead of virtual. Fixed dynamic primitive cache invalidation logic. #jira UE-122102 #rb andrew.lauritzen #preflight 63087c2592620e5ec3aa3f2f [CL 21590421 by ola olsson in ue5-main branch]
2022-08-26 11:06:04 -04:00
// Hard limit for max distant lights supported 8k for now - we may revise later. We need to keep them in a fixed range for now to make allocation easy and minimize overhead for indexing.
#define VSM_MAX_SINGLE_PAGE_SHADOW_MAPS (1024U * 8U)
#ifdef __cplusplus
#include "HLSLTypeAliases.h"
namespace UE::HLSL
{
#endif
struct FVSMVisibleInstanceCmd
{
uint PackedPageInfo;
uint InstanceIdAndFlags;
uint IndirectArgIndex;
};
struct FVSMCullingBatchInfo
{
uint FirstPrimaryView;
uint NumPrimaryViews;
uint PrimitiveRevealedOffset;
uint PrimitiveRevealedNum;
};
struct FNextVirtualShadowMapData
{
int NextVirtualShadowMapId;
int2 PageAddressOffset;
int _Padding;
};
#ifdef __cplusplus
} // namespace UE::HLSL
using FVSMVisibleInstanceCmd = UE::HLSL::FVSMVisibleInstanceCmd;
using FVSMCullingBatchInfo = UE::HLSL::FVSMCullingBatchInfo;
using FNextVirtualShadowMapData = UE::HLSL::FNextVirtualShadowMapData;
#endif