Skip to content
Permalink
Browse files

[Rendering] Removed SceneInstance dependency from rendering code

  • Loading branch information
xen2 committed Feb 12, 2019
1 parent e7ca9d2 commit cc4bd9f071536857bfb9eef5644da6f867dd5c97
@@ -280,7 +280,6 @@ protected override void CollectCore(RenderContext context)
IsIncrustEnabled = false;
}

RenderView.SceneInstance = context.SceneInstance;
context.RenderSystem.Views.Add(RenderView);
context.RenderView = RenderView;

@@ -50,7 +50,6 @@ protected override void CollectCore(RenderContext context)
{
var oldRenderView = context.RenderView;

RenderView.SceneInstance = context.SceneInstance;
context.RenderSystem.Views.Add(RenderView);
context.RenderView = RenderView;

@@ -69,7 +69,7 @@ protected override GraphicsCompositor CreateSharedGraphicsCompositor(GraphicsDev
private static void SafeRenderSprites(RenderDrawContext context)
{
// Note: this assumes that the Scene returned by CreateScene is the first child scene of the RootScene. Changing this in ThumbnailGenerator will break this code!
var command = context.RenderContext.SceneInstance.RootScene.Children.First().Tags.Get(ThumbnailFromSpriteBatchCommand.Key);
var command = SceneInstance.GetCurrent(context.RenderContext).RootScene.Children.First().Tags.Get(ThumbnailFromSpriteBatchCommand.Key);
command.RenderSprites(context);
}

@@ -26,7 +26,7 @@ partial class ForwardRenderer
private unsafe void PrepareLightprobeConstantBuffer(RenderContext context)
{
var renderView = context.RenderView;
var lightProbesData = context.RenderView.SceneInstance.GetProcessor<LightProbeProcessor>()?.RuntimeData;
var lightProbesData = SceneInstance.GetCurrent(context).GetProcessor<LightProbeProcessor>()?.RuntimeData;
if (lightProbesData != null)
{
foreach (var renderFeature in context.RenderSystem.RenderFeatures)
@@ -64,7 +64,7 @@ private unsafe void BakeLightProbes(RenderContext context, RenderDrawContext dra
Buffer lightprobesCoefficients = null;
var renderView = context.RenderView;

var lightProbesData = renderView.SceneInstance.GetProcessor<LightProbeProcessor>()?.RuntimeData;
var lightProbesData = SceneInstance.GetCurrent(context).GetProcessor<LightProbeProcessor>()?.RuntimeData;
if (lightProbesData == null || lightProbesData.Tetrahedra.Count == 0)
{
// No lightprobes, we still set GPU resources (otherwise rendering might fetch invalid data)
@@ -356,7 +356,6 @@ protected override unsafe void CollectCore(RenderContext context)
using (context.SaveViewportAndRestore())
{
context.RenderSystem.Views.Add(context.RenderView);
context.RenderView.SceneInstance = commonView.SceneInstance;
context.RenderView.LightingView = commonView;
context.ViewportState.Viewport0 = new Viewport(0, 0, VRSettings.VRDevice.ActualRenderFrameSize.Width / 2.0f, VRSettings.VRDevice.ActualRenderFrameSize.Height);

@@ -142,7 +142,6 @@ protected override void DrawCore(RenderDrawContext context)
{
// Set render system
context.RenderContext.RenderSystem = RenderSystem;
context.RenderContext.SceneInstance = sceneInstance;
context.RenderContext.VisibilityGroup = visibilityGroup;

// Set start states for viewports and output (it will be used during the Collect phase)
@@ -48,7 +48,6 @@ protected override void CollectCore(RenderContext context)

// Setup render view
context.RenderSystem.Views.Add(RenderView);
RenderView.SceneInstance = context.SceneInstance;
UpdateCameraToRenderView(context, RenderView, camera);

using (context.PushRenderViewAndRestore(RenderView))
@@ -120,7 +120,7 @@ protected override void Destroy()

public void Collect(RenderContext context)
{
lightShaftProcessor = context.SceneInstance.GetProcessor<LightShaftProcessor>();
lightShaftProcessor = Engine.SceneInstance.GetCurrent(context).GetProcessor<LightShaftProcessor>();
}

protected override void DrawCore(RenderDrawContext context)
@@ -92,7 +92,7 @@ public override void UpdateLayout(string compositionName)
// Setup light probe shader only if there is some light probe data
// TODO: Just like the ForwardLightingRenderFeature access the LightProcessor, accessing the SceneInstance.LightProbeProcessor is not what we want.
// Ideally, we should send the data the other way around. Let's fix that together when we refactor the lighting at some point.
var lightProbeRuntimeData = renderContext.SceneInstance?.GetProcessor<LightProbeProcessor>()?.RuntimeData;
var lightProbeRuntimeData = SceneInstance.GetCurrent(renderContext)?.GetProcessor<LightProbeProcessor>()?.RuntimeData;
ShaderSource = lightProbeRuntimeData != null ? shaderSourceEnabled : shaderSourceDisabled;
}
}
@@ -546,7 +546,7 @@ private void CollectVisibleLights()
renderViewLightData.VisibleLights.Clear();
renderViewLightData.VisibleLightsWithShadows.Clear();

lightProcessor = lightRenderView.SceneInstance.GetProcessor<LightProcessor>();
lightProcessor = SceneInstance.GetCurrent(Context).GetProcessor<LightProcessor>();

// No light processors means no light in the scene, so we can early exit
if (lightProcessor == null)
@@ -89,11 +89,6 @@ internal RenderContext(IServiceRegistry services)
/// </summary>
public RenderSystem RenderSystem { get; set; }

/// <summary>
/// The current scene instance.
/// </summary>
public SceneInstance SceneInstance { get; set; }

/// <summary>
/// The current visibility group from the <see cref="SceneInstance"/> and <see cref="RenderSystem"/>.
/// </summary>
@@ -56,12 +56,6 @@ public class RenderView
/// </summary>
public Matrix ViewProjection;

// TODO GRAPHICS REFACTOR probably obsolete (otherwise we can't share view between multiple SceneInstance)
/// <summary>
/// The scene instance that created this view.
/// </summary>
public SceneInstance SceneInstance;

/// <summary>
/// Far clip plane.
/// </summary>
@@ -80,7 +80,7 @@ private void DrawInternal(RenderDrawContext context, RenderView renderView, Rend
{
base.Draw(context, renderView, renderViewStage, startIndex, endIndex);

var uiProcessor = renderView.SceneInstance.GetProcessor<UIRenderProcessor>();
var uiProcessor = SceneInstance.GetCurrent(context.RenderContext).GetProcessor<UIRenderProcessor>();
if (uiProcessor == null)
return;

0 comments on commit cc4bd9f

Please sign in to comment.
You can’t perform that action at this time.