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 ========================== Change 3358140 on 2017/03/22 by Rolando.Caloca DR - Fix copy to cube face - Compile fix when using dump layer - Add new error enum Change 3358301 on 2017/03/22 by Mitchell.Wilson Initial check in of LODs in InfiltratorForward. First pass on optimization in level. Adding a visibility track for SceneCapture2D in tunnel section. Change 3358477 on 2017/03/22 by Mitchell.Wilson Updating Skeletal Mesh DPW_Robot_Export to resolve screen size being too low for LOD1. Cleaned up LOD1 which was showing some visible popping when transitioning. Change 3358529 on 2017/03/22 by Mark.Satterthwaite Globally disable clang's "constant-logical-operand" warning when running under Distcc - it is much easier and less invasive than constantly fixing the code. Change 3358745 on 2017/03/22 by Mark.Satterthwaite Disable another warning (parentheses-equality) under Distcc because again the separation of preprocessing from compilation means it turns up where it isn't expected. Change 3358837 on 2017/03/22 by Joe.Graf Merge of pull request #3214 for the RenderDocPlugin #CodeReview: matt.kuhlenschmidt, marcus.wassmer #rb: marcus.wassmer Change 3359112 on 2017/03/22 by Ben.Salem Update perf monitor to include frame time by default. Also, use only game/PIE world timers when in editor, instead of all worlds combined. #tests Ran several Showdown test runs with plugin! Change 3359363 on 2017/03/22 by Joe.Graf First pass at non-unity & no pch compilation Change 3359449 on 2017/03/22 by Joe.Graf Added missing null check when exporting a EXR on Linux (UE-40268) #CodeReview: dmitry.rekman #rb: n/a Change 3360349 on 2017/03/23 by Guillaume.Abadie Fixes TAA's AA_FORCE_ALPHA_CLAMP causing DOF layouts. #jira UE-42920 Change 3360405 on 2017/03/23 by Marcus.Wassmer Better method for detecting Kepler Change 3360718 on 2017/03/23 by Daniel.Wright Planar reflections handle views smaller than the render target in a general way * Fixes planar reflections with adaptive pixel density (ViewFamily size larger than actual views combined) * Planar reflections are now supported in splitscreen Change 3360758 on 2017/03/23 by Daniel.Wright [Copy] Added new light property bCastVolumetricShadow, which defaults to true for directional and sky lights, but false for point / spot lights as supporting volumetric fog shadowing has significant GPU overhead Change 3360762 on 2017/03/23 by Daniel.Wright [Copy] Texture flags are now properly routed to RHICreateTexture3D from the render target pool Change 3360768 on 2017/03/23 by Daniel.Wright [Copy] Disabled GPUProfiler histogram by default, controlled by r.ProfileGPU.ShowEventHistogram Change 3360770 on 2017/03/23 by Daniel.Wright [Copy] Disabled fast clears on CustomDepth, saves .2ms on xbox Change 3360771 on 2017/03/23 by Daniel.Wright [Copy] Particle lights no longer force tiled deferred lighting. Tiled deferred lighting is only used if enough unshadowed lights + particle lights are on screen. Saves 1.5ms Xbox with one particle light. Change 3360774 on 2017/03/23 by Daniel.Wright [Copy] Distance field cvar comments Change 3360782 on 2017/03/23 by Daniel.Wright [Copy] Disabled selection color on Volume materials Change 3360795 on 2017/03/23 by Daniel.Wright [Copy] Volume materials now specify Albedo and Extinction, which is more intuitive than Scattering and Absorption. Albedo is [0-1] reflectance, while Extinction is a world space density. Change 3360799 on 2017/03/23 by Daniel.Wright [Copy] Cinematic scalability levels get 2x volumetric fog resolution in x and y Change 3360806 on 2017/03/23 by Daniel.Wright [Copy] Fixed volumetric fog being offset when viewport min is not 0 Change 3360809 on 2017/03/23 by Daniel.Wright [Copy] Volumetric fog now adds a bias to the inverse squared light falloff denominator, prevents extreme aliasing from the hotspot. Can be controlled with r.VolumetricFog.InverseSquaredLightDistanceBiasScale. Change 3361651 on 2017/03/23 by Brian.Karis Higher quality sharp SSR at quality 4 Change 3361678 on 2017/03/23 by Brian.Karis Fresnel darkens diffuse for clearcoat. Change 3361683 on 2017/03/23 by Brian.Karis Fixed SSR artifact Change 3361691 on 2017/03/23 by Brian.Karis Chagned min roughness limit Change 3361707 on 2017/03/23 by Brian.Karis Added inverse film tone map Change 3361726 on 2017/03/23 by Brian.Karis Better precision inverse Change 3361758 on 2017/03/23 by Brian.Karis Material flag normal curvature to roughness is no longer forward only. Change 3361765 on 2017/03/23 by Brian.Karis Update ACES Change 3361774 on 2017/03/23 by Brian.Karis Cleaned up alpha support and disabled screen edge clipping. Change 3362478 on 2017/03/24 by Guillaume.Abadie Cherry pick 3316084's PostProcessing.cpp: Fixes a bug in Circle DOF where the apply pass was no longer using the downres DOF's TAA output. #author Brian.Karis #jira UE-42920 Change 3362738 on 2017/03/24 by Rolando.Caloca DR - Hide scene capture on IF Change 3362890 on 2017/03/24 by Guillaume.Abadie Renames r.SceneAlpha to r.PostProcessing.PropagateAlpha Change 3363665 on 2017/03/24 by Mark.Satterthwaite PR #3414: Add command line option "-noheartbeatthread" to disable heart beat thread (Contributed by JeffRous) Change 3363866 on 2017/03/24 by Arne.Schober DR - Updated NVAPI #RB Marcus.Wassmer Change 3364300 on 2017/03/24 by Brian.Karis SSR use dynamic velocity Change 3364372 on 2017/03/24 by Brian.Karis Fix changing off axis projection velocities. Change 3364373 on 2017/03/24 by Brian.Karis Enabled velocity drawing in scene captures Change 3365531 on 2017/03/27 by Guillaume.Abadie Computes the material's screen position material expression directly from the pixel shader SvPosition Change 3365764 on 2017/03/27 by Chris.Bunner Lowering severity of crash for missing values in scalability.ini. #jira UE-41331 Change 3365916 on 2017/03/27 by Guillaume.Abadie Exposes the viewport offset within the view property material expression Change 3365979 on 2017/03/27 by Brian.Karis Fixed skylight intensity from double applying Change 3365987 on 2017/03/27 by Brian.Karis Stopped post process indirect lighting intensity from scaling skylight reflections Change 3365991 on 2017/03/27 by Brian.Karis Fix for static analysis Change 3366028 on 2017/03/27 by Daniel.Wright Volumetric fog supports static shadowing from Stationary lights * Using bilinear on static shadowmap depths + 1 PCF to smooth out results Change 3366029 on 2017/03/27 by Daniel.Wright Static shadow depth maps for Stationary point and spot lights are 2x higher res by default (4x more texels), which is more appropriate for volumetric fog Change 3366055 on 2017/03/27 by Guillaume.Abadie Cherry picks 3251469: Implements scene capture component's CaptureSortPriority to control GPU execution order in order to manage inter dependencies. Change 3366447 on 2017/03/27 by Simon.Tourangeau Fix IES light profile importer. - Bug in the LM-63-1986 format importer. Change3366836on 2017/03/27 by Brian.Karis ClearUAV now supports int types Change 3367435 on 2017/03/28 by Benjamin.Hyder Submitting Decal Automation map for initial approval Change 3367572 on 2017/03/28 by Chris.Bunner Changed ClampedPow {max(abs(x),0.00001)} to PositiveClampedPow {max(x,0)} to give more expected results to Power node in material graphs. #jira UE-42989 Change 3367756 on 2017/03/28 by Olaf.Piesche Niagara material usage flags Change 3367835 on 2017/03/28 by Marcus.Wassmer Fix crash when TileRenderer runs before anything else. Make explicit behavior when rendering at a time when there is no valid scene. Change 3367837 on 2017/03/28 by Marcus.Wassmer Missed a file. Change 3367838 on 2017/03/28 by Richard.Wallis Updated items from original shelved version by Mark Satt: - Added MetalBackend.cpp to change main function string to have an initial crc + code length zero's **Description below taken from Mark Satt's original verison of this in CL3343280** Updated for Dev-Rendering's PSOs & integrates Richard's work on RHI shader libraries. Replace the FShaderCache's cook-time binary shader cache with Dmitriy Dyomin's standalone FShaderCodeLibrary that saves all shader byte-code arrays to files named by the FSHAHash. This de-duplicates shaders so we only ever store the byte code once. Includes optional support for generating a platform specific library file - which Metal implements to provide a single Metal library. The platform-native implementation can perform more de-duplication and in the case of Metal has lower file overheads and will compress more efficiently. - All of the support code for the FShaderCache's cook caching is gone, which affects all platforms. The FShaderCodeLibrary is currently supported by Cook-By-The-Book but can be used with iterate or child cookers - only DLC cooking requires further work. - With further modifications it should be possible to support Cook-on-the-Fly as well (output directories would be needed in FShaderCodeLibrary::InitForCooking) and the file-access pattern should be changed to use async. IO so that Material loading is not considered complete until all required byte-code arrays are loaded into the FShaderCodeLibrary. - For Metal archiving shaders this way will compile with debug information and the FShaderCodeLibrary, with some help from extensions to IShaderFormat, will save the debug information out into separate files during cooking - these can then be used to debug the game without having to locally recompile, recook & repackage but the shipped byte-code is stripped. Global shader caches are also subject to de-duplication in the library in order to support Metal's shader stripping. - File Move operations need to respect the 'Replace' flag - for FShaderCodeLibrary to work we need Move to be atomic. - This bumps the object version and will cause all content to recook. - Native library support is optional - only Metal currently implements one, but so could Vulkan and D3D12. For Metal the big advantages are further de-duplication where different materials generate the same MetalSL text but a different FSHAHash, that the single Metal library has lower overhead and that as a single file it all compresses far better (esp. with LZMA - 5x smaller). Change 3367854 on 2017/03/28 by Mark.Satterthwaite Don't track or record draw call resources for non-OpenGL shader platforms in the shader-cache as it is unnecessary and makes it slower on the CPU than it needs to be. Change 3367877 on 2017/03/28 by Brian.Karis Fixed linux build hopefully Change 3368001 on 2017/03/28 by Mark.Satterthwaite Compile fixes from Richard's checkin caused by not having visibility to all platforms from my original shelves. Change 3368019 on 2017/03/28 by Mark.Satterthwaite And another fix for Windows compilation of MetalShaderFormat. Change 3368042 on 2017/03/28 by Mark.Satterthwaite And a couple of simpler MSVC errors. Change 3368271 on 2017/03/28 by Mark.Satterthwaite Make SceneRenderTargets compile again. Change 3368691 on 2017/03/28 by Daniel.Wright [Copy from BenW] Renamed r.Shadow.MaxCSMShadowResolution to r.Shadow.MaxCSMResolution to match scalability inis Change 3369689 on 2017/03/29 by Marcus.Wassmer Fix non editor compile for now Change 3369862 on 2017/03/29 by Marcus.Wassmer Get the rest of the things compiling again. Change 3369896 on 2017/03/29 by Chris.Bunner Enabling AMD HDR support by default. #jira UE-42113 Change 3370535 on 2017/03/29 by Marcus.Wassmer DR - Fix template explicit instantiation for ClearUAV permutations #RB Brian.Karis, Arne.Schober Change 3370704 on 2017/03/29 by Rolando.Caloca DR - Rewrote GPU Skin Cache - Per section buffers - Limited memory per non-editor worlds (control with r.SkinCache.SceneMemoryLimitInMB) Copied from 3370529 Change 3371389 on 2017/03/30 by Richard.Wallis Remove temp working directories after archive packages built. Change 3371641 on 2017/03/30 by Rolando.Caloca DR - Copy 3371640 (fix mem leak) Change 3372436 on 2017/03/30 by Uriel.Doyon Added flags in UPrimitiveComponent to keep track of its state in the streaming manager. This allows to avoid unnecessary callback and processing in begin destroy reattach and being destroy logic. Removed the limitation of only processing UMeshComponent when handling spawed primitive. This releases the level manager from having to manage dynamic primitives. This improves performance by not having to manage dynamic references in the level manager. Primitives managed as dynamic now have a callback when ever their proxy is udpated, handling many cases automatically where previously a manual callback to notify would have been required. Fixed an issue where primitives with no reference to streaming textures would loose they dynamic state because of lack of references in the streamer. Change 3372740 on 2017/03/30 by Chris.Bunner [Experimental] Partial compute post process pipeline (r.PostProcess.PreferCompute). StencilSceneTexture added to deferred list. A few known issues to be fixed in a follow-up CL. Change 3372765 on 2017/03/30 by Uriel.Doyon Disabled concurrent call to NotifyPrimitiveUpdated while we don't have a safe concurrent update Change 3372979 on 2017/03/30 by Richard.Hinckley #jira UE-43501 The stencil buffer can now use single-channel bitmasks that ignore depth. This makes it possible to detect overlaps between stencil objects. Change 3373053 on 2017/03/30 by Simon.Tourangeau LPV Fade support - mostly integrated from CL 2959511 Change3373272on 2017/03/30 by Uriel.Doyon Added support for the concurrent update of dynamic primitives by the streaming manager. Change 3373450 on 2017/03/30 by Rolando.Caloca DR - FNT - Fix bad data for odd texcoord channels used on skin cache passthrough factory Copy 3373364 #jira UE-43492 Change 3373470 on 2017/03/30 by Marcus.Wassmer Nvidia Aftermath support Change 3374187 on 2017/03/31 by Chris.Bunner Volume texture support for CombineLUTs/Tonemap compute pass. Refactored common param code to shared sub-class in CombineLUTs and Tonemap PS/CS. Skip compute post process out-of-bounds writes. Unsigned type conversion fixes. Trimmed compute post process shader inputs. Change 3374233 on 2017/03/31 by Chris.Bunner Removed several redundant post process compute fences and resource transitions. Added testing CVar to force compute post processes to async (r.PostProcess.ForceAsyncDispatch). Change 3374412 on 2017/03/31 by Rolando.Caloca DR - Fix static analysis Change 3374544 on 2017/03/31 by Richard.Wallis FShaderCache Parallel-Context-Aware Merged with FShaderCache Single Library. Future Work - This was done before Engine PSO were in so this now needs a refector in the recording and playback on pipeline states instead an emulate PSO in OpenGL Driver. - Remove FShaderCacheState and replace the logic with FGraphicsPipelineStateInitializer which should be able to record from the RHI current pipeline state - This would reduce the Locking required as it's naturally per thread/context and only the final record would need a lock Change 3374588 on 2017/03/31 by Richard.Wallis Windows Compile Fixes Change 3374810 on 2017/03/31 by Benjamin.Hyder updating recommended GPU drivers Change 3375207 on 2017/03/31 by Rolando.Caloca DR - vk - Fixed swapchain format selection for some Linux platforms Change 3375248 on 2017/03/31 by Rolando.Caloca DR - vk - Prefer D32S8 Change 3375495 on 2017/03/31 by Rolando.Caloca DR - vk - Update to sdk 1.0.42.2 Change 3375496 on 2017/03/31 by Rolando.Caloca DR - Force compiling with updated Vulkan SDK Change 3375636 on 2017/03/31 by Mark.Satterthwaite Copying Metal improvements from task stream, with some modifications: - Off-by-default implementations for MTLFence & MTLHeap, including some small changes to the RHI interface for parallel contexts. - Support for Apple's Instruments "Points of Interest" tool. - Consolidation of some Mac & iOS compiler, memory and thread handling code. - Fixes for Metal not having implicit buffer SRV typecasting for DistanceField effects. - Improvements to the internal FMetalDebug layer, still off by default. - Limited support for Xcode automatic code-signing for iOS/tvOS. - Minimisation of render-target changes in some rendering code, esp. SceneOcclusion, DBufferDecals. - Added RHISetResourceAliasability_RenderThread to FDynamicRHI for RHIs to implement simple render-target aliasing. - Added FApplePlatformObject, a custom block allocator for Objective-C types (with NSZombie support) which is now used in MetalRHI to decrease allocation costs of Objective-C types. - Smattering of lesser fixes. Change 3375654 on 2017/03/31 by Mark.Satterthwaite Incremental Windows build fix. Change 3375656 on 2017/04/01 by Mark.Satterthwaite Correct extern declaration, including the module export macro which Mac unhelpfully doesn't enforce (for now...). Change 3375797 on 2017/04/01 by Mark.Satterthwaite Nullability qualifiers to fix Mac build-farm compilation: perversely this is not a problem for local builds... Change 3375798 on 2017/04/01 by Mark.Satterthwaite Fix the first mis-merge in ParticleGpuSimulation - these changes clearly weren't properly resolved in the task-stream. Change 3375835 on 2017/04/01 by Mark.Satterthwaite Try again with nullability and fix the occlusion changes as the PSO work wasn't merged correctly. Change 3376143 on 2017/04/02 by Mark.Satterthwaite Switch back to flat dSYMs for Dev-Rendering - they don't work with Instruments etc. but they are required by our build system. Change 3376324 on 2017/04/03 by Chris.Bunner Fixed cvar re-registration log spam and flagged a testing-only cvar as such. Change 3376726 on 2017/04/03 by Benjamin.Hyder Submitting initial HDR test map (WIP) Change 3376756 on 2017/04/03 by Guillaume.Abadie Fixes scene captures ordering's backward compatibility. Before, 2d scene captures were rendered before cube scene captures. The CaptureSortPriority broke backward compatibility by settings this new member to 0 in the USceneCaptureComponent's constructor. Since it is a higher come first policy, this CL set the default of this value to 1 in USceneCaptureComponent2D's constructor. Change 3377378 on 2017/04/03 by Arne.Schober DR - Fix ShaderRecompiling over and over again #RB Chris.Bunner Change 3377512 on 2017/04/03 by Daniel.Wright [Copy] Fixed profilegpu in d3d12 - initialize FLongGPUTaskPS when it is safe to do so, and fixed FSlateRHIRenderer's incorrect usage of draw events Change 3377518 on 2017/04/03 by Daniel.Wright [Copy] Distance field atlas coalesces updates to reduce RHIUpdateTexture3D memory overhead on d3d12 Change 3377526 on 2017/04/03 by Daniel.Wright [Copy] "Ran out of GPU queries!" log only happens once Change 3377535 on 2017/04/03 by Daniel.Wright [Copy] Fixed unreferenced local variable Change 3377539 on 2017/04/03 by Daniel.Wright [Copy] Xbox One RHIGetResourceInfo takes ESRAM into account - fixes render target pool 'VRamInKB request failed' messages Change 3377546 on 2017/04/03 by Daniel.Wright [Copy] Added r.LightMaxDrawDistanceScale for local light scalability Change 3377553 on 2017/04/03 by Daniel.Wright [Copy] Removed NEW_ESRAM_ALLOCATOR define and old unused path Change 3377560 on 2017/04/03 by Daniel.Wright [Copy] Fixed two d3d12 refcounting bugs causing -norhithread crashes Change 3377565 on 2017/04/03 by Daniel.Wright [Copy] Fixed Xbox One deleting GPU resources before the GPU is done reading from them (GRHINeedsExtraDeletionLatency was false) Change 3377572 on 2017/04/03 by Daniel.Wright [Copy] Disabled point / spot lights with MaxDrawDistance on LowPC Change 3377586 on 2017/04/03 by Daniel.Wright Fixed compile error Change 3377699 on 2017/04/03 by David.Hill FFT Code. Moved over from raven and refactored #review-3374589 @guillaume.abadie Change 3377910 on 2017/04/03 by David.Hill GPU FFT: Fix Linux Build adding a missing template<> to an IMPLEMENT_SHADER_TYPE Change 3378751 on 2017/04/04 by Marcus.Wassmer HQ particle lights now spawn attached to the same socket as their parent module. Change 3378819 on 2017/04/04 by Richard.Wallis Should be no need to protect shader cache against RHI thread now. Change 3378823 on 2017/04/04 by Richard.Wallis FRHIShaderLibrary Opaque Type - Base FRHIShaderLibrary has no Create*Shader functions and is passed to Overloaded RHICreate*Shader functions instead of creation directly through the library. - Assumed that only Native libraries will end up in the RHICreate*Shader functions. - ShaderCache and ShaderCode Libraries now inherit from a common factory interface. Change 3378883 on 2017/04/04 by Arne.Schober DR - Fix DCC build Change 3378885 on 2017/04/04 by Richard.Wallis Metal resource cast compile fix post merge. Change 3378946 on 2017/04/04 by Chris.Bunner SM4 assert fix. Change 3378953 on 2017/04/04 by Chris.Bunner Fixed type-correctness on legacy BreakMA material nodes and set more flexible formats to global attributes which should result in much more forgiving graphs for users. Allowed material nodes to opt out of mask-based pin coloration. #tests Compiled most Paragon materials + QAGame test maps. #jira UE-39885 Change 3379189 on 2017/04/04 by Arne.Schober DR - Fix aftermath staging Change 3379229 on 2017/04/04 by Arne.Schober DR - Fix missing include Change 3379374 on 2017/04/04 by Mark.Satterthwaite Revert an accidentally merged change in MacPlatformProcess that relies on further changes from the Metal task stream. Change 3379505 on 2017/04/04 by Rolando.Caloca DR - Fix mismatched interpolators Change 3379539 on 2017/04/04 by Mark.Satterthwaite No FFT for any hlslcc platform - the IR for one or more RWTexture2D isn't quite right... #jira UE-43626 Change 3379561 on 2017/04/04 by Rolando.Caloca DR - Fix root signature issues on D3D12 PC Change 3379590 on 2017/04/04 by Mark.Satterthwaite Back out changelist 3379539 & change the shader slightly instead, the HLSLCC library generates bogus IR when you have an inout RWTexture. #jira UE-43626 Change 3379917 on 2017/04/04 by Uriel.Doyon Fix to input mismatch Change 3380578 on 2017/04/05 by Chris.Bunner Shader type fixes. #jira UE-43652 Change 3380639 on 2017/04/05 by Rolando.Caloca DR - Expose GetOrCreate PSO and document Change 3380821 on 2017/04/05 by Guillaume.Abadie Fixes a crash in USceneCaptureComponent::UpdateDeferredCaptures() #jira UE-43642 Change 3381092 on 2017/04/05 by Guillaume.Abadie Cherry pick 3362517: Implements TAA's scene color unpremultiplication from alpha channel to reduce DOF alpha channel temporal ghosting. This CL take the oportunity to transform AA_ALPHA to an compile time enumeration, and add a basic TAA compile time configuration validation to improve readability of the different TAA passes' configurations. Change 3381300 on 2017/04/05 by Mark.Satterthwaite Quick fix for changes to MetalRHI's render-thread safe texture creation not correctly handling AVFoundation video player handing us an IOSurface. #jira UE-43597 Change3381359on 2017/04/05 by Guillaume.Abadie Back out changelist 3381092 Change 3381421 on 2017/04/05 by Mark.Satterthwaite Amended CL #3380995 from Richard Wallis to address crash in the Material Editor under the validation layer - when there are no textures bound the default pass descriptor assigns store actions, which means we can't override them with our deferred store actions. #jira UE-43689 Change 3381422 on 2017/04/05 by Mark.Satterthwaite Absolute time queries can't be batched in Metal but I also can't rely on them being started with a call to BeginQuery - only EndQuery. #jira UE-43691 Change3381503on 2017/04/05 by Daniel.Wright More intuitive controls for Volumetric Fog * Removed ScatteringScale / AbsorptionScale on Exponential Height Fog and added Albedo / Extinction * InscatteringColorCubemap is now supported by Volumetric Fog * Particle lights have a default VolumetricScatteringIntensity of 0 to avoid trailing * Tweaked GVolumetricFogDepthDistributionScale better for nearby details * Volume Materials have twice the interpolators available Change 3381527 on 2017/04/05 by Mark.Satterthwaite Disable Private GPU storage for PVRTC texture formats on iOS Metal - these require more changes to the blit-encoder usage as PVRTC has strange requirements. Change 3381671 on 2017/04/05 by Mark.Satterthwaite Better error message for failure to compile shaders remotely from PC for Metal. Change 3381769 on 2017/04/05 by Rolando.Caloca DR - Added lock texture array 2d on Vulkan Change 3382003 on 2017/04/05 by Mark.Satterthwaite Remove the automatic Metal aliasing/re-use when releasing some resource types as it doesn't work as intended. Change 3382030 on 2017/04/05 by Zachary.Wilson Fix compiling Metal text shaders from PC broken in merge from task stream. #submitter mark.satterthwaite #jira UE-43652 Change 3382880 on 2017/04/06 by Mark.Satterthwaite Michael Trepka's CL #3379927: VolumetricFogVoxelization implementation for Mac Change 3383315 on 2017/04/06 by Mark.Satterthwaite Partially revert CL #3382003 - the emulated Metal heaps require invoking makeAliasable in order to reclaim memory. #jira UE-43739 Change 3384639 on 2017/04/07 by Marcus.Wassmer Move ShaderResource version bump to RenderingObjectVersion Change 3384704 on 2017/04/07 by Mark.Satterthwaite Compile fix for merge. Change 3384933 on 2017/04/07 by Rolando.Caloca DR - Fix skin cache crash with BP (copy 3384714) Change 3385104 on 2017/04/07 by Mark.Satterthwaite Fix MetalRHI's abs(int2) handling - it can't be translated to fabs(int2) as that won't compile. Also rebuild hlslcc for my sanity. #jira UE-43783 Change 3385105 on 2017/04/07 by Mark.Satterthwaite Force a shader rebuild to ensure that everybody picks up the fix for #jira UE-43783 #jira UE-43783 Change 3385118 on 2017/04/07 by Arne.Schober DR - [OR-37359] - Fix disapearing Decals when StencilLod Fade is enabled #RB none Change 3385149 on 2017/04/07 by Marcus.Wassmer Fix skincache motion blur Change 3385189 on 2017/04/07 by Rolando.Caloca DR - Fix swapchain format for editor on Vulkan Change 3385287 on 2017/04/07 by Mark.Satterthwaite Enable SM5 on Intel as of 10.12.4 and later. Change 3385347 on 2017/04/07 by Rolando.Caloca DR - Temp fix for GL4 corruption on editor #jira UE-43785 Change 3385363 on 2017/04/07 by Rolando.Caloca DR - Actually fix all win platforms for GL bug #jira UE-43785 Change 3385557 on 2017/04/07 by Arne.Schober DR - [UE-43205] - Fix mesh paint #RB none Change3385608on 2017/04/07 by Daniel.Wright Fixed SampleCmp being used on a non-depth texture, causing a d3d error Change 3385980 on 2017/04/10 by Rolando.Caloca DR - Remove transition functions RHIClearColor* RHIClearDepthStencilTexture Change 3386042 on 2017/04/10 by Rolando.Caloca DR - Fix metal merge issue Change 3386157 on 2017/04/10 by Rolando.Caloca DR - Remove VS2013 libs generation off hlslcc & glslang (to match main) Change 3386356 on 2017/04/10 by Chris.Bunner Resolving merge errors. Change 3386414 on 2017/04/10 by Chris.Bunner Resolved merge issue in RendererScene.cpp. Change 3386700 on 2017/04/10 by Mark.Satterthwaite Silence documentation warnings. Change 3387178 on 2017/04/10 by Chris.Bunner Removed invalid mask correction on MakeMA material nodes. Change 3388177 on 2017/04/11 by Marcus.Wassmer Disable ensure that is no longer relevant now that we bind clear colors on texture creation Change 3388261 on 2017/04/11 by Chris.Bunner Static analysis fix. [CL3388266by Chris Bunner in Main branch]
1368 lines
51 KiB
C++
1368 lines
51 KiB
C++
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
DepthRendering.cpp: Depth rendering implementation.
|
|
=============================================================================*/
|
|
|
|
#include "DepthRendering.h"
|
|
#include "RendererInterface.h"
|
|
#include "StaticBoundShaderState.h"
|
|
#include "SceneUtils.h"
|
|
#include "EngineGlobals.h"
|
|
#include "Materials/Material.h"
|
|
#include "PostProcess/SceneRenderTargets.h"
|
|
#include "GlobalShader.h"
|
|
#include "MaterialShaderType.h"
|
|
#include "MeshMaterialShaderType.h"
|
|
#include "MeshMaterialShader.h"
|
|
#include "ShaderBaseClasses.h"
|
|
#include "SceneRendering.h"
|
|
#include "StaticMeshDrawList.h"
|
|
#include "DeferredShadingRenderer.h"
|
|
#include "ScenePrivate.h"
|
|
#include "OneColorShader.h"
|
|
#include "IHeadMountedDisplay.h"
|
|
#include "ScreenRendering.h"
|
|
#include "PostProcess/SceneFilterRendering.h"
|
|
#include "DynamicPrimitiveDrawing.h"
|
|
#include "PipelineStateCache.h"
|
|
#include "ClearQuad.h"
|
|
#include "GPUSkinCache.h"
|
|
|
|
static TAutoConsoleVariable<int32> CVarRHICmdPrePassDeferredContexts(
|
|
TEXT("r.RHICmdPrePassDeferredContexts"),
|
|
1,
|
|
TEXT("True to use deferred contexts to parallelize prepass command list execution."));
|
|
static TAutoConsoleVariable<int32> CVarParallelPrePass(
|
|
TEXT("r.ParallelPrePass"),
|
|
1,
|
|
TEXT("Toggles parallel zprepass rendering. Parallel rendering must be enabled for this to have an effect."),
|
|
ECVF_RenderThreadSafe
|
|
);
|
|
static TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasksPrePass(
|
|
TEXT("r.RHICmdFlushRenderThreadTasksPrePass"),
|
|
0,
|
|
TEXT("Wait for completion of parallel render thread tasks at the end of the pre pass. A more granular version of r.RHICmdFlushRenderThreadTasks. If either r.RHICmdFlushRenderThreadTasks or r.RHICmdFlushRenderThreadTasksPrePass is > 0 we will flush."));
|
|
|
|
const TCHAR* GetDepthDrawingModeString(EDepthDrawingMode Mode)
|
|
{
|
|
switch (Mode)
|
|
{
|
|
case DDM_None:
|
|
return TEXT("DDM_None");
|
|
case DDM_NonMaskedOnly:
|
|
return TEXT("DDM_NonMaskedOnly");
|
|
case DDM_AllOccluders:
|
|
return TEXT("DDM_AllOccluders");
|
|
case DDM_AllOpaque:
|
|
return TEXT("DDM_AllOpaque");
|
|
default:
|
|
check(0);
|
|
}
|
|
|
|
return TEXT("");
|
|
}
|
|
|
|
DECLARE_FLOAT_COUNTER_STAT(TEXT("Prepass"), Stat_GPU_Prepass, STATGROUP_GPU);
|
|
|
|
/**
|
|
* A vertex shader for rendering the depth of a mesh.
|
|
*/
|
|
template <bool bUsePositionOnlyStream>
|
|
class TDepthOnlyVS : public FMeshMaterialShader
|
|
{
|
|
DECLARE_SHADER_TYPE(TDepthOnlyVS,MeshMaterial);
|
|
protected:
|
|
|
|
TDepthOnlyVS() {}
|
|
TDepthOnlyVS(const FMeshMaterialShaderType::CompiledShaderInitializerType& Initializer) :
|
|
FMeshMaterialShader(Initializer)
|
|
{
|
|
InstancedEyeIndexParameter.Bind(Initializer.ParameterMap, TEXT("InstancedEyeIndex"));
|
|
IsInstancedStereoParameter.Bind(Initializer.ParameterMap, TEXT("bIsInstancedStereo"));
|
|
IsInstancedStereoEmulatedParameter.Bind(Initializer.ParameterMap, TEXT("bIsInstancedStereoEmulated"));
|
|
}
|
|
|
|
private:
|
|
|
|
FShaderParameter InstancedEyeIndexParameter;
|
|
FShaderParameter IsInstancedStereoParameter;
|
|
FShaderParameter IsInstancedStereoEmulatedParameter;
|
|
|
|
public:
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform,const FMaterial* Material,const FVertexFactoryType* VertexFactoryType)
|
|
{
|
|
// Only the local vertex factory supports the position-only stream
|
|
if (bUsePositionOnlyStream)
|
|
{
|
|
return VertexFactoryType->SupportsPositionOnly() && Material->IsSpecialEngineMaterial();
|
|
}
|
|
|
|
// Only compile for the default material and masked materials
|
|
return (Material->IsSpecialEngineMaterial() || !Material->WritesEveryPixel() || Material->MaterialMayModifyMeshPosition() || Material->IsTranslucencyWritingCustomDepth());
|
|
}
|
|
|
|
virtual bool Serialize(FArchive& Ar) override
|
|
{
|
|
const bool result = FMeshMaterialShader::Serialize(Ar);
|
|
Ar << InstancedEyeIndexParameter;
|
|
Ar << IsInstancedStereoParameter;
|
|
Ar << IsInstancedStereoEmulatedParameter;
|
|
return result;
|
|
}
|
|
|
|
void SetParameters(
|
|
FRHICommandList& RHICmdList,
|
|
const FMaterialRenderProxy* MaterialRenderProxy,
|
|
const FMaterial& MaterialResource,
|
|
const FSceneView& View,
|
|
const TUniformBufferRef<FViewUniformShaderParameters>& ViewUniformBuffer,
|
|
const bool bIsInstancedStereo,
|
|
const bool bIsInstancedStereoEmulated
|
|
)
|
|
{
|
|
FMeshMaterialShader::SetParameters(RHICmdList, GetVertexShader(),MaterialRenderProxy,MaterialResource,View,ViewUniformBuffer,ESceneRenderTargetsMode::DontSet);
|
|
|
|
if (IsInstancedStereoParameter.IsBound())
|
|
{
|
|
SetShaderValue(RHICmdList, GetVertexShader(), IsInstancedStereoParameter, bIsInstancedStereo);
|
|
}
|
|
|
|
if (IsInstancedStereoEmulatedParameter.IsBound())
|
|
{
|
|
SetShaderValue(RHICmdList, GetVertexShader(), IsInstancedStereoEmulatedParameter, bIsInstancedStereoEmulated);
|
|
}
|
|
|
|
if (InstancedEyeIndexParameter.IsBound())
|
|
{
|
|
SetShaderValue(RHICmdList, GetVertexShader(), InstancedEyeIndexParameter, 0);
|
|
}
|
|
}
|
|
|
|
void SetMesh(FRHICommandList& RHICmdList, const FVertexFactory* VertexFactory,const FSceneView& View,const FPrimitiveSceneProxy* Proxy,const FMeshBatchElement& BatchElement,const FDrawingPolicyRenderState& DrawRenderState)
|
|
{
|
|
FMeshMaterialShader::SetMesh(RHICmdList, GetVertexShader(),VertexFactory,View,Proxy,BatchElement,DrawRenderState);
|
|
}
|
|
|
|
void SetInstancedEyeIndex(FRHICommandList& RHICmdList, const uint32 EyeIndex)
|
|
{
|
|
if (EyeIndex > 0 && InstancedEyeIndexParameter.IsBound())
|
|
{
|
|
SetShaderValue(RHICmdList, GetVertexShader(), InstancedEyeIndexParameter, EyeIndex);
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Hull shader for depth rendering
|
|
*/
|
|
class FDepthOnlyHS : public FBaseHS
|
|
{
|
|
DECLARE_SHADER_TYPE(FDepthOnlyHS,MeshMaterial);
|
|
public:
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform,const FMaterial* Material,const FVertexFactoryType* VertexFactoryType)
|
|
{
|
|
return FBaseHS::ShouldCache(Platform, Material, VertexFactoryType)
|
|
&& TDepthOnlyVS<false>::ShouldCache(Platform,Material,VertexFactoryType);
|
|
}
|
|
|
|
FDepthOnlyHS(const ShaderMetaType::CompiledShaderInitializerType& Initializer):
|
|
FBaseHS(Initializer)
|
|
{}
|
|
|
|
FDepthOnlyHS() {}
|
|
};
|
|
|
|
/**
|
|
* Domain shader for depth rendering
|
|
*/
|
|
class FDepthOnlyDS : public FBaseDS
|
|
{
|
|
DECLARE_SHADER_TYPE(FDepthOnlyDS,MeshMaterial);
|
|
public:
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform,const FMaterial* Material,const FVertexFactoryType* VertexFactoryType)
|
|
{
|
|
return FBaseDS::ShouldCache(Platform, Material, VertexFactoryType)
|
|
&& TDepthOnlyVS<false>::ShouldCache(Platform,Material,VertexFactoryType);
|
|
}
|
|
|
|
FDepthOnlyDS(const ShaderMetaType::CompiledShaderInitializerType& Initializer):
|
|
FBaseDS(Initializer)
|
|
{}
|
|
|
|
FDepthOnlyDS() {}
|
|
};
|
|
|
|
IMPLEMENT_MATERIAL_SHADER_TYPE(template<>,TDepthOnlyVS<true>,TEXT("PositionOnlyDepthVertexShader"),TEXT("Main"),SF_Vertex);
|
|
IMPLEMENT_MATERIAL_SHADER_TYPE(template<>,TDepthOnlyVS<false>,TEXT("DepthOnlyVertexShader"),TEXT("Main"),SF_Vertex);
|
|
IMPLEMENT_MATERIAL_SHADER_TYPE(,FDepthOnlyHS,TEXT("DepthOnlyVertexShader"),TEXT("MainHull"),SF_Hull);
|
|
IMPLEMENT_MATERIAL_SHADER_TYPE(,FDepthOnlyDS,TEXT("DepthOnlyVertexShader"),TEXT("MainDomain"),SF_Domain);
|
|
|
|
/**
|
|
* A pixel shader for rendering the depth of a mesh.
|
|
*/
|
|
class FDepthOnlyPS : public FMeshMaterialShader
|
|
{
|
|
DECLARE_SHADER_TYPE(FDepthOnlyPS,MeshMaterial);
|
|
public:
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform,const FMaterial* Material,const FVertexFactoryType* VertexFactoryType)
|
|
{
|
|
return
|
|
// Compile for materials that are masked.
|
|
(!Material->WritesEveryPixel() || Material->HasPixelDepthOffsetConnected() || Material->IsTranslucencyWritingCustomDepth())
|
|
// Mobile uses material pixel shader to write custom stencil to color target
|
|
|| (IsMobilePlatform(Platform) && (Material->IsDefaultMaterial() || Material->MaterialMayModifyMeshPosition()));
|
|
}
|
|
|
|
FDepthOnlyPS(const ShaderMetaType::CompiledShaderInitializerType& Initializer):
|
|
FMeshMaterialShader(Initializer)
|
|
{
|
|
ApplyDepthOffsetParameter.Bind(Initializer.ParameterMap, TEXT("bApplyDepthOffset"));
|
|
MobileColorValue.Bind(Initializer.ParameterMap, TEXT("MobileColorValue"));
|
|
}
|
|
|
|
FDepthOnlyPS() {}
|
|
|
|
void SetParameters(FRHICommandList& RHICmdList, const FMaterialRenderProxy* MaterialRenderProxy,const FMaterial& MaterialResource,const FSceneView* View, const TUniformBufferRef<FViewUniformShaderParameters>& ViewUniformBuffer, float InMobileColorValue)
|
|
{
|
|
FMeshMaterialShader::SetParameters(RHICmdList, GetPixelShader(),MaterialRenderProxy,MaterialResource,*View,ViewUniformBuffer,ESceneRenderTargetsMode::DontSet);
|
|
|
|
// For debug view shaders, don't apply the depth offset as their base pass PS are using global shaders with depth equal.
|
|
SetShaderValue(RHICmdList, GetPixelShader(), ApplyDepthOffsetParameter, !View || !View->Family->UseDebugViewPS());
|
|
SetShaderValue(RHICmdList, GetPixelShader(), MobileColorValue, InMobileColorValue);
|
|
}
|
|
|
|
void SetMesh(FRHICommandList& RHICmdList, const FVertexFactory* VertexFactory,const FSceneView& View,const FPrimitiveSceneProxy* Proxy,const FMeshBatchElement& BatchElement,const FDrawingPolicyRenderState& DrawRenderState)
|
|
{
|
|
FMeshMaterialShader::SetMesh(RHICmdList, GetPixelShader(),VertexFactory,View,Proxy,BatchElement,DrawRenderState);
|
|
}
|
|
|
|
virtual bool Serialize(FArchive& Ar) override
|
|
{
|
|
bool bShaderHasOutdatedParameters = FMeshMaterialShader::Serialize(Ar);
|
|
Ar << ApplyDepthOffsetParameter;
|
|
Ar << MobileColorValue;
|
|
return bShaderHasOutdatedParameters;
|
|
}
|
|
|
|
FShaderParameter ApplyDepthOffsetParameter;
|
|
FShaderParameter MobileColorValue;
|
|
};
|
|
|
|
IMPLEMENT_MATERIAL_SHADER_TYPE(,FDepthOnlyPS,TEXT("DepthOnlyPixelShader"),TEXT("Main"),SF_Pixel);
|
|
|
|
IMPLEMENT_SHADERPIPELINE_TYPE_VS(DepthNoPixelPipeline, TDepthOnlyVS<false>, true);
|
|
IMPLEMENT_SHADERPIPELINE_TYPE_VS(DepthPosOnlyNoPixelPipeline, TDepthOnlyVS<true>, true);
|
|
IMPLEMENT_SHADERPIPELINE_TYPE_VSPS(DepthPipeline, TDepthOnlyVS<false>, FDepthOnlyPS, true);
|
|
|
|
|
|
static FORCEINLINE bool UseShaderPipelines()
|
|
{
|
|
static const auto* CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.ShaderPipelines"));
|
|
return CVar && CVar->GetValueOnAnyThread() != 0;
|
|
}
|
|
|
|
FDepthDrawingPolicy::FDepthDrawingPolicy(
|
|
const FVertexFactory* InVertexFactory,
|
|
const FMaterialRenderProxy* InMaterialRenderProxy,
|
|
const FMaterial& InMaterialResource,
|
|
const FMeshDrawingPolicyOverrideSettings& InOverrideSettings,
|
|
ERHIFeatureLevel::Type InFeatureLevel,
|
|
float InMobileColorValue)
|
|
: FMeshDrawingPolicy(InVertexFactory, InMaterialRenderProxy, InMaterialResource, InOverrideSettings, DVSM_None)
|
|
{
|
|
const bool bUsesMobileColorValue = (InMobileColorValue != 0.0f);
|
|
MobileColorValue = InMobileColorValue;
|
|
|
|
bNeedsPixelShader = bUsesMobileColorValue || (!InMaterialResource.WritesEveryPixel() || InMaterialResource.MaterialUsesPixelDepthOffset() || InMaterialResource.IsTranslucencyWritingCustomDepth());
|
|
|
|
if (!bNeedsPixelShader)
|
|
{
|
|
PixelShader = nullptr;
|
|
}
|
|
|
|
const EMaterialTessellationMode TessellationMode = InMaterialResource.GetTessellationMode();
|
|
if (RHISupportsTessellation(GShaderPlatformForFeatureLevel[InFeatureLevel])
|
|
&& InVertexFactory->GetType()->SupportsTessellationShaders()
|
|
&& TessellationMode != MTM_NoTessellation)
|
|
{
|
|
ShaderPipeline = nullptr;
|
|
VertexShader = InMaterialResource.GetShader<TDepthOnlyVS<false> >(VertexFactory->GetType());
|
|
HullShader = InMaterialResource.GetShader<FDepthOnlyHS>(VertexFactory->GetType());
|
|
DomainShader = InMaterialResource.GetShader<FDepthOnlyDS>(VertexFactory->GetType());
|
|
if (bNeedsPixelShader)
|
|
{
|
|
PixelShader = InMaterialResource.GetShader<FDepthOnlyPS>(InVertexFactory->GetType());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
HullShader = nullptr;
|
|
DomainShader = nullptr;
|
|
bool bUseShaderPipelines = UseShaderPipelines();
|
|
if (bNeedsPixelShader)
|
|
{
|
|
ShaderPipeline = bUseShaderPipelines ? InMaterialResource.GetShaderPipeline(&DepthPipeline, InVertexFactory->GetType(), false) : nullptr;
|
|
}
|
|
else
|
|
{
|
|
ShaderPipeline = bUseShaderPipelines ? InMaterialResource.GetShaderPipeline(&DepthNoPixelPipeline, InVertexFactory->GetType(), false) : nullptr;
|
|
}
|
|
|
|
if (ShaderPipeline)
|
|
{
|
|
VertexShader = ShaderPipeline->GetShader<TDepthOnlyVS<false> >();
|
|
if (bNeedsPixelShader)
|
|
{
|
|
PixelShader = ShaderPipeline->GetShader<FDepthOnlyPS>();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
VertexShader = InMaterialResource.GetShader<TDepthOnlyVS<false> >(VertexFactory->GetType());
|
|
if (bNeedsPixelShader)
|
|
{
|
|
PixelShader = InMaterialResource.GetShader<FDepthOnlyPS>(InVertexFactory->GetType());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void ApplyDitheredLODTransitionStateInternal(FDrawingPolicyRenderState& DrawRenderState, const FViewInfo& ViewInfo, const FStaticMesh& Mesh, const bool InAllowStencilDither)
|
|
{
|
|
DrawRenderState.SetDitheredLODTransitionAlpha(0.0f);
|
|
FDepthStencilStateRHIParamRef DepthStencilState = nullptr;
|
|
uint32 StencilRef = 0;
|
|
|
|
if (InAllowStencilDither)
|
|
{
|
|
DepthStencilState = TStaticDepthStencilState<>::GetRHI();
|
|
}
|
|
|
|
if (Mesh.bDitheredLODTransition)
|
|
{
|
|
if (ViewInfo.StaticMeshFadeOutDitheredLODMap[Mesh.Id])
|
|
{
|
|
if (InAllowStencilDither)
|
|
{
|
|
DepthStencilState = TStaticDepthStencilState<true, CF_DepthNearOrEqual,
|
|
true, CF_Equal, SO_Keep, SO_Keep, SO_Keep,
|
|
false, CF_Always, SO_Keep, SO_Keep, SO_Keep,
|
|
STENCIL_SANDBOX_MASK, STENCIL_SANDBOX_MASK
|
|
>::GetRHI();
|
|
StencilRef = STENCIL_SANDBOX_MASK;
|
|
}
|
|
else
|
|
{
|
|
DrawRenderState.SetDitheredLODTransitionAlpha(ViewInfo.GetTemporalLODTransition());
|
|
}
|
|
}
|
|
else if (ViewInfo.StaticMeshFadeInDitheredLODMap[Mesh.Id])
|
|
{
|
|
if (InAllowStencilDither)
|
|
{
|
|
DepthStencilState = TStaticDepthStencilState<true, CF_DepthNearOrEqual,
|
|
true, CF_Equal, SO_Keep, SO_Keep, SO_Keep,
|
|
false, CF_Always, SO_Keep, SO_Keep, SO_Keep,
|
|
STENCIL_SANDBOX_MASK, STENCIL_SANDBOX_MASK
|
|
>::GetRHI();
|
|
}
|
|
else
|
|
{
|
|
DrawRenderState.SetDitheredLODTransitionAlpha(ViewInfo.GetTemporalLODTransition() - 1.0f);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (DepthStencilState)
|
|
{
|
|
DrawRenderState.SetDepthStencilState(DepthStencilState);
|
|
DrawRenderState.SetStencilRef(StencilRef);
|
|
}
|
|
}
|
|
|
|
void FDepthDrawingPolicy::ApplyDitheredLODTransitionState(FDrawingPolicyRenderState& DrawRenderState, const FViewInfo& ViewInfo, const FStaticMesh& Mesh, const bool InAllowStencilDither)
|
|
{
|
|
ApplyDitheredLODTransitionStateInternal(DrawRenderState, ViewInfo, Mesh, InAllowStencilDither);
|
|
}
|
|
|
|
void FPositionOnlyDepthDrawingPolicy::ApplyDitheredLODTransitionState(FDrawingPolicyRenderState& DrawRenderState, const FViewInfo& ViewInfo, const FStaticMesh& Mesh, const bool InAllowStencilDither)
|
|
{
|
|
ApplyDitheredLODTransitionStateInternal(DrawRenderState, ViewInfo, Mesh, InAllowStencilDither);
|
|
}
|
|
|
|
|
|
void FDepthDrawingPolicy::SetInstancedEyeIndex(FRHICommandList& RHICmdList, const uint32 EyeIndex) const
|
|
{
|
|
VertexShader->SetInstancedEyeIndex(RHICmdList, EyeIndex);
|
|
}
|
|
|
|
void FDepthDrawingPolicy::SetSharedState(FRHICommandList& RHICmdList, const FDrawingPolicyRenderState& DrawRenderState, const FSceneView* View, const FDepthDrawingPolicy::ContextDataType PolicyContext) const
|
|
{
|
|
// Set the depth-only shader parameters for the material.
|
|
VertexShader->SetParameters(RHICmdList, MaterialRenderProxy, *MaterialResource, *View, DrawRenderState.GetViewUniformBuffer(), PolicyContext.bIsInstancedStereo, PolicyContext.bIsInstancedStereoEmulated);
|
|
if(HullShader && DomainShader)
|
|
{
|
|
HullShader->SetParameters(RHICmdList, MaterialRenderProxy,*View);
|
|
DomainShader->SetParameters(RHICmdList, MaterialRenderProxy,*View);
|
|
}
|
|
|
|
if (bNeedsPixelShader)
|
|
{
|
|
PixelShader->SetParameters(RHICmdList, MaterialRenderProxy, *MaterialResource, View, DrawRenderState.GetViewUniformBuffer(), MobileColorValue);
|
|
}
|
|
|
|
// Set the shared mesh resources.
|
|
FMeshDrawingPolicy::SetSharedState(RHICmdList, DrawRenderState, View, PolicyContext);
|
|
}
|
|
|
|
/**
|
|
* Create bound shader state using the vertex decl from the mesh draw policy
|
|
* as well as the shaders needed to draw the mesh
|
|
* @return new bound shader state object
|
|
*/
|
|
FBoundShaderStateInput FDepthDrawingPolicy::GetBoundShaderStateInput(ERHIFeatureLevel::Type InFeatureLevel) const
|
|
{
|
|
return FBoundShaderStateInput(
|
|
FMeshDrawingPolicy::GetVertexDeclaration(),
|
|
VertexShader->GetVertexShader(),
|
|
GETSAFERHISHADER_HULL(HullShader),
|
|
GETSAFERHISHADER_DOMAIN(DomainShader),
|
|
bNeedsPixelShader ? PixelShader->GetPixelShader() : NULL,
|
|
NULL);
|
|
}
|
|
|
|
void FDepthDrawingPolicy::SetMeshRenderState(
|
|
FRHICommandList& RHICmdList,
|
|
const FSceneView& View,
|
|
const FPrimitiveSceneProxy* PrimitiveSceneProxy,
|
|
const FMeshBatch& Mesh,
|
|
int32 BatchElementIndex,
|
|
const FDrawingPolicyRenderState& DrawRenderState,
|
|
const ElementDataType& ElementData,
|
|
const ContextDataType PolicyContext
|
|
) const
|
|
{
|
|
const FMeshBatchElement& BatchElement = Mesh.Elements[BatchElementIndex];
|
|
VertexShader->SetMesh(RHICmdList, VertexFactory,View,PrimitiveSceneProxy,BatchElement,DrawRenderState);
|
|
if(HullShader && DomainShader)
|
|
{
|
|
HullShader->SetMesh(RHICmdList, VertexFactory,View,PrimitiveSceneProxy,BatchElement,DrawRenderState);
|
|
DomainShader->SetMesh(RHICmdList, VertexFactory,View,PrimitiveSceneProxy,BatchElement,DrawRenderState);
|
|
}
|
|
|
|
if (bNeedsPixelShader)
|
|
{
|
|
PixelShader->SetMesh(RHICmdList, VertexFactory,View,PrimitiveSceneProxy,BatchElement,DrawRenderState);
|
|
}
|
|
}
|
|
|
|
int32 CompareDrawingPolicy(const FDepthDrawingPolicy& A,const FDepthDrawingPolicy& B)
|
|
{
|
|
COMPAREDRAWINGPOLICYMEMBERS(VertexShader);
|
|
COMPAREDRAWINGPOLICYMEMBERS(HullShader);
|
|
COMPAREDRAWINGPOLICYMEMBERS(DomainShader);
|
|
COMPAREDRAWINGPOLICYMEMBERS(bNeedsPixelShader);
|
|
COMPAREDRAWINGPOLICYMEMBERS(PixelShader);
|
|
COMPAREDRAWINGPOLICYMEMBERS(VertexFactory);
|
|
COMPAREDRAWINGPOLICYMEMBERS(MaterialRenderProxy);
|
|
COMPAREDRAWINGPOLICYMEMBERS(MobileColorValue);
|
|
return 0;
|
|
}
|
|
|
|
FPositionOnlyDepthDrawingPolicy::FPositionOnlyDepthDrawingPolicy(
|
|
const FVertexFactory* InVertexFactory,
|
|
const FMaterialRenderProxy* InMaterialRenderProxy,
|
|
const FMaterial& InMaterialResource,
|
|
const FMeshDrawingPolicyOverrideSettings& InOverrideSettings
|
|
)
|
|
: FMeshDrawingPolicy(InVertexFactory, InMaterialRenderProxy, InMaterialResource, InOverrideSettings, DVSM_None)
|
|
{
|
|
ShaderPipeline = UseShaderPipelines() ? InMaterialResource.GetShaderPipeline(&DepthPosOnlyNoPixelPipeline, VertexFactory->GetType()) : nullptr;
|
|
VertexShader = ShaderPipeline
|
|
? ShaderPipeline->GetShader<TDepthOnlyVS<true> >()
|
|
: InMaterialResource.GetShader<TDepthOnlyVS<true> >(InVertexFactory->GetType());
|
|
bUsePositionOnlyVS = true;
|
|
}
|
|
|
|
void FPositionOnlyDepthDrawingPolicy::SetSharedState(FRHICommandList& RHICmdList, const FDrawingPolicyRenderState& DrawRenderState, const FSceneView* View, FPositionOnlyDepthDrawingPolicy::ContextDataType PolicyContext) const
|
|
{
|
|
// Set the depth-only shader parameters for the material.
|
|
VertexShader->SetParameters(RHICmdList, MaterialRenderProxy, *MaterialResource, *View, View->ViewUniformBuffer, PolicyContext.bIsInstancedStereo, PolicyContext.bIsInstancedStereoEmulated);
|
|
|
|
// Set the shared mesh resources.
|
|
VertexFactory->SetPositionStream(RHICmdList);
|
|
}
|
|
|
|
/**
|
|
* Create bound shader state using the vertex decl from the mesh draw policy
|
|
* as well as the shaders needed to draw the mesh
|
|
* @return new bound shader state object
|
|
*/
|
|
FBoundShaderStateInput FPositionOnlyDepthDrawingPolicy::GetBoundShaderStateInput(ERHIFeatureLevel::Type InFeatureLevel) const
|
|
{
|
|
FVertexDeclarationRHIParamRef VertexDeclaration;
|
|
VertexDeclaration = VertexFactory->GetPositionDeclaration();
|
|
|
|
checkSlow(MaterialRenderProxy->GetMaterial(InFeatureLevel)->GetBlendMode() == BLEND_Opaque);
|
|
return FBoundShaderStateInput(VertexDeclaration, VertexShader->GetVertexShader(), FHullShaderRHIRef(), FDomainShaderRHIRef(), FPixelShaderRHIRef(), FGeometryShaderRHIRef());
|
|
}
|
|
|
|
void FPositionOnlyDepthDrawingPolicy::SetMeshRenderState(
|
|
FRHICommandList& RHICmdList,
|
|
const FSceneView& View,
|
|
const FPrimitiveSceneProxy* PrimitiveSceneProxy,
|
|
const FMeshBatch& Mesh,
|
|
int32 BatchElementIndex,
|
|
const FDrawingPolicyRenderState& DrawRenderState,
|
|
const ElementDataType& ElementData,
|
|
const ContextDataType PolicyContext
|
|
) const
|
|
{
|
|
VertexShader->SetMesh(RHICmdList, VertexFactory, View, PrimitiveSceneProxy, Mesh.Elements[BatchElementIndex], DrawRenderState);
|
|
}
|
|
|
|
void FPositionOnlyDepthDrawingPolicy::SetInstancedEyeIndex(FRHICommandList& RHICmdList, const uint32 EyeIndex) const
|
|
{
|
|
VertexShader->SetInstancedEyeIndex(RHICmdList, EyeIndex);
|
|
}
|
|
|
|
int32 CompareDrawingPolicy(const FPositionOnlyDepthDrawingPolicy& A, const FPositionOnlyDepthDrawingPolicy& B)
|
|
{
|
|
COMPAREDRAWINGPOLICYMEMBERS(VertexShader);
|
|
COMPAREDRAWINGPOLICYMEMBERS(VertexFactory);
|
|
COMPAREDRAWINGPOLICYMEMBERS(MaterialRenderProxy);
|
|
return 0;
|
|
}
|
|
|
|
void FDepthDrawingPolicyFactory::AddStaticMesh(FScene* Scene, FStaticMesh* StaticMesh)
|
|
{
|
|
const FMaterialRenderProxy* MaterialRenderProxy = StaticMesh->MaterialRenderProxy;
|
|
const FMaterial* Material = MaterialRenderProxy->GetMaterial(Scene->GetFeatureLevel());
|
|
const EBlendMode BlendMode = Material->GetBlendMode();
|
|
const auto FeatureLevel = Scene->GetFeatureLevel();
|
|
|
|
FMeshDrawingPolicyOverrideSettings OverrideSettings = ComputeMeshOverrideSettings(*StaticMesh);
|
|
OverrideSettings.MeshOverrideFlags |= Material->IsTwoSided() ? EDrawingPolicyOverrideFlags::TwoSided : EDrawingPolicyOverrideFlags::None;
|
|
|
|
if (!Material->WritesEveryPixel() || Material->MaterialUsesPixelDepthOffset())
|
|
{
|
|
FDepthDrawingPolicy DrawingPolicy(StaticMesh->VertexFactory,
|
|
MaterialRenderProxy,
|
|
*Material,
|
|
OverrideSettings,
|
|
FeatureLevel,
|
|
0.0f // MobileColorValue
|
|
);
|
|
|
|
// only draw if required
|
|
Scene->MaskedDepthDrawList.AddMesh(
|
|
StaticMesh,
|
|
FDepthDrawingPolicy::ElementDataType(),
|
|
DrawingPolicy,
|
|
FeatureLevel
|
|
);
|
|
}
|
|
else
|
|
{
|
|
if (StaticMesh->VertexFactory->SupportsPositionOnlyStream()
|
|
&& !Material->MaterialModifiesMeshPosition_RenderThread())
|
|
{
|
|
OverrideSettings.MeshOverrideFlags |= Material->IsWireframe() ? EDrawingPolicyOverrideFlags::Wireframe : EDrawingPolicyOverrideFlags::None;
|
|
|
|
const FMaterialRenderProxy* DefaultProxy = UMaterial::GetDefaultMaterial(MD_Surface)->GetRenderProxy(false);
|
|
FPositionOnlyDepthDrawingPolicy DrawingPolicy(StaticMesh->VertexFactory,
|
|
DefaultProxy,
|
|
*DefaultProxy->GetMaterial(Scene->GetFeatureLevel()),
|
|
OverrideSettings
|
|
);
|
|
|
|
// Add the static mesh to the position-only depth draw list.
|
|
Scene->PositionOnlyDepthDrawList.AddMesh(
|
|
StaticMesh,
|
|
FPositionOnlyDepthDrawingPolicy::ElementDataType(),
|
|
DrawingPolicy,
|
|
FeatureLevel
|
|
);
|
|
}
|
|
else
|
|
{
|
|
if (!Material->MaterialModifiesMeshPosition_RenderThread())
|
|
{
|
|
// Override with the default material for everything but opaque two sided materials
|
|
MaterialRenderProxy = UMaterial::GetDefaultMaterial(MD_Surface)->GetRenderProxy(false);
|
|
}
|
|
|
|
FDepthDrawingPolicy DrawingPolicy(StaticMesh->VertexFactory,
|
|
MaterialRenderProxy,
|
|
*MaterialRenderProxy->GetMaterial(Scene->GetFeatureLevel()),
|
|
OverrideSettings,
|
|
FeatureLevel,
|
|
0.0f // MobileColorValue
|
|
);
|
|
|
|
// Add the static mesh to the opaque depth-only draw list.
|
|
Scene->DepthDrawList.AddMesh(
|
|
StaticMesh,
|
|
FDepthDrawingPolicy::ElementDataType(),
|
|
DrawingPolicy,
|
|
FeatureLevel
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool FDepthDrawingPolicyFactory::DrawMesh(
|
|
FRHICommandList& RHICmdList,
|
|
const FViewInfo& View,
|
|
ContextType DrawingContext,
|
|
const FMeshBatch& Mesh,
|
|
const uint64& BatchElementMask,
|
|
const FDrawingPolicyRenderState& DrawRenderState,
|
|
bool bPreFog,
|
|
const FPrimitiveSceneProxy* PrimitiveSceneProxy,
|
|
FHitProxyId HitProxyId,
|
|
const bool bIsInstancedStereo,
|
|
const bool bIsInstancedStereoEmulated
|
|
)
|
|
{
|
|
const FMaterialRenderProxy* MaterialRenderProxy = Mesh.MaterialRenderProxy;
|
|
const FMaterial* Material = MaterialRenderProxy->GetMaterial(View.GetFeatureLevel());
|
|
bool bDirty = false;
|
|
|
|
//Do a per-FMeshBatch check on top of the proxy check in RenderPrePass to handle the case where a proxy that is relevant
|
|
//to the depth only pass has to submit multiple FMeshElements but only some of them should be used as occluders.
|
|
if ((Mesh.bUseAsOccluder || !DrawingContext.bRespectUseAsOccluderFlag || DrawingContext.DepthDrawingMode == DDM_AllOpaque)
|
|
&& ShouldIncludeDomainInMeshPass(Material->GetMaterialDomain()))
|
|
{
|
|
const EBlendMode BlendMode = Material->GetBlendMode();
|
|
const bool bUsesMobileColorValue = (DrawingContext.MobileColorValue != 0.0f);
|
|
|
|
// Check to see if the primitive is currently fading in or out using the screen door effect. If it is,
|
|
// then we can't assume the object is opaque as it may be forcibly masked.
|
|
const FSceneViewState* SceneViewState = static_cast<const FSceneViewState*>( View.State );
|
|
|
|
FMeshDrawingPolicyOverrideSettings OverrideSettings = ComputeMeshOverrideSettings(Mesh);
|
|
OverrideSettings.MeshOverrideFlags |= Material->IsTwoSided() ? EDrawingPolicyOverrideFlags::TwoSided : EDrawingPolicyOverrideFlags::None;
|
|
|
|
if ( BlendMode == BLEND_Opaque
|
|
&& Mesh.VertexFactory->SupportsPositionOnlyStream()
|
|
&& !Material->MaterialModifiesMeshPosition_RenderThread()
|
|
&& Material->WritesEveryPixel()
|
|
&& !bUsesMobileColorValue
|
|
)
|
|
{
|
|
//render opaque primitives that support a separate position-only vertex buffer
|
|
const FMaterialRenderProxy* DefaultProxy = UMaterial::GetDefaultMaterial(MD_Surface)->GetRenderProxy(false);
|
|
|
|
OverrideSettings.MeshOverrideFlags |= Material->IsWireframe() ? EDrawingPolicyOverrideFlags::Wireframe : EDrawingPolicyOverrideFlags::None;
|
|
|
|
FPositionOnlyDepthDrawingPolicy DrawingPolicy(
|
|
Mesh.VertexFactory,
|
|
DefaultProxy,
|
|
*DefaultProxy->GetMaterial(View.GetFeatureLevel()),
|
|
OverrideSettings
|
|
);
|
|
|
|
FDrawingPolicyRenderState DrawRenderStateLocal(DrawRenderState);
|
|
DrawingPolicy.SetupPipelineState(DrawRenderStateLocal, View);
|
|
CommitGraphicsPipelineState(RHICmdList, DrawingPolicy, DrawRenderStateLocal, DrawingPolicy.GetBoundShaderStateInput(View.GetFeatureLevel()));
|
|
DrawingPolicy.SetSharedState(RHICmdList, DrawRenderStateLocal, &View, FPositionOnlyDepthDrawingPolicy::ContextDataType(bIsInstancedStereo, bIsInstancedStereoEmulated));
|
|
|
|
int32 BatchElementIndex = 0;
|
|
uint64 Mask = BatchElementMask;
|
|
do
|
|
{
|
|
if(Mask & 1)
|
|
{
|
|
// We draw instanced static meshes twice when rendering with instanced stereo. Once for each eye.
|
|
const bool bIsInstancedMesh = Mesh.Elements[BatchElementIndex].bIsInstancedMesh;
|
|
const uint32 InstancedStereoDrawCount = (bIsInstancedStereo && bIsInstancedMesh) ? 2 : 1;
|
|
for (uint32 DrawCountIter = 0; DrawCountIter < InstancedStereoDrawCount; ++DrawCountIter)
|
|
{
|
|
DrawingPolicy.SetInstancedEyeIndex(RHICmdList, DrawCountIter);
|
|
|
|
TDrawEvent<FRHICommandList> MeshEvent;
|
|
BeginMeshDrawEvent(RHICmdList, PrimitiveSceneProxy, Mesh, MeshEvent);
|
|
|
|
DrawingPolicy.SetMeshRenderState(RHICmdList, View, PrimitiveSceneProxy, Mesh, BatchElementIndex, DrawRenderStateLocal, FPositionOnlyDepthDrawingPolicy::ElementDataType(), FPositionOnlyDepthDrawingPolicy::ContextDataType());
|
|
DrawingPolicy.DrawMesh(RHICmdList, Mesh, BatchElementIndex, bIsInstancedStereo);
|
|
}
|
|
}
|
|
Mask >>= 1;
|
|
BatchElementIndex++;
|
|
} while(Mask);
|
|
|
|
bDirty = true;
|
|
}
|
|
else if (!IsTranslucentBlendMode(BlendMode) || Material->IsTranslucencyWritingCustomDepth())
|
|
{
|
|
const bool bMaterialMasked = !Material->WritesEveryPixel() || Material->IsTranslucencyWritingCustomDepth();
|
|
|
|
bool bDraw = true;
|
|
|
|
switch(DrawingContext.DepthDrawingMode)
|
|
{
|
|
case DDM_AllOpaque:
|
|
break;
|
|
case DDM_AllOccluders:
|
|
break;
|
|
case DDM_NonMaskedOnly:
|
|
bDraw = !bMaterialMasked;
|
|
break;
|
|
default:
|
|
check(!"Unrecognized DepthDrawingMode");
|
|
}
|
|
|
|
if(bDraw)
|
|
{
|
|
if (!bMaterialMasked && !Material->MaterialModifiesMeshPosition_RenderThread())
|
|
{
|
|
// Override with the default material for opaque materials that are not two sided
|
|
MaterialRenderProxy = UMaterial::GetDefaultMaterial(MD_Surface)->GetRenderProxy(false);
|
|
}
|
|
|
|
FDepthDrawingPolicy DrawingPolicy(
|
|
Mesh.VertexFactory,
|
|
MaterialRenderProxy,
|
|
*MaterialRenderProxy->GetMaterial(View.GetFeatureLevel()),
|
|
OverrideSettings,
|
|
View.GetFeatureLevel(),
|
|
DrawingContext.MobileColorValue
|
|
);
|
|
|
|
FDrawingPolicyRenderState DrawRenderStateLocal(DrawRenderState);
|
|
DrawingPolicy.SetupPipelineState(DrawRenderStateLocal, View);
|
|
CommitGraphicsPipelineState(RHICmdList, DrawingPolicy, DrawRenderStateLocal, DrawingPolicy.GetBoundShaderStateInput(View.GetFeatureLevel()));
|
|
DrawingPolicy.SetSharedState(RHICmdList, DrawRenderStateLocal, &View, FDepthDrawingPolicy::ContextDataType(bIsInstancedStereo, bIsInstancedStereoEmulated));
|
|
|
|
int32 BatchElementIndex = 0;
|
|
uint64 Mask = BatchElementMask;
|
|
do
|
|
{
|
|
if(Mask & 1)
|
|
{
|
|
// We draw instanced static meshes twice when rendering with instanced stereo. Once for each eye.
|
|
const bool bIsInstancedMesh = Mesh.Elements[BatchElementIndex].bIsInstancedMesh;
|
|
const uint32 InstancedStereoDrawCount = (bIsInstancedStereo && bIsInstancedMesh) ? 2 : 1;
|
|
for (uint32 DrawCountIter = 0; DrawCountIter < InstancedStereoDrawCount; ++DrawCountIter)
|
|
{
|
|
DrawingPolicy.SetInstancedEyeIndex(RHICmdList, DrawCountIter);
|
|
|
|
TDrawEvent<FRHICommandList> MeshEvent;
|
|
BeginMeshDrawEvent(RHICmdList, PrimitiveSceneProxy, Mesh, MeshEvent);
|
|
|
|
DrawingPolicy.SetMeshRenderState(RHICmdList, View, PrimitiveSceneProxy, Mesh, BatchElementIndex, DrawRenderStateLocal, FMeshDrawingPolicy::ElementDataType(), FDepthDrawingPolicy::ContextDataType());
|
|
DrawingPolicy.DrawMesh(RHICmdList, Mesh, BatchElementIndex, bIsInstancedStereo);
|
|
}
|
|
}
|
|
Mask >>= 1;
|
|
BatchElementIndex++;
|
|
} while(Mask);
|
|
|
|
bDirty = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return bDirty;
|
|
}
|
|
|
|
bool FDepthDrawingPolicyFactory::DrawDynamicMesh(
|
|
FRHICommandList& RHICmdList,
|
|
const FViewInfo& View,
|
|
ContextType DrawingContext,
|
|
const FMeshBatch& Mesh,
|
|
bool bPreFog,
|
|
const FDrawingPolicyRenderState& DrawRenderState,
|
|
const FPrimitiveSceneProxy* PrimitiveSceneProxy,
|
|
FHitProxyId HitProxyId,
|
|
const bool bIsInstancedStereo,
|
|
const bool bIsInstancedStereoEmulated
|
|
)
|
|
{
|
|
return DrawMesh(
|
|
RHICmdList,
|
|
View,
|
|
DrawingContext,
|
|
Mesh,
|
|
Mesh.Elements.Num()==1 ? 1 : (1<<Mesh.Elements.Num())-1, // 1 bit set for each mesh element
|
|
DrawRenderState,
|
|
bPreFog,
|
|
PrimitiveSceneProxy,
|
|
HitProxyId,
|
|
bIsInstancedStereo,
|
|
bIsInstancedStereoEmulated
|
|
);
|
|
}
|
|
|
|
bool FDepthDrawingPolicyFactory::DrawStaticMesh(
|
|
FRHICommandList& RHICmdList,
|
|
const FViewInfo& View,
|
|
ContextType DrawingContext,
|
|
const FStaticMesh& StaticMesh,
|
|
const uint64& BatchElementMask,
|
|
bool bPreFog,
|
|
const FDrawingPolicyRenderState& DrawRenderState,
|
|
const FPrimitiveSceneProxy* PrimitiveSceneProxy,
|
|
FHitProxyId HitProxyId,
|
|
const bool bIsInstancedStereo,
|
|
const bool bIsInstancedStereoEmulated
|
|
)
|
|
{
|
|
bool bDirty = false;
|
|
|
|
const FMaterial* Material = StaticMesh.MaterialRenderProxy->GetMaterial(View.GetFeatureLevel());
|
|
const EMaterialShadingModel ShadingModel = Material->GetShadingModel();
|
|
bDirty |= DrawMesh(
|
|
RHICmdList,
|
|
View,
|
|
DrawingContext,
|
|
StaticMesh,
|
|
BatchElementMask,
|
|
DrawRenderState,
|
|
bPreFog,
|
|
PrimitiveSceneProxy,
|
|
HitProxyId,
|
|
bIsInstancedStereo,
|
|
bIsInstancedStereoEmulated
|
|
);
|
|
|
|
return bDirty;
|
|
}
|
|
|
|
bool FDeferredShadingSceneRenderer::RenderPrePassViewDynamic(FRHICommandList& RHICmdList, const FViewInfo& View, const FDrawingPolicyRenderState& DrawRenderState)
|
|
{
|
|
// Transition after static since only dynamic needs the skin cache (currently)
|
|
if (FGPUSkinCache* GPUSkinCache = Scene->GetGPUSkinCache())
|
|
{
|
|
GPUSkinCache->TransitionAllToReadable(RHICmdList);
|
|
}
|
|
|
|
FDepthDrawingPolicyFactory::ContextType Context(EarlyZPassMode, true);
|
|
|
|
for (int32 MeshBatchIndex = 0; MeshBatchIndex < View.DynamicMeshElements.Num(); MeshBatchIndex++)
|
|
{
|
|
const FMeshBatchAndRelevance& MeshBatchAndRelevance = View.DynamicMeshElements[MeshBatchIndex];
|
|
|
|
if (MeshBatchAndRelevance.GetHasOpaqueOrMaskedMaterial() && MeshBatchAndRelevance.GetRenderInMainPass())
|
|
{
|
|
const FMeshBatch& MeshBatch = *MeshBatchAndRelevance.Mesh;
|
|
const FPrimitiveSceneProxy* PrimitiveSceneProxy = MeshBatchAndRelevance.PrimitiveSceneProxy;
|
|
bool bShouldUseAsOccluder = true;
|
|
|
|
if (EarlyZPassMode < DDM_AllOccluders)
|
|
{
|
|
extern float GMinScreenRadiusForDepthPrepass;
|
|
//@todo - move these proxy properties into FMeshBatchAndRelevance so we don't have to dereference the proxy in order to reject a mesh
|
|
const float LODFactorDistanceSquared = (PrimitiveSceneProxy->GetBounds().Origin - View.ViewMatrices.GetViewOrigin()).SizeSquared() * FMath::Square(View.LODDistanceFactor);
|
|
|
|
// Only render primitives marked as occluders
|
|
bShouldUseAsOccluder = PrimitiveSceneProxy->ShouldUseAsOccluder()
|
|
// Only render static objects unless movable are requested
|
|
&& (!PrimitiveSceneProxy->IsMovable() || bEarlyZPassMovable)
|
|
&& (FMath::Square(PrimitiveSceneProxy->GetBounds().SphereRadius) > GMinScreenRadiusForDepthPrepass * GMinScreenRadiusForDepthPrepass * LODFactorDistanceSquared);
|
|
}
|
|
|
|
if (bShouldUseAsOccluder)
|
|
{
|
|
FDepthDrawingPolicyFactory::DrawDynamicMesh(RHICmdList, View, Context, MeshBatch, true, DrawRenderState, PrimitiveSceneProxy, MeshBatch.BatchHitProxyId, View.IsInstancedStereoPass());
|
|
}
|
|
}
|
|
}
|
|
|
|
RenderPrePassEditorPrimitives(RHICmdList, View, Context);
|
|
|
|
return true;
|
|
}
|
|
|
|
static void SetupPrePassView(FRHICommandList& RHICmdList, const FViewInfo& View, FDrawingPolicyRenderState& DrawRenderState)
|
|
{
|
|
// Disable color writes, enable depth tests and writes.
|
|
DrawRenderState.SetBlendState(TStaticBlendState<CW_NONE>::GetRHI());
|
|
DrawRenderState.SetDepthStencilState(TStaticDepthStencilState<true, CF_DepthNearOrEqual>::GetRHI());
|
|
|
|
RHICmdList.SetScissorRect(false, 0, 0, 0, 0);
|
|
|
|
if (!View.IsInstancedStereoPass())
|
|
{
|
|
RHICmdList.SetViewport(View.ViewRect.Min.X, View.ViewRect.Min.Y, 0.0f, View.ViewRect.Max.X, View.ViewRect.Max.Y, 1.0f);
|
|
}
|
|
else
|
|
{
|
|
if (View.bIsMultiViewEnabled)
|
|
{
|
|
const uint32 LeftMinX = View.Family->Views[0]->ViewRect.Min.X;
|
|
const uint32 LeftMaxX = View.Family->Views[0]->ViewRect.Max.X;
|
|
const uint32 RightMinX = View.Family->Views[1]->ViewRect.Min.X;
|
|
const uint32 RightMaxX = View.Family->Views[1]->ViewRect.Max.X;
|
|
RHICmdList.SetStereoViewport(LeftMinX, RightMinX, 0, 0.0f, LeftMaxX, RightMaxX, View.ViewRect.Max.Y, 1.0f);
|
|
}
|
|
else
|
|
{
|
|
RHICmdList.SetViewport(0, 0, 0, View.Family->InstancedStereoWidth, View.ViewRect.Max.Y, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void RenderHiddenAreaMaskView(FRHICommandList& RHICmdList, FGraphicsPipelineStateInitializer& GraphicsPSOInit, const FViewInfo& View)
|
|
{
|
|
const auto FeatureLevel = GMaxRHIFeatureLevel;
|
|
const auto ShaderMap = GetGlobalShaderMap(FeatureLevel);
|
|
TShaderMapRef<TOneColorVS<true> > VertexShader(ShaderMap);
|
|
|
|
GraphicsPSOInit.BoundShaderState.VertexDeclarationRHI = GetVertexDeclarationFVector4();
|
|
GraphicsPSOInit.BoundShaderState.VertexShaderRHI = GETSAFERHISHADER_VERTEX(*VertexShader);
|
|
GraphicsPSOInit.PrimitiveType = PT_TriangleList;
|
|
|
|
SetGraphicsPipelineState(RHICmdList, GraphicsPSOInit);
|
|
|
|
GEngine->HMDDevice->DrawHiddenAreaMesh_RenderThread(RHICmdList, View.StereoPass);
|
|
}
|
|
|
|
bool FDeferredShadingSceneRenderer::RenderPrePassView(FRHICommandList& RHICmdList, const FViewInfo& View)
|
|
{
|
|
bool bDirty = false;
|
|
|
|
FDrawingPolicyRenderState DrawRenderState(View);
|
|
SetupPrePassView(RHICmdList, View, DrawRenderState);
|
|
|
|
// Draw the static occluder primitives using a depth drawing policy.
|
|
|
|
if (!View.IsInstancedStereoPass())
|
|
{
|
|
{
|
|
// Draw opaque occluders which support a separate position-only
|
|
// vertex buffer to minimize vertex fetch bandwidth, which is
|
|
// often the bottleneck during the depth only pass.
|
|
SCOPED_DRAW_EVENT(RHICmdList, PosOnlyOpaque);
|
|
bDirty |= Scene->PositionOnlyDepthDrawList.DrawVisible(RHICmdList, View, DrawRenderState, View.StaticMeshOccluderMap, View.StaticMeshBatchVisibility);
|
|
}
|
|
{
|
|
// Draw opaque occluders, using double speed z where supported.
|
|
SCOPED_DRAW_EVENT(RHICmdList, Opaque);
|
|
bDirty |= Scene->DepthDrawList.DrawVisible(RHICmdList, View, DrawRenderState, View.StaticMeshOccluderMap, View.StaticMeshBatchVisibility);
|
|
}
|
|
|
|
if (EarlyZPassMode >= DDM_AllOccluders)
|
|
{
|
|
// Draw opaque occluders with masked materials
|
|
SCOPED_DRAW_EVENT(RHICmdList, Masked);
|
|
bDirty |= Scene->MaskedDepthDrawList.DrawVisible(RHICmdList, View, DrawRenderState, View.StaticMeshOccluderMap, View.StaticMeshBatchVisibility);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
const StereoPair StereoView(Views[0], Views[1], Views[0].StaticMeshOccluderMap, Views[1].StaticMeshOccluderMap, Views[0].StaticMeshBatchVisibility, Views[1].StaticMeshBatchVisibility);
|
|
{
|
|
SCOPED_DRAW_EVENT(RHICmdList, PosOnlyOpaque);
|
|
bDirty |= Scene->PositionOnlyDepthDrawList.DrawVisibleInstancedStereo(RHICmdList, StereoView, DrawRenderState);
|
|
}
|
|
{
|
|
SCOPED_DRAW_EVENT(RHICmdList, Opaque);
|
|
bDirty |= Scene->DepthDrawList.DrawVisibleInstancedStereo(RHICmdList, StereoView, DrawRenderState);
|
|
}
|
|
|
|
if (EarlyZPassMode >= DDM_AllOccluders)
|
|
{
|
|
SCOPED_DRAW_EVENT(RHICmdList, Masked);
|
|
bDirty |= Scene->MaskedDepthDrawList.DrawVisibleInstancedStereo(RHICmdList, StereoView, DrawRenderState);
|
|
}
|
|
}
|
|
|
|
{
|
|
SCOPED_DRAW_EVENT(RHICmdList, Dynamic);
|
|
bDirty |= RenderPrePassViewDynamic(RHICmdList, View, DrawRenderState);
|
|
}
|
|
|
|
return bDirty;
|
|
}
|
|
|
|
class FRenderPrepassDynamicDataThreadTask : public FRenderTask
|
|
{
|
|
FDeferredShadingSceneRenderer& ThisRenderer;
|
|
FRHICommandList& RHICmdList;
|
|
const FViewInfo& View;
|
|
FDrawingPolicyRenderState DrawRenderState;
|
|
|
|
public:
|
|
|
|
FRenderPrepassDynamicDataThreadTask(
|
|
FDeferredShadingSceneRenderer& InThisRenderer,
|
|
FRHICommandList& InRHICmdList,
|
|
const FViewInfo& InView,
|
|
const FDrawingPolicyRenderState& InDrawRenderState
|
|
)
|
|
: ThisRenderer(InThisRenderer)
|
|
, RHICmdList(InRHICmdList)
|
|
, View(InView)
|
|
, DrawRenderState(InDrawRenderState)
|
|
{
|
|
}
|
|
|
|
FORCEINLINE TStatId GetStatId() const
|
|
{
|
|
RETURN_QUICK_DECLARE_CYCLE_STAT(FRenderPrepassDynamicDataThreadTask, STATGROUP_TaskGraphTasks);
|
|
}
|
|
|
|
static ESubsequentsMode::Type GetSubsequentsMode() { return ESubsequentsMode::TrackSubsequents; }
|
|
|
|
void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent)
|
|
{
|
|
ThisRenderer.RenderPrePassViewDynamic(RHICmdList, View, DrawRenderState);
|
|
RHICmdList.HandleRTThreadTaskCompletion(MyCompletionGraphEvent);
|
|
}
|
|
};
|
|
|
|
DECLARE_CYCLE_STAT(TEXT("Prepass"), STAT_CLP_Prepass, STATGROUP_ParallelCommandListMarkers);
|
|
|
|
class FPrePassParallelCommandListSet : public FParallelCommandListSet
|
|
{
|
|
public:
|
|
FPrePassParallelCommandListSet(const FViewInfo& InView, FRHICommandListImmediate& InParentCmdList, bool bInParallelExecute, bool bInCreateSceneContext)
|
|
: FParallelCommandListSet(GET_STATID(STAT_CLP_Prepass), InView, InParentCmdList, bInParallelExecute, bInCreateSceneContext)
|
|
{
|
|
// Do not copy-paste. this is a very unusual FParallelCommandListSet because it is a prepass and we want to do some work after starting some tasks
|
|
}
|
|
|
|
virtual ~FPrePassParallelCommandListSet()
|
|
{
|
|
// Do not copy-paste. this is a very unusual FParallelCommandListSet because it is a prepass and we want to do some work after starting some tasks
|
|
SetStateOnCommandList(ParentCmdList);
|
|
Dispatch(true);
|
|
}
|
|
|
|
virtual void SetStateOnCommandList(FRHICommandList& CmdList) override
|
|
{
|
|
FParallelCommandListSet::SetStateOnCommandList(CmdList);
|
|
FSceneRenderTargets::Get(CmdList).BeginRenderingPrePass(CmdList, false);
|
|
SetupPrePassView(CmdList, View, DrawRenderState);
|
|
}
|
|
};
|
|
|
|
bool FDeferredShadingSceneRenderer::RenderPrePassViewParallel(const FViewInfo& View, FRHICommandListImmediate& ParentCmdList, TFunctionRef<void()> AfterTasksAreStarted, bool bDoPrePre)
|
|
{
|
|
bool bDepthWasCleared = false;
|
|
FPrePassParallelCommandListSet ParallelCommandListSet(View, ParentCmdList,
|
|
CVarRHICmdPrePassDeferredContexts.GetValueOnRenderThread() > 0,
|
|
CVarRHICmdFlushRenderThreadTasksPrePass.GetValueOnRenderThread() == 0 && CVarRHICmdFlushRenderThreadTasks.GetValueOnRenderThread() == 0);
|
|
|
|
if (!View.IsInstancedStereoPass())
|
|
{
|
|
// Draw the static occluder primitives using a depth drawing policy.
|
|
// Draw opaque occluders which support a separate position-only
|
|
// vertex buffer to minimize vertex fetch bandwidth, which is
|
|
// often the bottleneck during the depth only pass.
|
|
Scene->PositionOnlyDepthDrawList.DrawVisibleParallel(View.StaticMeshOccluderMap, View.StaticMeshBatchVisibility, ParallelCommandListSet);
|
|
|
|
// Draw opaque occluders, using double speed z where supported.
|
|
Scene->DepthDrawList.DrawVisibleParallel(View.StaticMeshOccluderMap, View.StaticMeshBatchVisibility, ParallelCommandListSet);
|
|
|
|
// Draw opaque occluders with masked materials
|
|
if (EarlyZPassMode >= DDM_AllOccluders)
|
|
{
|
|
Scene->MaskedDepthDrawList.DrawVisibleParallel(View.StaticMeshOccluderMap, View.StaticMeshBatchVisibility, ParallelCommandListSet);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
const StereoPair StereoView(Views[0], Views[1], Views[0].StaticMeshOccluderMap, Views[1].StaticMeshOccluderMap, Views[0].StaticMeshBatchVisibility, Views[1].StaticMeshBatchVisibility);
|
|
|
|
Scene->PositionOnlyDepthDrawList.DrawVisibleParallelInstancedStereo(StereoView, ParallelCommandListSet);
|
|
Scene->DepthDrawList.DrawVisibleParallelInstancedStereo(StereoView, ParallelCommandListSet);
|
|
|
|
if (EarlyZPassMode >= DDM_AllOccluders)
|
|
{
|
|
Scene->MaskedDepthDrawList.DrawVisibleParallelInstancedStereo(StereoView, ParallelCommandListSet);
|
|
}
|
|
}
|
|
|
|
// we do this step here (awkwardly) so that the above tasks can be in flight while we get the particles (which must be dynamic) setup.
|
|
if (bDoPrePre)
|
|
{
|
|
AfterTasksAreStarted();
|
|
bDepthWasCleared = PreRenderPrePass(ParentCmdList);
|
|
}
|
|
|
|
// Dynamic
|
|
FRHICommandList* CmdList = ParallelCommandListSet.NewParallelCommandList();
|
|
|
|
FGraphEventRef AnyThreadCompletionEvent = TGraphTask<FRenderPrepassDynamicDataThreadTask>::CreateTask(ParallelCommandListSet.GetPrereqs(), ENamedThreads::RenderThread)
|
|
.ConstructAndDispatchWhenReady(*this, *CmdList, View, ParallelCommandListSet.DrawRenderState);
|
|
|
|
ParallelCommandListSet.AddParallelCommandList(CmdList, AnyThreadCompletionEvent);
|
|
|
|
return bDepthWasCleared;
|
|
}
|
|
|
|
/** A pixel shader used to fill the stencil buffer with the current dithered transition mask. */
|
|
class FDitheredTransitionStencilPS : public FGlobalShader
|
|
{
|
|
DECLARE_SHADER_TYPE(FDitheredTransitionStencilPS, Global);
|
|
public:
|
|
|
|
static bool ShouldCache(EShaderPlatform Platform)
|
|
{
|
|
return IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM4);
|
|
}
|
|
|
|
FDitheredTransitionStencilPS(const ShaderMetaType::CompiledShaderInitializerType& Initializer)
|
|
: FGlobalShader(Initializer)
|
|
{
|
|
DitheredTransitionFactorParameter.Bind(Initializer.ParameterMap, TEXT("DitheredTransitionFactor"));
|
|
}
|
|
|
|
FDitheredTransitionStencilPS()
|
|
{
|
|
}
|
|
|
|
void SetParameters(FRHICommandList& RHICmdList, const FSceneView& View)
|
|
{
|
|
FGlobalShader::SetParameters<FViewUniformShaderParameters>(RHICmdList, GetPixelShader(), View.ViewUniformBuffer);
|
|
|
|
const float DitherFactor = View.GetTemporalLODTransition();
|
|
SetShaderValue(RHICmdList, GetPixelShader(), DitheredTransitionFactorParameter, DitherFactor);
|
|
}
|
|
|
|
virtual bool Serialize(FArchive& Ar) override
|
|
{
|
|
bool bShaderHasOutdatedParameters = FGlobalShader::Serialize(Ar);
|
|
Ar << DitheredTransitionFactorParameter;
|
|
return bShaderHasOutdatedParameters;
|
|
}
|
|
|
|
FShaderParameter DitheredTransitionFactorParameter;
|
|
};
|
|
|
|
IMPLEMENT_SHADER_TYPE(, FDitheredTransitionStencilPS, TEXT("DitheredTransitionStencil"), TEXT("Main"), SF_Pixel);
|
|
|
|
/** Possibly do the FX prerender and setup the prepass*/
|
|
bool FDeferredShadingSceneRenderer::PreRenderPrePass(FRHICommandListImmediate& RHICmdList)
|
|
{
|
|
RHICmdList.SetCurrentStat(GET_STATID(STAT_CLM_PrePass));
|
|
bool bDepthWasCleared = RenderPrePassHMD(RHICmdList);
|
|
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(RHICmdList);
|
|
|
|
SceneContext.BeginRenderingPrePass(RHICmdList, !bDepthWasCleared);
|
|
bDepthWasCleared = true;
|
|
|
|
// Dithered transition stencil mask fill
|
|
if (bDitheredLODTransitionsUseStencil)
|
|
{
|
|
FGraphicsPipelineStateInitializer GraphicsPSOInit;
|
|
RHICmdList.ApplyCachedRenderTargets(GraphicsPSOInit);
|
|
GraphicsPSOInit.RasterizerState = TStaticRasterizerState<>::GetRHI();
|
|
GraphicsPSOInit.BlendState = TStaticBlendState<>::GetRHI();
|
|
GraphicsPSOInit.DepthStencilState = TStaticDepthStencilState<false, CF_Always,
|
|
true, CF_Always, SO_Keep, SO_Keep, SO_Replace,
|
|
false, CF_Always, SO_Keep, SO_Keep, SO_Keep,
|
|
STENCIL_SANDBOX_MASK, STENCIL_SANDBOX_MASK>::GetRHI();
|
|
|
|
SCOPED_DRAW_EVENT(RHICmdList, DitheredStencilPrePass);
|
|
FIntPoint BufferSizeXY = SceneContext.GetBufferSizeXY();
|
|
|
|
for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ++ViewIndex)
|
|
{
|
|
SCOPED_CONDITIONAL_DRAW_EVENTF(RHICmdList, EventView, Views.Num() > 1, TEXT("View%d"), ViewIndex);
|
|
|
|
FViewInfo& View = Views[ViewIndex];
|
|
RHICmdList.SetViewport(View.ViewRect.Min.X, View.ViewRect.Min.Y, 0.0f, View.ViewRect.Max.X, View.ViewRect.Max.Y, 1.0f);
|
|
|
|
// Set shaders, states
|
|
TShaderMapRef<FScreenVS> ScreenVertexShader(View.ShaderMap);
|
|
TShaderMapRef<FDitheredTransitionStencilPS> PixelShader(View.ShaderMap);
|
|
|
|
extern TGlobalResource<FFilterVertexDeclaration> GFilterVertexDeclaration;
|
|
GraphicsPSOInit.BoundShaderState.VertexDeclarationRHI = GFilterVertexDeclaration.VertexDeclarationRHI;
|
|
GraphicsPSOInit.BoundShaderState.VertexShaderRHI = GETSAFERHISHADER_VERTEX(*ScreenVertexShader);
|
|
GraphicsPSOInit.BoundShaderState.PixelShaderRHI = GETSAFERHISHADER_PIXEL(*PixelShader);
|
|
GraphicsPSOInit.PrimitiveType = PT_TriangleList;
|
|
|
|
SetGraphicsPipelineState(RHICmdList, GraphicsPSOInit);
|
|
RHICmdList.SetStencilRef(STENCIL_SANDBOX_MASK);
|
|
|
|
PixelShader->SetParameters(RHICmdList, View);
|
|
|
|
DrawRectangle(
|
|
RHICmdList,
|
|
0, 0,
|
|
BufferSizeXY.X, BufferSizeXY.Y,
|
|
View.ViewRect.Min.X, View.ViewRect.Min.Y,
|
|
View.ViewRect.Width(), View.ViewRect.Height(),
|
|
BufferSizeXY,
|
|
BufferSizeXY,
|
|
*ScreenVertexShader,
|
|
EDRF_UseTriangleOptimization);
|
|
}
|
|
}
|
|
return bDepthWasCleared;
|
|
}
|
|
|
|
void FDeferredShadingSceneRenderer::RenderPrePassEditorPrimitives(FRHICommandList& RHICmdList, const FViewInfo& View, FDepthDrawingPolicyFactory::ContextType Context)
|
|
{
|
|
FDrawingPolicyRenderState DrawRenderState(View);
|
|
SetupPrePassView(RHICmdList, View, DrawRenderState);
|
|
|
|
View.SimpleElementCollector.DrawBatchedElements(RHICmdList, DrawRenderState, View, FTexture2DRHIRef(), EBlendModeFilter::OpaqueAndMasked);
|
|
|
|
bool bDirty = false;
|
|
if (!View.Family->EngineShowFlags.CompositeEditorPrimitives)
|
|
{
|
|
const auto ShaderPlatform = View.GetShaderPlatform();
|
|
const bool bNeedToSwitchVerticalAxis = RHINeedsToSwitchVerticalAxis(ShaderPlatform);
|
|
|
|
// Draw the base pass for the view's batched mesh elements.
|
|
bDirty |= DrawViewElements<FDepthDrawingPolicyFactory>(RHICmdList, View, DrawRenderState, Context, SDPG_World, true) || bDirty;
|
|
|
|
// Draw the view's batched simple elements(lines, sprites, etc).
|
|
bDirty |= View.BatchedViewElements.Draw(RHICmdList, DrawRenderState, FeatureLevel, bNeedToSwitchVerticalAxis, View, false) || bDirty;
|
|
|
|
// Draw foreground objects last
|
|
bDirty |= DrawViewElements<FDepthDrawingPolicyFactory>(RHICmdList, View, DrawRenderState, Context, SDPG_Foreground, true) || bDirty;
|
|
|
|
// Draw the view's batched simple elements(lines, sprites, etc).
|
|
bDirty |= View.TopBatchedViewElements.Draw(RHICmdList, DrawRenderState, FeatureLevel, bNeedToSwitchVerticalAxis, View, false) || bDirty;
|
|
}
|
|
}
|
|
|
|
bool FDeferredShadingSceneRenderer::RenderPrePass(FRHICommandListImmediate& RHICmdList, TFunctionRef<void()> AfterTasksAreStarted)
|
|
{
|
|
bool bDepthWasCleared = false;
|
|
|
|
extern const TCHAR* GetDepthPassReason(bool bDitheredLODTransitionsUseStencil, ERHIFeatureLevel::Type FeatureLevel);
|
|
SCOPED_DRAW_EVENTF(RHICmdList, PrePass, TEXT("PrePass %s %s"), GetDepthDrawingModeString(EarlyZPassMode), GetDepthPassReason(bDitheredLODTransitionsUseStencil, FeatureLevel));
|
|
|
|
SCOPE_CYCLE_COUNTER(STAT_DepthDrawTime);
|
|
SCOPED_GPU_STAT(RHICmdList, Stat_GPU_Prepass);
|
|
|
|
bool bDirty = false;
|
|
bool bDidPrePre = false;
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(RHICmdList);
|
|
|
|
bool bParallel = GRHICommandList.UseParallelAlgorithms() && CVarParallelPrePass.GetValueOnRenderThread();
|
|
|
|
if (!bParallel)
|
|
{
|
|
// nothing to be gained by delaying this.
|
|
AfterTasksAreStarted();
|
|
bDepthWasCleared = PreRenderPrePass(RHICmdList);
|
|
bDidPrePre = true;
|
|
}
|
|
else
|
|
{
|
|
SceneContext.GetSceneDepthSurface(); // this probably isn't needed, but if there was some lazy allocation of the depth surface going on, we want it allocated now before we go wide. We may not have called BeginRenderingPrePass yet if bDoFXPrerender is true
|
|
}
|
|
|
|
// Draw a depth pass to avoid overdraw in the other passes.
|
|
if(EarlyZPassMode != DDM_None)
|
|
{
|
|
if (bParallel)
|
|
{
|
|
FScopedCommandListWaitForTasks Flusher(CVarRHICmdFlushRenderThreadTasksPrePass.GetValueOnRenderThread() > 0 || CVarRHICmdFlushRenderThreadTasks.GetValueOnRenderThread() > 0, RHICmdList);
|
|
for(int32 ViewIndex = 0;ViewIndex < Views.Num();ViewIndex++)
|
|
{
|
|
SCOPED_CONDITIONAL_DRAW_EVENTF(RHICmdList, EventView, Views.Num() > 1, TEXT("View%d"), ViewIndex);
|
|
const FViewInfo& View = Views[ViewIndex];
|
|
if (View.ShouldRenderView())
|
|
{
|
|
bDepthWasCleared = RenderPrePassViewParallel(View, RHICmdList, AfterTasksAreStarted, !bDidPrePre) || bDepthWasCleared;
|
|
bDirty = true; // assume dirty since we are not going to wait
|
|
bDidPrePre = true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
|
|
{
|
|
SCOPED_CONDITIONAL_DRAW_EVENTF(RHICmdList, EventView, Views.Num() > 1, TEXT("View%d"), ViewIndex);
|
|
const FViewInfo& View = Views[ViewIndex];
|
|
if (View.ShouldRenderView())
|
|
{
|
|
bDirty |= RenderPrePassView(RHICmdList, View);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!bDidPrePre)
|
|
{
|
|
// For some reason we haven't done this yet. Best do it now for consistency with the old code.
|
|
AfterTasksAreStarted();
|
|
bDepthWasCleared = PreRenderPrePass(RHICmdList);
|
|
bDidPrePre = true;
|
|
}
|
|
|
|
// Dithered transition stencil mask clear, accounting for all active viewports
|
|
if (bDitheredLODTransitionsUseStencil)
|
|
{
|
|
if (Views.Num() > 1)
|
|
{
|
|
FIntRect FullViewRect = Views[0].ViewRect;
|
|
for (int32 ViewIndex = 1; ViewIndex < Views.Num(); ++ViewIndex)
|
|
{
|
|
FullViewRect.Union(Views[ViewIndex].ViewRect);
|
|
}
|
|
RHICmdList.SetViewport(FullViewRect.Min.X, FullViewRect.Min.Y, 0, FullViewRect.Max.X, FullViewRect.Max.Y, 1);
|
|
}
|
|
DrawClearQuad(RHICmdList, GMaxRHIFeatureLevel, false, FLinearColor::Transparent, false, 0, true, 0);
|
|
}
|
|
|
|
SceneContext.FinishRenderingPrePass(RHICmdList);
|
|
|
|
return bDepthWasCleared;
|
|
}
|
|
|
|
/**
|
|
* Returns true if there's a hidden area mask available
|
|
*/
|
|
static FORCEINLINE bool HasHiddenAreaMask()
|
|
{
|
|
static const auto* const HiddenAreaMaskCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("vr.HiddenAreaMask"));
|
|
return (HiddenAreaMaskCVar != nullptr &&
|
|
HiddenAreaMaskCVar->GetValueOnRenderThread() == 1 &&
|
|
GEngine &&
|
|
GEngine->HMDDevice.IsValid() &&
|
|
GEngine->HMDDevice->HasHiddenAreaMesh());
|
|
}
|
|
|
|
bool FDeferredShadingSceneRenderer::RenderPrePassHMD(FRHICommandListImmediate& RHICmdList)
|
|
{
|
|
// Early out before we change any state if there's not a mask to render
|
|
if (!HasHiddenAreaMask())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(RHICmdList);
|
|
SceneContext.BeginRenderingPrePass(RHICmdList, true);
|
|
|
|
|
|
FGraphicsPipelineStateInitializer GraphicsPSOInit;
|
|
RHICmdList.ApplyCachedRenderTargets(GraphicsPSOInit);
|
|
|
|
GraphicsPSOInit.BlendState = TStaticBlendState<CW_NONE>::GetRHI();
|
|
GraphicsPSOInit.DepthStencilState = TStaticDepthStencilState<true, CF_DepthNearOrEqual>::GetRHI();
|
|
GraphicsPSOInit.RasterizerState = TStaticRasterizerState<FM_Solid, CM_None>::GetRHI();
|
|
|
|
RHICmdList.SetScissorRect(false, 0, 0, 0, 0);
|
|
|
|
for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ++ViewIndex)
|
|
{
|
|
const FViewInfo& View = Views[ViewIndex];
|
|
if (View.StereoPass != eSSP_FULL)
|
|
{
|
|
RHICmdList.SetViewport(View.ViewRect.Min.X, View.ViewRect.Min.Y, 0.0f, View.ViewRect.Max.X, View.ViewRect.Max.Y, 1.0f);
|
|
RenderHiddenAreaMaskView(RHICmdList, GraphicsPSOInit, View);
|
|
}
|
|
}
|
|
|
|
SceneContext.FinishRenderingPrePass(RHICmdList);
|
|
|
|
return true;
|
|
}
|