2016-01-07 08:17:16 -05:00
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
/*=============================================================================
PostProcessUpscale . cpp : Post processing Upscale implementation .
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
# include "RendererPrivate.h"
# include "ScenePrivate.h"
# include "SceneFilterRendering.h"
# include "PostProcessUpscale.h"
# include "PostProcessing.h"
# include "PostProcessHistogram.h"
# include "PostProcessEyeAdaptation.h"
2014-08-21 06:03:00 -04:00
# include "SceneUtils.h"
2014-03-14 14:13:41 -04:00
2014-11-03 16:17:18 -05:00
static TAutoConsoleVariable < float > CVarUpscaleSoftness (
TEXT ( " r.Upscale.Softness " ) ,
2014-06-25 05:47:33 -04:00
0.3f ,
2014-12-08 09:45:54 -05:00
TEXT ( " To scale up with higher quality losing some sharpness \n " )
2014-06-25 05:47:33 -04:00
TEXT ( " 0..1 (0.3 is good for ScreenPercentage 90 " ) ,
ECVF_Scalability | ECVF_RenderThreadSafe ) ;
Copying //UE4/Orion-Staging to //UE4/Main (originated from //Orion/Dev-General @ 2831630)
#lockdown Nick.Penwarden
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2831624 on 2016/01/17 by Marcus.Wassmer
Merge disable of FCachedReadPlatformData on PS4. Reduces memory spikes. 2830986
#rb none
#test none
#codereview Michael.Noland,James.Golding
Change 2831402 on 2016/01/17 by Marcus.Wassmer
HLOD priority and streamout changes.
Give texture pool an extra 200MB which we can afford thanks to James/Michael
#rb Chris.Gagnon
#test run agora, notice nice textures.
#lockdown Andrew.Grant
Change 2831398 on 2016/01/17 by Marcus.Wassmer
Fix 3 logic bugs with Relocate
#rb chris.gagnon
#test run game, look for corruption.
#lockdown Andrew.Grant
Change 2831372 on 2016/01/16 by Marcus.Wassmer
Update param.sfo's and lockdown version in prep for good PS4 playtest build.
#rb none
#test build from last night...
#lockdown Andrew.Grant
Change 2831274 on 2016/01/16 by Graeme.Thornton
Disable platform file cache wrapper on PS4
#codereview James.Golding
#rb none
#tests ran cooked ps4 build, timed loading (no real change), measured memory used for file handles (small)
Change 2831237 on 2016/01/16 by Sammy.James
Fix PS4 compile error
#codereview Andrew.Grant
#rb none
#tests none
Change 2831219 on 2016/01/16 by Matt.Kuhlenschmidt
Fix possible invalid access to shared movie player resource across threads causing startup crash.
#codereview marcus.wassmer
#rb none, #tests initial load
Change 2831218 on 2016/01/16 by Marcus.Wassmer
Fix bad warning case.
#codereview Martin.Mittring
#rb none
#test none
Change 2831201 on 2016/01/16 by Andrew.Grant
Added extra info about referencer to missing asset reference message
#rb none
#tests cooked, ran editor
Change 2831183 on 2016/01/16 by David.Nikdel
#OSS #PS4 #Purchasing #StoreV2
- Force failure if we have no receipts after a "successful" checkout.
- Report consumed entitlements as well as unconsumed but leave ValidationInfo empty so we can tell the difference at the application level
- Convert productIds to skuIds at checkout time
- Added PS4 Implementation of IOnlineStoreV2
- Bugfix: set bSuccessfullyStartedUp=false when InitNPGameSettings() fails
- Adjusted FOnlineStoreOffer to use FText::AsCurrencyBase
#RB: Paul.Moore
#TESTS: login, purchase redemption, store MTX purchasing on PS4 & PC
Change 2831129 on 2016/01/16 by David.Nikdel
#MCP
- Added a ctor to make converting from FOnlineError to FMcpQueryResult easier (for stuff that was already using FMcpQueryResult).
#RB: none
#TESTS: frontend
Change 2830986 on 2016/01/15 by Michael.Noland
PS4: Disabling FCachedReadPlatformFile on PS4 to significantly reduce high watermark memory consumption during blocking loads
#rb marcus.wassmer
#tests Ran Paragon PS4 down a bad path that currently does a blocking map and hero load
#lockdown andrew.grant
Change 2830943 on 2016/01/15 by Max.Chen
Sequencer: Fix bug introduced with preroll. It was also causing a crash in particle track instance.
#tests Master sequence trailer plays without crashing
#rb none
Change 2830912 on 2016/01/15 by Michael.Noland
Rendering: Exposed GRHIDeviceId (only filled in on D3D11 and D3D12 RHI's under the same circumstances as GRHIAdapterName, etc..., 0 otherwise)
#rb mieszko.zielinski
#tests Tested printing the value out
#codereview martin.mittring
Change 2830910 on 2016/01/15 by Michael.Noland
Rendering: Improved GPU driver detection logic to handle more cases
#codereview martin.mittring
#rb mieszko.zielinski
#tests Tested on my machine which was previous reporting Unknown for the values as some entries contained the key in the Settings subfolder
Change 2830776 on 2016/01/15 by Martin.Mittring
from Dev-Rendering
added ensure to track down multiple issues like
OR-11771 CRASH: User Crashed when pressing the Play button
OR-12430 CRASH: OT2 user crashed with FRHIResource::AddRef()
#rb:Gil.Gribb
#code_review:Gil.Gribb,Mark.Satterthwaite,Marcus.Wassmer
2016-01-20 11:32:08 -05:00
static TAutoConsoleVariable < float > CVarUpscalePaniniD (
TEXT ( " r.Upscale.Panini.D " ) ,
0 ,
TEXT ( " Allow and configure to apply a panini distortion to the rendered image. Values between 0 and 1 allow to fade the effect (lerp). \n " )
TEXT ( " Implementation from research paper \" Pannini: A New Projection for Rendering Wide Angle Perspective Images \" \n " )
TEXT ( " 0: off (default) \n " )
TEXT ( " >0: enabled (requires an extra post processing pass if upsampling wasn't used - see r.ScreenPercentage) \n " )
TEXT ( " 1: Panini cylindrical stereographic projection " ) ,
ECVF_RenderThreadSafe ) ;
static TAutoConsoleVariable < float > CVarUpscalePaniniS (
TEXT ( " r.Upscale.Panini.S " ) ,
0 ,
TEXT ( " Panini projection's hard vertical compression factor. \n " )
TEXT ( " 0: no vertical compression factor (default) \n " )
TEXT ( " 1: Hard vertical compression " ) ,
ECVF_RenderThreadSafe ) ;
static TAutoConsoleVariable < float > CVarUpscalePaniniScreenFit (
TEXT ( " r.Upscale.Panini.ScreenFit " ) ,
1.0f ,
TEXT ( " Panini projection screen fit effect factor (lerp). \n " )
TEXT ( " 0: fit vertically \n " )
TEXT ( " 1: fit horizontally (default) " ) ,
ECVF_RenderThreadSafe ) ;
2015-05-22 19:44:45 -04:00
const FRCPassPostProcessUpscale : : PaniniParams FRCPassPostProcessUpscale : : PaniniParams : : Default ;
Copying //UE4/Orion-Staging to //UE4/Main (originated from //Orion/Dev-General @ 2831630)
#lockdown Nick.Penwarden
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2831624 on 2016/01/17 by Marcus.Wassmer
Merge disable of FCachedReadPlatformData on PS4. Reduces memory spikes. 2830986
#rb none
#test none
#codereview Michael.Noland,James.Golding
Change 2831402 on 2016/01/17 by Marcus.Wassmer
HLOD priority and streamout changes.
Give texture pool an extra 200MB which we can afford thanks to James/Michael
#rb Chris.Gagnon
#test run agora, notice nice textures.
#lockdown Andrew.Grant
Change 2831398 on 2016/01/17 by Marcus.Wassmer
Fix 3 logic bugs with Relocate
#rb chris.gagnon
#test run game, look for corruption.
#lockdown Andrew.Grant
Change 2831372 on 2016/01/16 by Marcus.Wassmer
Update param.sfo's and lockdown version in prep for good PS4 playtest build.
#rb none
#test build from last night...
#lockdown Andrew.Grant
Change 2831274 on 2016/01/16 by Graeme.Thornton
Disable platform file cache wrapper on PS4
#codereview James.Golding
#rb none
#tests ran cooked ps4 build, timed loading (no real change), measured memory used for file handles (small)
Change 2831237 on 2016/01/16 by Sammy.James
Fix PS4 compile error
#codereview Andrew.Grant
#rb none
#tests none
Change 2831219 on 2016/01/16 by Matt.Kuhlenschmidt
Fix possible invalid access to shared movie player resource across threads causing startup crash.
#codereview marcus.wassmer
#rb none, #tests initial load
Change 2831218 on 2016/01/16 by Marcus.Wassmer
Fix bad warning case.
#codereview Martin.Mittring
#rb none
#test none
Change 2831201 on 2016/01/16 by Andrew.Grant
Added extra info about referencer to missing asset reference message
#rb none
#tests cooked, ran editor
Change 2831183 on 2016/01/16 by David.Nikdel
#OSS #PS4 #Purchasing #StoreV2
- Force failure if we have no receipts after a "successful" checkout.
- Report consumed entitlements as well as unconsumed but leave ValidationInfo empty so we can tell the difference at the application level
- Convert productIds to skuIds at checkout time
- Added PS4 Implementation of IOnlineStoreV2
- Bugfix: set bSuccessfullyStartedUp=false when InitNPGameSettings() fails
- Adjusted FOnlineStoreOffer to use FText::AsCurrencyBase
#RB: Paul.Moore
#TESTS: login, purchase redemption, store MTX purchasing on PS4 & PC
Change 2831129 on 2016/01/16 by David.Nikdel
#MCP
- Added a ctor to make converting from FOnlineError to FMcpQueryResult easier (for stuff that was already using FMcpQueryResult).
#RB: none
#TESTS: frontend
Change 2830986 on 2016/01/15 by Michael.Noland
PS4: Disabling FCachedReadPlatformFile on PS4 to significantly reduce high watermark memory consumption during blocking loads
#rb marcus.wassmer
#tests Ran Paragon PS4 down a bad path that currently does a blocking map and hero load
#lockdown andrew.grant
Change 2830943 on 2016/01/15 by Max.Chen
Sequencer: Fix bug introduced with preroll. It was also causing a crash in particle track instance.
#tests Master sequence trailer plays without crashing
#rb none
Change 2830912 on 2016/01/15 by Michael.Noland
Rendering: Exposed GRHIDeviceId (only filled in on D3D11 and D3D12 RHI's under the same circumstances as GRHIAdapterName, etc..., 0 otherwise)
#rb mieszko.zielinski
#tests Tested printing the value out
#codereview martin.mittring
Change 2830910 on 2016/01/15 by Michael.Noland
Rendering: Improved GPU driver detection logic to handle more cases
#codereview martin.mittring
#rb mieszko.zielinski
#tests Tested on my machine which was previous reporting Unknown for the values as some entries contained the key in the Settings subfolder
Change 2830776 on 2016/01/15 by Martin.Mittring
from Dev-Rendering
added ensure to track down multiple issues like
OR-11771 CRASH: User Crashed when pressing the Play button
OR-12430 CRASH: OT2 user crashed with FRHIResource::AddRef()
#rb:Gil.Gribb
#code_review:Gil.Gribb,Mark.Satterthwaite,Marcus.Wassmer
2016-01-20 11:32:08 -05:00
FRCPassPostProcessUpscale : : PaniniParams : : PaniniParams ( const FViewInfo & View )
{
* this = PaniniParams ( ) ;
if ( View . IsPerspectiveProjection ( ) & & ! GEngine - > StereoRenderingDevice . IsValid ( ) )
{
D = FMath : : Max ( CVarUpscalePaniniD . GetValueOnRenderThread ( ) , 0.0f ) ;
S = CVarUpscalePaniniS . GetValueOnRenderThread ( ) ;
ScreenFit = FMath : : Max ( CVarUpscalePaniniScreenFit . GetValueOnRenderThread ( ) , 0.0f ) ;
}
}
2015-05-22 19:44:45 -04:00
static FVector2D PaniniProjection ( FVector2D OM , float d , float s )
{
float PaniniDirectionXZInvLength = 1.0f / FMath : : Sqrt ( 1.0f + OM . X * OM . X ) ;
float SinPhi = OM . X * PaniniDirectionXZInvLength ;
float TanTheta = OM . Y * PaniniDirectionXZInvLength ;
float CosPhi = FMath : : Sqrt ( 1.0f - SinPhi * SinPhi ) ;
float S = ( d + 1.0f ) / ( d + CosPhi ) ;
return S * FVector2D ( SinPhi , FMath : : Lerp ( TanTheta , TanTheta / CosPhi , s ) ) ;
}
2014-11-03 16:17:18 -05:00
/** Encapsulates the upscale vertex shader. */
class FPostProcessUpscaleVS : public FPostProcessVS
{
DECLARE_SHADER_TYPE ( FPostProcessUpscaleVS , Global ) ;
/** Default constructor. */
FPostProcessUpscaleVS ( ) { }
public :
2015-05-22 19:44:45 -04:00
FShaderParameter PaniniParameters ;
2014-11-03 16:17:18 -05:00
/** Initialization constructor. */
FPostProcessUpscaleVS ( const ShaderMetaType : : CompiledShaderInitializerType & Initializer )
: FPostProcessVS ( Initializer )
{
2015-05-22 19:44:45 -04:00
PaniniParameters . Bind ( Initializer . ParameterMap , TEXT ( " PaniniParams " ) ) ;
2014-11-03 16:17:18 -05:00
}
2014-11-04 08:07:19 -05:00
static bool ShouldCache ( EShaderPlatform Platform )
{
2014-12-08 09:45:54 -05:00
return true ;
2014-11-04 08:07:19 -05:00
}
2014-11-03 16:17:18 -05:00
static void ModifyCompilationEnvironment ( EShaderPlatform Platform , FShaderCompilerEnvironment & OutEnvironment )
{
FPostProcessVS : : ModifyCompilationEnvironment ( Platform , OutEnvironment ) ;
OutEnvironment . SetDefine ( TEXT ( " TESS_RECT_X " ) , FTesselatedScreenRectangleIndexBuffer : : Width ) ;
OutEnvironment . SetDefine ( TEXT ( " TESS_RECT_Y " ) , FTesselatedScreenRectangleIndexBuffer : : Height ) ;
}
2015-05-22 19:44:45 -04:00
void SetParameters ( const FRenderingCompositePassContext & Context , const FRCPassPostProcessUpscale : : PaniniParams & InPaniniConfig )
2014-11-03 16:17:18 -05:00
{
const FVertexShaderRHIParamRef ShaderRHI = GetVertexShader ( ) ;
FGlobalShader : : SetParameters ( Context . RHICmdList , ShaderRHI , Context . View ) ;
{
2015-06-15 20:55:07 -04:00
const FVector2D FOVPerAxis = Context . View . ViewMatrices . GetHalfFieldOfViewPerAxis ( ) ;
2015-05-22 19:44:45 -04:00
const FVector2D ScreenPosToPaniniFactor = FVector2D ( FMath : : Tan ( FOVPerAxis . X ) , FMath : : Tan ( FOVPerAxis . Y ) ) ;
const FVector2D PaniniDirection = FVector2D ( 1.0f , 0.0f ) * ScreenPosToPaniniFactor ;
const FVector2D PaniniPosition = PaniniProjection ( PaniniDirection , InPaniniConfig . D , InPaniniConfig . S ) ;
2014-11-03 16:17:18 -05:00
2015-05-22 19:44:45 -04:00
const float WidthFit = ScreenPosToPaniniFactor . X / PaniniPosition . X ;
const float OutScreenPosScale = FMath : : Lerp ( 1.0f , WidthFit , InPaniniConfig . ScreenFit ) ;
2014-11-03 16:17:18 -05:00
2015-05-22 19:44:45 -04:00
FVector Value ( InPaniniConfig . D , InPaniniConfig . S , OutScreenPosScale ) ;
2014-11-03 16:17:18 -05:00
2015-05-22 19:44:45 -04:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , PaniniParameters , Value ) ;
2014-11-03 16:17:18 -05:00
}
}
2015-04-01 07:20:55 -04:00
virtual bool Serialize ( FArchive & Ar ) override
2014-11-03 16:17:18 -05:00
{
bool bShaderHasOutdatedParameters = FPostProcessVS : : Serialize ( Ar ) ;
2015-05-22 19:44:45 -04:00
Ar < < PaniniParameters ;
2014-11-03 16:17:18 -05:00
return bShaderHasOutdatedParameters ;
}
} ;
IMPLEMENT_SHADER_TYPE ( , FPostProcessUpscaleVS , TEXT ( " PostProcessUpscale " ) , TEXT ( " MainVS " ) , SF_Vertex ) ;
/** Encapsulates the post processing upscale pixel shader. */
2014-03-14 14:13:41 -04:00
template < uint32 Method >
class FPostProcessUpscalePS : public FGlobalShader
{
DECLARE_SHADER_TYPE ( FPostProcessUpscalePS , Global ) ;
static bool ShouldCache ( EShaderPlatform Platform )
{
2015-12-09 15:04:15 -05:00
// Always allow point and bilinear upscale. (Provides upscaling for ES2 emulation)
if ( Method = = 0 | | Method = = 1 )
2014-12-08 09:45:54 -05:00
{
return true ;
}
2014-08-25 14:41:54 -04:00
return IsFeatureLevelSupported ( Platform , ERHIFeatureLevel : : SM4 ) ;
2014-03-14 14:13:41 -04:00
}
static void ModifyCompilationEnvironment ( EShaderPlatform Platform , FShaderCompilerEnvironment & OutEnvironment )
{
2014-06-05 16:38:54 -04:00
FGlobalShader : : ModifyCompilationEnvironment ( Platform , OutEnvironment ) ;
2014-03-14 14:13:41 -04:00
OutEnvironment . SetDefine ( TEXT ( " METHOD " ) , Method ) ;
}
/** Default constructor. */
FPostProcessUpscalePS ( ) { }
public :
FPostProcessPassParameters PostprocessParameter ;
FDeferredPixelShaderParameters DeferredParameters ;
FShaderParameter UpscaleSoftness ;
/** Initialization constructor. */
FPostProcessUpscalePS ( const ShaderMetaType : : CompiledShaderInitializerType & Initializer )
: FGlobalShader ( Initializer )
{
PostprocessParameter . Bind ( Initializer . ParameterMap ) ;
DeferredParameters . Bind ( Initializer . ParameterMap ) ;
UpscaleSoftness . Bind ( Initializer . ParameterMap , TEXT ( " UpscaleSoftness " ) ) ;
}
2014-06-12 07:13:34 -04:00
void SetPS ( const FRenderingCompositePassContext & Context )
2014-03-14 14:13:41 -04:00
{
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader ( ) ;
2014-06-12 07:13:34 -04:00
FGlobalShader : : SetParameters ( Context . RHICmdList , ShaderRHI , Context . View ) ;
2014-03-14 14:13:41 -04:00
FSamplerStateRHIParamRef FilterTable [ 2 ] ;
FilterTable [ 0 ] = TStaticSamplerState < SF_Bilinear , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ;
FilterTable [ 1 ] = TStaticSamplerState < SF_Point , AM_Clamp , AM_Clamp , AM_Clamp > : : GetRHI ( ) ;
2015-08-14 11:59:44 -04:00
PostprocessParameter . SetPS ( ShaderRHI , Context , 0 , eFC_0000 , FilterTable ) ;
2014-06-12 07:13:34 -04:00
DeferredParameters . Set ( Context . RHICmdList , ShaderRHI , Context . View ) ;
2014-03-14 14:13:41 -04:00
{
2014-11-03 16:17:18 -05:00
float UpscaleSoftnessValue = FMath : : Clamp ( CVarUpscaleSoftness . GetValueOnRenderThread ( ) , 0.0f , 1.0f ) ;
2014-03-14 14:13:41 -04:00
2014-06-12 07:13:34 -04:00
SetShaderValue ( Context . RHICmdList , ShaderRHI , UpscaleSoftness , UpscaleSoftnessValue ) ;
2014-03-14 14:13:41 -04:00
}
}
// FShader interface.
2015-04-01 07:20:55 -04:00
virtual bool Serialize ( FArchive & Ar ) override
2014-03-14 14:13:41 -04:00
{
bool bShaderHasOutdatedParameters = FGlobalShader : : Serialize ( Ar ) ;
Ar < < PostprocessParameter < < DeferredParameters < < UpscaleSoftness ;
return bShaderHasOutdatedParameters ;
}
static const TCHAR * GetSourceFilename ( )
{
return TEXT ( " PostProcessUpscale " ) ;
}
static const TCHAR * GetFunctionName ( )
{
return TEXT ( " MainPS " ) ;
}
} ;
// #define avoids a lot of code duplication
# define VARIATION1(A) typedef FPostProcessUpscalePS<A> FPostProcessUpscalePS##A; \
IMPLEMENT_SHADER_TYPE2 ( FPostProcessUpscalePS # # A , SF_Pixel ) ;
VARIATION1 ( 0 )
VARIATION1 ( 1 )
VARIATION1 ( 2 )
VARIATION1 ( 3 )
# undef VARIATION1
2015-05-22 19:44:45 -04:00
FRCPassPostProcessUpscale : : FRCPassPostProcessUpscale ( uint32 InUpscaleQuality , const PaniniParams & InPaniniConfig )
2014-11-03 16:17:18 -05:00
: UpscaleQuality ( InUpscaleQuality )
2014-03-14 14:13:41 -04:00
{
2015-05-22 19:44:45 -04:00
PaniniConfig . D = FMath : : Max ( InPaniniConfig . D , 0.0f ) ;
PaniniConfig . S = InPaniniConfig . S ;
PaniniConfig . ScreenFit = FMath : : Max ( InPaniniConfig . ScreenFit , 0.0f ) ;
2014-03-14 14:13:41 -04:00
}
2014-11-03 16:17:18 -05:00
template < uint32 Method , uint32 bTesselatedQuad >
2015-05-22 19:44:45 -04:00
FShader * FRCPassPostProcessUpscale : : SetShader ( const FRenderingCompositePassContext & Context , const PaniniParams & PaniniConfig )
2014-03-14 14:13:41 -04:00
{
2014-11-03 16:17:18 -05:00
if ( bTesselatedQuad )
{
2015-05-22 19:44:45 -04:00
check ( PaniniConfig . D > 0.0f ) ;
2014-03-14 14:13:41 -04:00
2014-11-03 16:17:18 -05:00
TShaderMapRef < FPostProcessUpscaleVS > VertexShader ( Context . GetShaderMap ( ) ) ;
TShaderMapRef < FPostProcessUpscalePS < Method > > PixelShader ( Context . GetShaderMap ( ) ) ;
2014-03-14 14:13:41 -04:00
2014-11-03 16:17:18 -05:00
static FGlobalBoundShaderState BoundShaderState ;
2014-03-14 14:13:41 -04:00
2014-11-03 16:17:18 -05:00
SetGlobalBoundShaderState ( Context . RHICmdList , Context . GetFeatureLevel ( ) , BoundShaderState , GFilterVertexDeclaration . VertexDeclarationRHI , * VertexShader , * PixelShader ) ;
PixelShader - > SetPS ( Context ) ;
2015-05-22 19:44:45 -04:00
VertexShader - > SetParameters ( Context , PaniniConfig ) ;
2014-11-03 16:17:18 -05:00
return * VertexShader ;
}
else
{
2015-05-22 19:44:45 -04:00
check ( PaniniConfig . D = = 0.0f ) ;
2014-11-03 16:17:18 -05:00
TShaderMapRef < FPostProcessVS > VertexShader ( Context . GetShaderMap ( ) ) ;
TShaderMapRef < FPostProcessUpscalePS < Method > > PixelShader ( Context . GetShaderMap ( ) ) ;
static FGlobalBoundShaderState BoundShaderState ;
SetGlobalBoundShaderState ( Context . RHICmdList , Context . GetFeatureLevel ( ) , BoundShaderState , GFilterVertexDeclaration . VertexDeclarationRHI , * VertexShader , * PixelShader ) ;
PixelShader - > SetPS ( Context ) ;
VertexShader - > SetParameters ( Context ) ;
return * VertexShader ;
}
2014-03-14 14:13:41 -04:00
}
void FRCPassPostProcessUpscale : : Process ( FRenderingCompositePassContext & Context )
{
2014-10-20 10:43:43 -04:00
SCOPED_DRAW_EVENT ( Context . RHICmdList , PostProcessUpscale ) ;
2014-03-14 14:13:41 -04:00
const FPooledRenderTargetDesc * InputDesc = GetInputDesc ( ePId_Input0 ) ;
if ( ! InputDesc )
{
// input is not hooked up correctly
return ;
}
const FSceneView & View = Context . View ;
const FSceneViewFamily & ViewFamily = * ( View . Family ) ;
FIntRect SrcRect = View . ViewRect ;
2015-06-18 12:56:30 -04:00
// no upscale if separate ren target is used.
FIntRect DestRect = ( ViewFamily . bUseSeparateRenderTarget ) ? View . ViewRect : View . UnscaledViewRect ; // Simple upscaling, ES2 post process does not currently have a specific upscaling pass.
2014-03-14 14:13:41 -04:00
FIntPoint SrcSize = InputDesc - > Extent ;
const FSceneRenderTargetItem & DestRenderTarget = PassOutputs [ 0 ] . RequestSurface ( Context ) ;
2015-06-18 12:56:30 -04:00
if ( ! DestRenderTarget . TargetableTexture )
{
return ;
}
2014-03-14 14:13:41 -04:00
// Set the view family's render target/viewport.
2014-06-12 07:13:34 -04:00
SetRenderTarget ( Context . RHICmdList , DestRenderTarget . TargetableTexture , FTextureRHIRef ( ) ) ;
2014-03-14 14:13:41 -04:00
2015-05-22 19:44:45 -04:00
bool bTessellatedQuad = PaniniConfig . D > = 0.01f ;
2014-11-03 16:17:18 -05:00
// with distortion (bTessellatedQuad) we need to clear the background
2015-05-29 10:47:57 -04:00
FIntRect ExcludeRect = bTessellatedQuad ? FIntRect ( ) : DestRect ;
2014-11-03 16:17:18 -05:00
2015-08-04 13:03:04 -04:00
Context . SetViewportAndCallRHI ( DestRect ) ;
2015-06-18 12:56:30 -04:00
if ( View . StereoPass = = eSSP_FULL | | View . StereoPass = = eSSP_LEFT_EYE )
{
Context . RHICmdList . Clear ( true , FLinearColor : : Black , false , 1.0f , false , 0 , ExcludeRect ) ;
}
2014-11-03 16:17:18 -05:00
2014-03-14 14:13:41 -04:00
// set the state
2014-06-12 07:13:34 -04:00
Context . RHICmdList . SetBlendState ( TStaticBlendState < > : : GetRHI ( ) ) ;
Context . RHICmdList . SetRasterizerState ( TStaticRasterizerState < > : : GetRHI ( ) ) ;
Context . RHICmdList . SetDepthStencilState ( TStaticDepthStencilState < false , CF_Always > : : GetRHI ( ) ) ;
2014-03-14 14:13:41 -04:00
2014-11-03 16:17:18 -05:00
FShader * VertexShader = 0 ;
if ( bTessellatedQuad )
2014-03-14 14:13:41 -04:00
{
2014-11-03 16:17:18 -05:00
switch ( UpscaleQuality )
{
2015-05-22 19:44:45 -04:00
case 0 : VertexShader = SetShader < 0 , 1 > ( Context , PaniniConfig ) ; break ;
case 1 : VertexShader = SetShader < 1 , 1 > ( Context , PaniniConfig ) ; break ;
case 2 : VertexShader = SetShader < 2 , 1 > ( Context , PaniniConfig ) ; break ;
case 3 : VertexShader = SetShader < 3 , 1 > ( Context , PaniniConfig ) ; break ;
2014-11-03 16:17:18 -05:00
default :
checkNoEntry ( ) ;
break ;
}
}
else
{
switch ( UpscaleQuality )
{
2015-05-22 19:44:45 -04:00
case 0 : VertexShader = SetShader < 0 , 0 > ( Context , PaniniParams : : Default ) ; break ;
case 1 : VertexShader = SetShader < 1 , 0 > ( Context , PaniniParams : : Default ) ; break ;
case 2 : VertexShader = SetShader < 2 , 0 > ( Context , PaniniParams : : Default ) ; break ;
case 3 : VertexShader = SetShader < 3 , 0 > ( Context , PaniniParams : : Default ) ; break ;
2014-11-03 16:17:18 -05:00
default :
checkNoEntry ( ) ;
break ;
}
2014-03-14 14:13:41 -04:00
}
2014-11-03 16:17:18 -05:00
// Draw a quad, a triangle or a tessellated quad
2014-03-14 14:13:41 -04:00
DrawRectangle (
2014-06-12 07:13:34 -04:00
Context . RHICmdList ,
2014-03-14 14:13:41 -04:00
0 , 0 ,
DestRect . Width ( ) , DestRect . Height ( ) ,
SrcRect . Min . X , SrcRect . Min . Y ,
SrcRect . Width ( ) , SrcRect . Height ( ) ,
DestRect . Size ( ) ,
SrcSize ,
2014-11-03 16:17:18 -05:00
VertexShader ,
bTessellatedQuad ? EDRF_UseTesselatedIndexBuffer : EDRF_UseTriangleOptimization ) ;
2014-03-14 14:13:41 -04:00
2014-06-12 07:13:34 -04:00
Context . RHICmdList . CopyToResolveTarget ( DestRenderTarget . TargetableTexture , DestRenderTarget . ShaderResourceTexture , false , FResolveParams ( ) ) ;
2014-03-14 14:13:41 -04:00
}
FPooledRenderTargetDesc FRCPassPostProcessUpscale : : ComputeOutputDesc ( EPassOutputId InPassOutputId ) const
{
2015-07-06 18:04:49 -04:00
FPooledRenderTargetDesc Ret = GetInput ( ePId_Input0 ) - > GetOutput ( ) - > RenderTargetDesc ;
2014-03-14 14:13:41 -04:00
Ret . Reset ( ) ;
Ret . DebugName = TEXT ( " Upscale " ) ;
return Ret ;
}