Files
UnrealEngineUWP/Engine/Shaders/Private/ParticleSimulationCommon.ush
serge bernier 334fcb5df6 Support resizing of the ParticleGPUSimulation resources. Cascade emitter are currently allocating a lot of render resources to support gpu simulation.
Ex:
position        PF_A32B32G32R32F   1024x1024 (16MB)
velocity        PF_FloatRGBA             1024x1024 (8MB)
Attribute1    PF_B8G8R8A8             1024x1024 (4MB)
Attribute2    PF_B8G8R8A8             1024x1024 (4MB)

Thoses textures are all double buffered and at full sizes, they represent 64 MB of render targets.

When GFXCascadeGpuSpriteAllowDynAllocs is enabled, resizing happens when the TileAllocator of the FParticleSimulationResources run out of tiles. We then allocate new tiles and resize the gpu simulation resources render targets, each time by a factor 2 (X,Y). This introduce a TileZ index (TilePageIndex) which allow us to compute a tile page index at runtime and retrieve the resized tile coordinates. Resizing is limited by the maximum morton index possible (65535) and also the original resource sizes provided by the device profile (fx.GPUSimulationTextureSizeX,fx.GPUSimulationTextureSizeY).

The resizing feature can be enable with fx.Cascade.GpuSpriteDynamicAllocations cvar, and the initial size is controlled by fx.GPUSimulationDynTextureSizeXY.

Depending on the platform and map content, this can saves alot of memorey, ranging from 7MB to 56MB depending on the platforms.

*Resizing feature currently dont support GPU sorting mode. Radix sort shader algo will need to support keys/values of different format than 32 bits to work with the dynamic resizing of the gpu sim resources. To work around this limitation, we currently, ignore gpu sorting mode on cascade emitters when resizing is enable. A Jira was created to track this issue, and potentially add support in the future.

#reviewer [at]stu.meckenna, [at]rob.krajcarski
#rb rob.krajcarski, Stu.McKenna

[CL 30858890 by serge bernier in 5.4 branch]
2024-01-24 15:23:14 -05:00

22 lines
551 B
Plaintext

// Copyright Epic Games, Inc. All Rights Reserved.
/*=============================================================================
ParticleSimulationCommon.usf: Particle Simulation shared functions and defines.
=============================================================================*/
#pragma once
#include "MortonCode.ush"
float2 GetTilePageOffset(float ZTileIndex, float2 PageScale, bool bResize = true)
{
float2 UV = 0.0f;
if(bResize)
{
uint2 PageOffset = MortonDecode(ZTileIndex);
UV = PageOffset * PageScale;
}
return UV;
}