2020-09-16 04:20:36 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "Strata.h"
# include "HAL/IConsoleManager.h"
2020-10-13 16:46:31 -04:00
# include "PixelShaderUtils.h"
2020-09-16 04:20:36 -04:00
# include "SceneView.h"
# include "ScenePrivate.h"
# include "SceneRendering.h"
# include "RendererInterface.h"
2020-10-08 03:11:37 -04:00
# include "UniformBuffer.h"
2020-11-05 06:16:12 -04:00
# include "SceneTextureParameters.h"
2021-11-29 18:03:54 -05:00
# include "ShaderCompiler.h"
2022-05-05 09:53:22 -04:00
# include "Lumen/Lumen.h"
2022-08-16 04:30:21 -04:00
# include "RendererUtils.h"
2022-08-25 06:29:15 -04:00
# include "EngineAnalytics.h"
2020-09-16 04:20:36 -04:00
2020-11-09 12:06:15 -04:00
//PRAGMA_DISABLE_OPTIMIZATION
2020-09-16 04:20:36 -04:00
// The project setting for Strata
static TAutoConsoleVariable < int32 > CVarStrata (
TEXT ( " r.Strata " ) ,
0 ,
2020-11-20 10:08:04 -04:00
TEXT ( " Enable Strata materials (Beta). " ) ,
2020-09-16 04:20:36 -04:00
ECVF_ReadOnly | ECVF_RenderThreadSafe ) ;
2021-05-25 08:20:38 -04:00
static TAutoConsoleVariable < int32 > CVarStrataBackCompatibility (
TEXT ( " r.StrataBackCompatibility " ) ,
0 ,
TEXT ( " Disables Strata multiple scattering and replaces Chan diffuse by Lambert. " ) ,
ECVF_ReadOnly | ECVF_RenderThreadSafe ) ;
2020-11-20 10:08:04 -04:00
static TAutoConsoleVariable < int32 > CVarStrataBytePerPixel (
TEXT ( " r.Strata.BytesPerPixel " ) ,
80 ,
TEXT ( " Strata allocated byte per pixel to store materials data. Higher value means more complex material can be represented. " ) ,
ECVF_ReadOnly | ECVF_RenderThreadSafe ) ;
2020-09-16 04:20:36 -04:00
2022-08-24 08:30:22 -04:00
static TAutoConsoleVariable < int32 > CVarStrataShadingQuality (
TEXT ( " r.Strata.ShadingQuality " ) ,
1 ,
2022-09-06 14:20:32 -04:00
TEXT ( " Define Strata shading quality (1: accurate lighting, 2: approximate lighting). This variable is read-only. " ) ,
ECVF_ReadOnly | ECVF_RenderThreadSafe ) ;
static TAutoConsoleVariable < int32 > CVarStrataTileCoord8Bits (
TEXT ( " r.Strata.TileCoord8bits " ) ,
0 ,
TEXT ( " Format of tile coord. This variable is read-only. " ) ,
2022-08-24 08:30:22 -04:00
ECVF_ReadOnly | ECVF_RenderThreadSafe ) ;
2021-11-03 04:18:34 -04:00
static TAutoConsoleVariable < int32 > CVarStrataRoughDiffuse (
TEXT ( " r.Strata.RoughDiffuse " ) ,
1 ,
TEXT ( " Enable Strata rough diffuse model (works only if r.Material.RoughDiffuse is enabled in the project settings). Togglable at runtime " ) ,
ECVF_RenderThreadSafe ) ;
2021-11-07 23:43:01 -05:00
// Transition render settings that will disapear when strata gets enabled
2021-02-15 08:15:16 -04:00
2021-11-07 23:43:01 -05:00
static TAutoConsoleVariable < int32 > CVarMaterialRoughDiffuse (
TEXT ( " r.Material.RoughDiffuse " ) ,
2021-02-23 04:34:03 -04:00
0 ,
2021-11-07 23:43:01 -05:00
TEXT ( " Enable rough diffuse material. " ) ,
ECVF_ReadOnly | ECVF_RenderThreadSafe ) ;
2021-12-06 08:54:37 -05:00
// STRATA_TODO we keep this for now and can remove it once battletested.
2022-08-16 04:30:21 -04:00
static TAutoConsoleVariable < int32 > CVarUseCmaskClear (
TEXT ( " r.Strata.UseCmaskClear " ) ,
2022-08-19 08:21:55 -04:00
0 ,
2021-12-06 08:54:37 -05:00
TEXT ( " TEST. " ) ,
ECVF_RenderThreadSafe ) ;
2021-02-23 04:34:03 -04:00
2022-05-02 12:12:18 -04:00
static TAutoConsoleVariable < float > CVarStrataTileOverflow (
2022-03-31 12:43:49 -04:00
TEXT ( " r.Strata.TileOverflow " ) ,
2022-03-18 13:43:33 -04:00
1.f ,
TEXT ( " Scale the number of Strata tile for overflowing tiles containing multi-BSDFs pixels. (0: 0%, 1: 100%. Default 1.0f). " ) ,
2022-03-31 12:43:49 -04:00
ECVF_RenderThreadSafe ) ;
2021-02-15 08:15:16 -04:00
2022-10-27 13:24:29 -04:00
static TAutoConsoleVariable < int32 > CVarStrataTileOverflowFromMaterial (
TEXT ( " r.Strata.TileOverflowFromMaterial " ) ,
1 ,
TEXT ( " When enable, scale the number of Strata tile for overflowing tiles containing multi-BSDFs pixels based on material data. Otherwise use global overflow scale defined by r.Strata.TileOverflow. " ) ,
ECVF_RenderThreadSafe ) ;
2022-04-13 13:49:36 -04:00
static TAutoConsoleVariable < int32 > CVarStrataDebugPeelLayersAboveDepth (
TEXT ( " r.Strata.Debug.PeelLayersAboveDepth " ) ,
0 ,
TEXT ( " Strata debug control to progressively peel off materials layer by layer. " ) ,
ECVF_RenderThreadSafe ) ;
2022-05-05 15:00:34 -04:00
static TAutoConsoleVariable < int32 > CVarStrataAsyncClassification (
TEXT ( " r.Strata.AsyncClassification " ) ,
1 ,
TEXT ( " Run Strata material classification in async (with shadow). " ) ,
ECVF_RenderThreadSafe ) ;
2022-09-16 08:21:00 -04:00
static TAutoConsoleVariable < int32 > CVarStrataDBufferPass (
TEXT ( " r.Strata.DBufferPass " ) ,
0 ,
TEXT ( " Apply DBuffer after the base-pass as a separate pass. " ) ,
ECVF_RenderThreadSafe ) ;
2022-09-20 09:05:17 -04:00
static TAutoConsoleVariable < int32 > CVarStrataDBufferPassDedicatedTiles (
TEXT ( " r.Strata.DBufferPass.DedicatedTiles " ) ,
0 ,
TEXT ( " Use dedicated tile for DBuffer application when DBuffer pass is enabled. " ) ,
ECVF_RenderThreadSafe ) ;
2020-10-08 03:11:37 -04:00
IMPLEMENT_GLOBAL_SHADER_PARAMETER_STRUCT ( FStrataGlobalUniformParameters , " Strata " ) ;
2022-08-31 05:33:41 -04:00
extern bool IsStrataAdvancedVisualizationShadersEnabled ( ) ;
2022-04-02 14:31:01 -04:00
void FStrataViewData : : Reset ( )
2021-03-30 02:33:35 -04:00
{
2022-10-27 13:24:29 -04:00
// Preserve old max BSDF count which is set prior to the reset operation
const uint32 OldMaxBSDFCount = MaxBSDFCount ;
2022-04-02 14:31:01 -04:00
* this = FStrataViewData ( ) ;
2022-10-27 13:24:29 -04:00
MaxBSDFCount = OldMaxBSDFCount ;
2022-03-15 09:55:16 -04:00
for ( uint32 i = 0 ; i < EStrataTileType : : ECount ; + + i )
2021-04-06 02:12:57 -04:00
{
ClassificationTileListBuffer [ i ] = nullptr ;
ClassificationTileListBufferUAV [ i ] = nullptr ;
ClassificationTileListBufferSRV [ i ] = nullptr ;
}
2021-03-30 02:33:35 -04:00
}
2022-03-15 09:55:16 -04:00
const TCHAR * ToString ( EStrataTileType Type )
2021-11-07 23:43:01 -05:00
{
switch ( Type )
{
2022-03-16 05:45:43 -04:00
case EStrataTileType : : ESimple : return TEXT ( " Simple " ) ;
case EStrataTileType : : ESingle : return TEXT ( " Single " ) ;
case EStrataTileType : : EComplex : return TEXT ( " Complex " ) ;
2022-09-20 09:05:17 -04:00
case EStrataTileType : : EOpaqueRoughRefraction : return TEXT ( " Opaque/RoughRefraction " ) ;
case EStrataTileType : : EOpaqueRoughRefractionSSSWithout : return TEXT ( " Opaque/RoughRefraction/SSSWithout " ) ;
case EStrataTileType : : EDecalSimple : return TEXT ( " Decal/Simple " ) ;
case EStrataTileType : : EDecalSingle : return TEXT ( " Decal/Single " ) ;
case EStrataTileType : : EDecalComplex : return TEXT ( " Decal/Complex " ) ;
2021-11-07 23:43:01 -05:00
}
return TEXT ( " Unknown " ) ;
}
2021-03-30 02:33:35 -04:00
2020-09-16 16:23:11 -04:00
namespace Strata
{
2020-09-16 04:20:36 -04:00
bool IsStrataEnabled ( )
{
2021-02-09 18:01:10 -04:00
return CVarStrata . GetValueOnAnyThread ( ) > 0 ;
2020-09-16 04:20:36 -04:00
}
2022-10-11 09:32:40 -04:00
bool IsStrataDbufferPassEnabled ( const EShaderPlatform InPlatform )
2022-09-16 08:21:00 -04:00
{
2022-10-11 09:32:40 -04:00
return IsStrataEnabled ( ) & & IsUsingDBuffers ( InPlatform ) & & CVarStrataDBufferPass . GetValueOnAnyThread ( ) > 0 ;
2022-09-16 08:21:00 -04:00
}
2022-05-02 12:12:18 -04:00
enum EStrataTileSpace
{
StrataTileSpace_Primary = 1u ,
StrataTileSpace_Overflow = 2u
} ;
2022-10-27 13:24:29 -04:00
bool DoesStrataTileOverflowUseMaterialData ( )
2022-10-27 09:52:35 -04:00
{
2022-10-27 13:24:29 -04:00
return CVarStrataTileOverflowFromMaterial . GetValueOnRenderThread ( ) > 0 ;
2022-10-27 09:52:35 -04:00
}
2022-10-27 13:24:29 -04:00
float GetStrataTileOverflowRatio ( const FViewInfo & View )
{
if ( DoesStrataTileOverflowUseMaterialData ( ) )
{
const uint32 MaxBDFCount = FMath : : Max ( View . StrataViewData . MaxBSDFCount , 1u ) ;
return FMath : : Clamp ( MaxBDFCount - 1 , 0.f , 4.0f ) ;
}
else
{
return FMath : : Clamp ( CVarStrataTileOverflow . GetValueOnRenderThread ( ) , 0.f , 4.0f ) ;
}
}
static FIntPoint GetStrataTextureTileResolution ( const FViewInfo & View , const FIntPoint & InResolution , uint32 InSpace )
2021-01-27 08:51:50 -04:00
{
2022-03-18 13:43:33 -04:00
FIntPoint Out = InResolution ;
2022-05-02 12:12:18 -04:00
Out . X = FMath : : DivideAndRoundUp ( Out . X , STRATA_TILE_SIZE ) ;
Out . Y = 0 ;
if ( InSpace & EStrataTileSpace : : StrataTileSpace_Primary )
2022-03-18 13:43:33 -04:00
{
2022-05-02 12:12:18 -04:00
Out . Y + = FMath : : DivideAndRoundUp ( InResolution . Y , STRATA_TILE_SIZE ) ;
}
if ( InSpace & EStrataTileSpace : : StrataTileSpace_Overflow )
{
2022-10-27 13:24:29 -04:00
const float OverflowRatio = GetStrataTileOverflowRatio ( View ) ;
2022-05-02 12:12:18 -04:00
Out . Y + = FMath : : DivideAndRoundUp ( FMath : : CeilToInt ( InResolution . Y * OverflowRatio ) , STRATA_TILE_SIZE ) ;
2022-03-18 13:43:33 -04:00
}
return Out ;
2021-01-27 08:51:50 -04:00
}
2022-10-27 13:24:29 -04:00
FIntPoint GetStrataTextureResolution ( const FViewInfo & View , const FIntPoint & InResolution )
2022-03-18 13:43:33 -04:00
{
2022-05-02 12:12:18 -04:00
if ( Strata : : IsStrataEnabled ( ) )
{
2022-10-27 13:24:29 -04:00
return GetStrataTextureTileResolution ( View , InResolution , EStrataTileSpace : : StrataTileSpace_Primary | EStrataTileSpace : : StrataTileSpace_Overflow ) * STRATA_TILE_SIZE ;
2022-05-02 12:12:18 -04:00
}
{
return InResolution ;
}
2022-03-18 13:43:33 -04:00
}
2021-02-15 08:15:16 -04:00
2022-04-02 14:31:01 -04:00
static void BindStrataGlobalUniformParameters ( FRDGBuilder & GraphBuilder , FStrataViewData * StrataViewData , FStrataGlobalUniformParameters & OutStrataUniformParameters ) ;
2022-04-01 08:35:55 -04:00
2022-10-27 09:52:35 -04:00
bool SupportsCMask ( const FStaticShaderPlatform InPlatform )
{
return CVarUseCmaskClear . GetValueOnRenderThread ( ) > 0 & & FDataDrivenShaderPlatformInfo : : GetSupportsRenderTargetWriteMask ( InPlatform ) ;
}
bool IsClassificationCoord8bits ( )
{
return CVarStrataTileCoord8Bits . GetValueOnRenderThread ( ) = = 1 ;
}
bool IsClassificationAsync ( )
{
return CVarStrataAsyncClassification . GetValueOnRenderThread ( ) > 0 ;
}
2022-09-06 14:20:32 -04:00
static EPixelFormat GetClassificationTileFormat ( const FIntPoint & InResolution )
{
// For platform which whose resolution is never above 1080p, use 8bit tile format for performance.
2022-10-27 09:52:35 -04:00
const bool bRequest8bit = IsClassificationCoord8bits ( ) ;
2022-09-08 06:34:05 -04:00
if ( bRequest8bit )
{
check ( InResolution . X < = 2048 & & InResolution . Y < = 2048 ) ;
}
return bRequest8bit ? PF_R16_UINT : PF_R32_UINT ;
2022-09-06 14:20:32 -04:00
}
2022-05-05 09:53:22 -04:00
static void InitialiseStrataViewData ( FRDGBuilder & GraphBuilder , FViewInfo & View , const FSceneTexturesConfig & SceneTexturesConfig , bool bNeedBSDFOffets , FStrataSceneData & SceneData )
2020-09-16 04:20:36 -04:00
{
2022-04-02 14:31:01 -04:00
// Sanity check: the scene data should already exist
check ( SceneData . MaterialTextureArray ! = nullptr ) ;
FStrataViewData & Out = View . StrataViewData ;
Out . Reset ( ) ;
Out . SceneData = & SceneData ;
const FIntPoint ViewResolution ( View . ViewRect . Width ( ) , View . ViewRect . Height ( ) ) ;
if ( IsStrataEnabled ( ) )
{
const FIntPoint TileResolution ( FMath : : DivideAndRoundUp ( ViewResolution . X , STRATA_TILE_SIZE ) , FMath : : DivideAndRoundUp ( ViewResolution . Y , STRATA_TILE_SIZE ) ) ;
const TCHAR * StrataTileListBufferNames [ EStrataTileType : : ECount ] =
{
TEXT ( " Strata.StrataTileListBuffer(Simple) " ) ,
TEXT ( " Strata.StrataTileListBuffer(Single) " ) ,
TEXT ( " Strata.StrataTileListBuffer(Complex) " ) ,
TEXT ( " Strata.StrataTileListBuffer(OpaqueRoughRefraction) " ) ,
2022-09-20 09:05:17 -04:00
TEXT ( " Strata.StrataTileListBuffer(OpaqueRoughRefractionSSSWithout) " ) ,
TEXT ( " Strata.StrataTileListBuffer(DecalSimple) " ) ,
TEXT ( " Strata.StrataTileListBuffer(DecalSingle) " ) ,
TEXT ( " Strata.StrataTileListBuffer(DecalComplex) " ) ,
2022-04-02 14:31:01 -04:00
} ;
// Tile classification buffers
{
// Indirect draw
Out . ClassificationTileDrawIndirectBuffer = GraphBuilder . CreateBuffer ( FRDGBufferDesc : : CreateIndirectDesc < FRHIDrawIndirectParameters > ( EStrataTileType : : ECount ) , TEXT ( " Strata.StrataTileDrawIndirectBuffer " ) ) ;
Out . ClassificationTileDrawIndirectBufferUAV = GraphBuilder . CreateUAV ( Out . ClassificationTileDrawIndirectBuffer , PF_R32_UINT ) ;
AddClearUAVPass ( GraphBuilder , Out . ClassificationTileDrawIndirectBufferUAV , 0 ) ;
// Indirect dispatch
Out . ClassificationTileDispatchIndirectBuffer = GraphBuilder . CreateBuffer ( FRDGBufferDesc : : CreateIndirectDesc < FRHIDispatchIndirectParameters > ( EStrataTileType : : ECount ) , TEXT ( " Strata.StrataTileDispatchIndirectBuffer " ) ) ;
Out . ClassificationTileDispatchIndirectBufferUAV = GraphBuilder . CreateUAV ( Out . ClassificationTileDispatchIndirectBuffer , PF_R32_UINT ) ;
AddClearUAVPass ( GraphBuilder , Out . ClassificationTileDispatchIndirectBufferUAV , 0 ) ;
2022-09-20 09:05:17 -04:00
// Separated subsurface & rough refraction textures (tile data)
const uint32 RoughTileCount = IsStrataOpaqueMaterialRoughRefractionEnabled ( ) ? TileResolution . X * TileResolution . Y : 4 ;
2022-10-11 09:32:40 -04:00
const uint32 DecalTileCount = IsStrataDbufferPassEnabled ( View . GetShaderPlatform ( ) ) ? TileResolution . X * TileResolution . Y : 4 ;
2022-09-20 09:05:17 -04:00
const uint32 RegularTileCount = TileResolution . X * TileResolution . Y ;
2022-09-06 14:20:32 -04:00
const EPixelFormat ClassificationTileFormat = GetClassificationTileFormat ( ViewResolution ) ;
2022-09-20 09:05:17 -04:00
for ( uint32 i = 0 ; i < EStrataTileType : : ECount ; + + i )
2022-04-02 14:31:01 -04:00
{
2022-09-20 09:05:17 -04:00
const EStrataTileType TileType = EStrataTileType ( i ) ;
const uint32 FormatBytes = ClassificationTileFormat = = PF_R16_UINT ? sizeof ( uint16 ) : sizeof ( uint32 ) ;
uint32 TileCount = 0 ;
switch ( TileType )
{
case EStrataTileType : : ESimple :
case EStrataTileType : : ESingle :
case EStrataTileType : : EComplex :
TileCount = RegularTileCount ; break ;
case EStrataTileType : : EOpaqueRoughRefraction :
case EStrataTileType : : EOpaqueRoughRefractionSSSWithout :
TileCount = RoughTileCount ; break ;
case EStrataTileType : : EDecalSimple :
case EStrataTileType : : EDecalSingle :
case EStrataTileType : : EDecalComplex :
TileCount = DecalTileCount ; break ;
}
check ( TileCount > 0 ) ;
Out . ClassificationTileListBuffer [ i ] = GraphBuilder . CreateBuffer ( FRDGBufferDesc : : CreateBufferDesc ( FormatBytes , TileCount ) , StrataTileListBufferNames [ i ] ) ;
2022-09-06 14:20:32 -04:00
Out . ClassificationTileListBufferSRV [ i ] = GraphBuilder . CreateSRV ( Out . ClassificationTileListBuffer [ i ] , ClassificationTileFormat ) ;
Out . ClassificationTileListBufferUAV [ i ] = GraphBuilder . CreateUAV ( Out . ClassificationTileListBuffer [ i ] , ClassificationTileFormat ) ;
2022-04-02 14:31:01 -04:00
}
}
// BSDF tiles
2022-05-05 09:53:22 -04:00
if ( bNeedBSDFOffets )
{
2022-05-02 12:12:36 -04:00
const FIntPoint BufferSize = SceneTexturesConfig . Extent ;
2022-10-27 13:24:29 -04:00
const FIntPoint BufferSize_Extended = GetStrataTextureTileResolution ( View , SceneTexturesConfig . Extent , EStrataTileSpace : : StrataTileSpace_Primary | EStrataTileSpace : : StrataTileSpace_Overflow ) ;
2022-04-02 14:31:01 -04:00
2022-05-02 14:06:39 -04:00
const FIntPoint BaseOverflowTileOffset = FIntPoint ( 0 , FMath : : DivideAndRoundUp ( BufferSize . Y , STRATA_TILE_SIZE ) ) ;
2022-05-02 12:12:18 -04:00
2022-10-27 13:24:29 -04:00
Out . TileCount = GetStrataTextureTileResolution ( View , ViewResolution , EStrataTileSpace : : StrataTileSpace_Primary ) ;
2022-05-02 12:12:18 -04:00
Out . TileOffset = FIntPoint ( FMath : : DivideAndRoundUp ( View . ViewRect . Min . X , STRATA_TILE_SIZE ) , FMath : : DivideAndRoundUp ( View . ViewRect . Min . Y , STRATA_TILE_SIZE ) ) ;
2022-10-27 13:24:29 -04:00
Out . OverflowTileCount = GetStrataTextureTileResolution ( View , ViewResolution , EStrataTileSpace : : StrataTileSpace_Overflow ) ;
Out . OverflowTileOffset = GetStrataTextureTileResolution ( View , Out . TileOffset * STRATA_TILE_SIZE , EStrataTileSpace : : StrataTileSpace_Overflow ) + BaseOverflowTileOffset ;
2022-05-02 12:12:18 -04:00
Out . BSDFTileTexture = GraphBuilder . CreateTexture ( FRDGTextureDesc : : Create2D ( BufferSize_Extended , PF_R32_UINT , FClearValueBinding : : None , TexCreate_UAV | TexCreate_ShaderResource ) , TEXT ( " Strata.BSDFTiles " ) ) ;
2022-04-02 14:31:01 -04:00
AddClearUAVPass ( GraphBuilder , GraphBuilder . CreateUAV ( Out . BSDFTileTexture ) , 0u ) ;
2022-05-02 12:12:18 -04:00
Out . BSDFTilePerThreadDispatchIndirectBuffer = GraphBuilder . CreateBuffer ( FRDGBufferDesc : : CreateIndirectDesc < FRHIDispatchIndirectParameters > ( 1 ) , TEXT ( " Strata.StrataBSDFTilePerThreadDispatchIndirectBuffer " ) ) ;
2022-04-02 14:31:01 -04:00
Out . BSDFTileDispatchIndirectBuffer = GraphBuilder . CreateBuffer ( FRDGBufferDesc : : CreateIndirectDesc < FRHIDispatchIndirectParameters > ( 1 ) , TEXT ( " Strata.StrataBSDFTileDispatchIndirectBuffer " ) ) ;
Out . BSDFTileCountBuffer = GraphBuilder . CreateBuffer ( FRDGBufferDesc : : CreateBufferDesc ( 4 , 1 ) , TEXT ( " Strata.BSDFTileCount " ) ) ;
}
2022-05-05 09:53:22 -04:00
else
{
2022-10-27 13:24:29 -04:00
Out . TileCount = GetStrataTextureTileResolution ( View , ViewResolution , EStrataTileSpace : : StrataTileSpace_Primary ) ;
2022-05-05 09:53:22 -04:00
Out . TileOffset = FIntPoint ( 0 , 0 ) ;
Out . OverflowTileCount = FIntPoint ( 0 , 0 ) ;
Out . OverflowTileOffset = FIntPoint ( 0 , 0 ) ;
Out . BSDFTileTexture = nullptr ;
Out . BSDFTilePerThreadDispatchIndirectBuffer = nullptr ;
Out . BSDFTileDispatchIndirectBuffer = nullptr ;
Out . BSDFTileCountBuffer = nullptr ;
}
2022-04-02 14:31:01 -04:00
}
// Create the readable uniform buffers
if ( IsStrataEnabled ( ) )
{
FStrataGlobalUniformParameters * StrataUniformParameters = GraphBuilder . AllocParameters < FStrataGlobalUniformParameters > ( ) ;
BindStrataGlobalUniformParameters ( GraphBuilder , & Out , * StrataUniformParameters ) ;
Out . StrataGlobalUniformParameters = GraphBuilder . CreateUniformBuffer ( StrataUniformParameters ) ;
}
}
2022-05-05 09:53:22 -04:00
static bool NeedBSDFOffsets ( const FScene * Scene , const FViewInfo & View )
{
return ShouldRenderLumenDiffuseGI ( Scene , View ) | | ShouldRenderLumenReflections ( View ) | | Strata : : ShouldRenderStrataDebugPasses ( View ) ;
}
2022-09-15 05:43:33 -04:00
static uint32 StrataGetBytePerPixel ( )
{
// We enforce at least 20 bytes per pixel because this is the minimal Strata GBuffer footprint of the simplest material.
const uint32 MinStrataBytePerPixel = 20u ;
const uint32 MaxStrataBytePerPixel = 256u ;
return FMath : : Clamp ( uint32 ( CVarStrataBytePerPixel . GetValueOnAnyThread ( ) ) , MinStrataBytePerPixel , MaxStrataBytePerPixel ) ;
}
2022-08-25 06:29:15 -04:00
static void RecordStrataAnalytics ( )
{
if ( FEngineAnalytics : : IsAvailable ( ) )
{
TArray < FAnalyticsEventAttribute > EventAttributes ;
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " Enabled " ) , 1 ) ) ;
2022-09-15 05:43:33 -04:00
EventAttributes . Add ( FAnalyticsEventAttribute ( TEXT ( " BytesPerPixel " ) , StrataGetBytePerPixel ( ) ) ) ;
2022-08-25 06:29:15 -04:00
FString OutStr ( TEXT ( " Strata " ) ) ;
FEngineAnalytics : : GetProvider ( ) . RecordEvent ( OutStr , EventAttributes ) ;
}
}
2022-11-16 11:35:48 -05:00
static EPixelFormat GetTopLayerTextureFormat ( )
{
2022-11-21 11:12:38 -05:00
static const auto CVarStrataGBufferFormat = IConsoleManager : : Get ( ) . FindTConsoleVariableDataInt ( TEXT ( " r.GBufferFormat " ) ) ;
const bool bStrataHighQualityNormal = CVarStrataGBufferFormat & & CVarStrataGBufferFormat - > GetValueOnAnyThread ( ) > 1 ;
// High quality normal is not supported on platforms that do not support R32G32 UAV load.
// This is dues to the way Strata account for decals. See FStrataDBufferPassCS, updating TopLayerTexture this way.
// If you encounter this check, you must disable high quality normal for Strata (material shaders must be recompiled to account for that).
check ( ! bStrataHighQualityNormal | | ( bStrataHighQualityNormal & & UE : : PixelFormat : : HasCapabilities ( PF_R32G32_UINT , EPixelFormatCapabilities : : TypedUAVLoad ) ) ) ;
return bStrataHighQualityNormal ? PF_R32G32_UINT : PF_R32_UINT ;
2022-11-16 11:35:48 -05:00
}
2022-08-25 06:29:15 -04:00
2022-04-02 14:31:01 -04:00
void InitialiseStrataFrameSceneData ( FRDGBuilder & GraphBuilder , FSceneRenderer & SceneRenderer )
{
FStrataSceneData & Out = SceneRenderer . Scene - > StrataSceneData ;
Out = FStrataSceneData ( ) ;
2020-09-16 04:20:36 -04:00
2021-03-30 05:18:53 -04:00
auto UpdateMaterialBufferToTiledResolution = [ ] ( FIntPoint InBufferSizeXY , FIntPoint & OutMaterialBufferSizeXY )
{
// We need to allocate enough for the tiled memory addressing to always work
2022-03-31 13:05:44 -04:00
OutMaterialBufferSizeXY . X = FMath : : DivideAndRoundUp ( InBufferSizeXY . X , STRATA_TILE_SIZE ) * STRATA_TILE_SIZE ;
OutMaterialBufferSizeXY . Y = FMath : : DivideAndRoundUp ( InBufferSizeXY . Y , STRATA_TILE_SIZE ) * STRATA_TILE_SIZE ;
2021-03-30 05:18:53 -04:00
} ;
2022-05-05 09:53:22 -04:00
bool bNeedBSDFOffsets = false ;
for ( const FViewInfo & View : SceneRenderer . Views )
{
bNeedBSDFOffsets = bNeedBSDFOffsets | | NeedBSDFOffsets ( SceneRenderer . Scene , View ) ;
}
2021-03-30 05:18:53 -04:00
FIntPoint MaterialBufferSizeXY ;
UpdateMaterialBufferToTiledResolution ( FIntPoint ( 1 , 1 ) , MaterialBufferSizeXY ) ;
2020-09-16 04:20:36 -04:00
if ( IsStrataEnabled ( ) )
{
2022-08-25 06:29:15 -04:00
// Analytics for tracking Strata usage
static bool bAnalyticsInitialized = false ;
if ( ! bAnalyticsInitialized )
{
RecordStrataAnalytics ( ) ;
bAnalyticsInitialized = true ;
}
UE5_MAIN: Multi-view-family scene renderer refactor, part 2. Move FSceneTextures singleton out of RDG blackboard and FSceneTexturesConfig global variable singleton, into FViewFamilyInfo. This is necessary to allow multiple view families to render in a single render graph and a single scene renderer call.
* Existing calls to CreateSceneTextureShaderParameters and similar functions use "GetSceneTexturesChecked", which allows for the possibility that they are reached in a code path where scene textures haven't been initialized, and nullptr is returned instead of asserting. The shader parameter setup functions then fill in dummy defaults for that case. The goal was to precisely match the original behavior, which queried the RDG blackboard, and gracefully handled null if scene textures weren't there. This definitely appears to occur in FNiagaraGpuComputeDispatch::ProcessPendingTicksFlush, which can be called with a dummy scene with no scene textures. In the future, I may change this so dummy defaults are filled in for FSceneTextures at construction time, so the structure is never in an uninitialized state, but I would like to set up a test case for the Niagara code path before doing that, and the checks aren't harmful in the meantime.
* I marked as deprecated global functions which query values from FSceneTexturesConfig, but they'll still work with the caveat that if you use multi-view-family rendering, the results will be indeterminate (whatever view family rendered last). There was only one case outside the scene renderer that accessed the globals (depth clear value), which I removed, noting that there is nowhere in the code where we modify the depth clear value from its global default. I would like to permanently deprecate or remove these at some point. Display Cluster is the only code that's currently using the multi-view-family code path, and as a new (still incomplete) feature, third party code can't be using it, and won't be affected.
#jira NONE
#rb chris.kulla zach.bethel mihnea.balta
#preflight 6261aca76119a1a496bd2644
[CL 19873983 by jason hoerner in ue5-main branch]
2022-04-22 17:33:02 -04:00
FIntPoint SceneTextureExtent = SceneRenderer . GetActiveSceneTexturesConfig ( ) . Extent ;
2020-09-16 04:20:36 -04:00
2021-03-30 05:18:53 -04:00
// We need to allocate enough for the tiled memory addressing of material data to always work
UpdateMaterialBufferToTiledResolution ( SceneTextureExtent , MaterialBufferSizeXY ) ;
2020-09-16 04:20:36 -04:00
2020-11-09 12:06:15 -04:00
const uint32 RoundToValue = 4u ;
2022-09-15 05:43:33 -04:00
Out . MaxBytesPerPixel = FMath : : DivideAndRoundUp ( StrataGetBytePerPixel ( ) , RoundToValue ) * RoundToValue ;
2021-01-27 08:51:50 -04:00
2020-12-16 19:25:24 -04:00
// Top layer texture
{
2022-09-16 08:21:00 -04:00
const bool bNeedUAV = CVarStrataDBufferPass . GetValueOnRenderThread ( ) > 0 ;
2022-11-16 11:35:48 -05:00
Out . TopLayerTexture = GraphBuilder . CreateTexture ( FRDGTextureDesc : : Create2D ( SceneTextureExtent , GetTopLayerTextureFormat ( ) , FClearValueBinding : : Black , TexCreate_RenderTargetable | TexCreate_ShaderResource | TexCreate_FastVRAM | ( bNeedUAV ? TexCreate_UAV : TexCreate_None ) ) , TEXT ( " Strata.TopLayerTexture " ) ) ;
2020-12-16 19:25:24 -04:00
}
2021-02-15 08:15:16 -04:00
2022-03-15 03:11:08 -04:00
// Separated subsurface and rough refraction textures
{
2022-04-14 03:13:39 -04:00
const bool bIsStrataOpaqueMaterialRoughRefractionEnabled = IsStrataOpaqueMaterialRoughRefractionEnabled ( ) ;
2022-03-15 03:11:08 -04:00
const FIntPoint OpaqueRoughRefractionSceneExtent = bIsStrataOpaqueMaterialRoughRefractionEnabled ? SceneTextureExtent : FIntPoint ( 4 , 4 ) ;
2022-04-02 14:31:01 -04:00
Out . OpaqueRoughRefractionTexture = GraphBuilder . CreateTexture (
2022-03-16 11:42:57 -04:00
FRDGTextureDesc : : Create2D ( OpaqueRoughRefractionSceneExtent , PF_FloatR11G11B10 , FClearValueBinding : : Black , TexCreate_ShaderResource | TexCreate_UAV | TexCreate_RenderTargetable ) , TEXT ( " Strata.OpaqueRoughRefractionTexture " ) ) ;
2022-04-02 14:31:01 -04:00
Out . OpaqueRoughRefractionTextureUAV = GraphBuilder . CreateUAV ( Out . OpaqueRoughRefractionTexture ) ;
2022-03-15 03:11:08 -04:00
2022-04-02 14:31:01 -04:00
Out . SeparatedSubSurfaceSceneColor = GraphBuilder . CreateTexture (
2022-03-15 03:11:08 -04:00
FRDGTextureDesc : : Create2D ( OpaqueRoughRefractionSceneExtent , PF_FloatR11G11B10 , FClearValueBinding : : Black , TexCreate_ShaderResource | TexCreate_UAV | TexCreate_RenderTargetable ) , TEXT ( " Strata.SeparatedSubSurfaceSceneColor " ) ) ;
2022-04-02 14:31:01 -04:00
Out . SeparatedOpaqueRoughRefractionSceneColor = GraphBuilder . CreateTexture (
2022-03-15 03:11:08 -04:00
FRDGTextureDesc : : Create2D ( OpaqueRoughRefractionSceneExtent , PF_FloatR11G11B10 , FClearValueBinding : : Black , TexCreate_ShaderResource | TexCreate_UAV | TexCreate_RenderTargetable ) , TEXT ( " Strata.SeparatedOpaqueRoughRefractionSceneColor " ) ) ;
if ( bIsStrataOpaqueMaterialRoughRefractionEnabled )
{
// Fast clears
2022-04-02 14:31:01 -04:00
AddClearRenderTargetPass ( GraphBuilder , Out . OpaqueRoughRefractionTexture , Out . OpaqueRoughRefractionTexture - > Desc . ClearValue . GetClearColor ( ) ) ;
AddClearRenderTargetPass ( GraphBuilder , Out . SeparatedSubSurfaceSceneColor , Out . SeparatedSubSurfaceSceneColor - > Desc . ClearValue . GetClearColor ( ) ) ;
AddClearRenderTargetPass ( GraphBuilder , Out . SeparatedOpaqueRoughRefractionSceneColor , Out . SeparatedOpaqueRoughRefractionSceneColor - > Desc . ClearValue . GetClearColor ( ) ) ;
2022-03-15 03:11:08 -04:00
}
}
2022-03-18 13:43:33 -04:00
2022-04-02 14:31:01 -04:00
// BSDF offsets
2022-05-05 09:53:22 -04:00
if ( bNeedBSDFOffsets )
2022-03-18 13:43:33 -04:00
{
2022-04-02 14:31:01 -04:00
Out . BSDFOffsetTexture = GraphBuilder . CreateTexture ( FRDGTextureDesc : : Create2D ( SceneTextureExtent , PF_R32_UINT , FClearValueBinding : : None , TexCreate_UAV | TexCreate_ShaderResource ) , TEXT ( " Strata.BSDFOffsets " ) ) ;
AddClearUAVPass ( GraphBuilder , GraphBuilder . CreateUAV ( Out . BSDFOffsetTexture ) , 0u ) ;
2022-03-21 06:29:05 -04:00
}
2020-09-16 04:20:36 -04:00
}
else
{
2022-04-02 14:31:01 -04:00
Out . MaxBytesPerPixel = 4u * STRATA_BASE_PASS_MRT_OUTPUT_COUNT ;
2020-09-16 04:20:36 -04:00
}
2021-11-29 09:31:58 -05:00
// Create the material data container
UE5_MAIN: Multi-view-family scene renderer refactor, part 2. Move FSceneTextures singleton out of RDG blackboard and FSceneTexturesConfig global variable singleton, into FViewFamilyInfo. This is necessary to allow multiple view families to render in a single render graph and a single scene renderer call.
* Existing calls to CreateSceneTextureShaderParameters and similar functions use "GetSceneTexturesChecked", which allows for the possibility that they are reached in a code path where scene textures haven't been initialized, and nullptr is returned instead of asserting. The shader parameter setup functions then fill in dummy defaults for that case. The goal was to precisely match the original behavior, which queried the RDG blackboard, and gracefully handled null if scene textures weren't there. This definitely appears to occur in FNiagaraGpuComputeDispatch::ProcessPendingTicksFlush, which can be called with a dummy scene with no scene textures. In the future, I may change this so dummy defaults are filled in for FSceneTextures at construction time, so the structure is never in an uninitialized state, but I would like to set up a test case for the Niagara code path before doing that, and the checks aren't harmful in the meantime.
* I marked as deprecated global functions which query values from FSceneTexturesConfig, but they'll still work with the caveat that if you use multi-view-family rendering, the results will be indeterminate (whatever view family rendered last). There was only one case outside the scene renderer that accessed the globals (depth clear value), which I removed, noting that there is nowhere in the code where we modify the depth clear value from its global default. I would like to permanently deprecate or remove these at some point. Display Cluster is the only code that's currently using the multi-view-family code path, and as a new (still incomplete) feature, third party code can't be using it, and won't be affected.
#jira NONE
#rb chris.kulla zach.bethel mihnea.balta
#preflight 6261aca76119a1a496bd2644
[CL 19873983 by jason hoerner in ue5-main branch]
2022-04-22 17:33:02 -04:00
FIntPoint SceneTextureExtent = IsStrataEnabled ( ) ? SceneRenderer . GetActiveSceneTexturesConfig ( ) . Extent : FIntPoint ( 2 , 2 ) ;
2021-11-29 10:12:58 -05:00
2022-08-29 02:55:17 -04:00
const uint32 SliceCountSSS = STRATA_SSS_DATA_UINT_COUNT ;
2022-08-31 05:33:41 -04:00
const uint32 SliceCountAdvDebug = IsStrataAdvancedVisualizationShadersEnabled ( ) ? 1 : 0 ;
const uint32 SliceCount = FMath : : DivideAndRoundUp ( Out . MaxBytesPerPixel , 4u ) + SliceCountSSS + SliceCountAdvDebug ;
2022-09-21 04:35:09 -04:00
FRDGTextureDesc MaterialTextureDesc = FRDGTextureDesc : : Create2DArray ( SceneTextureExtent , PF_R32_UINT , FClearValueBinding : : Transparent , TexCreate_TargetArraySlicesIndependently | TexCreate_DisableDCC | TexCreate_NoFastClear | TexCreate_RenderTargetable | TexCreate_ShaderResource | TexCreate_UAV | TexCreate_FastVRAM , SliceCount , 1 , 1 ) ;
MaterialTextureDesc . FastVRAMPercentage = ( 1.0f / SliceCount ) * 0xFF ; // Only allocate the first slice into ESRAM
2022-04-02 14:31:01 -04:00
Out . MaterialTextureArray = GraphBuilder . CreateTexture ( MaterialTextureDesc , TEXT ( " Strata.Material " ) ) ;
Out . MaterialTextureArraySRV = GraphBuilder . CreateSRV ( FRDGTextureSRVDesc : : Create ( Out . MaterialTextureArray ) ) ;
Out . MaterialTextureArrayUAV = GraphBuilder . CreateUAV ( FRDGTextureUAVDesc ( Out . MaterialTextureArray , 0 ) ) ;
2020-09-16 04:20:36 -04:00
2022-01-04 12:18:49 -05:00
// See AppendStrataMRTs
2022-08-31 05:33:41 -04:00
check ( STRATA_BASE_PASS_MRT_OUTPUT_COUNT < = ( SliceCount - SliceCountSSS - SliceCountAdvDebug ) ) ; // We want enough slice for MRTs but also do not want the SSSData to be a MRT.
2022-04-02 14:31:01 -04:00
Out . MaterialTextureArrayUAVWithoutRTs = GraphBuilder . CreateUAV ( FRDGTextureUAVDesc ( Out . MaterialTextureArray , 0 , PF_Unknown , STRATA_BASE_PASS_MRT_OUTPUT_COUNT , SliceCount - STRATA_BASE_PASS_MRT_OUTPUT_COUNT ) ) ;
2022-01-04 12:18:49 -05:00
2021-11-03 04:18:34 -04:00
// Rough diffuse model
2022-04-02 14:31:01 -04:00
Out . bRoughDiffuse = CVarStrataRoughDiffuse . GetValueOnRenderThread ( ) > 0 ? 1u : 0u ;
2020-11-02 10:05:56 -04:00
2022-04-13 13:49:36 -04:00
Out . PeelLayersAboveDepth = FMath : : Max ( CVarStrataDebugPeelLayersAboveDepth . GetValueOnRenderThread ( ) , 0 ) ;
2022-08-29 02:55:17 -04:00
2022-08-31 05:33:41 -04:00
// STRATA_TODO allocate a slice for StoringDebugStrata only if STRATA_ADVANCED_DEBUG_ENABLED is enabled
Out . SliceStoringDebugStrataTreeData = SliceCount - SliceCountAdvDebug ; // When we read, there is no slices excluded
Out . SliceStoringDebugStrataTreeDataWithoutMRT = SliceCount - SliceCountAdvDebug - STRATA_BASE_PASS_MRT_OUTPUT_COUNT ; // The UAV skips the first slices set as render target
2022-08-29 02:55:17 -04:00
2022-08-31 05:33:41 -04:00
Out . FirstSliceStoringStrataSSSData = SliceCount - SliceCountSSS - SliceCountAdvDebug ; // When we read, there is no slices excluded
Out . FirstSliceStoringStrataSSSDataWithoutMRT = SliceCount - SliceCountSSS - SliceCountAdvDebug - STRATA_BASE_PASS_MRT_OUTPUT_COUNT ; // The UAV skips the first slices set as render target
2022-04-13 13:49:36 -04:00
2022-04-02 14:31:01 -04:00
// Initialized view data
for ( int32 ViewIndex = 0 ; ViewIndex < SceneRenderer . Views . Num ( ) ; ViewIndex + + )
2021-03-30 02:33:35 -04:00
{
2022-05-05 09:53:22 -04:00
Strata : : InitialiseStrataViewData ( GraphBuilder , SceneRenderer . Views [ ViewIndex ] , SceneRenderer . GetActiveSceneTexturesConfig ( ) , bNeedBSDFOffsets , Out ) ;
2021-03-30 06:48:19 -04:00
}
2020-09-16 04:20:36 -04:00
}
2022-04-01 08:35:55 -04:00
void BindStrataBasePassUniformParameters ( FRDGBuilder & GraphBuilder , const FViewInfo & View , FStrataBasePassUniformParameters & OutStrataUniformParameters )
2020-09-16 04:20:36 -04:00
{
2022-04-02 14:31:01 -04:00
const FStrataSceneData * StrataSceneData = View . StrataViewData . SceneData ;
2021-04-10 07:34:33 -04:00
if ( IsStrataEnabled ( ) & & StrataSceneData )
2020-09-16 12:39:51 -04:00
{
2021-11-03 04:18:34 -04:00
OutStrataUniformParameters . bRoughDiffuse = StrataSceneData - > bRoughDiffuse ? 1u : 0u ;
2021-03-30 11:27:24 -04:00
OutStrataUniformParameters . MaxBytesPerPixel = StrataSceneData - > MaxBytesPerPixel ;
2022-04-13 13:49:36 -04:00
OutStrataUniformParameters . PeelLayersAboveDepth = StrataSceneData - > PeelLayersAboveDepth ;
2022-08-31 05:33:41 -04:00
OutStrataUniformParameters . SliceStoringDebugStrataTreeDataWithoutMRT = StrataSceneData - > SliceStoringDebugStrataTreeDataWithoutMRT ;
2022-08-29 02:55:17 -04:00
OutStrataUniformParameters . FirstSliceStoringStrataSSSDataWithoutMRT = StrataSceneData - > FirstSliceStoringStrataSSSDataWithoutMRT ;
2022-01-04 12:18:49 -05:00
OutStrataUniformParameters . MaterialTextureArrayUAVWithoutRTs = StrataSceneData - > MaterialTextureArrayUAVWithoutRTs ;
2022-03-15 03:11:08 -04:00
OutStrataUniformParameters . OpaqueRoughRefractionTextureUAV = StrataSceneData - > OpaqueRoughRefractionTextureUAV ;
2020-09-16 12:39:51 -04:00
}
else
{
2022-03-15 03:11:08 -04:00
FRDGTextureRef DummyWritableRefracTexture = GraphBuilder . CreateTexture ( FRDGTextureDesc : : Create2D ( FIntPoint ( 1 , 1 ) , PF_R8 , FClearValueBinding : : None , TexCreate_ShaderResource | TexCreate_UAV ) , TEXT ( " Strata.DummyWritableTexture " ) ) ;
FRDGTextureUAVRef DummyWritableRefracTextureUAV = GraphBuilder . CreateUAV ( FRDGTextureUAVDesc ( DummyWritableRefracTexture ) ) ;
2021-11-29 09:31:58 -05:00
FRDGTextureRef DummyWritableTextureArray = GraphBuilder . CreateTexture ( FRDGTextureDesc : : Create2DArray ( FIntPoint ( 1 , 1 ) , PF_R32_UINT , FClearValueBinding : : None , TexCreate_ShaderResource | TexCreate_UAV , 1 ) , TEXT ( " Strata.DummyWritableTexture " ) ) ;
FRDGTextureUAVRef DummyWritableTextureArrayUAV = GraphBuilder . CreateUAV ( FRDGTextureUAVDesc ( DummyWritableTextureArray ) ) ;
2021-11-24 10:34:04 -05:00
const FRDGSystemTextures & SystemTextures = FRDGSystemTextures : : Get ( GraphBuilder ) ;
2021-11-03 04:18:34 -04:00
OutStrataUniformParameters . bRoughDiffuse = 0u ;
2020-09-16 12:39:51 -04:00
OutStrataUniformParameters . MaxBytesPerPixel = 0 ;
2022-04-13 13:49:36 -04:00
OutStrataUniformParameters . PeelLayersAboveDepth = 0 ;
2022-08-31 05:33:41 -04:00
OutStrataUniformParameters . SliceStoringDebugStrataTreeDataWithoutMRT = - 1 ;
2022-08-29 02:55:17 -04:00
OutStrataUniformParameters . FirstSliceStoringStrataSSSDataWithoutMRT = - 1 ;
2022-01-04 12:18:49 -05:00
OutStrataUniformParameters . MaterialTextureArrayUAVWithoutRTs = DummyWritableTextureArrayUAV ;
2022-03-15 03:11:08 -04:00
OutStrataUniformParameters . OpaqueRoughRefractionTextureUAV = DummyWritableRefracTextureUAV ;
2020-09-16 12:39:51 -04:00
}
2020-09-16 04:20:36 -04:00
}
2022-04-02 14:31:01 -04:00
static void BindStrataGlobalUniformParameters ( FRDGBuilder & GraphBuilder , FStrataViewData * StrataViewData , FStrataGlobalUniformParameters & OutStrataUniformParameters )
2021-11-18 14:37:34 -05:00
{
2022-04-02 14:31:01 -04:00
FStrataSceneData * StrataSceneData = StrataViewData - > SceneData ;
2021-11-18 14:37:34 -05:00
if ( IsStrataEnabled ( ) & & StrataSceneData )
{
OutStrataUniformParameters . bRoughDiffuse = StrataSceneData - > bRoughDiffuse ? 1u : 0u ;
OutStrataUniformParameters . MaxBytesPerPixel = StrataSceneData - > MaxBytesPerPixel ;
2022-04-13 13:49:36 -04:00
OutStrataUniformParameters . PeelLayersAboveDepth = StrataSceneData - > PeelLayersAboveDepth ;
2022-08-31 05:33:41 -04:00
OutStrataUniformParameters . SliceStoringDebugStrataTreeData = StrataSceneData - > SliceStoringDebugStrataTreeData ;
2022-08-29 02:55:17 -04:00
OutStrataUniformParameters . FirstSliceStoringStrataSSSData = StrataSceneData - > FirstSliceStoringStrataSSSData ;
2022-03-31 13:05:44 -04:00
OutStrataUniformParameters . TileSize = STRATA_TILE_SIZE ;
OutStrataUniformParameters . TileSizeLog2 = STRATA_TILE_SIZE_DIV_AS_SHIFT ;
2022-05-02 12:12:18 -04:00
OutStrataUniformParameters . TileCount = StrataViewData - > TileCount ;
OutStrataUniformParameters . TileOffset = StrataViewData - > TileOffset ;
2022-05-02 14:06:39 -04:00
OutStrataUniformParameters . OverflowTileCount = StrataViewData - > OverflowTileCount ;
OutStrataUniformParameters . OverflowTileOffset = StrataViewData - > OverflowTileOffset ;
2021-12-01 17:11:17 -05:00
OutStrataUniformParameters . MaterialTextureArray = StrataSceneData - > MaterialTextureArray ;
2021-11-26 10:59:06 -05:00
OutStrataUniformParameters . TopLayerTexture = StrataSceneData - > TopLayerTexture ;
2022-03-15 03:11:08 -04:00
OutStrataUniformParameters . OpaqueRoughRefractionTexture = StrataSceneData - > OpaqueRoughRefractionTexture ;
2022-04-02 14:31:01 -04:00
OutStrataUniformParameters . BSDFTileTexture = StrataViewData - > BSDFTileTexture ;
2022-03-18 13:43:33 -04:00
OutStrataUniformParameters . BSDFOffsetTexture = StrataSceneData - > BSDFOffsetTexture ;
2022-05-05 09:53:22 -04:00
OutStrataUniformParameters . BSDFTileCountBuffer = StrataViewData - > BSDFTileCountBuffer ? GraphBuilder . CreateSRV ( StrataViewData - > BSDFTileCountBuffer , PF_R32_UINT ) : nullptr ;
if ( OutStrataUniformParameters . BSDFOffsetTexture = = nullptr )
{
const FRDGSystemTextures & SystemTextures = FRDGSystemTextures : : Get ( GraphBuilder ) ;
FRDGBufferSRVRef DefaultBuffer = GraphBuilder . CreateSRV ( GSystemTextures . GetDefaultBuffer ( GraphBuilder , 4 , 0u ) , PF_R32_UINT ) ;
OutStrataUniformParameters . BSDFOffsetTexture = SystemTextures . Black ;
OutStrataUniformParameters . BSDFTileTexture = SystemTextures . Black ;
OutStrataUniformParameters . BSDFTileCountBuffer = DefaultBuffer ;
}
2021-11-18 14:37:34 -05:00
}
else
{
const FRDGSystemTextures & SystemTextures = FRDGSystemTextures : : Get ( GraphBuilder ) ;
2021-11-29 09:31:58 -05:00
FRDGTextureRef DefaultTextureArray = GSystemTextures . GetDefaultTexture ( GraphBuilder , ETextureDimension : : Texture2DArray , EPixelFormat : : PF_R32_UINT , FClearValueBinding : : Transparent ) ;
2022-03-31 12:43:49 -04:00
FRDGBufferSRVRef DefaultBuffer = GraphBuilder . CreateSRV ( GSystemTextures . GetDefaultBuffer ( GraphBuilder , 4 , 0u ) , PF_R32_UINT ) ;
2021-11-18 14:37:34 -05:00
OutStrataUniformParameters . bRoughDiffuse = 0 ;
OutStrataUniformParameters . MaxBytesPerPixel = 0 ;
2022-04-13 13:49:36 -04:00
OutStrataUniformParameters . PeelLayersAboveDepth = 0 ;
2022-08-31 05:33:41 -04:00
OutStrataUniformParameters . SliceStoringDebugStrataTreeData = - 1 ;
2022-08-29 02:55:17 -04:00
OutStrataUniformParameters . FirstSliceStoringStrataSSSData = - 1 ;
2022-03-18 13:43:33 -04:00
OutStrataUniformParameters . TileSize = 0 ;
OutStrataUniformParameters . TileSizeLog2 = 0 ;
OutStrataUniformParameters . TileCount = 0 ;
2022-05-02 12:12:18 -04:00
OutStrataUniformParameters . TileOffset = 0 ;
2022-05-02 14:06:39 -04:00
OutStrataUniformParameters . OverflowTileCount = 0 ;
OutStrataUniformParameters . OverflowTileOffset = 0 ;
2021-12-01 17:11:17 -05:00
OutStrataUniformParameters . MaterialTextureArray = DefaultTextureArray ;
2021-11-26 10:59:06 -05:00
OutStrataUniformParameters . TopLayerTexture = SystemTextures . DefaultNormal8Bit ;
2022-03-15 03:11:08 -04:00
OutStrataUniformParameters . OpaqueRoughRefractionTexture = SystemTextures . Black ;
2022-03-18 13:43:33 -04:00
OutStrataUniformParameters . BSDFTileTexture = SystemTextures . Black ;
OutStrataUniformParameters . BSDFOffsetTexture = SystemTextures . Black ;
2022-03-31 12:43:49 -04:00
OutStrataUniformParameters . BSDFTileCountBuffer = DefaultBuffer ;
2021-11-18 14:37:34 -05:00
}
}
2022-04-01 08:35:55 -04:00
void BindStrataForwardPasslUniformParameters ( FRDGBuilder & GraphBuilder , const FViewInfo & View , FStrataForwardPassUniformParameters & OutStrataUniformParameters )
2021-12-01 17:11:17 -05:00
{
2022-04-02 14:31:01 -04:00
FStrataSceneData * StrataSceneData = View . StrataViewData . SceneData ;
2021-12-01 17:11:17 -05:00
if ( IsStrataEnabled ( ) & & StrataSceneData )
{
2022-06-17 04:21:29 -04:00
OutStrataUniformParameters . MaxBytesPerPixel = StrataSceneData - > MaxBytesPerPixel ;
2021-12-01 17:11:17 -05:00
OutStrataUniformParameters . bRoughDiffuse = StrataSceneData - > bRoughDiffuse ? 1u : 0u ;
2022-04-13 13:49:36 -04:00
OutStrataUniformParameters . PeelLayersAboveDepth = StrataSceneData - > PeelLayersAboveDepth ;
2022-06-17 04:21:29 -04:00
OutStrataUniformParameters . MaterialTextureArray = StrataSceneData - > MaterialTextureArray ;
OutStrataUniformParameters . TopLayerTexture = StrataSceneData - > TopLayerTexture ;
2021-12-01 17:11:17 -05:00
}
else
{
2022-06-17 04:21:29 -04:00
const FRDGSystemTextures & SystemTextures = FRDGSystemTextures : : Get ( GraphBuilder ) ;
FRDGTextureRef DefaultTextureArray = GSystemTextures . GetDefaultTexture ( GraphBuilder , ETextureDimension : : Texture2DArray , EPixelFormat : : PF_R32_UINT , FClearValueBinding : : Transparent ) ;
OutStrataUniformParameters . MaxBytesPerPixel = 0 ;
2021-12-01 17:11:17 -05:00
OutStrataUniformParameters . bRoughDiffuse = 0 ;
2022-04-13 13:49:36 -04:00
OutStrataUniformParameters . PeelLayersAboveDepth = 0 ;
2022-06-17 04:21:29 -04:00
OutStrataUniformParameters . MaterialTextureArray = DefaultTextureArray ;
OutStrataUniformParameters . TopLayerTexture = SystemTextures . DefaultNormal8Bit ;
2021-12-01 17:11:17 -05:00
}
}
2022-11-21 02:30:07 -05:00
void BindStrataMobileForwardPasslUniformParameters ( FRDGBuilder & GraphBuilder , const FViewInfo & View , FStrataMobileForwardPassUniformParameters & OutStrataUniformParameters )
{
FStrataSceneData * StrataSceneData = View . StrataViewData . SceneData ;
if ( IsStrataEnabled ( ) & & StrataSceneData )
{
OutStrataUniformParameters . MaxBytesPerPixel = StrataSceneData - > MaxBytesPerPixel ;
OutStrataUniformParameters . bRoughDiffuse = StrataSceneData - > bRoughDiffuse ? 1u : 0u ;
OutStrataUniformParameters . PeelLayersAboveDepth = StrataSceneData - > PeelLayersAboveDepth ;
}
else
{
OutStrataUniformParameters . MaxBytesPerPixel = 0 ;
OutStrataUniformParameters . bRoughDiffuse = 0 ;
OutStrataUniformParameters . PeelLayersAboveDepth = 0 ;
}
}
2022-04-01 08:35:55 -04:00
TRDGUniformBufferRef < FStrataGlobalUniformParameters > BindStrataGlobalUniformParameters ( const FViewInfo & View )
2020-10-08 03:11:37 -04:00
{
2022-04-02 14:31:01 -04:00
check ( View . StrataViewData . StrataGlobalUniformParameters ! = nullptr | | ! IsStrataEnabled ( ) ) ;
return View . StrataViewData . StrataGlobalUniformParameters ;
2020-10-08 03:11:37 -04:00
}
2021-01-27 08:51:50 -04:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2022-03-18 13:43:33 -04:00
class FStrataBSDFTilePassCS : public FGlobalShader
{
DECLARE_GLOBAL_SHADER ( FStrataBSDFTilePassCS ) ;
SHADER_USE_PARAMETER_STRUCT ( FStrataBSDFTilePassCS , FGlobalShader ) ;
class FWaveOps : SHADER_PERMUTATION_BOOL ( " PERMUTATION_WAVE_OPS " ) ;
using FPermutationDomain = TShaderPermutationDomain < FWaveOps > ;
BEGIN_SHADER_PARAMETER_STRUCT ( FParameters , )
SHADER_PARAMETER_STRUCT_REF ( FViewUniformShaderParameters , ViewUniformBuffer )
SHADER_PARAMETER ( int32 , bRectPrimitive )
SHADER_PARAMETER ( int32 , TileSizeLog2 )
SHADER_PARAMETER ( FIntPoint , TileCount_Primary )
2022-05-02 12:12:18 -04:00
SHADER_PARAMETER ( FIntPoint , TileOffset_Primary )
2022-05-02 14:06:39 -04:00
SHADER_PARAMETER ( FIntPoint , OverflowTileCount )
SHADER_PARAMETER ( FIntPoint , OverflowTileOffset )
2022-03-18 13:43:33 -04:00
SHADER_PARAMETER ( FIntPoint , ViewResolution )
SHADER_PARAMETER ( uint32 , MaxBytesPerPixel )
SHADER_PARAMETER_RDG_TEXTURE ( Texture2D , TopLayerTexture )
SHADER_PARAMETER_RDG_TEXTURE_SRV ( Texture2DArray < uint > , MaterialTextureArray )
SHADER_PARAMETER_RDG_TEXTURE_UAV ( RWTexture2D < uint > , RWBSDFTileTexture )
SHADER_PARAMETER_RDG_TEXTURE_UAV ( RWTexture2D < uint > , RWBSDFOffsetTexture )
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer < uint > , RWBSDFTileCountBuffer )
SHADER_PARAMETER_RDG_BUFFER_SRV ( Buffer < uint > , TileListBuffer )
RDG_BUFFER_ACCESS ( TileIndirectBuffer , ERHIAccess : : IndirectArgs )
END_SHADER_PARAMETER_STRUCT ( )
static bool ShouldCompilePermutation ( const FGlobalShaderPermutationParameters & Parameters )
{
2022-06-23 11:15:46 -04:00
const bool bUseWaveIntrinsics = FDataDrivenShaderPlatformInfo : : GetSupportsWaveOperations ( Parameters . Platform ) ! = ERHIFeatureSupport : : Unsupported ;
2022-03-18 13:43:33 -04:00
FPermutationDomain PermutationVector ( Parameters . PermutationId ) ;
if ( PermutationVector . Get < FWaveOps > ( ) & & ! bUseWaveIntrinsics )
{
return false ;
}
return GetMaxSupportedFeatureLevel ( Parameters . Platform ) > = ERHIFeatureLevel : : SM5 & & Strata : : IsStrataEnabled ( ) ;
}
static void ModifyCompilationEnvironment ( const FGlobalShaderPermutationParameters & Parameters , FShaderCompilerEnvironment & OutEnvironment )
{
FGlobalShader : : ModifyCompilationEnvironment ( Parameters , OutEnvironment ) ;
OutEnvironment . SetDefine ( TEXT ( " SHADER_BSDF_TILE " ) , 1 ) ;
FPermutationDomain PermutationVector ( Parameters . PermutationId ) ;
if ( PermutationVector . Get < FWaveOps > ( ) )
{
OutEnvironment . CompilerFlags . Add ( CFLAG_WaveOperations ) ;
}
}
} ;
IMPLEMENT_GLOBAL_SHADER ( FStrataBSDFTilePassCS , " /Engine/Private/Strata/StrataMaterialClassification.usf " , " BSDFTileMainCS " , SF_Compute ) ;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2021-01-27 08:51:50 -04:00
class FStrataMaterialTileClassificationPassCS : public FGlobalShader
{
DECLARE_GLOBAL_SHADER ( FStrataMaterialTileClassificationPassCS ) ;
SHADER_USE_PARAMETER_STRUCT ( FStrataMaterialTileClassificationPassCS , FGlobalShader ) ;
2022-08-16 04:30:21 -04:00
class FCmask : SHADER_PERMUTATION_BOOL ( " PERMUTATION_CMASK " ) ;
2021-11-24 13:13:31 -05:00
class FWaveOps : SHADER_PERMUTATION_BOOL ( " PERMUTATION_WAVE_OPS " ) ;
2022-09-20 09:05:17 -04:00
class FDecal : SHADER_PERMUTATION_BOOL ( " PERMUTATION_DECAL " ) ;
using FPermutationDomain = TShaderPermutationDomain < FCmask , FWaveOps , FDecal > ;
2021-01-27 08:51:50 -04:00
BEGIN_SHADER_PARAMETER_STRUCT ( FParameters , )
SHADER_PARAMETER_STRUCT_REF ( FViewUniformShaderParameters , ViewUniformBuffer )
2022-08-29 02:55:17 -04:00
SHADER_PARAMETER ( int32 , FirstSliceStoringStrataSSSData )
2021-01-28 07:26:46 -04:00
SHADER_PARAMETER ( int32 , bRectPrimitive )
2021-01-29 18:01:50 -04:00
SHADER_PARAMETER ( FIntPoint , ViewResolution )
2021-11-26 10:59:06 -05:00
SHADER_PARAMETER ( uint32 , MaxBytesPerPixel )
2021-11-29 18:42:19 -05:00
SHADER_PARAMETER_RDG_TEXTURE ( Texture2D , TopLayerTexture )
2022-08-16 04:30:21 -04:00
SHADER_PARAMETER_RDG_TEXTURE ( Texture2D , TopLayerCmaskTexture )
2022-03-18 13:43:33 -04:00
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , TileDrawIndirectDataBuffer )
2021-04-06 02:12:57 -04:00
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , SimpleTileListDataBuffer )
2021-12-14 10:24:57 -05:00
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , SingleTileListDataBuffer )
2021-04-06 02:12:57 -04:00
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , ComplexTileListDataBuffer )
2022-03-15 03:11:08 -04:00
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , OpaqueRoughRefractionTileListDataBuffer )
2022-09-20 09:05:17 -04:00
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , OpaqueRoughRefractionSSSWithoutTileListDataBuffer )
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , DecalSimpleTileListDataBuffer )
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , DecalSingleTileListDataBuffer )
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , DecalComplexTileListDataBuffer )
2022-08-29 02:55:17 -04:00
SHADER_PARAMETER_RDG_TEXTURE_UAV ( RWTexture2DArray < uint > , MaterialTextureArrayUAV )
2022-03-16 11:42:57 -04:00
SHADER_PARAMETER_RDG_TEXTURE ( Texture2D < float3 > , OpaqueRoughRefractionTexture )
2022-09-20 09:05:17 -04:00
SHADER_PARAMETER_STRUCT_INCLUDE ( FDBufferParameters , DBuffer )
SHADER_PARAMETER_RDG_TEXTURE_SRV ( Texture2D < float > , SceneStencilTexture )
2021-01-27 08:51:50 -04:00
END_SHADER_PARAMETER_STRUCT ( )
static bool ShouldCompilePermutation ( const FGlobalShaderPermutationParameters & Parameters )
{
2022-06-23 11:15:46 -04:00
const bool bUseWaveIntrinsics = FDataDrivenShaderPlatformInfo : : GetSupportsWaveOperations ( Parameters . Platform ) ! = ERHIFeatureSupport : : Unsupported ;
2021-11-24 13:13:31 -05:00
FPermutationDomain PermutationVector ( Parameters . PermutationId ) ;
if ( PermutationVector . Get < FWaveOps > ( ) & & ! bUseWaveIntrinsics )
{
return false ;
}
2021-01-27 08:51:50 -04:00
return GetMaxSupportedFeatureLevel ( Parameters . Platform ) > = ERHIFeatureLevel : : SM5 & & Strata : : IsStrataEnabled ( ) ;
}
static void ModifyCompilationEnvironment ( const FGlobalShaderPermutationParameters & Parameters , FShaderCompilerEnvironment & OutEnvironment )
{
FGlobalShader : : ModifyCompilationEnvironment ( Parameters , OutEnvironment ) ;
OutEnvironment . SetDefine ( TEXT ( " SHADER_TILE_CATEGORIZATION " ) , 1 ) ;
2021-11-24 13:13:31 -05:00
FPermutationDomain PermutationVector ( Parameters . PermutationId ) ;
if ( PermutationVector . Get < FWaveOps > ( ) )
{
OutEnvironment . CompilerFlags . Add ( CFLAG_WaveOperations ) ;
}
2021-01-27 08:51:50 -04:00
}
} ;
IMPLEMENT_GLOBAL_SHADER ( FStrataMaterialTileClassificationPassCS , " /Engine/Private/Strata/StrataMaterialClassification.usf " , " TileMainCS " , SF_Compute ) ;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2022-09-16 08:21:00 -04:00
class FStrataDBufferPassCS : public FGlobalShader
{
DECLARE_GLOBAL_SHADER ( FStrataDBufferPassCS ) ;
SHADER_USE_PARAMETER_STRUCT ( FStrataDBufferPassCS , FGlobalShader ) ;
2022-09-20 09:05:17 -04:00
class FTileType : SHADER_PERMUTATION_INT ( " PERMUTATION_TILETYPE " , 3 ) ;
2022-09-16 08:21:00 -04:00
using FPermutationDomain = TShaderPermutationDomain < FTileType > ;
BEGIN_SHADER_PARAMETER_STRUCT ( FParameters , )
SHADER_PARAMETER ( FIntPoint , ViewResolution )
SHADER_PARAMETER ( uint32 , MaxBytesPerPixel )
SHADER_PARAMETER ( uint32 , FirstSliceStoringStrataSSSData )
SHADER_PARAMETER_STRUCT_REF ( FViewUniformShaderParameters , ViewUniformBuffer )
SHADER_PARAMETER_STRUCT_INCLUDE ( FDBufferParameters , DBuffer )
2022-09-16 12:20:04 -04:00
SHADER_PARAMETER_RDG_TEXTURE_UAV ( RWTexture2D < uint > , TopLayerTexture )
2022-09-16 08:21:00 -04:00
SHADER_PARAMETER_RDG_TEXTURE_UAV ( RWTexture2DArray < uint > , MaterialTextureArrayUAV )
SHADER_PARAMETER_RDG_BUFFER_SRV ( Buffer < uint > , TileListBuffer )
2022-09-16 11:26:53 -04:00
SHADER_PARAMETER_RDG_TEXTURE_SRV ( Texture2D < float > , SceneStencilTexture )
2022-09-16 08:21:00 -04:00
RDG_BUFFER_ACCESS ( TileIndirectBuffer , ERHIAccess : : IndirectArgs )
END_SHADER_PARAMETER_STRUCT ( )
static bool ShouldCompilePermutation ( const FGlobalShaderPermutationParameters & Parameters )
{
2022-10-11 09:32:40 -04:00
return GetMaxSupportedFeatureLevel ( Parameters . Platform ) > = ERHIFeatureLevel : : SM5 & & Strata : : IsStrataEnabled ( ) & & IsUsingDBuffers ( Parameters . Platform ) ;
2022-09-16 08:21:00 -04:00
}
static void ModifyCompilationEnvironment ( const FGlobalShaderPermutationParameters & Parameters , FShaderCompilerEnvironment & OutEnvironment )
{
2022-09-16 11:26:53 -04:00
const uint32 StrataStencilDbufferMask
= GET_STENCIL_BIT_MASK ( STRATA_RECEIVE_DBUFFER_NORMAL , 1 )
| GET_STENCIL_BIT_MASK ( STRATA_RECEIVE_DBUFFER_DIFFUSE , 1 )
| GET_STENCIL_BIT_MASK ( STRATA_RECEIVE_DBUFFER_ROUGHNESS , 1 ) ;
2022-09-16 08:21:00 -04:00
FGlobalShader : : ModifyCompilationEnvironment ( Parameters , OutEnvironment ) ;
OutEnvironment . SetDefine ( TEXT ( " SHADER_DBUFFER " ) , 1 ) ;
2022-09-16 11:26:53 -04:00
OutEnvironment . SetDefine ( TEXT ( " STRATA_STENCIL_DBUFFER_MASK " ) , StrataStencilDbufferMask ) ;
OutEnvironment . SetDefine ( TEXT ( " STENCIL_STRATA_RECEIVE_DBUFFER_NORMAL_BIT_ID " ) , STENCIL_STRATA_RECEIVE_DBUFFER_NORMAL_BIT_ID ) ;
OutEnvironment . SetDefine ( TEXT ( " STENCIL_STRATA_RECEIVE_DBUFFER_DIFFUSE_BIT_ID " ) , STENCIL_STRATA_RECEIVE_DBUFFER_DIFFUSE_BIT_ID ) ;
OutEnvironment . SetDefine ( TEXT ( " STENCIL_STRATA_RECEIVE_DBUFFER_ROUGHNESS_BIT_ID " ) , STENCIL_STRATA_RECEIVE_DBUFFER_ROUGHNESS_BIT_ID ) ;
2022-11-21 06:43:48 -05:00
// Needed as top layer texture can be a uint2
OutEnvironment . CompilerFlags . Add ( CFLAG_AllowTypedUAVLoads ) ;
2022-09-16 08:21:00 -04:00
}
} ;
IMPLEMENT_GLOBAL_SHADER ( FStrataDBufferPassCS , " /Engine/Private/Strata/StrataDBuffer.usf " , " MainCS " , SF_Compute ) ;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2022-03-18 13:43:33 -04:00
class FStrataMaterialTilePrepareArgsPassCS : public FGlobalShader
{
DECLARE_GLOBAL_SHADER ( FStrataMaterialTilePrepareArgsPassCS ) ;
SHADER_USE_PARAMETER_STRUCT ( FStrataMaterialTilePrepareArgsPassCS , FGlobalShader ) ;
BEGIN_SHADER_PARAMETER_STRUCT ( FParameters , )
SHADER_PARAMETER_RDG_BUFFER_SRV ( Buffer , TileDrawIndirectDataBuffer )
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , TileDispatchIndirectDataBuffer )
END_SHADER_PARAMETER_STRUCT ( )
static bool ShouldCompilePermutation ( const FGlobalShaderPermutationParameters & Parameters )
{
return GetMaxSupportedFeatureLevel ( Parameters . Platform ) > = ERHIFeatureLevel : : SM5 & & Strata : : IsStrataEnabled ( ) ;
}
static void ModifyCompilationEnvironment ( const FGlobalShaderPermutationParameters & Parameters , FShaderCompilerEnvironment & OutEnvironment )
{
FGlobalShader : : ModifyCompilationEnvironment ( Parameters , OutEnvironment ) ;
2022-03-21 06:29:05 -04:00
OutEnvironment . SetDefine ( TEXT ( " SHADER_MATERIAL_TILE_PREPARE_ARGS " ) , 1 ) ;
2022-03-18 13:43:33 -04:00
}
} ;
IMPLEMENT_GLOBAL_SHADER ( FStrataMaterialTilePrepareArgsPassCS , " /Engine/Private/Strata/StrataMaterialClassification.usf " , " ArgsMainCS " , SF_Compute ) ;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2022-03-21 06:29:05 -04:00
class FStrataBSDFTilePrepareArgsPassCS : public FGlobalShader
{
DECLARE_GLOBAL_SHADER ( FStrataBSDFTilePrepareArgsPassCS ) ;
SHADER_USE_PARAMETER_STRUCT ( FStrataBSDFTilePrepareArgsPassCS , FGlobalShader ) ;
BEGIN_SHADER_PARAMETER_STRUCT ( FParameters , )
SHADER_PARAMETER ( FIntPoint , TileCount_Primary )
2022-05-02 12:12:18 -04:00
SHADER_PARAMETER ( FIntPoint , TileOffset_Primary )
2022-05-02 14:06:39 -04:00
SHADER_PARAMETER ( FIntPoint , OverflowTileCount )
SHADER_PARAMETER ( FIntPoint , OverflowTileOffset )
2022-03-21 06:29:05 -04:00
SHADER_PARAMETER_RDG_BUFFER_SRV ( Buffer , TileDrawIndirectDataBuffer )
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , TileDispatchIndirectDataBuffer )
2022-05-02 12:12:18 -04:00
SHADER_PARAMETER_RDG_BUFFER_UAV ( RWBuffer , TileDispatchPerThreadIndirectDataBuffer )
2022-03-21 06:29:05 -04:00
END_SHADER_PARAMETER_STRUCT ( )
static bool ShouldCompilePermutation ( const FGlobalShaderPermutationParameters & Parameters )
{
return GetMaxSupportedFeatureLevel ( Parameters . Platform ) > = ERHIFeatureLevel : : SM5 & & Strata : : IsStrataEnabled ( ) ;
}
static void ModifyCompilationEnvironment ( const FGlobalShaderPermutationParameters & Parameters , FShaderCompilerEnvironment & OutEnvironment )
{
FGlobalShader : : ModifyCompilationEnvironment ( Parameters , OutEnvironment ) ;
OutEnvironment . SetDefine ( TEXT ( " SHADER_BSDF_TILE_PREPARE_ARGS " ) , 1 ) ;
}
} ;
IMPLEMENT_GLOBAL_SHADER ( FStrataBSDFTilePrepareArgsPassCS , " /Engine/Private/Strata/StrataMaterialClassification.usf " , " ArgsMainCS " , SF_Compute ) ;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2021-04-06 02:12:57 -04:00
class FStrataMaterialStencilTaggingPassPS : public FGlobalShader
2021-01-27 08:51:50 -04:00
{
2021-04-06 02:12:57 -04:00
DECLARE_GLOBAL_SHADER ( FStrataMaterialStencilTaggingPassPS ) ;
SHADER_USE_PARAMETER_STRUCT ( FStrataMaterialStencilTaggingPassPS , FGlobalShader ) ;
2021-01-27 08:51:50 -04:00
using FPermutationDomain = TShaderPermutationDomain < > ;
BEGIN_SHADER_PARAMETER_STRUCT ( FParameters , )
2021-04-06 02:12:57 -04:00
SHADER_PARAMETER_STRUCT_INCLUDE ( Strata : : FStrataTilePassVS : : FParameters , VS )
2021-09-22 10:01:48 -04:00
SHADER_PARAMETER ( FVector4f , DebugTileColor )
2021-01-27 08:51:50 -04:00
RENDER_TARGET_BINDING_SLOTS ( )
END_SHADER_PARAMETER_STRUCT ( )
2021-01-28 07:26:46 -04:00
static FPermutationDomain RemapPermutation ( FPermutationDomain PermutationVector )
2021-01-27 08:51:50 -04:00
{
return PermutationVector ;
}
static bool ShouldCompilePermutation ( const FGlobalShaderPermutationParameters & Parameters )
{
return GetMaxSupportedFeatureLevel ( Parameters . Platform ) > = ERHIFeatureLevel : : SM5 & & Strata : : IsStrataEnabled ( ) ;
}
static void ModifyCompilationEnvironment ( const FGlobalShaderPermutationParameters & Parameters , FShaderCompilerEnvironment & OutEnvironment )
{
FGlobalShader : : ModifyCompilationEnvironment ( Parameters , OutEnvironment ) ;
2022-01-04 06:43:29 -05:00
OutEnvironment . SetDefine ( TEXT ( " SHADER_STENCIL_TAGGING_PS " ) , 1 ) ;
2021-01-27 08:51:50 -04:00
}
} ;
2022-03-18 08:20:50 -04:00
IMPLEMENT_GLOBAL_SHADER ( FStrataTilePassVS , " /Engine/Private/Strata/StrataTile.usf " , " StrataTilePassVS " , SF_Vertex ) ;
IMPLEMENT_GLOBAL_SHADER ( FStrataMaterialStencilTaggingPassPS , " /Engine/Private/Strata/StrataTile.usf " , " StencilTaggingMainPS " , SF_Pixel ) ;
2021-01-27 08:51:50 -04:00
2022-03-15 09:55:16 -04:00
static FStrataTileParameter InternalSetTileParameters ( FRDGBuilder * GraphBuilder , const FViewInfo & View , const EStrataTileType TileType )
2022-02-10 04:16:37 -05:00
{
FStrataTileParameter Out ;
2022-04-02 14:31:01 -04:00
if ( TileType ! = EStrataTileType : : ECount )
2022-02-10 04:16:37 -05:00
{
2022-04-02 14:31:01 -04:00
Out . TileListBuffer = View . StrataViewData . ClassificationTileListBufferSRV [ TileType ] ;
Out . TileIndirectBuffer = View . StrataViewData . ClassificationTileDrawIndirectBuffer ;
2022-02-10 04:16:37 -05:00
}
else if ( GraphBuilder )
{
FRDGBufferRef BufferDummy = GSystemTextures . GetDefaultBuffer ( * GraphBuilder , 4 , 0u ) ;
FRDGBufferSRVRef BufferDummySRV = GraphBuilder - > CreateSRV ( BufferDummy , PF_R32_UINT ) ;
Out . TileListBuffer = BufferDummySRV ;
Out . TileIndirectBuffer = BufferDummy ;
}
return Out ;
}
FStrataTilePassVS : : FParameters SetTileParameters (
const FViewInfo & View ,
2022-03-15 09:55:16 -04:00
const EStrataTileType TileType ,
2021-04-06 02:12:57 -04:00
EPrimitiveType & PrimitiveType )
{
2022-02-10 04:16:37 -05:00
FStrataTileParameter Temp = InternalSetTileParameters ( nullptr , View , TileType ) ;
2021-04-06 02:12:57 -04:00
PrimitiveType = GRHISupportsRectTopology ? PT_RectList : PT_TriangleList ;
2022-02-10 04:16:37 -05:00
FStrataTilePassVS : : FParameters Out ;
2022-04-02 14:31:01 -04:00
Out . OutputViewMinRect = FVector2f ( View . CachedViewUniformShaderParameters - > ViewRectMin . X , View . CachedViewUniformShaderParameters - > ViewRectMin . Y ) ;
2022-02-10 04:16:37 -05:00
Out . OutputViewSizeAndInvSize = View . CachedViewUniformShaderParameters - > ViewSizeAndInvSize ;
Out . OutputBufferSizeAndInvSize = View . CachedViewUniformShaderParameters - > BufferSizeAndInvSize ;
Out . ViewScreenToTranslatedWorld = View . CachedViewUniformShaderParameters - > ScreenToTranslatedWorld ;
Out . TileListBuffer = Temp . TileListBuffer ;
Out . TileIndirectBuffer = Temp . TileIndirectBuffer ;
return Out ;
}
FStrataTilePassVS : : FParameters SetTileParameters (
FRDGBuilder & GraphBuilder ,
const FViewInfo & View ,
2022-03-15 09:55:16 -04:00
const EStrataTileType TileType ,
2022-02-10 04:16:37 -05:00
EPrimitiveType & PrimitiveType )
{
FStrataTileParameter Temp = InternalSetTileParameters ( & GraphBuilder , View , TileType ) ;
PrimitiveType = GRHISupportsRectTopology ? PT_RectList : PT_TriangleList ;
FStrataTilePassVS : : FParameters Out ;
2022-04-02 14:31:01 -04:00
Out . OutputViewMinRect = FVector2f ( View . CachedViewUniformShaderParameters - > ViewRectMin . X , View . CachedViewUniformShaderParameters - > ViewRectMin . Y ) ;
2022-02-10 04:16:37 -05:00
Out . OutputViewSizeAndInvSize = View . CachedViewUniformShaderParameters - > ViewSizeAndInvSize ;
Out . OutputBufferSizeAndInvSize = View . CachedViewUniformShaderParameters - > BufferSizeAndInvSize ;
Out . ViewScreenToTranslatedWorld = View . CachedViewUniformShaderParameters - > ScreenToTranslatedWorld ;
Out . TileListBuffer = Temp . TileListBuffer ;
Out . TileIndirectBuffer = Temp . TileIndirectBuffer ;
return Out ;
}
2022-03-15 09:55:16 -04:00
FStrataTileParameter SetTileParameters ( FRDGBuilder & GraphBuilder , const FViewInfo & View , const EStrataTileType TileType )
2022-02-10 04:16:37 -05:00
{
return InternalSetTileParameters ( & GraphBuilder , View , TileType ) ;
2021-04-06 02:12:57 -04:00
}
2022-03-15 09:55:16 -04:00
uint32 TileTypeDrawIndirectArgOffset ( const EStrataTileType Type )
{
check ( Type > = 0 & & Type < EStrataTileType : : ECount ) ;
return GetStrataTileTypeDrawIndirectArgOffset_Byte ( Type ) ;
}
2022-03-18 13:43:33 -04:00
uint32 TileTypeDispatchIndirectArgOffset ( const EStrataTileType Type )
{
check ( Type > = 0 & & Type < EStrataTileType : : ECount ) ;
return GetStrataTileTypeDispatchIndirectArgOffset_Byte ( Type ) ;
}
2022-02-11 11:38:18 -05:00
// Add additionnaly bits for filling/clearing stencil to ensure that the 'Strata' bits are not corrupted by the stencil shadows
// when generating shadow mask. Withouth these 'trailing' bits, the incr./decr. operation would change/corrupt the 'Strata' bits
2022-05-09 13:33:36 -04:00
constexpr uint32 StencilBit_Fast_1 = StencilBit_Fast ;
constexpr uint32 StencilBit_Single_1 = StencilBit_Single ;
constexpr uint32 StencilBit_Complex_1 = StencilBit_Complex ;
2022-02-11 11:38:18 -05:00
2022-04-13 09:51:33 -04:00
void AddStrataInternalClassificationTilePass (
2021-01-27 08:51:50 -04:00
FRDGBuilder & GraphBuilder ,
const FViewInfo & View ,
2021-02-17 11:12:16 -04:00
const FRDGTextureRef * DepthTexture ,
const FRDGTextureRef * ColorTexture ,
2022-03-15 09:55:16 -04:00
EStrataTileType TileMaterialType ,
2021-04-06 02:12:57 -04:00
const bool bDebug = false )
{
EPrimitiveType StrataTilePrimitiveType = PT_TriangleList ;
2022-10-11 12:59:51 -04:00
FIntPoint DebugOutputResolution = FIntPoint ( View . UnscaledViewRect . Width ( ) , View . UnscaledViewRect . Height ( ) ) ;
2022-04-02 14:31:01 -04:00
const FIntRect ViewRect = View . ViewRect ;
2021-01-27 08:51:50 -04:00
2021-04-06 02:12:57 -04:00
FStrataMaterialStencilTaggingPassPS : : FParameters * ParametersPS = GraphBuilder . AllocParameters < FStrataMaterialStencilTaggingPassPS : : FParameters > ( ) ;
2022-02-10 04:16:37 -05:00
ParametersPS - > VS = Strata : : SetTileParameters ( GraphBuilder , View , TileMaterialType , StrataTilePrimitiveType ) ;
2021-01-27 08:51:50 -04:00
2021-04-06 05:39:35 -04:00
FStrataTilePassVS : : FPermutationDomain VSPermutationVector ;
2021-04-21 08:10:24 -04:00
VSPermutationVector . Set < FStrataTilePassVS : : FEnableDebug > ( bDebug ) ;
2021-04-06 05:39:35 -04:00
VSPermutationVector . Set < FStrataTilePassVS : : FEnableTexCoordScreenVector > ( false ) ;
TShaderMapRef < FStrataTilePassVS > VertexShader ( View . ShaderMap , VSPermutationVector ) ;
2021-04-06 02:12:57 -04:00
TShaderMapRef < FStrataMaterialStencilTaggingPassPS > PixelShader ( View . ShaderMap ) ;
2021-01-27 08:51:50 -04:00
// For debug purpose
2021-02-17 11:12:16 -04:00
if ( bDebug )
{
2022-10-11 12:59:51 -04:00
// ViewRect contains the scaled resolution according to TSR screen percentage.
// The ColorTexture can be larger than the screen resolution if the screen percentage has be manipulated to be >100%.
// So we simply re-use the previously computed ViewResolutionFraction to recover the targeted resolution in the editor.
// TODO fix this for split screen.
const float InvViewResolutionFraction = 1.0f / View . CachedViewUniformShaderParameters - > ViewResolutionFraction ;
DebugOutputResolution = FIntPoint ( float ( ViewRect . Width ( ) ) * InvViewResolutionFraction , float ( ViewRect . Height ( ) ) * InvViewResolutionFraction ) ;
2021-04-06 02:12:57 -04:00
check ( ColorTexture ) ;
2021-02-17 11:12:16 -04:00
ParametersPS - > RenderTargets [ 0 ] = FRenderTargetBinding ( * ColorTexture , ERenderTargetLoadAction : : ELoad ) ;
2021-04-21 08:10:24 -04:00
switch ( TileMaterialType )
{
2022-03-16 05:45:43 -04:00
case EStrataTileType : : ESimple : ParametersPS - > DebugTileColor = FVector4f ( 0.0f , 1.0f , 0.0f , 1.0 ) ; break ;
case EStrataTileType : : ESingle : ParametersPS - > DebugTileColor = FVector4f ( 1.0f , 1.0f , 0.0f , 1.0 ) ; break ;
case EStrataTileType : : EComplex : ParametersPS - > DebugTileColor = FVector4f ( 1.0f , 0.0f , 0.0f , 1.0 ) ; break ;
2022-09-20 09:05:17 -04:00
2022-03-16 05:45:43 -04:00
case EStrataTileType : : EOpaqueRoughRefraction : ParametersPS - > DebugTileColor = FVector4f ( 0.0f , 1.0f , 1.0f , 1.0 ) ; break ;
2022-09-20 09:05:17 -04:00
case EStrataTileType : : EOpaqueRoughRefractionSSSWithout : ParametersPS - > DebugTileColor = FVector4f ( 0.0f , 0.0f , 1.0f , 1.0 ) ; break ;
case EStrataTileType : : EDecalSingle : ParametersPS - > DebugTileColor = FVector4f ( 0.0f , 1.0f , 0.0f , 1.0 ) ; break ;
case EStrataTileType : : EDecalSimple : ParametersPS - > DebugTileColor = FVector4f ( 1.0f , 1.0f , 0.0f , 1.0 ) ; break ;
case EStrataTileType : : EDecalComplex : ParametersPS - > DebugTileColor = FVector4f ( 1.0f , 0.0f , 0.0f , 1.0 ) ; break ;
2021-12-14 10:24:57 -05:00
default : check ( false ) ;
2021-04-21 08:10:24 -04:00
}
2021-02-17 11:12:16 -04:00
}
else
{
check ( DepthTexture ) ;
ParametersPS - > RenderTargets . DepthStencil = FDepthStencilBinding (
* DepthTexture ,
ERenderTargetLoadAction : : ELoad ,
ERenderTargetLoadAction : : ELoad ,
FExclusiveDepthStencil : : DepthNop_StencilWrite ) ;
2021-09-22 10:01:48 -04:00
ParametersPS - > DebugTileColor = FVector4f ( ForceInitToZero ) ;
2021-02-17 11:12:16 -04:00
}
2021-01-27 08:51:50 -04:00
GraphBuilder . AddPass (
2021-12-14 10:24:57 -05:00
RDG_EVENT_NAME ( " Strata::%sClassificationPass(%s) " , bDebug ? TEXT ( " Debug " ) : TEXT ( " Stencil " ) , ToString ( TileMaterialType ) ) ,
2021-01-27 08:51:50 -04:00
ParametersPS ,
ERDGPassFlags : : Raster ,
2022-10-11 12:59:51 -04:00
[ ParametersPS , VertexShader , PixelShader , ViewRect , DebugOutputResolution , StrataTilePrimitiveType , TileMaterialType , bDebug ] ( FRHICommandList & RHICmdList )
2021-01-27 08:51:50 -04:00
{
FGraphicsPipelineStateInitializer GraphicsPSOInit ;
RHICmdList . ApplyCachedRenderTargets ( GraphicsPSOInit ) ;
GraphicsPSOInit . RasterizerState = TStaticRasterizerState < > : : GetRHI ( ) ;
2022-01-06 16:44:09 +00:00
uint32 StencilRef = 0xFF ;
2021-02-17 11:12:16 -04:00
if ( bDebug )
{
2021-04-21 08:10:24 -04:00
// Use premultiplied alpha blending, pixel shader and depth/stencil is off
GraphicsPSOInit . BoundShaderState . PixelShaderRHI = PixelShader . GetPixelShader ( ) ;
GraphicsPSOInit . BlendState = TStaticBlendState < CW_RGBA , BO_Add , BF_One , BF_InverseSourceAlpha , BO_Add , BF_Zero , BF_One > : : GetRHI ( ) ;
2021-02-17 11:12:16 -04:00
GraphicsPSOInit . DepthStencilState = TStaticDepthStencilState < false , CF_Always > : : GetRHI ( ) ;
}
else
{
2022-09-20 09:05:17 -04:00
check ( TileMaterialType ! = EStrataTileType : : ECount & & TileMaterialType ! = EStrataTileType : : EOpaqueRoughRefraction & & TileMaterialType ! = EStrataTileType : : EOpaqueRoughRefractionSSSWithout ) ;
2022-01-06 16:44:09 +00:00
2022-03-15 09:55:16 -04:00
// No blending and no pixel shader required. Stencil will be written to.
2021-04-21 08:10:24 -04:00
GraphicsPSOInit . BoundShaderState . PixelShaderRHI = nullptr ;
GraphicsPSOInit . BlendState = TStaticBlendState < > : : GetRHI ( ) ;
2022-02-11 05:05:02 -05:00
switch ( TileMaterialType )
{
2022-03-15 09:55:16 -04:00
case EStrataTileType : : ESimple :
2022-01-06 16:44:09 +00:00
{
GraphicsPSOInit . DepthStencilState = TStaticDepthStencilState <
false , CF_Always ,
true , CF_Always , SO_Keep , SO_Keep , SO_Replace ,
false , CF_Always , SO_Keep , SO_Keep , SO_Keep ,
2022-02-11 11:38:18 -05:00
0xFF , StencilBit_Fast_1 > : : GetRHI ( ) ;
StencilRef = StencilBit_Fast_1 ;
2022-01-06 16:44:09 +00:00
}
2022-02-11 05:05:02 -05:00
break ;
2022-03-15 09:55:16 -04:00
case EStrataTileType : : ESingle :
2022-01-06 16:44:09 +00:00
{
GraphicsPSOInit . DepthStencilState = TStaticDepthStencilState <
false , CF_Always ,
true , CF_Always , SO_Keep , SO_Keep , SO_Replace ,
false , CF_Always , SO_Keep , SO_Keep , SO_Keep ,
2022-02-11 11:38:18 -05:00
0xFF , StencilBit_Single_1 > : : GetRHI ( ) ;
StencilRef = StencilBit_Single_1 ;
2022-01-06 16:44:09 +00:00
}
2022-02-11 05:05:02 -05:00
break ;
2022-03-15 09:55:16 -04:00
case EStrataTileType : : EComplex :
2022-02-11 05:05:02 -05:00
{
GraphicsPSOInit . DepthStencilState = TStaticDepthStencilState <
false , CF_Always ,
true , CF_Always , SO_Keep , SO_Keep , SO_Replace ,
false , CF_Always , SO_Keep , SO_Keep , SO_Keep ,
2022-02-11 11:38:18 -05:00
0xFF , StencilBit_Complex_1 > : : GetRHI ( ) ;
StencilRef = StencilBit_Complex_1 ;
2022-02-11 05:05:02 -05:00
}
break ;
}
2021-02-17 11:12:16 -04:00
}
2021-01-27 08:51:50 -04:00
GraphicsPSOInit . BoundShaderState . VertexDeclarationRHI = GFilterVertexDeclaration . VertexDeclarationRHI ;
GraphicsPSOInit . BoundShaderState . VertexShaderRHI = VertexShader . GetVertexShader ( ) ;
2021-04-06 02:12:57 -04:00
GraphicsPSOInit . PrimitiveType = StrataTilePrimitiveType ;
2022-01-06 16:44:09 +00:00
SetGraphicsPipelineState ( RHICmdList , GraphicsPSOInit , StencilRef ) ;
2021-04-06 02:12:57 -04:00
SetShaderParameters ( RHICmdList , VertexShader , VertexShader . GetVertexShader ( ) , ParametersPS - > VS ) ;
2021-11-18 14:37:34 -05:00
if ( bDebug )
{
2022-04-02 14:31:01 -04:00
// Debug rendering is aways done during the post-processing stage, which has an ViewMinRect set to (0,0)
2021-11-18 14:37:34 -05:00
SetShaderParameters ( RHICmdList , PixelShader , PixelShader . GetPixelShader ( ) , * ParametersPS ) ;
2022-10-11 12:59:51 -04:00
RHICmdList . SetViewport ( 0 , 0 , 0.0f , DebugOutputResolution . X , DebugOutputResolution . Y , 1.0f ) ;
2022-04-02 14:31:01 -04:00
}
else
{
RHICmdList . SetViewport ( ViewRect . Min . X , ViewRect . Min . Y , 0.0f , ViewRect . Max . X , ViewRect . Max . Y , 1.0f ) ;
2021-11-18 14:37:34 -05:00
}
2021-01-27 08:51:50 -04:00
RHICmdList . SetStreamSource ( 0 , nullptr , 0 ) ;
2022-03-15 09:55:16 -04:00
RHICmdList . DrawPrimitiveIndirect ( ParametersPS - > VS . TileIndirectBuffer - > GetIndirectRHICallBuffer ( ) , TileTypeDrawIndirectArgOffset ( TileMaterialType ) ) ;
2021-01-27 08:51:50 -04:00
} ) ;
}
void AddStrataStencilPass (
FRDGBuilder & GraphBuilder ,
2022-06-07 13:19:54 -04:00
const TArray < FViewInfo > & Views ,
2021-01-27 08:51:50 -04:00
const FMinimalSceneTextures & SceneTextures )
{
for ( int32 i = 0 ; i < Views . Num ( ) ; + + i )
{
2022-05-02 12:12:18 -04:00
RDG_EVENT_SCOPE_CONDITIONAL ( GraphBuilder , Views . Num ( ) > 1 , " View%d " , i ) ;
2021-01-27 08:51:50 -04:00
const FViewInfo & View = Views [ i ] ;
2022-03-15 09:55:16 -04:00
AddStrataInternalClassificationTilePass ( GraphBuilder , View , & SceneTextures . Depth . Target , nullptr , EStrataTileType : : EComplex ) ;
2022-05-06 15:08:26 -04:00
AddStrataInternalClassificationTilePass ( GraphBuilder , View , & SceneTextures . Depth . Target , nullptr , EStrataTileType : : ESingle ) ;
AddStrataInternalClassificationTilePass ( GraphBuilder , View , & SceneTextures . Depth . Target , nullptr , EStrataTileType : : ESimple ) ;
2021-02-17 11:12:16 -04:00
}
}
2021-01-27 08:51:50 -04:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2022-04-04 03:13:11 -04:00
void AppendStrataMRTs ( const FSceneRenderer & SceneRenderer , uint32 & RenderTargetCount , TStaticArray < FTextureRenderTargetBinding , MaxSimultaneousRenderTargets > & RenderTargets )
2021-11-29 09:31:58 -05:00
{
if ( Strata : : IsStrataEnabled ( ) & & SceneRenderer . Scene )
{
2021-11-29 18:03:54 -05:00
// If this function changes, update Strata::SetBasePassRenderTargetOutputFormat()
2021-12-06 08:54:37 -05:00
// Add 2 uint for Strata fast path.
// - We must clear the first uint to 0 to identify pixels that have not been written to.
// - We must never clear the second uint, it will only be written/read if needed.
auto AddStrataOutputTarget = [ & ] ( int16 StrataMaterialArraySlice , bool bNeverClear = false )
2021-11-29 09:31:58 -05:00
{
2022-01-04 12:18:49 -05:00
RenderTargets [ RenderTargetCount ] = FTextureRenderTargetBinding ( SceneRenderer . Scene - > StrataSceneData . MaterialTextureArray , StrataMaterialArraySlice , bNeverClear ) ;
2021-11-29 09:31:58 -05:00
RenderTargetCount + + ;
} ;
2022-08-16 04:30:21 -04:00
const bool bSupportCMask = SupportsCMask ( GMaxRHIShaderPlatform ) ;
2022-01-04 12:18:49 -05:00
for ( int i = 0 ; i < STRATA_BASE_PASS_MRT_OUTPUT_COUNT ; + + i )
{
2022-08-16 04:30:21 -04:00
const bool bNeverClear = bSupportCMask | | i ! = 0 ; // Only allow clearing the first slice containing the header
2022-01-04 12:18:49 -05:00
AddStrataOutputTarget ( i , bNeverClear ) ;
}
2021-11-29 09:31:58 -05:00
2021-12-06 08:54:37 -05:00
// Add another MRT for Strata top layer information. We want to follow the usual clear process which can leverage fast clear.
2021-11-29 09:31:58 -05:00
{
2021-12-06 08:54:37 -05:00
RenderTargets [ RenderTargetCount ] = FTextureRenderTargetBinding ( SceneRenderer . Scene - > StrataSceneData . TopLayerTexture ) ;
2021-11-29 09:31:58 -05:00
RenderTargetCount + + ;
} ;
}
}
2022-10-17 17:59:19 -04:00
void SetBasePassRenderTargetOutputFormat ( const EShaderPlatform Platform , const FMaterialShaderParameters & MaterialParameters , FShaderCompilerEnvironment & OutEnvironment , EGBufferLayout GBufferLayout )
2021-11-29 18:03:54 -05:00
{
if ( Strata : : IsStrataEnabled ( ) )
{
2022-10-17 17:59:19 -04:00
FGBufferParams GBufferParams = FShaderCompileUtilities : : FetchGBufferParamsRuntime ( Platform , GBufferLayout ) ;
2022-08-16 13:50:53 -04:00
// If it is not a water material, we force bHasSingleLayerWaterSeparatedMainLight to false, in order to
// ensure non-used MRTs are not inserted in BufferInfo. Otherwise this would offset Strata MRTs, causing
// MRTs' format to be incorrect
if ( ! MaterialParameters . bIsUsedWithWater )
{
GBufferParams . bHasSingleLayerWaterSeparatedMainLight = false ;
}
2021-11-29 18:03:54 -05:00
const FGBufferInfo BufferInfo = FetchFullGBufferInfo ( GBufferParams ) ;
2022-11-16 03:26:45 -05:00
// Add N uint for Strata fast path
for ( int i = 0 ; i < STRATA_BASE_PASS_MRT_OUTPUT_COUNT ; + + i )
{
OutEnvironment . SetRenderTargetOutputFormat ( BufferInfo . NumTargets + i , PF_R32_UINT ) ;
}
2021-11-29 18:03:54 -05:00
// Add another MRT for Strata top layer information
2022-11-16 11:35:48 -05:00
OutEnvironment . SetRenderTargetOutputFormat ( BufferInfo . NumTargets + STRATA_BASE_PASS_MRT_OUTPUT_COUNT , GetTopLayerTextureFormat ( ) ) ;
2021-11-29 18:03:54 -05:00
}
}
2021-11-29 09:31:58 -05:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2022-08-16 04:30:21 -04:00
//#include "RendererUtils.h"
2022-09-20 09:05:17 -04:00
void AddStrataMaterialClassificationPass ( FRDGBuilder & GraphBuilder , const FMinimalSceneTextures & SceneTextures , const FDBufferTextures & DBufferTextures , const TArray < FViewInfo > & Views )
2020-12-08 09:06:58 -04:00
{
2022-03-16 05:59:35 -04:00
RDG_EVENT_SCOPE_CONDITIONAL ( GraphBuilder , IsStrataEnabled ( ) & & Views . Num ( ) > 0 , " Strata::MaterialClassification " ) ;
2020-12-08 09:06:58 -04:00
if ( ! IsStrataEnabled ( ) )
{
return ;
}
2022-05-05 15:00:34 -04:00
// Optionally run tile classification in async compute
2022-10-27 09:52:35 -04:00
const ERDGPassFlags PassFlags = IsClassificationAsync ( ) ? ERDGPassFlags : : AsyncCompute : ERDGPassFlags : : Compute ;
2022-05-05 15:00:34 -04:00
2020-12-08 09:06:58 -04:00
for ( int32 i = 0 ; i < Views . Num ( ) ; + + i )
{
2022-05-02 12:12:18 -04:00
RDG_EVENT_SCOPE_CONDITIONAL ( GraphBuilder , Views . Num ( ) > 1 , " View%d " , i ) ;
2020-12-08 09:06:58 -04:00
const FViewInfo & View = Views [ i ] ;
2022-06-23 11:15:46 -04:00
bool bWaveOps = GRHISupportsWaveOperations & & GRHIMaximumWaveSize > = 64 & & FDataDrivenShaderPlatformInfo : : GetSupportsWaveOperations ( View . GetShaderPlatform ( ) ) ! = ERHIFeatureSupport : : Unsupported ;
2020-12-08 09:06:58 -04:00
2022-04-02 14:31:01 -04:00
const FStrataViewData * StrataViewData = & View . StrataViewData ;
const FStrataSceneData * StrataSceneData = View . StrataViewData . SceneData ;
2021-11-24 10:34:04 -05:00
// Tile reduction
2021-01-27 08:51:50 -04:00
{
2022-08-16 04:30:21 -04:00
// When the platform support explicit CMask texture, we disable material data bufferclear. Material buffer buffer clear (the header part) is done during the classification pass.
// To reduce the reading bandwidth, we rely on TopLayerData CMask to 'drive' the clearing process. This allows to clear quickly empty tiles.
const bool bSupportCMask = SupportsCMask ( View . GetShaderPlatform ( ) ) ;
FRDGTextureRef TopLayerCmaskTexture = StrataSceneData - > TopLayerTexture ;
if ( bSupportCMask )
{
// Combine DBuffer RTWriteMasks; will end up in one texture we can load from in the base pass PS and decide whether to do the actual work or not.
FRDGTextureRef SourceCMaskTextures [ ] = { StrataSceneData - > TopLayerTexture } ;
FRenderTargetWriteMask : : Decode ( GraphBuilder , View . ShaderMap , MakeArrayView ( SourceCMaskTextures ) , TopLayerCmaskTexture , GFastVRamConfig . DBufferMask , TEXT ( " Strata::TopLayerCmask " ) ) ;
}
2022-09-20 09:05:17 -04:00
// If Dbuffer pass (i.e. apply DBuffer data after the base-pass) is enabled, run special classification for outputing tile with/without tiles
const bool bDBufferTiles = CVarStrataDBufferPass . GetValueOnRenderThread ( ) > 0 & & CVarStrataDBufferPassDedicatedTiles . GetValueOnRenderThread ( ) > 0 & & DBufferTextures . IsValid ( ) ;
2021-11-24 13:13:31 -05:00
FStrataMaterialTileClassificationPassCS : : FPermutationDomain PermutationVector ;
2022-08-16 04:30:21 -04:00
PermutationVector . Set < FStrataMaterialTileClassificationPassCS : : FCmask > ( bSupportCMask ) ;
2021-11-24 13:13:31 -05:00
PermutationVector . Set < FStrataMaterialTileClassificationPassCS : : FWaveOps > ( bWaveOps ) ;
2022-09-20 09:05:17 -04:00
PermutationVector . Set < FStrataMaterialTileClassificationPassCS : : FDecal > ( bDBufferTiles ) ;
2021-11-24 13:13:31 -05:00
TShaderMapRef < FStrataMaterialTileClassificationPassCS > ComputeShader ( View . ShaderMap , PermutationVector ) ;
2021-01-27 08:51:50 -04:00
FStrataMaterialTileClassificationPassCS : : FParameters * PassParameters = GraphBuilder . AllocParameters < FStrataMaterialTileClassificationPassCS : : FParameters > ( ) ;
2021-11-26 10:59:06 -05:00
PassParameters - > ViewUniformBuffer = View . ViewUniformBuffer ;
2021-01-28 07:26:46 -04:00
PassParameters - > bRectPrimitive = GRHISupportsRectTopology ? 1 : 0 ;
2021-01-29 18:01:50 -04:00
PassParameters - > ViewResolution = View . ViewRect . Size ( ) ;
2022-04-02 14:31:01 -04:00
PassParameters - > MaxBytesPerPixel = StrataSceneData - > MaxBytesPerPixel ;
2022-08-29 02:55:17 -04:00
PassParameters - > FirstSliceStoringStrataSSSData = StrataSceneData - > FirstSliceStoringStrataSSSData ;
2022-04-02 14:31:01 -04:00
PassParameters - > TopLayerTexture = StrataSceneData - > TopLayerTexture ;
2022-08-16 04:30:21 -04:00
PassParameters - > TopLayerCmaskTexture = TopLayerCmaskTexture ;
2022-08-29 02:55:17 -04:00
PassParameters - > MaterialTextureArrayUAV = StrataSceneData - > MaterialTextureArrayUAV ;
2022-04-02 14:31:01 -04:00
PassParameters - > OpaqueRoughRefractionTexture = StrataSceneData - > OpaqueRoughRefractionTexture ;
PassParameters - > TileDrawIndirectDataBuffer = StrataViewData - > ClassificationTileDrawIndirectBufferUAV ;
2022-09-20 09:05:17 -04:00
PassParameters - > DBuffer = GetDBufferParameters ( GraphBuilder , DBufferTextures , View . GetShaderPlatform ( ) ) ;
PassParameters - > SceneStencilTexture = SceneTextures . Stencil ;
// Regular tiles
2022-04-02 14:31:01 -04:00
PassParameters - > SimpleTileListDataBuffer = StrataViewData - > ClassificationTileListBufferUAV [ EStrataTileType : : ESimple ] ;
PassParameters - > SingleTileListDataBuffer = StrataViewData - > ClassificationTileListBufferUAV [ EStrataTileType : : ESingle ] ;
PassParameters - > ComplexTileListDataBuffer = StrataViewData - > ClassificationTileListBufferUAV [ EStrataTileType : : EComplex ] ;
2022-09-20 09:05:17 -04:00
// Decal tiles
PassParameters - > DecalSimpleTileListDataBuffer = StrataViewData - > ClassificationTileListBufferUAV [ EStrataTileType : : EDecalSimple ] ;
PassParameters - > DecalSingleTileListDataBuffer = StrataViewData - > ClassificationTileListBufferUAV [ EStrataTileType : : EDecalSingle ] ;
PassParameters - > DecalComplexTileListDataBuffer = StrataViewData - > ClassificationTileListBufferUAV [ EStrataTileType : : EDecalComplex ] ;
// Rough refraction tiles
2022-04-02 14:31:01 -04:00
PassParameters - > OpaqueRoughRefractionTileListDataBuffer = StrataViewData - > ClassificationTileListBufferUAV [ EStrataTileType : : EOpaqueRoughRefraction ] ;
2022-09-20 09:05:17 -04:00
PassParameters - > OpaqueRoughRefractionSSSWithoutTileListDataBuffer = StrataViewData - > ClassificationTileListBufferUAV [ EStrataTileType : : EOpaqueRoughRefractionSSSWithout ] ;
2021-01-27 08:51:50 -04:00
const uint32 GroupSize = 8 ;
FComputeShaderUtils : : AddPass (
GraphBuilder ,
2022-08-16 04:30:21 -04:00
RDG_EVENT_NAME ( " Strata::MaterialTileClassification(%s%s) " , bWaveOps ? TEXT ( " Wave " ) : TEXT ( " SharedMemory " ) , bSupportCMask ? TEXT ( " , CMask " ) : TEXT ( " " ) ) ,
2022-05-05 15:00:34 -04:00
PassFlags ,
2021-01-27 08:51:50 -04:00
ComputeShader ,
PassParameters ,
2021-11-26 10:59:06 -05:00
FComputeShaderUtils : : GetGroupCount ( PassParameters - > ViewResolution , GroupSize ) ) ;
2021-01-27 08:51:50 -04:00
}
2022-03-18 13:43:33 -04:00
// Tile indirect dispatch args conversion
{
TShaderMapRef < FStrataMaterialTilePrepareArgsPassCS > ComputeShader ( View . ShaderMap ) ;
FStrataMaterialTilePrepareArgsPassCS : : FParameters * PassParameters = GraphBuilder . AllocParameters < FStrataMaterialTilePrepareArgsPassCS : : FParameters > ( ) ;
2022-04-02 14:31:01 -04:00
PassParameters - > TileDrawIndirectDataBuffer = GraphBuilder . CreateSRV ( StrataViewData - > ClassificationTileDrawIndirectBuffer , PF_R32_UINT ) ;
PassParameters - > TileDispatchIndirectDataBuffer = StrataViewData - > ClassificationTileDispatchIndirectBufferUAV ;
2022-03-18 13:43:33 -04:00
FComputeShaderUtils : : AddPass (
GraphBuilder ,
RDG_EVENT_NAME ( " Strata::MaterialTilePrepareArgs " ) ,
2022-05-05 15:00:34 -04:00
PassFlags ,
2022-03-18 13:43:33 -04:00
ComputeShader ,
PassParameters ,
FIntVector ( 1 , 1 , 1 ) ) ;
}
// Compute BSDF tile index and material read offset
2022-05-05 09:53:22 -04:00
if ( StrataSceneData - > BSDFOffsetTexture )
2022-03-18 13:43:33 -04:00
{
2022-04-02 14:31:01 -04:00
FRDGBufferUAVRef RWBSDFTileCountBuffer = GraphBuilder . CreateUAV ( StrataViewData - > BSDFTileCountBuffer , PF_R32_UINT ) ;
2022-03-18 13:43:33 -04:00
AddClearUAVPass ( GraphBuilder , RWBSDFTileCountBuffer , 0u ) ;
FStrataBSDFTilePassCS : : FPermutationDomain PermutationVector ;
PermutationVector . Set < FStrataBSDFTilePassCS : : FWaveOps > ( bWaveOps ) ;
TShaderMapRef < FStrataBSDFTilePassCS > ComputeShader ( View . ShaderMap , PermutationVector ) ;
FStrataBSDFTilePassCS : : FParameters * PassParameters = GraphBuilder . AllocParameters < FStrataBSDFTilePassCS : : FParameters > ( ) ;
PassParameters - > ViewUniformBuffer = View . ViewUniformBuffer ;
2022-03-31 13:05:44 -04:00
PassParameters - > TileSizeLog2 = STRATA_TILE_SIZE_DIV_AS_SHIFT ;
2022-05-02 12:12:18 -04:00
PassParameters - > TileCount_Primary = StrataViewData - > TileCount ;
PassParameters - > TileOffset_Primary = StrataViewData - > TileOffset ;
2022-05-02 14:06:39 -04:00
PassParameters - > OverflowTileCount = StrataViewData - > OverflowTileCount ;
PassParameters - > OverflowTileOffset = StrataViewData - > OverflowTileOffset ;
2022-03-18 13:43:33 -04:00
PassParameters - > ViewResolution = View . ViewRect . Size ( ) ;
2022-04-02 14:31:01 -04:00
PassParameters - > MaxBytesPerPixel = StrataSceneData - > MaxBytesPerPixel ;
PassParameters - > TopLayerTexture = StrataSceneData - > TopLayerTexture ;
PassParameters - > MaterialTextureArray = StrataSceneData - > MaterialTextureArraySRV ;
PassParameters - > TileListBuffer = StrataViewData - > ClassificationTileListBufferSRV [ EStrataTileType : : EComplex ] ;
PassParameters - > TileIndirectBuffer = StrataViewData - > ClassificationTileDispatchIndirectBuffer ;
2022-03-18 13:43:33 -04:00
2022-04-02 14:31:01 -04:00
PassParameters - > RWBSDFOffsetTexture = GraphBuilder . CreateUAV ( StrataSceneData - > BSDFOffsetTexture ) ;
PassParameters - > RWBSDFTileTexture = GraphBuilder . CreateUAV ( StrataViewData - > BSDFTileTexture ) ;
2022-03-18 13:43:33 -04:00
PassParameters - > RWBSDFTileCountBuffer = RWBSDFTileCountBuffer ;
FComputeShaderUtils : : AddPass (
GraphBuilder ,
RDG_EVENT_NAME ( " Strata::BSDFTileAndOffsets(%s) " , bWaveOps ? TEXT ( " Wave " ) : TEXT ( " SharedMemory " ) ) ,
2022-05-05 15:00:34 -04:00
PassFlags ,
2022-03-18 13:43:33 -04:00
ComputeShader ,
PassParameters ,
PassParameters - > TileIndirectBuffer ,
TileTypeDispatchIndirectArgOffset ( EStrataTileType : : EComplex ) ) ;
}
2022-03-21 06:29:05 -04:00
// Tile indirect dispatch args conversion
2022-05-05 09:53:22 -04:00
if ( StrataSceneData - > BSDFOffsetTexture )
2022-03-21 06:29:05 -04:00
{
TShaderMapRef < FStrataBSDFTilePrepareArgsPassCS > ComputeShader ( View . ShaderMap ) ;
FStrataBSDFTilePrepareArgsPassCS : : FParameters * PassParameters = GraphBuilder . AllocParameters < FStrataBSDFTilePrepareArgsPassCS : : FParameters > ( ) ;
2022-05-02 12:12:18 -04:00
PassParameters - > TileCount_Primary = StrataViewData - > TileCount ;
PassParameters - > TileOffset_Primary = StrataViewData - > TileOffset ;
2022-05-02 14:06:39 -04:00
PassParameters - > OverflowTileCount = StrataViewData - > OverflowTileCount ;
PassParameters - > OverflowTileOffset = StrataViewData - > OverflowTileOffset ;
2022-04-02 14:31:01 -04:00
PassParameters - > TileDrawIndirectDataBuffer = GraphBuilder . CreateSRV ( StrataViewData - > BSDFTileCountBuffer , PF_R32_UINT ) ;
PassParameters - > TileDispatchIndirectDataBuffer = GraphBuilder . CreateUAV ( StrataViewData - > BSDFTileDispatchIndirectBuffer , PF_R32_UINT ) ;
2022-05-02 12:12:18 -04:00
PassParameters - > TileDispatchPerThreadIndirectDataBuffer = GraphBuilder . CreateUAV ( StrataViewData - > BSDFTilePerThreadDispatchIndirectBuffer , PF_R32_UINT ) ;
2022-03-21 06:29:05 -04:00
FComputeShaderUtils : : AddPass (
GraphBuilder ,
RDG_EVENT_NAME ( " Strata::BSDFTilePrepareArgs " ) ,
2022-05-05 15:00:34 -04:00
PassFlags ,
2022-03-21 06:29:05 -04:00
ComputeShader ,
PassParameters ,
FIntVector ( 1 , 1 , 1 ) ) ;
}
2020-12-08 09:06:58 -04:00
}
}
2022-09-16 08:21:00 -04:00
void AddStrataDBufferPass ( FRDGBuilder & GraphBuilder , const FMinimalSceneTextures & SceneTextures , const FDBufferTextures & DBufferTextures , const TArray < FViewInfo > & Views )
{
RDG_EVENT_SCOPE_CONDITIONAL ( GraphBuilder , IsStrataEnabled ( ) & & Views . Num ( ) > 0 , " Strata::DBuffer " ) ;
if ( ! IsStrataEnabled ( ) | | ! DBufferTextures . IsValid ( ) | | CVarStrataDBufferPass . GetValueOnRenderThread ( ) < = 0 )
{
return ;
}
for ( int32 i = 0 ; i < Views . Num ( ) ; + + i )
{
RDG_EVENT_SCOPE_CONDITIONAL ( GraphBuilder , Views . Num ( ) > 1 , " View%d " , i ) ;
const FViewInfo & View = Views [ i ] ;
if ( ! IsUsingDBuffers ( View . GetShaderPlatform ( ) ) | | View . Family - > EngineShowFlags . Decals = = 0 )
{
continue ;
}
const FStrataViewData * StrataViewData = & View . StrataViewData ;
const FStrataSceneData * StrataSceneData = View . StrataViewData . SceneData ;
2022-09-20 11:15:19 -04:00
FRDGTextureUAVRef RWMaterialTexture = GraphBuilder . CreateUAV ( StrataSceneData - > MaterialTextureArray , ERDGUnorderedAccessViewFlags : : SkipBarrier ) ;
FRDGTextureUAVRef RWTopLayerTexture = GraphBuilder . CreateUAV ( StrataSceneData - > TopLayerTexture , ERDGUnorderedAccessViewFlags : : SkipBarrier ) ;
2022-09-16 08:21:00 -04:00
auto DBufferPass = [ & ] ( EStrataTileType TileType )
{
// Only simple & single material are support but also dispatch complex tiles,
// as they can contain simple/single material pixels
2022-09-20 09:05:17 -04:00
uint32 TilePermutation = 0 ;
switch ( TileType )
{
case EStrataTileType : : EComplex :
case EStrataTileType : : EDecalComplex :
TilePermutation = 2 ;
break ;
case EStrataTileType : : ESingle :
case EStrataTileType : : EDecalSingle :
TilePermutation = 1 ;
break ;
case EStrataTileType : : ESimple :
case EStrataTileType : : EDecalSimple :
TilePermutation = 0 ;
break ;
}
2022-09-16 08:21:00 -04:00
FStrataDBufferPassCS : : FPermutationDomain PermutationVector ;
2022-09-20 09:05:17 -04:00
PermutationVector . Set < FStrataDBufferPassCS : : FTileType > ( TilePermutation ) ;
2022-09-16 08:21:00 -04:00
TShaderMapRef < FStrataDBufferPassCS > ComputeShader ( View . ShaderMap , PermutationVector ) ;
FStrataDBufferPassCS : : FParameters * PassParameters = GraphBuilder . AllocParameters < FStrataDBufferPassCS : : FParameters > ( ) ;
PassParameters - > DBuffer = GetDBufferParameters ( GraphBuilder , DBufferTextures , View . GetShaderPlatform ( ) ) ;
PassParameters - > ViewUniformBuffer = View . ViewUniformBuffer ;
PassParameters - > ViewResolution = View . ViewRect . Size ( ) ;
PassParameters - > MaxBytesPerPixel = StrataSceneData - > MaxBytesPerPixel ;
2022-09-20 11:15:19 -04:00
PassParameters - > TopLayerTexture = RWTopLayerTexture ;
PassParameters - > MaterialTextureArrayUAV = RWMaterialTexture ;
2022-09-16 08:21:00 -04:00
PassParameters - > FirstSliceStoringStrataSSSData = StrataSceneData - > FirstSliceStoringStrataSSSData ;
2022-09-16 11:26:53 -04:00
PassParameters - > SceneStencilTexture = SceneTextures . Stencil ;
2022-09-16 08:21:00 -04:00
PassParameters - > TileListBuffer = StrataViewData - > ClassificationTileListBufferSRV [ TileType ] ;
PassParameters - > TileIndirectBuffer = StrataViewData - > ClassificationTileDispatchIndirectBuffer ;
// Dispatch with tile data
const uint32 GroupSize = 8 ;
FComputeShaderUtils : : AddPass (
GraphBuilder ,
RDG_EVENT_NAME ( " Strata::Dbuffer(%s) " , ToString ( TileType ) ) ,
ERDGPassFlags : : Compute ,
ComputeShader ,
PassParameters ,
PassParameters - > TileIndirectBuffer ,
TileTypeDispatchIndirectArgOffset ( TileType ) ) ;
} ;
2022-09-20 09:05:17 -04:00
const bool bDbufferTiles = CVarStrataDBufferPassDedicatedTiles . GetValueOnRenderThread ( ) > 0 ;
DBufferPass ( bDbufferTiles ? EStrataTileType : : EDecalComplex : EStrataTileType : : EComplex ) ;
2022-09-20 11:15:19 -04:00
DBufferPass ( bDbufferTiles ? EStrataTileType : : EDecalSingle : EStrataTileType : : ESingle ) ;
DBufferPass ( bDbufferTiles ? EStrataTileType : : EDecalSimple : EStrataTileType : : ESimple ) ;
2022-09-16 08:21:00 -04:00
}
}
2022-04-13 09:51:33 -04:00
} // namespace Strata