2016-01-07 08:17:16 -05:00
|
|
|
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
2015-12-10 21:55:37 -05:00
|
|
|
|
|
|
|
|
/*=============================================================================
|
|
|
|
|
PostProcessVisualizeComplexity.cpp: Contains definitions for complexity viewmode.
|
|
|
|
|
=============================================================================*/
|
|
|
|
|
|
|
|
|
|
#include "RendererPrivate.h"
|
|
|
|
|
#include "ScenePrivate.h"
|
|
|
|
|
#include "SceneFilterRendering.h"
|
|
|
|
|
#include "PostProcessVisualizeComplexity.h"
|
|
|
|
|
#include "SceneUtils.h"
|
|
|
|
|
#include "PostProcessing.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the maximum shader complexity count from the ini settings.
|
|
|
|
|
*/
|
|
|
|
|
float GetMaxShaderComplexityCount(ERHIFeatureLevel::Type InFeatureType)
|
|
|
|
|
{
|
|
|
|
|
return InFeatureType == ERHIFeatureLevel::ES2 ? GEngine->MaxES2PixelShaderAdditiveComplexityCount : GEngine->MaxPixelShaderAdditiveComplexityCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor - binds all shader params
|
|
|
|
|
* @param Initializer - init data from shader compiler
|
|
|
|
|
*/
|
|
|
|
|
FVisualizeComplexityApplyPS::FVisualizeComplexityApplyPS(const ShaderMetaType::CompiledShaderInitializerType& Initializer)
|
|
|
|
|
: FGlobalShader(Initializer)
|
|
|
|
|
{
|
|
|
|
|
PostprocessParameter.Bind(Initializer.ParameterMap);
|
|
|
|
|
ShaderComplexityColors.Bind(Initializer.ParameterMap,TEXT("ShaderComplexityColors"));
|
|
|
|
|
MiniFontTexture.Bind(Initializer.ParameterMap, TEXT("MiniFontTexture"));
|
|
|
|
|
ShaderComplexityParams.Bind(Initializer.ParameterMap, TEXT("ShaderComplexityParams"));
|
|
|
|
|
NumComplexityColors.Bind(Initializer.ParameterMap, TEXT("NumComplexityColors"));
|
|
|
|
|
QuadOverdrawTexture.Bind(Initializer.ParameterMap,TEXT("QuadOverdrawTexture"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FVisualizeComplexityApplyPS::SetParameters(
|
|
|
|
|
const FRenderingCompositePassContext& Context,
|
|
|
|
|
const TArray<FLinearColor>& Colors,
|
|
|
|
|
EColorSampling ColorSampling,
|
|
|
|
|
float ComplexityScale,
|
|
|
|
|
bool bLegend
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
|
|
|
|
|
|
|
|
|
|
FGlobalShader::SetParameters(Context.RHICmdList, ShaderRHI, Context.View);
|
|
|
|
|
|
|
|
|
|
PostprocessParameter.SetPS(ShaderRHI, Context, TStaticSamplerState<SF_Bilinear, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI());
|
|
|
|
|
|
|
|
|
|
//Make sure there are at least NumShaderComplexityColors colors specified in the ini.
|
|
|
|
|
//If there are more than NumShaderComplexityColors they will be ignored.
|
|
|
|
|
check(Colors.Num() >= 1 && Colors.Num() <= MaxNumShaderComplexityColors);
|
|
|
|
|
|
|
|
|
|
//pass the complexity -> color mapping into the pixel shader
|
|
|
|
|
for(int32 ColorIndex = 0; ColorIndex < Colors.Num(); ColorIndex ++)
|
|
|
|
|
{
|
|
|
|
|
SetShaderValue(Context.RHICmdList, ShaderRHI, ShaderComplexityColors, Colors[ColorIndex], ColorIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetTextureParameter(Context.RHICmdList, ShaderRHI, MiniFontTexture, GEngine->MiniFontTexture ? GEngine->MiniFontTexture->Resource->TextureRHI : GSystemTextures.WhiteDummy->GetRenderTargetItem().TargetableTexture);
|
|
|
|
|
|
|
|
|
|
// Whether acccess or not the QuadOverdraw buffer.
|
Copying //UE4/Dev-Rendering to Dev-Main (//UE4/Dev-Main)
#lockdown ben.marsh
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2774277 on 2015/11/19 by Gil.Gribb
UE4 - Did minor optimizations to the PS4 RHI and drawlists.
Change 2791226 on 2015/12/04 by Uriel.Doyon
Added source code for Embree 2.7.0
Removed duplicate files from the /doc folder.
Change 2800193 on 2015/12/11 by Marcus.Wassmer
SSAO AsyncCompute support.
#rb Martin.Mittring
Change 2801631 on 2015/12/14 by Olaf.Piesche
Making auto deactivate true by default, moving checks to HasCompleted, eliminating some unnecessary logic
#rb martin.mittring
Change 2803240 on 2015/12/15 by Gil.Gribb
UE4 - Added command to collect stats on spammy stats.
Change 2803476 on 2015/12/15 by Rolando.Caloca
DR - Allow toggling compute skin dispatch at runtime
- r.SkinCacheShaders Now enable the shaders and feature
- r.SkinCaching enables toggling at runtime
- r.SkinCache.BufferSize Sets the size in bytes of buffer for outputting
- Now uses 3 UAV buffers instead of one (avoid RenderDoc crashes)
#codereview Marcus.Wassmer, Martin.Mittring
Change 2803940 on 2015/12/15 by Marcus.Wassmer
Add r.PS4.AsyncComputeBudgetMode to switch between CUMasking and WaveLimit modes. So far it looks like WaveLimits behave better in UE4.
Also rearrange AsyncSSAO to run immediately after HZB to overlap with occlusion queries. In my testing this takes SSAO cost from .5ms -> .2ms. However it had to be hacked to run without normals. Hopefully Martin can get some real AsyncSSAO in.
#rb Martin.Mittring
#codereview Martin.Mittring
Change 2803999 on 2015/12/15 by Uriel.Doyon
Refactored the shader complexity material override logic to allow other viewmodes shader overrides.
TexelFactorAccuracy ViewMode : shows the accuracy of the static mesh texel factors, used for streaming.
WantedMipsAccuracy ViewMode : shows the accuracy of the static mesh wanted mips accuracy, used for streaming.
Added an option to stream textures based on the AABB distance instead of using the sphere approximation.
Added an option to only keep a the wanted mips.
Moved optimization related viewmodes into a submenu to avoid polluting the interface.
#jira UE-24502
#jira UE-24503
#jira UERNDR-89
Change 2804150 on 2015/12/15 by Olaf.Piesche
make separate translucency screen percentage a bit more robust; add numsamples to the render target creation functions in preparation for MSAA support for higher quality with low res separate translucency
#rb martin.mittring
Change 2804367 on 2015/12/15 by Daniel.Wright
Capsule shadow primitives are tracked separately on registration - saves 2.6ms of RT time doing the view frustum culling in a medium sized map
Change 2805293 on 2015/12/16 by Olaf.Piesche
logging if potentially immortal emitters are spawned from gameplay; this should catch if we spawn burst only emitters with indefinite life spans (muzzle flashes, hit impacts, etc.)
#rb martin.mittring
Change 2805586 on 2015/12/16 by Zabir.Hoque
Adding support for decals to fade and destroy themselves automatically.
#CodeReview: Martin.Mittring, Daniel.Wright, Olaf.Piesche
Change 2807663 on 2015/12/17 by Rolando.Caloca
DR - Remove expensive logging
#codereview Marcus.Wassmer
Change 2807903 on 2015/12/17 by Zabir.Hoque
Refactored DecalComponent's lifetime management such that it can be set and reset from Blueprints.
#CodeReview Daniel.Wright, Martin.Mittring, Olaf.Piesche
Change 2809261 on 2015/12/18 by Martin.Mittring
Added VisualizeShadingModels to track down issues like that:
FORT-16913 Textures on Hero Mesh is not shown
#rb:David.Hill
#code_review:Bob.Tellez
Change 2810136 on 2015/12/21 by Rolando.Caloca
DR - Added back draw event colors
PR #1602
#jira UE-21526
#codereview Mark.Satterthwaite, Keith.Judge, Marcus.Wassmer, Josh.Adams
Change 2810680 on 2015/12/21 by Martin.Mittring
moved SSAO ComputeShader running without per pixel normal (for AsyncCompute) into DevRendering
#test:editor
Change 2811205 on 2015/12/22 by Brian.Karis
Pulled clear coat out of the reflection compute shader. Added permutation for skylight.
Clear coat base layer now done in base pass. It only picks up the closest capture. This will cause popping when the object moves. Still needs a cross fade.
Change 2811275 on 2015/12/22 by David.Hill
UE-24675
#rb martin.mittring
Corrected buffer-size related problem with fringe.
Change 2811397 on 2015/12/22 by Brian.Karis
2016-01-08 11:12:28 -05:00
|
|
|
EDebugViewShaderMode DebugViewShaderMode = Context.View.Family->GetDebugViewShaderMode();
|
2015-12-10 21:55:37 -05:00
|
|
|
if (QuadOverdrawTexture.IsBound())
|
|
|
|
|
{
|
|
|
|
|
const FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(Context.RHICmdList);
|
|
|
|
|
if (SceneContext.QuadOverdrawBuffer.IsValid() && SceneContext.QuadOverdrawBuffer->GetRenderTargetItem().ShaderResourceTexture.IsValid())
|
|
|
|
|
{
|
|
|
|
|
Context.RHICmdList.TransitionResource(EResourceTransitionAccess::EReadable, EResourceTransitionPipeline::EGfxToGfx, SceneContext.QuadOverdrawBuffer->GetRenderTargetItem().UAV);
|
|
|
|
|
SetTextureParameter(Context.RHICmdList, ShaderRHI, QuadOverdrawTexture, SceneContext.QuadOverdrawBuffer->GetRenderTargetItem().ShaderResourceTexture);
|
|
|
|
|
}
|
Copying //UE4/Dev-Rendering to Dev-Main (//UE4/Dev-Main)
#lockdown ben.marsh
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2774277 on 2015/11/19 by Gil.Gribb
UE4 - Did minor optimizations to the PS4 RHI and drawlists.
Change 2791226 on 2015/12/04 by Uriel.Doyon
Added source code for Embree 2.7.0
Removed duplicate files from the /doc folder.
Change 2800193 on 2015/12/11 by Marcus.Wassmer
SSAO AsyncCompute support.
#rb Martin.Mittring
Change 2801631 on 2015/12/14 by Olaf.Piesche
Making auto deactivate true by default, moving checks to HasCompleted, eliminating some unnecessary logic
#rb martin.mittring
Change 2803240 on 2015/12/15 by Gil.Gribb
UE4 - Added command to collect stats on spammy stats.
Change 2803476 on 2015/12/15 by Rolando.Caloca
DR - Allow toggling compute skin dispatch at runtime
- r.SkinCacheShaders Now enable the shaders and feature
- r.SkinCaching enables toggling at runtime
- r.SkinCache.BufferSize Sets the size in bytes of buffer for outputting
- Now uses 3 UAV buffers instead of one (avoid RenderDoc crashes)
#codereview Marcus.Wassmer, Martin.Mittring
Change 2803940 on 2015/12/15 by Marcus.Wassmer
Add r.PS4.AsyncComputeBudgetMode to switch between CUMasking and WaveLimit modes. So far it looks like WaveLimits behave better in UE4.
Also rearrange AsyncSSAO to run immediately after HZB to overlap with occlusion queries. In my testing this takes SSAO cost from .5ms -> .2ms. However it had to be hacked to run without normals. Hopefully Martin can get some real AsyncSSAO in.
#rb Martin.Mittring
#codereview Martin.Mittring
Change 2803999 on 2015/12/15 by Uriel.Doyon
Refactored the shader complexity material override logic to allow other viewmodes shader overrides.
TexelFactorAccuracy ViewMode : shows the accuracy of the static mesh texel factors, used for streaming.
WantedMipsAccuracy ViewMode : shows the accuracy of the static mesh wanted mips accuracy, used for streaming.
Added an option to stream textures based on the AABB distance instead of using the sphere approximation.
Added an option to only keep a the wanted mips.
Moved optimization related viewmodes into a submenu to avoid polluting the interface.
#jira UE-24502
#jira UE-24503
#jira UERNDR-89
Change 2804150 on 2015/12/15 by Olaf.Piesche
make separate translucency screen percentage a bit more robust; add numsamples to the render target creation functions in preparation for MSAA support for higher quality with low res separate translucency
#rb martin.mittring
Change 2804367 on 2015/12/15 by Daniel.Wright
Capsule shadow primitives are tracked separately on registration - saves 2.6ms of RT time doing the view frustum culling in a medium sized map
Change 2805293 on 2015/12/16 by Olaf.Piesche
logging if potentially immortal emitters are spawned from gameplay; this should catch if we spawn burst only emitters with indefinite life spans (muzzle flashes, hit impacts, etc.)
#rb martin.mittring
Change 2805586 on 2015/12/16 by Zabir.Hoque
Adding support for decals to fade and destroy themselves automatically.
#CodeReview: Martin.Mittring, Daniel.Wright, Olaf.Piesche
Change 2807663 on 2015/12/17 by Rolando.Caloca
DR - Remove expensive logging
#codereview Marcus.Wassmer
Change 2807903 on 2015/12/17 by Zabir.Hoque
Refactored DecalComponent's lifetime management such that it can be set and reset from Blueprints.
#CodeReview Daniel.Wright, Martin.Mittring, Olaf.Piesche
Change 2809261 on 2015/12/18 by Martin.Mittring
Added VisualizeShadingModels to track down issues like that:
FORT-16913 Textures on Hero Mesh is not shown
#rb:David.Hill
#code_review:Bob.Tellez
Change 2810136 on 2015/12/21 by Rolando.Caloca
DR - Added back draw event colors
PR #1602
#jira UE-21526
#codereview Mark.Satterthwaite, Keith.Judge, Marcus.Wassmer, Josh.Adams
Change 2810680 on 2015/12/21 by Martin.Mittring
moved SSAO ComputeShader running without per pixel normal (for AsyncCompute) into DevRendering
#test:editor
Change 2811205 on 2015/12/22 by Brian.Karis
Pulled clear coat out of the reflection compute shader. Added permutation for skylight.
Clear coat base layer now done in base pass. It only picks up the closest capture. This will cause popping when the object moves. Still needs a cross fade.
Change 2811275 on 2015/12/22 by David.Hill
UE-24675
#rb martin.mittring
Corrected buffer-size related problem with fringe.
Change 2811397 on 2015/12/22 by Brian.Karis
2016-01-08 11:12:28 -05:00
|
|
|
else // Otherwise fallback to a complexity mode that does not require the QuadOverdraw resources.
|
2015-12-10 21:55:37 -05:00
|
|
|
{
|
|
|
|
|
SetTextureParameter(Context.RHICmdList, ShaderRHI, QuadOverdrawTexture, FTextureRHIRef());
|
Copying //UE4/Dev-Rendering to Dev-Main (//UE4/Dev-Main)
#lockdown ben.marsh
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2774277 on 2015/11/19 by Gil.Gribb
UE4 - Did minor optimizations to the PS4 RHI and drawlists.
Change 2791226 on 2015/12/04 by Uriel.Doyon
Added source code for Embree 2.7.0
Removed duplicate files from the /doc folder.
Change 2800193 on 2015/12/11 by Marcus.Wassmer
SSAO AsyncCompute support.
#rb Martin.Mittring
Change 2801631 on 2015/12/14 by Olaf.Piesche
Making auto deactivate true by default, moving checks to HasCompleted, eliminating some unnecessary logic
#rb martin.mittring
Change 2803240 on 2015/12/15 by Gil.Gribb
UE4 - Added command to collect stats on spammy stats.
Change 2803476 on 2015/12/15 by Rolando.Caloca
DR - Allow toggling compute skin dispatch at runtime
- r.SkinCacheShaders Now enable the shaders and feature
- r.SkinCaching enables toggling at runtime
- r.SkinCache.BufferSize Sets the size in bytes of buffer for outputting
- Now uses 3 UAV buffers instead of one (avoid RenderDoc crashes)
#codereview Marcus.Wassmer, Martin.Mittring
Change 2803940 on 2015/12/15 by Marcus.Wassmer
Add r.PS4.AsyncComputeBudgetMode to switch between CUMasking and WaveLimit modes. So far it looks like WaveLimits behave better in UE4.
Also rearrange AsyncSSAO to run immediately after HZB to overlap with occlusion queries. In my testing this takes SSAO cost from .5ms -> .2ms. However it had to be hacked to run without normals. Hopefully Martin can get some real AsyncSSAO in.
#rb Martin.Mittring
#codereview Martin.Mittring
Change 2803999 on 2015/12/15 by Uriel.Doyon
Refactored the shader complexity material override logic to allow other viewmodes shader overrides.
TexelFactorAccuracy ViewMode : shows the accuracy of the static mesh texel factors, used for streaming.
WantedMipsAccuracy ViewMode : shows the accuracy of the static mesh wanted mips accuracy, used for streaming.
Added an option to stream textures based on the AABB distance instead of using the sphere approximation.
Added an option to only keep a the wanted mips.
Moved optimization related viewmodes into a submenu to avoid polluting the interface.
#jira UE-24502
#jira UE-24503
#jira UERNDR-89
Change 2804150 on 2015/12/15 by Olaf.Piesche
make separate translucency screen percentage a bit more robust; add numsamples to the render target creation functions in preparation for MSAA support for higher quality with low res separate translucency
#rb martin.mittring
Change 2804367 on 2015/12/15 by Daniel.Wright
Capsule shadow primitives are tracked separately on registration - saves 2.6ms of RT time doing the view frustum culling in a medium sized map
Change 2805293 on 2015/12/16 by Olaf.Piesche
logging if potentially immortal emitters are spawned from gameplay; this should catch if we spawn burst only emitters with indefinite life spans (muzzle flashes, hit impacts, etc.)
#rb martin.mittring
Change 2805586 on 2015/12/16 by Zabir.Hoque
Adding support for decals to fade and destroy themselves automatically.
#CodeReview: Martin.Mittring, Daniel.Wright, Olaf.Piesche
Change 2807663 on 2015/12/17 by Rolando.Caloca
DR - Remove expensive logging
#codereview Marcus.Wassmer
Change 2807903 on 2015/12/17 by Zabir.Hoque
Refactored DecalComponent's lifetime management such that it can be set and reset from Blueprints.
#CodeReview Daniel.Wright, Martin.Mittring, Olaf.Piesche
Change 2809261 on 2015/12/18 by Martin.Mittring
Added VisualizeShadingModels to track down issues like that:
FORT-16913 Textures on Hero Mesh is not shown
#rb:David.Hill
#code_review:Bob.Tellez
Change 2810136 on 2015/12/21 by Rolando.Caloca
DR - Added back draw event colors
PR #1602
#jira UE-21526
#codereview Mark.Satterthwaite, Keith.Judge, Marcus.Wassmer, Josh.Adams
Change 2810680 on 2015/12/21 by Martin.Mittring
moved SSAO ComputeShader running without per pixel normal (for AsyncCompute) into DevRendering
#test:editor
Change 2811205 on 2015/12/22 by Brian.Karis
Pulled clear coat out of the reflection compute shader. Added permutation for skylight.
Clear coat base layer now done in base pass. It only picks up the closest capture. This will cause popping when the object moves. Still needs a cross fade.
Change 2811275 on 2015/12/22 by David.Hill
UE-24675
#rb martin.mittring
Corrected buffer-size related problem with fringe.
Change 2811397 on 2015/12/22 by Brian.Karis
2016-01-08 11:12:28 -05:00
|
|
|
DebugViewShaderMode = DVSM_ShaderComplexity;
|
2015-12-10 21:55:37 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Copying //UE4/Dev-Rendering to Dev-Main (//UE4/Dev-Main)
#lockdown ben.marsh
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2774277 on 2015/11/19 by Gil.Gribb
UE4 - Did minor optimizations to the PS4 RHI and drawlists.
Change 2791226 on 2015/12/04 by Uriel.Doyon
Added source code for Embree 2.7.0
Removed duplicate files from the /doc folder.
Change 2800193 on 2015/12/11 by Marcus.Wassmer
SSAO AsyncCompute support.
#rb Martin.Mittring
Change 2801631 on 2015/12/14 by Olaf.Piesche
Making auto deactivate true by default, moving checks to HasCompleted, eliminating some unnecessary logic
#rb martin.mittring
Change 2803240 on 2015/12/15 by Gil.Gribb
UE4 - Added command to collect stats on spammy stats.
Change 2803476 on 2015/12/15 by Rolando.Caloca
DR - Allow toggling compute skin dispatch at runtime
- r.SkinCacheShaders Now enable the shaders and feature
- r.SkinCaching enables toggling at runtime
- r.SkinCache.BufferSize Sets the size in bytes of buffer for outputting
- Now uses 3 UAV buffers instead of one (avoid RenderDoc crashes)
#codereview Marcus.Wassmer, Martin.Mittring
Change 2803940 on 2015/12/15 by Marcus.Wassmer
Add r.PS4.AsyncComputeBudgetMode to switch between CUMasking and WaveLimit modes. So far it looks like WaveLimits behave better in UE4.
Also rearrange AsyncSSAO to run immediately after HZB to overlap with occlusion queries. In my testing this takes SSAO cost from .5ms -> .2ms. However it had to be hacked to run without normals. Hopefully Martin can get some real AsyncSSAO in.
#rb Martin.Mittring
#codereview Martin.Mittring
Change 2803999 on 2015/12/15 by Uriel.Doyon
Refactored the shader complexity material override logic to allow other viewmodes shader overrides.
TexelFactorAccuracy ViewMode : shows the accuracy of the static mesh texel factors, used for streaming.
WantedMipsAccuracy ViewMode : shows the accuracy of the static mesh wanted mips accuracy, used for streaming.
Added an option to stream textures based on the AABB distance instead of using the sphere approximation.
Added an option to only keep a the wanted mips.
Moved optimization related viewmodes into a submenu to avoid polluting the interface.
#jira UE-24502
#jira UE-24503
#jira UERNDR-89
Change 2804150 on 2015/12/15 by Olaf.Piesche
make separate translucency screen percentage a bit more robust; add numsamples to the render target creation functions in preparation for MSAA support for higher quality with low res separate translucency
#rb martin.mittring
Change 2804367 on 2015/12/15 by Daniel.Wright
Capsule shadow primitives are tracked separately on registration - saves 2.6ms of RT time doing the view frustum culling in a medium sized map
Change 2805293 on 2015/12/16 by Olaf.Piesche
logging if potentially immortal emitters are spawned from gameplay; this should catch if we spawn burst only emitters with indefinite life spans (muzzle flashes, hit impacts, etc.)
#rb martin.mittring
Change 2805586 on 2015/12/16 by Zabir.Hoque
Adding support for decals to fade and destroy themselves automatically.
#CodeReview: Martin.Mittring, Daniel.Wright, Olaf.Piesche
Change 2807663 on 2015/12/17 by Rolando.Caloca
DR - Remove expensive logging
#codereview Marcus.Wassmer
Change 2807903 on 2015/12/17 by Zabir.Hoque
Refactored DecalComponent's lifetime management such that it can be set and reset from Blueprints.
#CodeReview Daniel.Wright, Martin.Mittring, Olaf.Piesche
Change 2809261 on 2015/12/18 by Martin.Mittring
Added VisualizeShadingModels to track down issues like that:
FORT-16913 Textures on Hero Mesh is not shown
#rb:David.Hill
#code_review:Bob.Tellez
Change 2810136 on 2015/12/21 by Rolando.Caloca
DR - Added back draw event colors
PR #1602
#jira UE-21526
#codereview Mark.Satterthwaite, Keith.Judge, Marcus.Wassmer, Josh.Adams
Change 2810680 on 2015/12/21 by Martin.Mittring
moved SSAO ComputeShader running without per pixel normal (for AsyncCompute) into DevRendering
#test:editor
Change 2811205 on 2015/12/22 by Brian.Karis
Pulled clear coat out of the reflection compute shader. Added permutation for skylight.
Clear coat base layer now done in base pass. It only picks up the closest capture. This will cause popping when the object moves. Still needs a cross fade.
Change 2811275 on 2015/12/22 by David.Hill
UE-24675
#rb martin.mittring
Corrected buffer-size related problem with fringe.
Change 2811397 on 2015/12/22 by Brian.Karis
2016-01-08 11:12:28 -05:00
|
|
|
SetShaderValue(Context.RHICmdList, ShaderRHI, ShaderComplexityParams, FVector4(bLegend, DebugViewShaderMode, ColorSampling, ComplexityScale));
|
2015-12-10 21:55:37 -05:00
|
|
|
SetShaderValue(Context.RHICmdList, ShaderRHI, NumComplexityColors, Colors.Num());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_SHADER_TYPE(,FVisualizeComplexityApplyPS,TEXT("ShaderComplexityApplyPixelShader"),TEXT("Main"),SF_Pixel);
|
|
|
|
|
|
|
|
|
|
//reuse the generic filter vertex declaration
|
|
|
|
|
extern TGlobalResource<FFilterVertexDeclaration> GFilterVertexDeclaration;
|
|
|
|
|
|
|
|
|
|
void FRCPassPostProcessVisualizeComplexity::Process(FRenderingCompositePassContext& Context)
|
|
|
|
|
{
|
|
|
|
|
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessVisualizeComplexity);
|
|
|
|
|
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;
|
|
|
|
|
FIntRect DestRect = View.UnscaledViewRect;
|
|
|
|
|
FIntPoint SrcSize = InputDesc->Extent;
|
|
|
|
|
|
|
|
|
|
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
|
|
|
|
|
|
|
|
|
|
// Set the view family's render target/viewport.
|
|
|
|
|
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
|
|
|
|
|
Context.SetViewportAndCallRHI(DestRect);
|
|
|
|
|
|
|
|
|
|
// turn off culling and blending
|
|
|
|
|
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<FM_Solid, CM_None>::GetRHI());
|
|
|
|
|
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
|
|
|
|
|
|
|
|
|
|
// turn off depth reads/writes
|
|
|
|
|
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
|
|
|
|
|
|
|
|
|
|
//reuse this generic vertex shader
|
|
|
|
|
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
|
|
|
|
|
TShaderMapRef<FVisualizeComplexityApplyPS> PixelShader(Context.GetShaderMap());
|
|
|
|
|
|
|
|
|
|
static FGlobalBoundShaderState VisualizeComplexityBoundShaderState;
|
|
|
|
|
|
|
|
|
|
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), VisualizeComplexityBoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
|
|
|
|
|
|
|
|
|
|
PixelShader->SetParameters(Context, Colors, ColorSampling, ComplexityScale, bLegend);
|
|
|
|
|
|
|
|
|
|
DrawRectangle(
|
|
|
|
|
Context.RHICmdList,
|
|
|
|
|
0, 0,
|
|
|
|
|
DestRect.Width(), DestRect.Height(),
|
|
|
|
|
SrcRect.Min.X, SrcRect.Min.Y,
|
|
|
|
|
SrcRect.Width(), SrcRect.Height(),
|
|
|
|
|
DestRect.Size(),
|
|
|
|
|
SrcSize,
|
|
|
|
|
*VertexShader,
|
|
|
|
|
EDRF_UseTriangleOptimization);
|
|
|
|
|
|
|
|
|
|
if(bLegend)
|
|
|
|
|
{
|
|
|
|
|
// this is a helper class for FCanvas to be able to get screen size
|
|
|
|
|
class FRenderTargetTemp : public FRenderTarget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
const FSceneView& View;
|
|
|
|
|
const FTexture2DRHIRef Texture;
|
|
|
|
|
|
|
|
|
|
FRenderTargetTemp(const FSceneView& InView, const FTexture2DRHIRef InTexture)
|
|
|
|
|
: View(InView), Texture(InTexture)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
virtual FIntPoint GetSizeXY() const
|
|
|
|
|
{
|
|
|
|
|
return View.ViewRect.Size();
|
|
|
|
|
};
|
|
|
|
|
virtual const FTexture2DRHIRef& GetRenderTargetTexture() const
|
|
|
|
|
{
|
|
|
|
|
return Texture;
|
|
|
|
|
}
|
|
|
|
|
} TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);
|
|
|
|
|
|
|
|
|
|
FCanvas Canvas(&TempRenderTarget, NULL, ViewFamily.CurrentRealTime, ViewFamily.CurrentWorldTime, ViewFamily.DeltaWorldTime, Context.GetFeatureLevel());
|
|
|
|
|
|
|
|
|
|
//later? Canvas.DrawShadowedString(View.ViewRect.Max.X - View.ViewRect.Width() / 3 - 64 + 8, View.ViewRect.Max.Y - 80, TEXT("Overdraw"), GetStatsFont(), FLinearColor(0.7f, 0.7f, 0.7f), FLinearColor(0,0,0,0));
|
|
|
|
|
//later? Canvas.DrawShadowedString(View.ViewRect.Min.X + 64 + 4, View.ViewRect.Max.Y - 80, TEXT("VS Instructions"), GetStatsFont(), FLinearColor(0.0f, 0.0f, 0.0f), FLinearColor(0,0,0,0));
|
|
|
|
|
|
Copying //UE4/Dev-Rendering to Dev-Main (//UE4/Dev-Main)
#lockdown ben.marsh
==========================
MAJOR FEATURES + CHANGES
==========================
Change 2774277 on 2015/11/19 by Gil.Gribb
UE4 - Did minor optimizations to the PS4 RHI and drawlists.
Change 2791226 on 2015/12/04 by Uriel.Doyon
Added source code for Embree 2.7.0
Removed duplicate files from the /doc folder.
Change 2800193 on 2015/12/11 by Marcus.Wassmer
SSAO AsyncCompute support.
#rb Martin.Mittring
Change 2801631 on 2015/12/14 by Olaf.Piesche
Making auto deactivate true by default, moving checks to HasCompleted, eliminating some unnecessary logic
#rb martin.mittring
Change 2803240 on 2015/12/15 by Gil.Gribb
UE4 - Added command to collect stats on spammy stats.
Change 2803476 on 2015/12/15 by Rolando.Caloca
DR - Allow toggling compute skin dispatch at runtime
- r.SkinCacheShaders Now enable the shaders and feature
- r.SkinCaching enables toggling at runtime
- r.SkinCache.BufferSize Sets the size in bytes of buffer for outputting
- Now uses 3 UAV buffers instead of one (avoid RenderDoc crashes)
#codereview Marcus.Wassmer, Martin.Mittring
Change 2803940 on 2015/12/15 by Marcus.Wassmer
Add r.PS4.AsyncComputeBudgetMode to switch between CUMasking and WaveLimit modes. So far it looks like WaveLimits behave better in UE4.
Also rearrange AsyncSSAO to run immediately after HZB to overlap with occlusion queries. In my testing this takes SSAO cost from .5ms -> .2ms. However it had to be hacked to run without normals. Hopefully Martin can get some real AsyncSSAO in.
#rb Martin.Mittring
#codereview Martin.Mittring
Change 2803999 on 2015/12/15 by Uriel.Doyon
Refactored the shader complexity material override logic to allow other viewmodes shader overrides.
TexelFactorAccuracy ViewMode : shows the accuracy of the static mesh texel factors, used for streaming.
WantedMipsAccuracy ViewMode : shows the accuracy of the static mesh wanted mips accuracy, used for streaming.
Added an option to stream textures based on the AABB distance instead of using the sphere approximation.
Added an option to only keep a the wanted mips.
Moved optimization related viewmodes into a submenu to avoid polluting the interface.
#jira UE-24502
#jira UE-24503
#jira UERNDR-89
Change 2804150 on 2015/12/15 by Olaf.Piesche
make separate translucency screen percentage a bit more robust; add numsamples to the render target creation functions in preparation for MSAA support for higher quality with low res separate translucency
#rb martin.mittring
Change 2804367 on 2015/12/15 by Daniel.Wright
Capsule shadow primitives are tracked separately on registration - saves 2.6ms of RT time doing the view frustum culling in a medium sized map
Change 2805293 on 2015/12/16 by Olaf.Piesche
logging if potentially immortal emitters are spawned from gameplay; this should catch if we spawn burst only emitters with indefinite life spans (muzzle flashes, hit impacts, etc.)
#rb martin.mittring
Change 2805586 on 2015/12/16 by Zabir.Hoque
Adding support for decals to fade and destroy themselves automatically.
#CodeReview: Martin.Mittring, Daniel.Wright, Olaf.Piesche
Change 2807663 on 2015/12/17 by Rolando.Caloca
DR - Remove expensive logging
#codereview Marcus.Wassmer
Change 2807903 on 2015/12/17 by Zabir.Hoque
Refactored DecalComponent's lifetime management such that it can be set and reset from Blueprints.
#CodeReview Daniel.Wright, Martin.Mittring, Olaf.Piesche
Change 2809261 on 2015/12/18 by Martin.Mittring
Added VisualizeShadingModels to track down issues like that:
FORT-16913 Textures on Hero Mesh is not shown
#rb:David.Hill
#code_review:Bob.Tellez
Change 2810136 on 2015/12/21 by Rolando.Caloca
DR - Added back draw event colors
PR #1602
#jira UE-21526
#codereview Mark.Satterthwaite, Keith.Judge, Marcus.Wassmer, Josh.Adams
Change 2810680 on 2015/12/21 by Martin.Mittring
moved SSAO ComputeShader running without per pixel normal (for AsyncCompute) into DevRendering
#test:editor
Change 2811205 on 2015/12/22 by Brian.Karis
Pulled clear coat out of the reflection compute shader. Added permutation for skylight.
Clear coat base layer now done in base pass. It only picks up the closest capture. This will cause popping when the object moves. Still needs a cross fade.
Change 2811275 on 2015/12/22 by David.Hill
UE-24675
#rb martin.mittring
Corrected buffer-size related problem with fringe.
Change 2811397 on 2015/12/22 by Brian.Karis
2016-01-08 11:12:28 -05:00
|
|
|
if (View.Family->GetDebugViewShaderMode() == DVSM_QuadComplexity)
|
2015-12-10 21:55:37 -05:00
|
|
|
{
|
|
|
|
|
int32 StartX = View.ViewRect.Min.X + 62;
|
|
|
|
|
int32 EndX = View.ViewRect.Max.X - 66;
|
|
|
|
|
int32 NumOffset = (EndX - StartX) / (Colors.Num() - 1);
|
|
|
|
|
for (int32 PosX = StartX, Number = 0; PosX <= EndX; PosX += NumOffset, ++Number)
|
|
|
|
|
{
|
|
|
|
|
FString Line;
|
|
|
|
|
Line = FString::Printf(TEXT("%d"), Number);
|
|
|
|
|
Canvas.DrawShadowedString(PosX, View.ViewRect.Max.Y - 87, *Line, GetStatsFont(), FLinearColor(0.5f, 0.5f, 0.5f));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Canvas.DrawShadowedString(View.ViewRect.Min.X + 63, View.ViewRect.Max.Y - 51, TEXT("Good"), GetStatsFont(), FLinearColor(0.5f, 0.5f, 0.5f));
|
|
|
|
|
Canvas.DrawShadowedString(View.ViewRect.Min.X + 63 + (int32)(View.ViewRect.Width() * 107.0f / 397.0f), View.ViewRect.Max.Y - 51, TEXT("Bad"), GetStatsFont(), FLinearColor(0.5f, 0.5f, 0.5f));
|
|
|
|
|
Canvas.DrawShadowedString(View.ViewRect.Max.X - 162, View.ViewRect.Max.Y - 51, TEXT("Extremely bad"), GetStatsFont(), FLinearColor(0.5f, 0.5f, 0.5f));
|
|
|
|
|
|
|
|
|
|
Canvas.DrawShadowedString(View.ViewRect.Min.X + 62, View.ViewRect.Max.Y - 87, TEXT("0"), GetStatsFont(), FLinearColor(0.5f, 0.5f, 0.5f));
|
|
|
|
|
|
|
|
|
|
FString Line;
|
|
|
|
|
Line = FString::Printf(TEXT("MaxShaderComplexityCount=%d"), (int32)GetMaxShaderComplexityCount(Context.GetFeatureLevel()));
|
|
|
|
|
Canvas.DrawShadowedString(View.ViewRect.Max.X - 260, View.ViewRect.Max.Y - 88, *Line, GetStatsFont(), FLinearColor(0.5f, 0.5f, 0.5f));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Canvas.Flush_RenderThread(Context.RHICmdList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FPooledRenderTargetDesc FRCPassPostProcessVisualizeComplexity::ComputeOutputDesc(EPassOutputId InPassOutputId) const
|
|
|
|
|
{
|
|
|
|
|
FPooledRenderTargetDesc Ret = GetInput(ePId_Input0)->GetOutput()->RenderTargetDesc;
|
|
|
|
|
|
|
|
|
|
Ret.Reset();
|
|
|
|
|
Ret.DebugName = TEXT("VisualizeComplexity");
|
|
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
|
}
|
|
|
|
|
|