Files
UnrealEngineUWP/Engine/Shaders/Shared/VirtualShadowMapDefinitions.h
ola olsson 6c563cf263 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

25 lines
1.3 KiB
C

// 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)
#define VSM_PROJ_FLAG_CURRENT_DISTANT_LIGHT (1U << 0)
#define VSM_PROJ_FLAG_UNCACHED (1U << 1) // Used to indicate that the light is uncached and should only render to dynamic pages
// 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)