Files
UnrealEngineUWP/Engine/Shaders/Private/RenderGraphUtilities.usf
Krzysztof Narkowicz f94472aea1 Lumen surface cache compression
* First all cards are allocated to a temporary atlas of fixed size set by r.LumenScene.CardCaptureAtlasFactor
* After cards are captured into temporary atlas, they are compressed into final BC compressed atlas. Compression can be disabled with r.LumenScene.SurfaceCache.Compress
* Atlas clears were also converted to support clearing compressed surfaces
* Atlas capture operations work on uploaded rect list, instead of a GPU generated card list
* Renamed r.LumenSurfaceCache.* to r.LumenScene.SurfaceCache.*
* Renamed LumenSceneLighting.usf to LumenSurfaceCache.usf
* Renamed LumenScenePrefilter.cpp to LumenSurfaceCache.cpp

Cuts down VRAM memory usage by 160mb
Compression performance on console: ~0.18ms for 1M texels (~0.9ms with UAV aliasing path, which is currently disabled due to missing pieces in RHI)

[CL 16160800 by Krzysztof Narkowicz in ue5-main branch]
2021-04-29 15:30:04 -04:00

43 lines
1.2 KiB
Plaintext

// Copyright Epic Games, Inc. All Rights Reserved.
/*=============================================================================
RenderGraphUtilities.usf
=============================================================================*/
#include "Common.ush"
Buffer<uint4> RectCoordBuffer; // [MinX, MinY, MaxX, MaxY]
Buffer<uint4> RectUVBuffer;
float DownsampleFactor;
float2 InvViewSize;
float2 InvTextureSize;
bool2 VertMax(uint VertexId)
{
bool2 bVertMax;
bVertMax.x = VertexId == 1 || VertexId == 2 || VertexId == 4;
bVertMax.y = VertexId == 2 || VertexId == 4 || VertexId == 5;
return bVertMax;
}
void RasterizeToRectsVS(
in uint InstanceId : SV_InstanceID,
in uint VertexId : SV_VertexID,
out float4 OutPosition : SV_POSITION,
out float2 OutUV : TEXCOORD0)
{
uint4 RectCoord = RectCoordBuffer[InstanceId] * DownsampleFactor;
uint2 VertexCoord = VertMax(VertexId) ? RectCoord.zw : RectCoord.xy;
float4 RectUV = RectCoord * InvViewSize.xyxy;
#if RECT_UV
{
RectUV = RectUVBuffer[InstanceId] * DownsampleFactor * InvTextureSize.xyxy;
}
#endif
float2 VertexUV = VertMax(VertexId) ? RectUV.zw : RectUV.xy;
OutPosition = float4(float2(VertexCoord) * InvViewSize * float2(2.0f, -2.0f) + float2(-1.0, 1.0f), 0.0f, 1.0f);
OutUV = VertexUV;
}