Files
UnrealEngineUWP/Engine/Shaders/Private/VirtualShadowMaps/VirtualShadowMapCacheLoadBalancer.usf
andrew lauritzen ce2d5721b7 Move some of the invalidation tracking back to per-primitive and on the CPU since we ended up doing WPO stuff slightly differently.
This lets us get rid of the GPU static->dynamic pass that was non-trivially expensive on scenes with many instances, and is currently unnecessary.
Behavior should be the same as before, just with the logic moved back to the CPU and per-primitive (which that part of it functionally still was).

Swap invaliation dispatch back to single per group and go back to expanding on the CPU to avoid redundantly hitting cases that were already CPU culled to specific lights. More of these will be present with Ola's recent changes.

#rb jamie.hayes

[CL 30676139 by andrew lauritzen in ue5-main branch]
2024-01-17 19:35:33 -05:00

51 lines
1.6 KiB
Plaintext

// Copyright Epic Games, Inc. All Rights Reserved.
#include "../Common.ush"
#include "../SceneData.ush"
#include "VirtualShadowMapPageCacheCommon.ush"
#include "VirtualShadowMapCacheInvalidation.ush"
#include "../WaveOpUtil.ush"
#include "../InstanceCulling/InstanceCullingLoadBalancer.ush"
struct FInstanceInvalidationPayload
{
int VirtualShadowMapId;
uint Flags;
};
FInstanceInvalidationPayload DecodeInstanceInvalidationPayload(uint Payload)
{
FInstanceInvalidationPayload Result;
Result.VirtualShadowMapId = Payload >> VSM_INVALIDATION_PAYLOAD_FLAG_BITS;
Result.Flags = Payload & ((1U<<VSM_INVALIDATION_PAYLOAD_FLAG_BITS)-1U);
return Result;
}
[numthreads(CS_1D_GROUP_SIZE_X, 1, 1)]
void InvalidateInstancePagesLoadBalancerCS(
uint3 GroupId : SV_GroupID,
uint GroupThreadIndex : SV_GroupIndex,
uint3 DispatchThreadId : SV_DispatchThreadID)
{
FInstanceWorkSetup WorkSetup = InstanceCullingLoadBalancer_Setup(GroupId, GroupThreadIndex, 0U, true);
if (!WorkSetup.bValid)
{
return;
}
const uint InstanceId = WorkSetup.Item.InstanceDataOffset + uint(WorkSetup.LocalItemIndex);
const uint ShadowMapIndex = WorkSetup.GroupIndexPerBatch;
if (!IsValidInstanceAndCastShadows(InstanceId))
{
return;
}
checkSlow(ShadowMapIndex < VirtualShadowMap.NumFullShadowMaps);
const int VirtualShadowMapId = VSM_MAX_SINGLE_PAGE_SHADOW_MAPS + ShadowMapIndex;
FInstanceInvalidationPayload Payload = DecodeInstanceInvalidationPayload(WorkSetup.Item.Payload);
bool bForceStatic = (Payload.Flags & VSM_INVALIDATION_PAYLOAD_FLAG_FORCE_STATIC) != 0;
InvalidateInstancePages(Payload.VirtualShadowMapId, InstanceId, bForceStatic);
}