You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change3244756on 2017/01/03 by Marcus.Wassmer Copying //Tasks/UE4/Dev-Niagara@3244743 to Dev-Rendering (//UE4/Dev-Rendering) Change 3248667 on 2017/01/05 by Olaf.Piesche Resaving default asset because of engine verison issue; maybe unnecessary, but resaving niagara engine content to be sure #jira UE-40160 Change 3249324 on 2017/01/06 by Marcus.Wassmer Resave with an actual version to stop cook warning Change 3249611 on 2017/01/06 by Marcus.Wassmer Just remove warning-causing niagara data for now. Change 3308052 on 2017/02/16 by Rolando.Caloca DR - Check for Vulkan SDK, and only use it if it's newer or the same as the headers we distribute Change 3308109 on 2017/02/16 by Rolando.Caloca DR - Upgrade glslang to 1.0.39.1 Change 3308111 on 2017/02/16 by Rolando.Caloca DR - Update Vulkan distribution to 1.0.39.1 Change 3308153 on 2017/02/16 by Rolando.Caloca DR - Updated glslang libs Change 3308842 on 2017/02/17 by Rolando.Caloca DR - Fixed copy/paste Change 3310007 on 2017/02/17 by Chris.Bunner Back out CL 3221219 - causing MIC generation issues and superseded by CL 3273971. #jira UE-37792 Change 3310154 on 2017/02/17 by Chris.Bunner Assert when attempting to add a custom material attribute already in the base attributes list. Change 3310155 on 2017/02/17 by Chris.Bunner PR #3231: Validate material index before accessing (Contributed by projectgheist) #jira UE-41774, UE-41788 Change 3310162 on 2017/02/17 by Chris.Bunner PR #3252: Added MobileMaterialInterface to UsedMaterials (Contributed by projectgheist) #jira UE-41823, UE-41950 Change 3310176 on 2017/02/17 by Chris.Bunner Merging CL 3233886: AMD HDR support (requires r.AMDSupportsHDRDisplayOutput=1 in ini). Update to AGS 5.0.5. Partial code tidy up. Change 3310187 on 2017/02/17 by Chris.Bunner Preserve constant expressions rather than always casting after translating a material attribute. Losing the notion of constant means we can't correctly detect used properties and falsely enable e.g. PDO. Happened because of the incorrect component masks in BreakMaterialNodes which then had to be downcast to the correct type which is done as an inline fragment rather than swizzle expression. #jira UE-41594 Change 3310215 on 2017/02/17 by Chris.Bunner Prevent SpeedTree node compiling for skeletal meshes (not supported as uses more UV sets than available). More descriptive error for missing Cubemap UV input on TextureSample material node . #jira UE-33098 Change 3310838 on 2017/02/18 by Joe.Graf Moved some private functions to public for a licensee #CodeReview: matt.kuhlenschmidt #rb: n/a Change 3311876 on 2017/02/20 by Rolando.Caloca DR - Expose skin cache cvar r.SkinCache.AccumulationBufferSizeInKB #jira UE-42014 Change 3314139 on 2017/02/21 by Rolando.Caloca DR - Minor cleanup pass - Remove FVulkanPendingState - Renamed some classes for clarity - Hoist pending UAVs for flush out to pending compute state Change 3314642 on 2017/02/21 by Rolando.Caloca DR - Some more renaming Change3315431on 2017/02/21 by Ben.Salem Properly set default values for test time out and tick. We now will default to ticking once per second, and tracking the macro stats of GPU/Render/Game thread time. #tests Ran showdown demo several times Change 3316710 on 2017/02/22 by Rolando.Caloca DR - hlslcc - Fix refract intrinsic Change 3316718 on 2017/02/22 by Rolando.Caloca DR - hlslcc - Built libs to pick up change from 3316710 - refract fix Change 3316820 on 2017/02/22 by Benjamin.Hyder updating Tm-TrigNodes map Change 3317192 on 2017/02/22 by Benjamin.Hyder Updating QA-Decals map Change 3317528 on 2017/02/22 by Benjamin.Hyder Updating QA-Decals map Change 3317639 on 2017/02/22 by Benjamin.Hyder Updating Decal on Complex Mesh example in QA-Decals Change 3317764 on 2017/02/22 by Benjamin.Hyder Final updates to QA-Decals Change 3318319 on 2017/02/22 by Rolando.Caloca DR - minor reorg/rename Change 3318379 on 2017/02/22 by Rolando.Caloca DR - more cleanup Change 3321181 on 2017/02/24 by Rolando.Caloca DR - Fix GL bug Change 3321247 on 2017/02/24 by Rolando.Caloca DR - Fix misc bugs Change 3321898 on 2017/02/24 by Chris.Bunner Only issue clear TLV dispatch if required. #jira UERNDR-193 Change 3321904 on 2017/02/24 by Chris.Bunner Added comment for potential future optimization. Change 3322013 on 2017/02/24 by Uriel.Doyon Fixed separate translucency being affected by Gaussian DOF #jira UE-40489 Change 3322517 on 2017/02/24 by Uriel.Doyon Fixed issue with InvestigateTexture command removing budget limit. Fixed StreamingBounds show flag not working. It nows shows the streaming bound for the currently selected textures. #jira UE-40485 Change 3323470 on 2017/02/27 by Chad.Garyet Removing DDC job from dev-rendering Change 3323479 on 2017/02/27 by Chad.Garyet Removing RDU agent type Change 3323519 on 2017/02/27 by Chad.Garyet removing NCL/LHR/SEA agent types to clean up space Change 3323639 on 2017/02/27 by Benjamin.Hyder More updates to QA-Decals Change 3324207 on 2017/02/27 by Uriel.Doyon Fixed typo ScaleTexturesByGlobalMyBias -> ScaleTexturesByGlobalMipBias Removed bad merge in FStreamingTextureLevelContext::GetBuildDataIndexRef Change 3324396 on 2017/02/27 by Uriel.Doyon Fixed an issue with the Streaming Bounds show flag interferring with the static level data initialization #jira UE-40485 Change 3325227 on 2017/02/28 by Chris.Bunner Fix-up AMD AGS libs. Change 3325566 on 2017/02/28 by Uriel.Doyon Fixed possible out-of-bound access in GetUsedTexture() when passing ERHIFeatureLevel::Num Change 3326009 on 2017/02/28 by Uriel.Doyon Better fix for 3325566, as the previous fix would ignore the material instance overrides. Change 3327058 on 2017/03/01 by Benjamin.Hyder Preparing TM_Shadermodels map for automation Change 3328222 on 2017/03/01 by Chris.Bunner Prevent decals from drawing in separate translucency pass. Whilst user control and material relevance were already removed, if the flag was checked before being disabled (by swapping to decal domain) this was still being read in the render loop, now explicitly ignores decals. #jira UE-42449, UE-42446 Change 3329848 on 2017/03/02 by Uriel.Doyon Added some extra logs to help track UE-42168 Change 3329977 on 2017/03/02 by Rolando.Caloca DR - Fix bad clear value Change 3330008 on 2017/03/02 by Benjamin.Hyder More preparations for QA-Decals automation Change 3330754 on 2017/03/02 by Daniel.Wright Prominent comment explaining reflection env async compute usage and why it's not overlapped with anything Change 3331451 on 2017/03/03 by Marc.Olano Manually unroll simplex noise loop to avoid PSO bug on AMD/Metal Change 3331839 on 2017/03/03 by Rolando.Caloca DR - hlslcc - add missing file to project Change 3332247 on 2017/03/03 by Rolando.Caloca DR - Fix for integrated intel PR #3305 #jira UE-42393 Change 3332259 on 2017/03/03 by Rolando.Caloca DR - Fix bad index into pixel formats PR #3237 #jira UE-41855 Change 3332305 on 2017/03/03 by Rolando.Caloca DR - OpenGL SRV for index buffers PR #3271 #jira UE-32618 Change 3332313 on 2017/03/03 by Rolando.Caloca DR - Fix for integrated intel (properly) PR #3305 #jira UE-42393 Change 3332317 on 2017/03/03 by Rolando.Caloca DR - OpenGL SRV for index buffers (properly) PR #3271 #jira UE-32618 Change 3332368 on 2017/03/03 by Rolando.Caloca DR - Minor fixes so -sm4 and -sm5 can be used on windows with OpenGL/Vulkan Change 3333690 on 2017/03/06 by Daniel.Wright [Copy] Changing movable skylight properties no longer affects static draw lists Change 3333693 on 2017/03/06 by Daniel.Wright [Copy] Added 'r.AOListMeshDistanceFields' which dumps out mesh distance fields sorted by memory size, useful for directing content optimizations Change3333705on 2017/03/06 by Daniel.Wright [Copy] Mesh distance fields are now 8 bit fixed point by default, but can be changed back to 16 bit floating piont with a project setting. * 8 bit uses half memory but introduces error for thin surfaces or large meshes. Change 3333721 on 2017/03/06 by David.Hill DecalProxy: Copy float FadeScreenSize to FDeferredDecalProxy for use in the render thread. This avoids pointer chasing to the UDecalComponent (game thread component). Change 3333772 on 2017/03/06 by Daniel.Wright [Copy] Scene motion blur data is only updated for the main renderer frames. Fixes scene captures and planar reflections breaking object motion blur. Change 3333790 on 2017/03/06 by Daniel.Wright [Copy] Mesh distance field generation uses Embree, for a 2.5x speedup * Can switch back to old kDOP generation with 'r.DistanceFieldBuild.UseEmbree 0' for debugging Change 3333822 on 2017/03/06 by Daniel.Wright [Copy] Moved mesh distance field code into MeshDistanceFieldUtilities.cpp * Moved FMeshUtilities to its own header so the 8k line MeshUtilites.cpp file can be further split up Change 3333827 on 2017/03/06 by Daniel.Wright [Copy] Range compress 8bit distance fields - gets one extra bit of precision on average Change 3333828 on 2017/03/06 by Daniel.Wright [Copy] Raised High ShadowQuality to 2048 as 1024 for CSM is way too low Change 3333831 on 2017/03/06 by Daniel.Wright Non-editor compile fix Change 3333836 on 2017/03/06 by Daniel.Wright [Copy] Workaround for gobal distance field volume textures being bloated by 4x on PS4 due to the recommended tiling modes. They now use a 2d tiling mode which avoids the bloat, saving 96Mb. Change 3333843 on 2017/03/06 by Daniel.Wright [Copy] Added OcclusionExponent to skylight component * Useful for brightening up indoors without losing contact shadows as MinOcclusion does Change 3333845 on 2017/03/06 by Daniel.Wright [Copy] Capsule shadow BP functions Change 3333850 on 2017/03/06 by Daniel.Wright [Copy] Added OcclusionCombineMode to skylight component Change 3333854 on 2017/03/06 by Daniel.Wright [Copy] Gnm properly registers clears as GPU work so those events show up in profilegpu Change 3333857 on 2017/03/06 by Daniel.Wright [Copy] Clear light attenuation for local lights with a quad covering their screen extents * Clearing the entire light attenuation buffer costs .1ms on PS4. This optimization lowers the minimum cost of a shadow casting light from .15ms -> .03ms. * Shadowed lights in Fortnite with 25 lights 3.7ms -> 1.42ms on PS4 Change 3333860 on 2017/03/06 by Daniel.Wright [Copy] Flush deferred deletes when reallocating distance field atlas to reduce peak memory Change 3333861 on 2017/03/06 by Daniel.Wright [Copy] Disable all distance field features on Intel cards as HD 4000 hangs in the RHICreateTexture3D call to allocate the large atlas Change 3333869 on 2017/03/06 by Daniel.Wright [Copy] Volumetric Fog using a volume texture mapped to the camera frustum * Volumetric fog can be enabled on an Exponential Height Fog component with additional controls * Lights have a VolumetricScatteringIntensity * New cvars r.VolumetricFog, r.VolumetricFog.GridPixelSize, r.VolumetricFog.GridSizeZ, r.VolumetricFog.DepthDistributionScale * Lighting features supported: * Directional light with CSM and a light function * Point / spot lights without shadows / light functions / IES profiles * Skylight with occlusion from distance fields * Analytical height fog covers the view range past where the volumetric fog ends * Temporal reprojection is used on the volumetric fog scattering and extinction to achieve stability * Translucency integrates properly into volumetric fog * Height fog StartDistance is not supported by volumetric fog and should be set to 0. Change 3333894 on 2017/03/06 by Daniel.Wright [Copy] Initialize GDummyVolumetricFogGlobalDataUniformBuffer outside of parallel rendering Change 3333902 on 2017/03/06 by Daniel.Wright [Copy] Better handling of volumetric fog enabled with distance of 0 Change 3333903 on 2017/03/06 by Daniel.Wright [Copy] Fixed volumetric fog trying to render light functions for a point light Change 3333908 on 2017/03/06 by Daniel.Wright [Copy] Volumetric materials * Added new material domain Volume, which can output Scattering, Absorption and Emissive. All properties are in world space densities. * Particle systems using the Volume domain are voxelized based on their ParticlePosition and ParticleRadius * Volumetric fog integration is now energy conservative - scattering is integrated against transmission over the depth of each slice. * Added bOverrideLightColorsWithFogInscatteringColors to exponential height fog, which can be enabled to make Volumetric Fog match Height fog more closely Change 3334134 on 2017/03/06 by Daniel.Wright [Copy from Michael Trepka] Added Embree 2.14.0 and changed MeshUtilities to use it as this solves issues with Embree leaking TLS keys. UnrealLightmass is still using older Embree 2.7.0 until we can find time to properly test it with the new version. Also, invalidated distance field DDC to force it to rebuild with updated Embree. Change 3334420 on 2017/03/06 by Daniel.Wright Fixed RTDF shadows Change 3335467 on 2017/03/07 by Benjamin.Hyder Initial submission of QA-Decals map to EngineTest Change 3335556 on 2017/03/07 by Daniel.Wright Changed mesh distance field default format back to R16f Change 3338020 on 2017/03/08 by Daniel.Wright Disable volumetric fog in vertex shaders for feature levels which don't support it Change 3339394 on 2017/03/09 by Chris.Bunner Correctly handle material texture translation error edge case. #jira UE-42579, UE-42670 Change 3339992 on 2017/03/09 by Daniel.Wright Only compile volumetric fog shaders on supporting platforms Change 3341858 on 2017/03/10 by Arne.Schober Copying //UE4/Dev-Rendering-PSO to Dev-Rendering (//UE4/Dev-Rendering) #RB Rolando.Caloca, Marcus.Wassmer, Daniel.Wright, Nick.Penwarden, Mark.Satterthwaite Change 3342004 on 2017/03/10 by Arne.Schober Copying //UE4/Dev-Rendering-PSO to Dev-Rendering (//UE4/Dev-Rendering) Fix unity build #RB Marcus.Wassmer Change 3343307 on 2017/03/13 by Marcus.Wassmer Update showflags when we are guaranteed it will happen in all possible ways to spawn the scenecapture. (drag into editor, PIE, -game, etc) Change 3343732 on 2017/03/13 by Rolando.Caloca DR - Vulkan compute pipeline & refactor Change 3344846 on 2017/03/14 by Rolando.Caloca DR - Android compile fixes Change 3344883 on 2017/03/14 by Rolando.Caloca DR - Add missing stencil load/store to PSO initializer Change 3344985 on 2017/03/14 by Rolando.Caloca DR - Made load/store actions uint8 Change 3345141 on 2017/03/14 by Rolando.Caloca DR - vk - Rework render pass hash Change 3345304 on 2017/03/14 by Benjamin.Hyder Updating TM-Distancefields map to include TemplateFloor mesh Change 3345387 on 2017/03/14 by Rolando.Caloca DR - Add _RenderThread calls for Create*Shader so RHIs can choose not to stall when creating Change 3345388 on 2017/03/14 by Rolando.Caloca DR - Do not stall when creating shaders on Vulkan Change 3345722 on 2017/03/14 by Chris.Bunner PR #3357: MinimalAPI add to many material expressions (Contributed by DeanoC) #jira UE-42752 Change 3345723 on 2017/03/14 by Chris.Bunner Reduce log verbosity causing spamming during landscape editing. #jira UE-42714 Change 3345725 on 2017/03/14 by Chris.Bunner [Duplicate 3341860] Fixed material translation error with multiple connections from custom interpolator nodes. Change 3345726 on 2017/03/14 by Chris.Bunner Typo fixes. Change 3345732 on 2017/03/14 by Rolando.Caloca DR - Decouple vertex declaration off BSS Change 3345746 on 2017/03/14 by Chris.Bunner Added sign() intrinsic material graph node and delisted material function workaround. Change 3346042 on 2017/03/14 by Chris.Bunner Implement missing size query interface for FRenderTargetResources. #jira UE-41672 Change 3346387 on 2017/03/14 by Daniel.Wright [Copy] Added VolumetricScatteringIntensity to particle lights Change 3346389 on 2017/03/14 by Daniel.Wright [Copy] Clamp Volumetric material attributes to fp16 range to avoid INFs Disable volumetric fog when the fog show flag is disabled Change 3346392 on 2017/03/14 by Daniel.Wright [Copy] Fixed skylight being much too bright on volumetric fog Change 3346406 on 2017/03/14 by Daniel.Wright [Copy] CSM resolution is now controlled by r.Shadow.MaxCSMResolution. * Changed HighPC to use 1024 MaxShadowResolution (max for all non-CSM shadows), saves 60Mb in Fortnite Change 3346412 on 2017/03/14 by Daniel.Wright [Copy] TexCreate_ReduceMemoryWithTilingMode for translucency lighting 3d textures, saves 13Mb Change3346414on 2017/03/14 by Daniel.Wright [Copy] TexCreate_ReduceMemoryWithTilingMode for volumetric fog 3d textures, saves 13Mb Change 3346415 on 2017/03/14 by Daniel.Wright [Copy] Missing file from cl 3338451 Change 3346421 on 2017/03/14 by Daniel.Wright [Copy] Fixed NaNs in volumetric fog due to rendering when height fog is disabled * Volumetric fog converts NaNs to black now so they don't spread Change 3346422 on 2017/03/14 by Daniel.Wright [Copy] Fixed NaN in volumetric fog with low density values Change 3346423 on 2017/03/14 by Daniel.Wright [Copy] Changed default VolumetricFogScatteringDistribution to .2 Change 3346430 on 2017/03/14 by Daniel.Wright [Copy] New translucent material option to compute fog per pixel instead of the default per vertex Change 3346432 on 2017/03/14 by Daniel.Wright [Copy] Moved Volumetric Fog parameters to view uniform buffer for translucency pass Fixed lifetimes of temporary Volumetric Fog render targets Change 3346526 on 2017/03/14 by Daniel.Wright [Copy] Volumetric Fog supports point and spot light shadows * These lights are injected separately so that per-light resources can be bound (shadow depth map, static shadow depth map) * Forward lighting of local lights can be forced with 'r.VolumetricFog.InjectShadowedLightsSeparately 0' * Shadowed lights come at a cost: 2.9ms for volumetric fog on 970 -> 4.2ms with shadowing Change 3347053 on 2017/03/15 by Rolando.Caloca DR - android compile fix Change 3347384 on 2017/03/15 by Rolando.Caloca DR - Fix merge issue Change 3347643 on 2017/03/15 by Marcus.Wassmer Fix some bugs with the 'disable stationary skylight ffor the project' feature. Fixes lighting in Persona on Paragon. Change 3347979 on 2017/03/15 by Rolando.Caloca DR - Allow to automatically apply cached rendertargets to PSO initializer Change 3348024 on 2017/03/15 by Rolando.Caloca DR - Remove NullPS on Vulkan to avoid deadlock Change 3348303 on 2017/03/15 by Rolando.Caloca DR - Fix for debugging SCW with material SRT Change 3348357 on 2017/03/15 by Marcus.Wassmer Fix stencildither and a stencilref bug that was probably breaking decals sometimes. Change 3348549 on 2017/03/15 by Marcus.Wassmer Hopefully fix static analysis for potential nullptr access. Change 3348614 on 2017/03/15 by Marcus.Wassmer Duplicate some switch changes to fix crash on launch. Change 3349369 on 2017/03/16 by Gil.Gribb Fixed botched merge Change 3349947 on 2017/03/16 by Rolando.Caloca DR - Fix for mismatched primitive type Change 3349956 on 2017/03/16 by Benjamin.Hyder initial updates to TM-DistanceFields map Change 3350151 on 2017/03/16 by Rolando.Caloca DR - Fix UT compile issue Change 3350155 on 2017/03/16 by Rolando.Caloca DR - Catch mismatched primitive type on PSOs on D3D11 Change 3350192 on 2017/03/16 by Daniel.Wright Fix for point light shadow depths rendering with wrong cull mode due to PSO refactor Change 3350736 on 2017/03/16 by Daniel.Wright Fixed formatting from merge Change 3350881 on 2017/03/16 by Rolando.Caloca DR - Fix texture arrays as UAVs on Metal Change 3350927 on 2017/03/16 by Rolando.Caloca DR - Fix warning Change 3350935 on 2017/03/16 by Daniel.Wright Fix for materials with non-Surface domains being skipped in mesh passes Change 3351583 on 2017/03/17 by Marcus.Wassmer Fix clang platforms Change 3351917 on 2017/03/17 by Marcus.Wassmer Fix linux compile Change 3351973 on 2017/03/17 by Marcus.Wassmer Fix mismatched rendertargetformat Change 3352038 on 2017/03/17 by Daniel.Wright Enabled GetAndOrCreateGraphicsPipelineState ensures in Development for testing Change 3352110 on 2017/03/17 by Marcus.Wassmer Fix missing RT PSO apply Change 3352695 on 2017/03/17 by Arne.Schober DR - Remove PSO Rendertarget check in DX12 Resolve with Shader. #RB Rolando.Caloca Change 3352960 on 2017/03/17 by Arne.Schober DR - Fix some things that slipped trough the PSO merge #RB none Change 3353150 on 2017/03/18 by Rolando.Caloca DR - compile fix Change 3353205 on 2017/03/18 by Arne.Schober DR - Fix Incremental Compile and PS4 runtime error where CMASK is not allowed for ThickTile Mode #RB none Change 3353207 on 2017/03/18 by Arne.Schober DR - Fix Confusion #RB none Change 3355183 on 2017/03/20 by Nick.Bullard Fixed up Content orginzation for Decals automation tests in EngineTest Change 3355627 on 2017/03/20 by Arne.Schober DR - [UE-43094] - removed ensure in comporiton graph as control of the clear color cannot be gurantueed. Change 3356342 on 2017/03/21 by Marcus.Wassmer Fix clang errors Change 3356591 on 2017/03/21 by Arne.Schober DR - Fix ensure message #RB none Change 3356873 on 2017/03/21 by Arne.Schober DR - Fix comparission of undefined values in RendertargetApply Check Change 3357261 on 2017/03/21 by Marcus.Wassmer Fix LinuxEditor compile Change 3357294 on 2017/03/21 by Marcus.Wassmer Add missing SSE functions Change 3357351 on 2017/03/21 by Frank.Fella Fix win32 and linux compiler errors Change 3357370 on 2017/03/21 by Arne.Schober DR - disable ensure in test builds #RB Marcus.Wassmer [CL 3357449 by Marcus Wassmer in Main branch]
1050 lines
34 KiB
C++
1050 lines
34 KiB
C++
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
VisualizeTexture.cpp: Post processing visualize texture.
|
|
=============================================================================*/
|
|
|
|
#include "PostProcess/VisualizeTexture.h"
|
|
#include "ShaderParameters.h"
|
|
#include "RHIStaticStates.h"
|
|
#include "Shader.h"
|
|
#include "StaticBoundShaderState.h"
|
|
#include "SceneUtils.h"
|
|
#include "HAL/FileManager.h"
|
|
#include "Misc/FileHelper.h"
|
|
#include "Misc/Paths.h"
|
|
#include "Misc/App.h"
|
|
#include "CanvasTypes.h"
|
|
#include "UnrealEngine.h"
|
|
#include "PostProcess/RenderTargetPool.h"
|
|
#include "PostProcess/SceneRenderTargets.h"
|
|
#include "GlobalShader.h"
|
|
#include "RenderTargetTemp.h"
|
|
#include "ScreenRendering.h"
|
|
#include "PostProcess/SceneFilterRendering.h"
|
|
#include "PostProcess/PostProcessing.h"
|
|
#include "PipelineStateCache.h"
|
|
|
|
|
|
/** A pixel shader which filters a texture. */
|
|
// @param TextureType 0:Cube, 1:1D(not yet supported), 2:2D no MSAA, 3:3D, 4:Cube[], 5:2D MSAA, 6:2D DepthStencil no MSAA (needed to avoid D3DDebug error)
|
|
template<uint32 TextureType>
|
|
class VisualizeTexturePS : public FGlobalShader
|
|
{
|
|
DECLARE_SHADER_TYPE(VisualizeTexturePS,Global);
|
|
public:
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
static void ModifyCompilationEnvironment(EShaderPlatform Platform, FShaderCompilerEnvironment& OutEnvironment)
|
|
{
|
|
FGlobalShader::ModifyCompilationEnvironment(Platform, OutEnvironment);
|
|
OutEnvironment.SetDefine(TEXT("TEXTURE_TYPE"), TextureType);
|
|
}
|
|
|
|
/** Default constructor. */
|
|
VisualizeTexturePS() {}
|
|
|
|
/** Initialization constructor. */
|
|
VisualizeTexturePS(const ShaderMetaType::CompiledShaderInitializerType& Initializer):
|
|
FGlobalShader(Initializer)
|
|
{
|
|
VisualizeTexture2D.Bind(Initializer.ParameterMap,TEXT("VisualizeTexture2D"));
|
|
VisualizeDepthStencilTexture.Bind(Initializer.ParameterMap, TEXT("VisualizeDepthStencilTexture"));
|
|
|
|
VisualizeTexture2DSampler.Bind(Initializer.ParameterMap,TEXT("VisualizeTexture2DSampler"));
|
|
VisualizeTexture2DMS.Bind(Initializer.ParameterMap,TEXT("VisualizeTexture2DMS"));
|
|
VisualizeTexture3D.Bind(Initializer.ParameterMap,TEXT("VisualizeTexture3D"));
|
|
VisualizeTexture3DSampler.Bind(Initializer.ParameterMap,TEXT("VisualizeTexture3DSampler"));
|
|
VisualizeTextureCube.Bind(Initializer.ParameterMap,TEXT("VisualizeTextureCube"));
|
|
VisualizeTextureCubeSampler.Bind(Initializer.ParameterMap,TEXT("VisualizeTextureCubeSampler"));
|
|
VisualizeTextureCubeArray.Bind(Initializer.ParameterMap,TEXT("VisualizeTextureCubeArray"));
|
|
VisualizeTextureCubeArraySampler.Bind(Initializer.ParameterMap,TEXT("VisualizeTextureCubeArraySampler"));
|
|
VisualizeParam.Bind(Initializer.ParameterMap,TEXT("VisualizeParam"));
|
|
TextureExtent.Bind(Initializer.ParameterMap,TEXT("TextureExtent"));
|
|
}
|
|
|
|
/** Serializer */
|
|
virtual bool Serialize(FArchive& Ar) override
|
|
{
|
|
bool bShaderHasOutdatedParameters = FGlobalShader::Serialize(Ar);
|
|
Ar << VisualizeTexture2D;
|
|
Ar << VisualizeDepthStencilTexture;
|
|
Ar << VisualizeTexture2DSampler;
|
|
Ar << VisualizeTexture2DMS;
|
|
Ar << VisualizeTexture3D;
|
|
Ar << VisualizeTexture3DSampler;
|
|
Ar << VisualizeTextureCube;
|
|
Ar << VisualizeTextureCubeSampler;
|
|
Ar << VisualizeTextureCubeArray;
|
|
Ar << VisualizeTextureCubeArraySampler;
|
|
Ar << VisualizeParam;
|
|
Ar << TextureExtent;
|
|
return bShaderHasOutdatedParameters;
|
|
}
|
|
|
|
void SetParameters(FRHICommandList& RHICmdList, const FVisualizeTextureData& Data)
|
|
{
|
|
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
|
|
|
|
{
|
|
// alternates between 0 and 1 with a short pause
|
|
const float FracTimeScale = 2.0f;
|
|
float FracTime = FApp::GetCurrentTime() * FracTimeScale - floor(FApp::GetCurrentTime() * FracTimeScale);
|
|
float BlinkState = (FracTime > 0.5f) ? 1.0f : 0.0f;
|
|
|
|
FVector4 VisualizeParamValue[3];
|
|
|
|
float Add = 0.0f;
|
|
float FracScale = 1.0f;
|
|
|
|
// w * almost_1 to avoid frac(1) => 0
|
|
VisualizeParamValue[0] = FVector4(Data.RGBMul, Data.SingleChannelMul, Add, FracScale * 0.9999f);
|
|
VisualizeParamValue[1] = FVector4(BlinkState, Data.bSaturateInsteadOfFrac ? 1.0f : 0.0f, Data.ArrayIndex, Data.CustomMip);
|
|
VisualizeParamValue[2] = FVector4(Data.InputValueMapping, 0.0f, Data.SingleChannel );
|
|
|
|
SetShaderValueArray(RHICmdList, ShaderRHI, VisualizeParam, VisualizeParamValue, 3);
|
|
}
|
|
|
|
{
|
|
FVector4 TextureExtentValue(Data.Desc.Extent.X, Data.Desc.Extent.Y, Data.Desc.Depth, 0);
|
|
|
|
SetShaderValue(RHICmdList, ShaderRHI, TextureExtent, TextureExtentValue);
|
|
}
|
|
|
|
|
|
SetSRVParameter(RHICmdList, ShaderRHI, VisualizeDepthStencilTexture, Data.StencilSRV );
|
|
SetTextureParameter(RHICmdList, ShaderRHI, VisualizeTexture2D, VisualizeTexture2DSampler, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), (FTextureRHIRef&)Data.RenderTargetItem.ShaderResourceTexture);
|
|
SetTextureParameter(RHICmdList, ShaderRHI, VisualizeTexture2DMS, (FTextureRHIRef&)Data.RenderTargetItem.TargetableTexture);
|
|
SetTextureParameter(RHICmdList, ShaderRHI, VisualizeTexture3D, VisualizeTexture3DSampler, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), (FTextureRHIRef&)Data.RenderTargetItem.ShaderResourceTexture);
|
|
SetTextureParameter(RHICmdList, ShaderRHI, VisualizeTextureCube, VisualizeTextureCubeSampler, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), (FTextureRHIRef&)Data.RenderTargetItem.ShaderResourceTexture);
|
|
SetTextureParameter(RHICmdList, ShaderRHI, VisualizeTextureCubeArray, VisualizeTextureCubeArraySampler, TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), (FTextureRHIRef&)Data.RenderTargetItem.ShaderResourceTexture);
|
|
}
|
|
|
|
static const TCHAR* GetSourceFilename()
|
|
{
|
|
return TEXT("VisualizeTexture");
|
|
}
|
|
|
|
static const TCHAR* GetFunctionName()
|
|
{
|
|
return TEXT("VisualizeTexturePS");
|
|
}
|
|
|
|
protected:
|
|
FShaderResourceParameter VisualizeTexture2D;
|
|
FShaderResourceParameter VisualizeDepthStencilTexture;
|
|
FShaderResourceParameter VisualizeTexture2DSampler;
|
|
FShaderResourceParameter VisualizeTexture2DMS;
|
|
FShaderResourceParameter VisualizeTexture3D;
|
|
FShaderResourceParameter VisualizeTexture3DSampler;
|
|
FShaderResourceParameter VisualizeTextureCube;
|
|
FShaderResourceParameter VisualizeTextureCubeSampler;
|
|
FShaderResourceParameter VisualizeTextureCubeArray;
|
|
FShaderResourceParameter VisualizeTextureCubeArraySampler;
|
|
FShaderParameter VisualizeParam;
|
|
FShaderParameter TextureExtent;
|
|
};
|
|
|
|
// #define avoids a lot of code duplication
|
|
#define VARIATION1(A) typedef VisualizeTexturePS<A> VisualizeTexturePS##A; \
|
|
IMPLEMENT_SHADER_TYPE2(VisualizeTexturePS##A, SF_Pixel);
|
|
|
|
VARIATION1(0) VARIATION1(2) VARIATION1(3) VARIATION1(4) VARIATION1(5) VARIATION1(6)
|
|
#undef VARIATION1
|
|
|
|
|
|
/** Encapsulates a simple copy pixel shader. */
|
|
class FVisualizeTexturePresentPS : public FGlobalShader
|
|
{
|
|
DECLARE_SHADER_TYPE(FVisualizeTexturePresentPS, Global);
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/** Default constructor. */
|
|
FVisualizeTexturePresentPS() {}
|
|
|
|
public:
|
|
FShaderResourceParameter VisualizeTexture2D;
|
|
FShaderResourceParameter VisualizeTexture2DSampler;
|
|
|
|
/** Initialization constructor. */
|
|
FVisualizeTexturePresentPS(const ShaderMetaType::CompiledShaderInitializerType& Initializer)
|
|
: FGlobalShader(Initializer)
|
|
{
|
|
VisualizeTexture2D.Bind(Initializer.ParameterMap,TEXT("VisualizeTexture2D"));
|
|
VisualizeTexture2DSampler.Bind(Initializer.ParameterMap,TEXT("VisualizeTexture2DSampler"));
|
|
}
|
|
|
|
// FShader interface.
|
|
virtual bool Serialize(FArchive& Ar) override
|
|
{
|
|
bool bShaderHasOutdatedParameters = FGlobalShader::Serialize(Ar);
|
|
Ar << VisualizeTexture2D << VisualizeTexture2DSampler;
|
|
return bShaderHasOutdatedParameters;
|
|
}
|
|
|
|
void SetParameters(FRHICommandList& RHICmdList, const FSceneView& View, const IPooledRenderTarget& Src)
|
|
{
|
|
const FPixelShaderRHIParamRef ShaderRHI = GetPixelShader();
|
|
|
|
FGlobalShader::SetParameters<FViewUniformShaderParameters>(RHICmdList, ShaderRHI, View.ViewUniformBuffer);
|
|
SetTextureParameter(RHICmdList, ShaderRHI, VisualizeTexture2D, VisualizeTexture2DSampler,
|
|
TStaticSamplerState<SF_Point,AM_Clamp,AM_Clamp,AM_Clamp>::GetRHI(), (FTextureRHIRef&)Src.GetRenderTargetItem().ShaderResourceTexture);
|
|
}
|
|
};
|
|
|
|
IMPLEMENT_SHADER_TYPE(,FVisualizeTexturePresentPS,TEXT("VisualizeTexture"),TEXT("PresentPS"),SF_Pixel);
|
|
|
|
|
|
template<uint32 TextureType> void VisualizeTextureForTextureType(FRHICommandList& RHICmdList, ERHIFeatureLevel::Type FeatureLevel, const FVisualizeTextureData& Data)
|
|
{
|
|
FGraphicsPipelineStateInitializer GraphicsPSOInit;
|
|
RHICmdList.ApplyCachedRenderTargets(GraphicsPSOInit);
|
|
GraphicsPSOInit.BlendState = TStaticBlendState<>::GetRHI();
|
|
GraphicsPSOInit.RasterizerState = TStaticRasterizerState<>::GetRHI();
|
|
GraphicsPSOInit.DepthStencilState = TStaticDepthStencilState<false, CF_Always>::GetRHI();
|
|
|
|
auto ShaderMap = GetGlobalShaderMap(FeatureLevel);
|
|
TShaderMapRef<FScreenVS> VertexShader(ShaderMap);
|
|
TShaderMapRef<VisualizeTexturePS<TextureType> > PixelShader(ShaderMap);
|
|
|
|
GraphicsPSOInit.BoundShaderState.VertexDeclarationRHI = GFilterVertexDeclaration.VertexDeclarationRHI;
|
|
GraphicsPSOInit.BoundShaderState.VertexShaderRHI = GETSAFERHISHADER_VERTEX(*VertexShader);
|
|
GraphicsPSOInit.BoundShaderState.PixelShaderRHI = GETSAFERHISHADER_PIXEL(*PixelShader);
|
|
GraphicsPSOInit.PrimitiveType = PT_TriangleList;
|
|
SetGraphicsPipelineState(RHICmdList, GraphicsPSOInit);
|
|
|
|
PixelShader->SetParameters(RHICmdList, Data);
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(RHICmdList);
|
|
|
|
DrawRectangle(
|
|
RHICmdList,
|
|
// XY
|
|
0, 0,
|
|
// SizeXY
|
|
SceneContext.GetBufferSizeXY().X, SceneContext.GetBufferSizeXY().Y,
|
|
// UV
|
|
Data.Tex00.X, Data.Tex00.Y,
|
|
// SizeUV
|
|
Data.Tex11.X - Data.Tex00.X, Data.Tex11.Y - Data.Tex00.Y,
|
|
// TargetSize
|
|
SceneContext.GetBufferSizeXY(),
|
|
// TextureSize
|
|
FIntPoint(1, 1),
|
|
*VertexShader,
|
|
EDRF_UseTriangleOptimization);
|
|
}
|
|
|
|
void RenderVisualizeTexture(FRHICommandListImmediate& RHICmdList, ERHIFeatureLevel::Type FeatureLevel, const FVisualizeTextureData& Data)
|
|
{
|
|
RHICmdList.CopyToResolveTarget(Data.RenderTargetItem.ShaderResourceTexture, Data.RenderTargetItem.ShaderResourceTexture, true, FResolveParams());
|
|
if(Data.Desc.Is2DTexture())
|
|
{
|
|
// 2D
|
|
if(Data.Desc.NumSamples > 1)
|
|
{
|
|
// MSAA
|
|
VisualizeTextureForTextureType<5>(RHICmdList, FeatureLevel, Data);
|
|
}
|
|
else
|
|
{
|
|
if(Data.Desc.Format == PF_DepthStencil)
|
|
{
|
|
// DepthStencil non MSAA (needed to avoid D3DDebug error)
|
|
VisualizeTextureForTextureType<6>(RHICmdList, FeatureLevel, Data);
|
|
}
|
|
else
|
|
{
|
|
// non MSAA
|
|
VisualizeTextureForTextureType<2>(RHICmdList, FeatureLevel, Data);
|
|
}
|
|
}
|
|
}
|
|
else if(Data.Desc.Is3DTexture())
|
|
{
|
|
VisualizeTextureForTextureType<3>(RHICmdList, FeatureLevel, Data);
|
|
}
|
|
else if(Data.Desc.IsCubemap())
|
|
{
|
|
if(Data.Desc.IsArray())
|
|
{
|
|
// Cube[]
|
|
VisualizeTextureForTextureType<4>(RHICmdList, FeatureLevel, Data);
|
|
}
|
|
else
|
|
{
|
|
// Cube
|
|
VisualizeTextureForTextureType<0>(RHICmdList, FeatureLevel, Data);
|
|
}
|
|
}
|
|
}
|
|
|
|
FVisualizeTexture::FVisualizeTexture()
|
|
{
|
|
Mode = 0;
|
|
RGBMul = 1.0f;
|
|
SingleChannelMul = 0.0f;
|
|
SingleChannel = -1;
|
|
AMul = 0.0f;
|
|
UVInputMapping = 3;
|
|
Flags = 0;
|
|
ObservedDebugNameReusedGoal = 0xffffffff;
|
|
ArrayIndex = 0;
|
|
CustomMip = 0;
|
|
bSaveBitmap = false;
|
|
bOutputStencil = false;
|
|
bFullList = false;
|
|
SortOrder = -1;
|
|
bEnabled = true;
|
|
}
|
|
|
|
void FVisualizeTexture::Destroy()
|
|
{
|
|
VisualizeTextureContent.SafeRelease();
|
|
StencilSRV.SafeRelease();
|
|
}
|
|
|
|
FIntRect FVisualizeTexture::ComputeVisualizeTextureRect(FIntPoint InputTextureSize) const
|
|
{
|
|
FIntRect ret = ViewRect;
|
|
FIntPoint ViewExtent = ViewRect.Size();
|
|
|
|
// set ViewRect
|
|
switch(UVInputMapping)
|
|
{
|
|
// pixel perfect centered (not yet for volume textures)
|
|
case 2:
|
|
{
|
|
FIntPoint Center = ViewExtent / 2;
|
|
FIntPoint HalfMin = InputTextureSize / 2;
|
|
FIntPoint HalfMax = InputTextureSize - HalfMin;
|
|
|
|
ret = FIntRect(Center - HalfMin, Center + HalfMax);
|
|
break;
|
|
}
|
|
|
|
// whole texture in PIP
|
|
case 3:
|
|
{
|
|
int32 LeftOffset = AspectRatioConstrainedViewRect.Min.X;
|
|
int32 BottomOffset = AspectRatioConstrainedViewRect.Max.Y - ViewRect.Max.Y;
|
|
|
|
ret = FIntRect(LeftOffset + 80, ViewExtent.Y - ViewExtent.Y / 3 - 10 + BottomOffset, ViewExtent.X / 3 + 10, ViewExtent.Y - 10 + BottomOffset) + ViewRect.Min;
|
|
break;
|
|
}
|
|
|
|
default:
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
void FVisualizeTexture::GenerateContent(FRHICommandListImmediate& RHICmdList, const FSceneRenderTargetItem& RenderTargetItem, const FPooledRenderTargetDesc& Desc)
|
|
{
|
|
// otherwise StartFrame() wasn't called
|
|
check(ViewRect != FIntRect(0, 0, 0, 0))
|
|
|
|
|
|
FTexture2DRHIRef VisTexture = (FTexture2DRHIRef&)RenderTargetItem.ShaderResourceTexture;
|
|
|
|
if(!IsValidRef(VisTexture) || !Desc.IsValid())
|
|
{
|
|
// todo: improve
|
|
return;
|
|
}
|
|
|
|
FIntRect VisualizeTextureRect = ComputeVisualizeTextureRect(Desc.Extent);
|
|
|
|
FIntPoint Size = VisualizeTextureRect.Size();
|
|
|
|
// clamp to reasonable value to prevent crash
|
|
Size.X = FMath::Max(Size.X, 1);
|
|
Size.Y = FMath::Max(Size.Y, 1);
|
|
|
|
FPooledRenderTargetDesc OutputDesc(FPooledRenderTargetDesc::Create2DDesc(Size, PF_B8G8R8A8, FClearValueBinding(FLinearColor(1, 1, 0, 1)), TexCreate_None, TexCreate_RenderTargetable | TexCreate_ShaderResource, false));
|
|
|
|
GRenderTargetPool.FindFreeElement(RHICmdList, OutputDesc, VisualizeTextureContent, TEXT("VisualizeTexture"));
|
|
|
|
if(!VisualizeTextureContent)
|
|
{
|
|
return;
|
|
}
|
|
|
|
const FSceneRenderTargetItem& DestRenderTarget = VisualizeTextureContent->GetRenderTargetItem();
|
|
|
|
TransitionSetRenderTargetsHelper(RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIParamRef(), FExclusiveDepthStencil::DepthWrite_StencilWrite);
|
|
|
|
FRHIRenderTargetView RtView = FRHIRenderTargetView(DestRenderTarget.TargetableTexture, ERenderTargetLoadAction::EClear);
|
|
FRHISetRenderTargetsInfo Info(1, &RtView, FRHIDepthRenderTargetView());
|
|
RHICmdList.SetRenderTargetsAndClear(Info);
|
|
|
|
FIntPoint RTExtent = FSceneRenderTargets::Get(RHICmdList).GetBufferSizeXY();
|
|
|
|
FVector2D Tex00 = FVector2D(0, 0);
|
|
FVector2D Tex11 = FVector2D(1, 1);
|
|
|
|
uint32 LocalVisualizeTextureInputMapping = UVInputMapping;
|
|
|
|
if(!Desc.Is2DTexture())
|
|
{
|
|
LocalVisualizeTextureInputMapping = 1;
|
|
}
|
|
|
|
// set UV
|
|
switch(LocalVisualizeTextureInputMapping)
|
|
{
|
|
// UV in left top
|
|
case 0:
|
|
Tex11 = FVector2D((float)ViewRect.Width() / RTExtent.X, (float)ViewRect.Height() / RTExtent.Y);
|
|
break;
|
|
|
|
// whole texture
|
|
default:
|
|
break;
|
|
}
|
|
|
|
bool bIsDefault = StencilSRVSrc == GBlackTexture->TextureRHI;
|
|
bool bDepthStencil = Desc.Is2DTexture() && Desc.Format == PF_DepthStencil;
|
|
|
|
//clear if this is a new different Stencil buffer, or it's not a stencil buffer and we haven't switched to the default yet.
|
|
bool bNeedsClear = bDepthStencil && (StencilSRVSrc != RenderTargetItem.TargetableTexture);
|
|
bNeedsClear |= !bDepthStencil && !bIsDefault;
|
|
if (bNeedsClear)
|
|
{
|
|
StencilSRVSrc = nullptr;
|
|
StencilSRV.SafeRelease();
|
|
}
|
|
|
|
//always set something into the StencilSRV slot for platforms that require a full resource binding, even if
|
|
//dynamic branching will cause them not to be used.
|
|
if(bDepthStencil && !StencilSRVSrc)
|
|
{
|
|
StencilSRVSrc = RenderTargetItem.TargetableTexture;
|
|
StencilSRV = RHICreateShaderResourceView((FTexture2DRHIRef&) RenderTargetItem.TargetableTexture, 0, 1, PF_X24_G8);
|
|
}
|
|
else if(!StencilSRVSrc)
|
|
{
|
|
StencilSRVSrc = GBlackTexture->TextureRHI;
|
|
StencilSRV = RHICreateShaderResourceView((FTexture2DRHIRef&) GBlackTexture->TextureRHI, 0, 1, PF_B8G8R8A8);
|
|
}
|
|
|
|
FVisualizeTextureData VisualizeTextureData(RenderTargetItem, Desc);
|
|
|
|
// distinguish between standard depth and shadow depth to produce more reasonable default value mapping in the pixel shader.
|
|
const bool bDepthTexture = (Desc.TargetableFlags & TexCreate_DepthStencilTargetable) != 0;
|
|
const bool bShadowDepth = (Desc.Format == PF_ShadowDepth);
|
|
|
|
VisualizeTextureData.RGBMul = RGBMul;
|
|
VisualizeTextureData.SingleChannelMul = SingleChannelMul;
|
|
VisualizeTextureData.SingleChannel = SingleChannel;
|
|
VisualizeTextureData.AMul = AMul;
|
|
VisualizeTextureData.Tex00 = Tex00;
|
|
VisualizeTextureData.Tex11 = Tex11;
|
|
VisualizeTextureData.bSaturateInsteadOfFrac = (Flags & 1) != 0;
|
|
VisualizeTextureData.InputValueMapping = bShadowDepth ? 2 : (bDepthTexture ? 1 : 0);
|
|
VisualizeTextureData.ArrayIndex = ArrayIndex;
|
|
VisualizeTextureData.CustomMip = CustomMip;
|
|
VisualizeTextureData.StencilSRV = StencilSRV;
|
|
|
|
if(!(Desc.Flags & TexCreate_CPUReadback)) // We cannot make a texture lookup on such elements
|
|
{
|
|
SCOPED_DRAW_EVENT(RHICmdList, VisualizeTexture);
|
|
// continue rendering to HDR if necessary
|
|
RenderVisualizeTexture(RHICmdList, FeatureLevel, VisualizeTextureData);
|
|
}
|
|
|
|
{
|
|
SCOPED_DRAW_EVENT(RHICmdList, VisCopy);
|
|
RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
|
|
}
|
|
|
|
VisualizeTextureDesc = Desc;
|
|
|
|
// save to disk
|
|
if(bSaveBitmap)
|
|
{
|
|
bSaveBitmap = false;
|
|
|
|
uint32 MipAdjustedExtentX = FMath::Clamp(Desc.Extent.X >> CustomMip, 0, Desc.Extent.X);
|
|
uint32 MipAdjustedExtentY = FMath::Clamp(Desc.Extent.Y >> CustomMip, 0, Desc.Extent.Y);
|
|
FIntPoint Extent(MipAdjustedExtentX, MipAdjustedExtentY);
|
|
|
|
FReadSurfaceDataFlags ReadDataFlags;
|
|
ReadDataFlags.SetLinearToGamma(false);
|
|
ReadDataFlags.SetOutputStencil(bOutputStencil);
|
|
ReadDataFlags.SetMip(CustomMip);
|
|
|
|
FTextureRHIRef Texture = RenderTargetItem.TargetableTexture ? RenderTargetItem.TargetableTexture : RenderTargetItem.ShaderResourceTexture;
|
|
|
|
check(Texture);
|
|
|
|
TArray<FColor> Bitmap;
|
|
|
|
|
|
|
|
RHICmdList.ReadSurfaceData(Texture, FIntRect(0, 0, Extent.X, Extent.Y), Bitmap, ReadDataFlags);
|
|
|
|
// if the format and texture type is supported
|
|
if(Bitmap.Num())
|
|
{
|
|
// Create screenshot folder if not already present.
|
|
IFileManager::Get().MakeDirectory(*FPaths::ScreenShotDir(), true);
|
|
|
|
const FString ScreenFileName(FPaths::ScreenShotDir() / TEXT("VisualizeTexture"));
|
|
|
|
uint32 ExtendXWithMSAA = Bitmap.Num() / Extent.Y;
|
|
|
|
// Save the contents of the array to a bitmap file. (24bit only so alpha channel is dropped)
|
|
FFileHelper::CreateBitmap(*ScreenFileName, ExtendXWithMSAA, Extent.Y, Bitmap.GetData());
|
|
|
|
UE_LOG(LogConsoleResponse, Display, TEXT("Content was saved to \"%s\""), *FPaths::ScreenShotDir());
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogConsoleResponse, Error, TEXT("Failed to save BMP for VisualizeTexture, format or texture type is not supported"));
|
|
}
|
|
}
|
|
}
|
|
|
|
void FVisualizeTexture::PresentContent(FRHICommandListImmediate& RHICmdList, const FViewInfo& View)
|
|
{
|
|
if(Mode != 0)
|
|
{
|
|
// old mode is used, lets copy the specified texture to do it similar to the new system
|
|
FPooledRenderTarget* Element = GRenderTargetPool.GetElementById(Mode - 1);
|
|
if(Element)
|
|
{
|
|
GenerateContent(RHICmdList, Element->GetRenderTargetItem(), Element->GetDesc());
|
|
}
|
|
}
|
|
|
|
const FTexture2DRHIRef& RenderTargetTexture = View.Family->RenderTarget->GetRenderTargetTexture();
|
|
|
|
if(!VisualizeTextureContent
|
|
|| !IsValidRef(RenderTargetTexture)
|
|
|| !bEnabled)
|
|
{
|
|
// visualize feature is deactivated
|
|
return;
|
|
}
|
|
|
|
FPooledRenderTargetDesc Desc = VisualizeTextureDesc;
|
|
|
|
auto& RenderTarget = View.Family->RenderTarget->GetRenderTargetTexture();
|
|
SetRenderTarget(RHICmdList, RenderTarget, FTextureRHIRef(), true);
|
|
RHICmdList.SetViewport(0, 0, 0.0f, RenderTarget->GetSizeX(), RenderTarget->GetSizeY(), 1.0f);
|
|
|
|
FGraphicsPipelineStateInitializer GraphicsPSOInit;
|
|
RHICmdList.ApplyCachedRenderTargets(GraphicsPSOInit);
|
|
GraphicsPSOInit.BlendState = TStaticBlendState<>::GetRHI();
|
|
GraphicsPSOInit.RasterizerState = TStaticRasterizerState<>::GetRHI();
|
|
GraphicsPSOInit.DepthStencilState = TStaticDepthStencilState<false, CF_Always>::GetRHI();
|
|
|
|
auto ShaderMap = View.ShaderMap;
|
|
TShaderMapRef<FPostProcessVS> VertexShader(ShaderMap);
|
|
TShaderMapRef<FVisualizeTexturePresentPS> PixelShader(ShaderMap);
|
|
|
|
GraphicsPSOInit.BoundShaderState.VertexDeclarationRHI = GFilterVertexDeclaration.VertexDeclarationRHI;
|
|
GraphicsPSOInit.BoundShaderState.VertexShaderRHI = GETSAFERHISHADER_VERTEX(*VertexShader);
|
|
GraphicsPSOInit.BoundShaderState.PixelShaderRHI = GETSAFERHISHADER_PIXEL(*PixelShader);
|
|
GraphicsPSOInit.PrimitiveType = PT_TriangleList;
|
|
SetGraphicsPipelineState(RHICmdList, GraphicsPSOInit);
|
|
|
|
VertexShader->SetParameters(RHICmdList, View.ViewUniformBuffer);
|
|
PixelShader->SetParameters(RHICmdList, View, *VisualizeTextureContent);
|
|
|
|
FIntRect DestRect = View.ViewRect;
|
|
|
|
FIntRect VisualizeTextureRect = ComputeVisualizeTextureRect(Desc.Extent);
|
|
|
|
{
|
|
SCOPED_DRAW_EVENT(RHICmdList, VisCopyToMain);
|
|
// Draw a quad mapping scene color to the view's render target
|
|
DrawRectangle(
|
|
RHICmdList,
|
|
VisualizeTextureRect.Min.X, VisualizeTextureRect.Min.Y,
|
|
VisualizeTextureRect.Width(), VisualizeTextureRect.Height(),
|
|
0, 0,
|
|
VisualizeTextureRect.Width(), VisualizeTextureRect.Height(),
|
|
FIntPoint(RenderTarget->GetSizeX(), RenderTarget->GetSizeY()),
|
|
VisualizeTextureRect.Size(),
|
|
*VertexShader,
|
|
EDRF_Default);
|
|
}
|
|
|
|
FRenderTargetTemp TempRenderTarget(View, View.UnscaledViewRect.Size());
|
|
FCanvas Canvas(&TempRenderTarget, NULL, View.Family->CurrentRealTime, View.Family->CurrentWorldTime, View.Family->DeltaWorldTime, View.GetFeatureLevel());
|
|
|
|
float X = 100 + View.ViewRect.Min.X;
|
|
float Y = 160 + View.ViewRect.Min.Y;
|
|
float YStep = 14;
|
|
|
|
{
|
|
uint32 ReuseCount = ObservedDebugNameReusedCurrent;
|
|
|
|
FString ExtendedName;
|
|
if(ReuseCount)
|
|
{
|
|
uint32 ReuseGoal = FMath::Min(ReuseCount - 1, ObservedDebugNameReusedGoal);
|
|
|
|
// was reused this frame
|
|
ExtendedName = FString::Printf(TEXT("%s@%d @0..%d"), Desc.DebugName, ReuseGoal, ReuseCount - 1);
|
|
}
|
|
else
|
|
{
|
|
// was not reused this frame but can be referenced
|
|
ExtendedName = FString::Printf(TEXT("%s"), Desc.DebugName);
|
|
}
|
|
|
|
FString Channels = TEXT("RGB");
|
|
switch( SingleChannel )
|
|
{
|
|
case 0: Channels = TEXT("R"); break;
|
|
case 1: Channels = TEXT("G"); break;
|
|
case 2: Channels = TEXT("B"); break;
|
|
case 3: Channels = TEXT("A"); break;
|
|
}
|
|
float Multiplier = ( SingleChannel == -1 ) ? RGBMul : SingleChannelMul;
|
|
|
|
FString Line = FString::Printf(TEXT("VisualizeTexture: %d \"%s\" %s*%g UV%d"),
|
|
Mode,
|
|
*ExtendedName,
|
|
*Channels,
|
|
Multiplier,
|
|
UVInputMapping);
|
|
|
|
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
|
|
}
|
|
{
|
|
FString Line = FString::Printf(TEXT(" TextureInfoString(): %s"), *(Desc.GenerateInfoString()));
|
|
Canvas.DrawShadowedString( X + 10, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
|
|
}
|
|
{
|
|
FString Line = FString::Printf(TEXT(" BufferSize:(%d,%d)"), FSceneRenderTargets::Get(RHICmdList).GetBufferSizeXY().X, FSceneRenderTargets::Get(RHICmdList).GetBufferSizeXY().Y);
|
|
Canvas.DrawShadowedString( X + 10, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
|
|
}
|
|
|
|
const FSceneViewFamily& ViewFamily = *View.Family;
|
|
|
|
for(int32 ViewId = 0; ViewId < ViewFamily.Views.Num(); ++ViewId)
|
|
{
|
|
const FSceneView& ViewIt = *ViewFamily.Views[ViewId];
|
|
FString Line = FString::Printf(TEXT(" View #%d: (%d,%d)-(%d,%d)"), ViewId + 1,
|
|
ViewIt.ViewRect.Min.X, ViewIt.ViewRect.Min.Y, ViewIt.ViewRect.Max.X, ViewIt.ViewRect.Max.Y);
|
|
Canvas.DrawShadowedString( X + 10, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
|
|
}
|
|
|
|
X += 40;
|
|
|
|
if(Desc.Flags & TexCreate_CPUReadback)
|
|
{
|
|
Canvas.DrawShadowedString( X, Y += YStep, TEXT("Content cannot be visualized on the GPU (TexCreate_CPUReadback)"), GetStatsFont(), FLinearColor(1,1,0));
|
|
}
|
|
else
|
|
{
|
|
Canvas.DrawShadowedString( X, Y += YStep, TEXT("Blinking Red: <0"), GetStatsFont(), FLinearColor(1,0,0));
|
|
Canvas.DrawShadowedString( X, Y += YStep, TEXT("Blinking Blue: NAN or Inf"), GetStatsFont(), FLinearColor(0,0,1));
|
|
|
|
// add explicit legend for SceneDepth and ShadowDepth as the display coloring is an artificial choice.
|
|
const bool bDepthTexture = (Desc.TargetableFlags & TexCreate_DepthStencilTargetable) != 0;
|
|
const bool bShadowDepth = (Desc.Format == PF_ShadowDepth);
|
|
if (bShadowDepth)
|
|
{
|
|
Canvas.DrawShadowedString(X, Y += YStep, TEXT("Color Key: Linear with white near and teal distant"), GetStatsFont(), FLinearColor(54.f / 255.f, 117.f / 255.f, 136.f / 255.f));
|
|
}
|
|
else if (bDepthTexture)
|
|
{
|
|
Canvas.DrawShadowedString(X, Y += YStep, TEXT("Color Key: Nonlinear with white distant"), GetStatsFont(), FLinearColor(0.5, 0, 0));
|
|
}
|
|
}
|
|
|
|
Canvas.Flush_RenderThread(RHICmdList);
|
|
}
|
|
|
|
|
|
void FVisualizeTexture::SetObserveTarget(const FString& InObservedDebugName, uint32 InObservedDebugNameReusedGoal)
|
|
{
|
|
ObservedDebugName = InObservedDebugName;
|
|
ObservedDebugNameReusedGoal = InObservedDebugNameReusedGoal;
|
|
}
|
|
|
|
void FVisualizeTexture::SetCheckPoint(FRHICommandList& RHICmdList, const IPooledRenderTarget* PooledRenderTarget)
|
|
{
|
|
|
|
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
check(IsInRenderingThread());
|
|
if (!PooledRenderTarget || !bEnabled)
|
|
{
|
|
// Don't checkpoint on ES2 to avoid TMap alloc/reallocations
|
|
return;
|
|
}
|
|
|
|
const FSceneRenderTargetItem& RenderTargetItem = PooledRenderTarget->GetRenderTargetItem();
|
|
const FPooledRenderTargetDesc& Desc = PooledRenderTarget->GetDesc();
|
|
const TCHAR* DebugName = Desc.DebugName;
|
|
|
|
uint32* UsageCountPtr = VisualizeTextureCheckpoints.Find(DebugName);
|
|
|
|
if(!UsageCountPtr)
|
|
{
|
|
// create a new element with count 0
|
|
UsageCountPtr = &VisualizeTextureCheckpoints.Add(DebugName, 0);
|
|
}
|
|
|
|
// is this is the name we are observing with visualize texture?
|
|
// First check if we need to find anything to avoid string the comparison
|
|
if (!ObservedDebugName.IsEmpty() && ObservedDebugName == DebugName)
|
|
{
|
|
// if multiple times reused during the frame, is that the one we want to look at?
|
|
if(*UsageCountPtr == ObservedDebugNameReusedGoal || ObservedDebugNameReusedGoal == 0xffffffff)
|
|
{
|
|
FRHICommandListImmediate& RHICmdListIm = FRHICommandListExecutor::GetImmediateCommandList();
|
|
if (RHICmdListIm.IsExecuting())
|
|
{
|
|
UE_LOG(LogConsoleResponse, Fatal, TEXT("We can't create a checkpoint because that requires the immediate commandlist, which is currently executing. You might try disabling parallel rendering."));
|
|
}
|
|
else
|
|
{
|
|
if (&RHICmdList != &RHICmdListIm)
|
|
{
|
|
UE_LOG(LogConsoleResponse, Warning, TEXT("Attempt to checkpoint a render target from a non-immediate command list. We will flush it and hope that works. If it doesn't you might try disabling parallel rendering."));
|
|
RHICmdList.Flush();
|
|
}
|
|
GenerateContent(RHICmdListIm, RenderTargetItem, Desc);
|
|
if (&RHICmdList != &RHICmdListIm)
|
|
{
|
|
RHICmdListIm.Flush();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// only needed for VisualizeTexture (todo: optimize out when possible)
|
|
*UsageCountPtr = *UsageCountPtr + 1;
|
|
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
}
|
|
|
|
|
|
struct FSortedLines
|
|
{
|
|
FString Line;
|
|
int32 SortIndex;
|
|
uint32 PoolIndex;
|
|
|
|
FORCEINLINE bool operator<( const FSortedLines &B ) const
|
|
{
|
|
// first large ones
|
|
if(SortIndex < B.SortIndex)
|
|
{
|
|
return true;
|
|
}
|
|
if(SortIndex > B.SortIndex)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return Line < B.Line;
|
|
}
|
|
};
|
|
|
|
void FVisualizeTexture::DebugLog(bool bExtended)
|
|
{
|
|
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
{
|
|
TArray<FSortedLines> SortedLines;
|
|
|
|
for(uint32 i = 0, Num = GRenderTargetPool.GetElementCount(); i < Num; ++i)
|
|
{
|
|
FPooledRenderTarget* RT = GRenderTargetPool.GetElementById(i);
|
|
|
|
if(!RT)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
FPooledRenderTargetDesc Desc = RT->GetDesc();
|
|
|
|
if(bFullList || (Desc.Flags & TexCreate_HideInVisualizeTexture) == 0)
|
|
{
|
|
uint32 SizeInKB = (RT->ComputeMemorySize() + 1023) / 1024;
|
|
|
|
FString UnusedStr;
|
|
|
|
if(RT->GetUnusedForNFrames() > 0)
|
|
{
|
|
if(!bFullList)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
UnusedStr = FString::Printf(TEXT(" unused(%d)"), RT->GetUnusedForNFrames());
|
|
}
|
|
|
|
FSortedLines Element;
|
|
|
|
Element.PoolIndex = i;
|
|
|
|
// sort by index
|
|
Element.SortIndex = i;
|
|
|
|
FString InfoString = Desc.GenerateInfoString();
|
|
if(SortOrder == -1)
|
|
{
|
|
// constant works well with the average name length
|
|
const uint32 TotelSpacerSize = 36;
|
|
uint32 SpaceCount = FMath::Max<int32>(0, TotelSpacerSize - InfoString.Len());
|
|
|
|
for(uint32 Space = 0; Space < SpaceCount; ++Space)
|
|
{
|
|
InfoString.AppendChar((TCHAR)' ');
|
|
}
|
|
|
|
// sort by index
|
|
Element.Line = FString::Printf(TEXT("%s %s %d KB%s"), *InfoString, Desc.DebugName, SizeInKB, *UnusedStr);
|
|
}
|
|
else if(SortOrder == 0)
|
|
{
|
|
// sort by name
|
|
Element.Line = FString::Printf(TEXT("%s %s %d KB%s"), Desc.DebugName, *InfoString, SizeInKB, *UnusedStr);
|
|
Element.SortIndex = 0;
|
|
}
|
|
else if(SortOrder == 1)
|
|
{
|
|
// sort by size (large ones first)
|
|
Element.Line = FString::Printf(TEXT("%d KB %s %s%s"), SizeInKB, *InfoString, Desc.DebugName, *UnusedStr);
|
|
Element.SortIndex = -(int32)SizeInKB;
|
|
}
|
|
else
|
|
{
|
|
check(0);
|
|
}
|
|
|
|
if(Desc.Flags & TexCreate_FastVRAM)
|
|
{
|
|
FRHIResourceInfo Info;
|
|
|
|
FTextureRHIRef Texture = RT->GetRenderTargetItem().ShaderResourceTexture;
|
|
|
|
if(!IsValidRef(Texture))
|
|
{
|
|
Texture = RT->GetRenderTargetItem().TargetableTexture;
|
|
}
|
|
|
|
if(IsValidRef(Texture))
|
|
{
|
|
RHIGetResourceInfo(Texture, Info);
|
|
}
|
|
|
|
if(Info.VRamAllocation.AllocationSize)
|
|
{
|
|
// note we do KB for more readable numbers but this can cause quantization loss
|
|
Element.Line += FString::Printf(TEXT(" VRamInKB(Start/Size):%d/%d"),
|
|
Info.VRamAllocation.AllocationStart / 1024,
|
|
(Info.VRamAllocation.AllocationSize + 1023) / 1024);
|
|
}
|
|
else
|
|
{
|
|
Element.Line += TEXT(" VRamInKB(Start/Size):<NONE>");
|
|
}
|
|
}
|
|
|
|
SortedLines.Add(Element);
|
|
}
|
|
}
|
|
|
|
SortedLines.Sort();
|
|
|
|
{
|
|
for(int32 Index = 0; Index < SortedLines.Num(); Index++)
|
|
{
|
|
const FSortedLines& Entry = SortedLines[Index];
|
|
|
|
UE_LOG(LogConsoleResponse, Log, TEXT(" %3d = %s"), Entry.PoolIndex + 1, *Entry.Line);
|
|
}
|
|
}
|
|
|
|
// clean flags for next use
|
|
bFullList = false;
|
|
SortOrder = -1;
|
|
}
|
|
|
|
UE_LOG(LogConsoleResponse, Log, TEXT(""));
|
|
|
|
// log names (alternative method to look at the rendertargets)
|
|
if(bExtended)
|
|
{
|
|
UE_LOG(LogConsoleResponse, Log, TEXT("CheckpointName (what was rendered this frame, use <Name>@<Number> to get intermediate versions):"));
|
|
|
|
TArray<FString> Entries;
|
|
|
|
// sorted by pointer for efficiency, now we want to print sorted alphabetically
|
|
for (TMap<const TCHAR*, uint32>:: TIterator It(GRenderTargetPool.VisualizeTexture.VisualizeTextureCheckpoints); It; ++It)
|
|
{
|
|
const TCHAR* Key = It.Key();
|
|
uint32 Value = It.Value();
|
|
|
|
/* if(Value)
|
|
{
|
|
// was reused this frame
|
|
Entries.Add(FString::Printf(TEXT("%s @0..%d"), *Key.GetPlainNameString(), Value - 1));
|
|
}
|
|
else
|
|
*/ {
|
|
// was not reused this frame but can be referenced
|
|
Entries.Add(Key);
|
|
}
|
|
}
|
|
|
|
Entries.Sort();
|
|
|
|
// that number works well with the name length we have
|
|
const uint32 ColumnCount = 5;
|
|
const uint32 SpaceBetweenColumns = 1;
|
|
uint32 ColumnHeight = FMath::DivideAndRoundUp((uint32)Entries.Num(), ColumnCount);
|
|
|
|
// width of the column in characters, init with 0
|
|
uint32 ColumnWidths[ColumnCount] = {};
|
|
|
|
for(int32 Index = 0; Index < Entries.Num(); ++Index)
|
|
{
|
|
uint32 Column = Index / ColumnHeight;
|
|
|
|
const FString& Entry = *Entries[Index];
|
|
|
|
ColumnWidths[Column] = FMath::Max(ColumnWidths[Column], (uint32)Entry.Len());
|
|
}
|
|
|
|
// print them sorted, if possible multiple in a line
|
|
{
|
|
FString Line;
|
|
|
|
for(int32 OutputIndex = 0; OutputIndex < Entries.Num(); ++OutputIndex)
|
|
{
|
|
// 0..ColumnCount-1
|
|
uint32 Column = OutputIndex % ColumnCount;
|
|
int32 Row = OutputIndex / ColumnCount;
|
|
|
|
uint32 Index = Row + Column * ColumnHeight;
|
|
|
|
bool bLineEnd = true;
|
|
|
|
if(Index < (uint32)Entries.Num())
|
|
{
|
|
bLineEnd = (Column + 1 == ColumnCount);
|
|
|
|
// for human readability we order them to be per column
|
|
const FString& Entry = *Entries[Index];
|
|
|
|
Line += Entry;
|
|
|
|
int32 SpaceCount = ColumnWidths[Column] + SpaceBetweenColumns - Entry.Len();
|
|
|
|
// otehrwise a fomer pass was producing bad data
|
|
check(SpaceCount >= 0);
|
|
|
|
for(int32 Space = 0; Space < SpaceCount; ++Space)
|
|
{
|
|
Line.AppendChar((TCHAR)' ');
|
|
}
|
|
}
|
|
|
|
if(bLineEnd)
|
|
{
|
|
Line = Line.TrimTrailing();
|
|
UE_LOG(LogConsoleResponse, Log, TEXT(" %s"), *Line);
|
|
Line.Empty();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
{
|
|
uint32 WholeCount;
|
|
uint32 WholePoolInKB;
|
|
uint32 UsedInKB;
|
|
|
|
GRenderTargetPool.GetStats(WholeCount, WholePoolInKB, UsedInKB);
|
|
|
|
UE_LOG(LogConsoleResponse, Log, TEXT("Pool: %d/%d MB (referenced/allocated)"), (UsedInKB + 1023) / 1024, (WholePoolInKB + 1023) / 1024);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
// @return 0 if not found
|
|
IPooledRenderTarget* FVisualizeTexture::GetObservedElement() const
|
|
{
|
|
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
IPooledRenderTarget* RT = VisualizeTextureContent.GetReference();
|
|
|
|
if(!RT && Mode >= 0)
|
|
{
|
|
uint32 Id = Mode - 1;
|
|
|
|
RT = GRenderTargetPool.GetElementById(Id);
|
|
}
|
|
|
|
return RT;
|
|
#else
|
|
return 0;
|
|
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
}
|
|
|
|
void FVisualizeTexture::OnStartFrame(const FSceneView& View)
|
|
{
|
|
FeatureLevel = View.GetFeatureLevel();
|
|
bEnabled = true;
|
|
ViewRect = View.UnscaledViewRect;
|
|
AspectRatioConstrainedViewRect = View.Family->EngineShowFlags.CameraAspectRatioBars ? View.CameraConstrainedViewRect : ViewRect;
|
|
|
|
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
// VisualizeTexture observed render target is set each frame
|
|
VisualizeTextureContent.SafeRelease();
|
|
VisualizeTextureDesc = FPooledRenderTargetDesc();
|
|
VisualizeTextureDesc.DebugName = TEXT("VisualizeTexture");
|
|
|
|
ObservedDebugNameReusedCurrent = 0;
|
|
|
|
// only needed for VisualizeTexture (todo: optimize out when possible)
|
|
{
|
|
for (TMap<const TCHAR*, uint32>:: TIterator It(VisualizeTextureCheckpoints); It; ++It)
|
|
{
|
|
uint32& Value = It.Value();
|
|
|
|
// 0 as it was not used this frame yet
|
|
Value = 0;
|
|
}
|
|
}
|
|
#endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
|
|
}
|
|
|
|
void FVisualizeTexture::QueryInfo( FQueryVisualizeTexureInfo& Out )
|
|
{
|
|
for(uint32 i = 0, Num = GRenderTargetPool.GetElementCount(); i < Num; ++i)
|
|
{
|
|
FPooledRenderTarget* RT = GRenderTargetPool.GetElementById(i);
|
|
|
|
if(!RT)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
FPooledRenderTargetDesc Desc = RT->GetDesc();
|
|
uint32 SizeInKB = (RT->ComputeMemorySize() + 1023) / 1024;
|
|
FString Entry = FString::Printf(TEXT("%s %d %s %d"),
|
|
*Desc.GenerateInfoString(),
|
|
i + 1,
|
|
Desc.DebugName ? Desc.DebugName : TEXT("<Unnamed>"),
|
|
SizeInKB);
|
|
Out.Entries.Add(Entry);
|
|
}
|
|
}
|