void FForwardShadingSceneRenderer::ConditionalResolveSceneDepth(FRHICommandListImmediate& RHICmdList) { FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(RHICmdList); SceneContext.ResolveSceneDepthToAuxiliaryTexture(RHICmdList); #if !PLATFORM_HTML5 auto ShaderPlatform = ViewFamily.GetShaderPlatform(); if (IsMobilePlatform(ShaderPlatform) && !IsPCPlatform(ShaderPlatform)) // exclude mobile emulation on PC { bool bSceneDepthInAlpha = (SceneContext.GetSceneColor()->GetDesc().Format == PF_FloatRGBA); bool bOnChipDepthFetch = (GSupportsShaderDepthStencilFetch || (bSceneDepthInAlpha && GSupportsShaderFramebufferFetch)); if (!bOnChipDepthFetch) { // Only these features require depth texture bool bDecals = ViewFamily.EngineShowFlags.Decals && Scene->Decals.Num(); bool bModulatedShadows = ViewFamily.EngineShowFlags.DynamicShadows && GetShadowQuality() > 0 && bModulatedShadowsInUse; if (bDecals || bModulatedShadows) { // Switch target to force hardware flush current depth to texture FTextureRHIRef DummySceneColor = GSystemTextures.BlackDummy->GetRenderTargetItem().TargetableTexture; FTextureRHIRef DummyDepthTarget = GSystemTextures.DepthDummy->GetRenderTargetItem().TargetableTexture; SetRenderTarget(RHICmdList, DummySceneColor, DummyDepthTarget, ESimpleRenderTargetMode::EUninitializedColorClearDepth, FExclusiveDepthStencil::DepthWrite_StencilWrite); RHICmdList.DiscardRenderTargets(true, true, 0); } } } #endif //!PLATFORM_HTML5 }
/** * Initialize scene's views. * Check visibility, sort translucent items, etc. */ void FForwardShadingSceneRenderer::InitViews(FRHICommandListImmediate& RHICmdList) { SCOPED_DRAW_EVENT(RHICmdList, InitViews); SCOPE_CYCLE_COUNTER(STAT_InitViewsTime); FILCUpdatePrimTaskData ILCTaskData; PreVisibilityFrameSetup(RHICmdList); ComputeViewVisibility(RHICmdList); PostVisibilityFrameSetup(ILCTaskData); bool bDynamicShadows = ViewFamily.EngineShowFlags.DynamicShadows && GetShadowQuality() > 0; if (bDynamicShadows && !IsSimpleDynamicLightingEnabled()) { // Setup dynamic shadows. InitDynamicShadows(RHICmdList); } // if we kicked off ILC update via task, wait and finalize. if (ILCTaskData.TaskRef.IsValid()) { Scene->IndirectLightingCache.FinalizeCacheUpdates(Scene, *this, ILCTaskData); } // initialize per-view uniform buffer. Pass in shadow info as necessary. for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++) { const TArray<FProjectedShadowInfo*, SceneRenderingAllocator>* DirectionalLightShadowInfo = nullptr; FViewInfo& ViewInfo = Views[ViewIndex]; FScene* Scene = (FScene*)ViewInfo.Family->Scene; if (bDynamicShadows && Scene->SimpleDirectionalLight) { int32 LightId = Scene->SimpleDirectionalLight->Id; if (VisibleLightInfos.IsValidIndex(LightId)) { const FVisibleLightInfo& VisibleLightInfo = VisibleLightInfos[LightId]; if (VisibleLightInfo.AllProjectedShadows.Num() > 0) { DirectionalLightShadowInfo = &VisibleLightInfo.AllProjectedShadows; } } } // Initialize the view's RHI resources. Views[ViewIndex].InitRHIResources(DirectionalLightShadowInfo); } // Now that the indirect lighting cache is updated, we can update the primitive precomputed lighting buffers. UpdatePrimitivePrecomputedLightingBuffers(); OnStartFrame(); }
/** * Initialize scene's views. * Check visibility, sort translucent items, etc. */ void FForwardShadingSceneRenderer::InitViews(FRHICommandListImmediate& RHICmdList) { SCOPED_DRAW_EVENT(RHICmdList, InitViews); SCOPE_CYCLE_COUNTER(STAT_InitViewsTime); PreVisibilityFrameSetup(RHICmdList); ComputeViewVisibility(RHICmdList); PostVisibilityFrameSetup(); bool bDynamicShadows = ViewFamily.EngineShowFlags.DynamicShadows && GetShadowQuality() > 0; if (bDynamicShadows && !IsSimpleDynamicLightingEnabled()) { // Setup dynamic shadows. InitDynamicShadows(RHICmdList); } // initialize per-view uniform buffer. Pass in shadow info as necessary. for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++) { const TArray<FProjectedShadowInfo*, SceneRenderingAllocator>* DirectionalLightShadowInfo = nullptr; FViewInfo& ViewInfo = Views[ViewIndex]; FScene* Scene = (FScene*)ViewInfo.Family->Scene; if (bDynamicShadows && Scene->SimpleDirectionalLight) { int32 LightId = Scene->SimpleDirectionalLight->Id; if (VisibleLightInfos.IsValidIndex(LightId)) { const FVisibleLightInfo& VisibleLightInfo = VisibleLightInfos[LightId]; if (VisibleLightInfo.AllProjectedShadows.Num() > 0) { DirectionalLightShadowInfo = &VisibleLightInfo.AllProjectedShadows; } } } // Initialize the view's RHI resources. Views[ViewIndex].InitRHIResources(DirectionalLightShadowInfo); } OnStartFrame(); }