public bool IsUsedDuringThisFrame(RenderSystem renderSystem) { return(LastFrameUsed == renderSystem.FrameCounter); }
/// <summary> /// Mark resource group as used during this frame. /// </summary> /// <returns>True if state changed (object was not mark as used during this frame until now), otherwise false.</returns> public bool MarkAsUsed(RenderSystem renderSystem) { return(Interlocked.Exchange(ref LastFrameUsed, renderSystem.FrameCounter) != renderSystem.FrameCounter); }
public PipelinePluginManager(RenderSystem renderSystem) { this.renderSystem = renderSystem; }
public static RenderStage GetRenderStage(this RenderSystem renderSystem, string name) { return(renderSystem.RenderStages.FirstOrDefault(x => x.Name == name)); }
protected override void DrawCore(RenderDrawContext context) { var currentViewport = context.CommandList.Viewport; // GBuffer //if (GBuffer) //{ // context.PushRenderTargets(); // // var gbuffer = PushScopedResource(Context.Allocator.GetTemporaryTexture2D((int)currentViewport.Width, (int)currentViewport.Height, GBufferRenderStage.Output.RenderTargetFormat0)); // context.CommandList.Clear(gbuffer, Color4.Black); // context.CommandList.SetDepthAndRenderTarget(context.CommandList.DepthStencilBuffer, gbuffer); // RenderSystem.Draw(context, mainRenderView, GBufferRenderStage); // // context.PopRenderTargets(); //} // Shadow maps var shadowMapRenderer = meshPipelinePlugin?.ForwardLightingRenderFeature?.ShadowMapRenderer; if (Shadows && shadowMapRenderer != null) { // Clear atlases shadowMapRenderer.PrepareAtlasAsRenderTargets(context.CommandList); context.PushRenderTargets(); // Draw all shadow views generated for the current view foreach (var renderView in RenderSystem.Views) { var shadowmapRenderView = renderView as ShadowMapRenderView; if (shadowmapRenderView != null && shadowmapRenderView.RenderView == MainRenderView) { var shadowMapRectangle = shadowmapRenderView.Rectangle; shadowmapRenderView.ShadowMapTexture.Atlas.RenderFrame.Activate(context); shadowmapRenderView.ShadowMapTexture.Atlas.MarkClearNeeded(); context.CommandList.SetViewport(new Viewport(shadowMapRectangle.X, shadowMapRectangle.Y, shadowMapRectangle.Width, shadowMapRectangle.Height)); RenderSystem.Draw(context, shadowmapRenderView, ShadowMapRenderStage); } } context.PopRenderTargets(); shadowMapRenderer.PrepareAtlasAsShaderResourceViews(context.CommandList); } // Draw [main view | main stage] RenderSystem.Draw(context, MainRenderView, MainRenderStage); // Some transparent shaders will require the depth as a shader resource - resolve it only once and set it here Texture depthStencilSRV = ResolveDepthAsSRV(context); // Draw [main view | transparent stage] RenderSystem.Draw(context, MainRenderView, TransparentRenderStage); // Free the depth texture since we won't need it anymore if (depthStencilSRV != null) { context.Resolver.ReleaseDepthStenctilAsShaderResource(depthStencilSRV); } }