4 using System.Collections.Generic;
5 using System.Collections.Specialized;
6 using System.Threading.Tasks;
7 using SiliconStudio.Core.Diagnostics;
8 using SiliconStudio.Core.Mathematics;
9 using SiliconStudio.Paradox.Games;
10 using SiliconStudio.Core;
11 using SiliconStudio.Core.Collections;
13 namespace SiliconStudio.
Paradox.Effects
20 private static readonly
Logger Log = GlobalLogger.GetLogger(
"RenderSystem");
23 private TrackingHashSet<RenderPipeline> pipelines =
new TrackingHashSet<RenderPipeline>();
25 internal readonly List<SpriteRenderer> SpriteRenderProcessors =
new List<SpriteRenderer>();
30 pipelines.CollectionChanged += Pipelines_CollectionChanged;
39 pipelines.Add(Pipeline);
67 public ISet<RenderPipeline> Pipelines
69 get {
return pipelines; }
81 GraphicsDevice.Begin();
83 GraphicsDevice.ClearState();
85 if (GraphicsDevice.IsProfilingSupported)
87 GraphicsDevice.EnableProfile(
true);
91 Draw(Pipeline, drawContext);
95 Log.Error(
"An exception occured while rendering", ex);
106 context.CurrentPass = pass;
108 if (pass.
Name != null)
110 context.GraphicsDevice.BeginProfile(Color.Green, pass.Name);
113 pass.StartPass.Invoke(context);
115 foreach (var child
in pass.Children)
117 Draw(child, context);
120 context.CurrentPass = pass;
121 pass.EndPass.Invoke(context);
123 if (pass.Name != null)
125 context.GraphicsDevice.EndProfile();
129 private void RenderPassAdded(
RenderPass renderPass)
131 foreach (var child
in renderPass.
Children)
133 RenderPassAdded(child);
135 renderPass.Children.CollectionChanged += Pipelines_CollectionChanged;
137 foreach (var processor
in renderPass.
Renderers)
141 renderPass.Renderers.CollectionChanged += Processors_CollectionChanged;
144 private void RenderPassRemoved(RenderPass renderPass)
146 foreach (var child
in renderPass.Children)
148 RenderPassRemoved(child);
150 renderPass.Children.CollectionChanged -= Pipelines_CollectionChanged;
152 foreach (var processor
in renderPass.Renderers)
156 renderPass.Renderers.CollectionChanged -= Processors_CollectionChanged;
161 var renderPass = (RenderPass)e.
Item;
164 case NotifyCollectionChangedAction.Add:
165 RenderPassAdded(renderPass);
167 case NotifyCollectionChangedAction.Remove:
168 RenderPassRemoved(renderPass);
175 var renderer = (Renderer)e.
Item;
178 case NotifyCollectionChangedAction.Add:
181 case NotifyCollectionChangedAction.Remove:
void Draw(RenderPass pass, RenderContext context)
TrackingCollection< RenderPass > Children
Gets the sub render passes.
RenderSystem(IServiceRegistry registry)
override void Draw(GameTime gameTime)
Draws this instance. The current timing.
A service registry is a IServiceProvider that provides methods to register and unregister services...
Base class for a GameSystemBase component.
Base implementation for ILogger.
Current timing used for variable-step (real time) or fixed-step (game time) games.
Thread-local storage context used during rendering.
Renders its RenderSystem.Pipeline, which will usually result in drawing all meshes, UI, etc...
object Item
Gets the added or removed item (if dictionary, value only).
NotifyCollectionChangedAction Action
Gets the type of action performed. Allowed values are NotifyCollectionChangedAction.Add and NotifyCollectionChangedAction.Remove.
string Name
Gets or sets the name of this component.
override void LoadContent()
Loads the assets.
RenderPass is a hierarchy that defines how to collect and render meshes.
Output message to log right away.
Defines an entry point for mesh instantiation and recursive rendering.
TrackingCollection< Renderer > Renderers
Gets the Renderers attached to this renderpass.